mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-12-01 11:09:44 +01:00
Compare commits
6 Commits
c2d5611ab9
...
dcf10e0819
Author | SHA1 | Date | |
---|---|---|---|
|
dcf10e0819 | ||
|
6b78733a5d | ||
|
c124a99901 | ||
|
d7df4002da | ||
|
8b0ef97a82 | ||
|
75d3bef5c8 |
@ -24,10 +24,10 @@ overlay.top.color=1, 1, 1, 1
|
|||||||
settings.show=false
|
settings.show=false
|
||||||
#
|
#
|
||||||
# Specifies the width of the application window in pixels.
|
# Specifies the width of the application window in pixels.
|
||||||
settings.resolution.width=1920
|
settings.resolution.width=1200
|
||||||
#
|
#
|
||||||
# Specifies the height of the application window in pixels.
|
# Specifies the height of the application window in pixels.
|
||||||
settings.resolution.height=1080
|
settings.resolution.height=800
|
||||||
#
|
#
|
||||||
# Determines whether the application runs in full-screen mode.
|
# Determines whether the application runs in full-screen mode.
|
||||||
settings.full-screen=false
|
settings.full-screen=false
|
||||||
|
@ -22,6 +22,7 @@ import com.simsilica.lemur.GuiGlobals;
|
|||||||
import com.simsilica.lemur.style.BaseStyles;
|
import com.simsilica.lemur.style.BaseStyles;
|
||||||
import pp.monopoly.game.client.MonopolyClient;
|
import pp.monopoly.game.client.MonopolyClient;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
import pp.monopoly.client.gui.SettingsMenu;
|
||||||
|
import pp.monopoly.client.gui.StartMenu;
|
||||||
import pp.monopoly.game.client.ClientGameLogic;
|
import pp.monopoly.game.client.ClientGameLogic;
|
||||||
import pp.monopoly.game.client.ServerConnection;
|
import pp.monopoly.game.client.ServerConnection;
|
||||||
import pp.monopoly.notification.ClientStateEvent;
|
import pp.monopoly.notification.ClientStateEvent;
|
||||||
@ -218,7 +219,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
setupInput();
|
setupInput();
|
||||||
setupStates();
|
setupStates();
|
||||||
setupGui();
|
setupGui();
|
||||||
// serverConnection.connect();
|
new StartMenu(this).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,6 +319,13 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
return draw;
|
return draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to connect
|
||||||
|
*/
|
||||||
|
public void connect() {
|
||||||
|
serverConnection.connect();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a request to close the application.
|
* Handles a request to close the application.
|
||||||
* If the request is initiated by pressing ESC, this parameter is true.
|
* If the request is initiated by pressing ESC, this parameter is true.
|
||||||
|
@ -12,6 +12,7 @@ import java.lang.System.Logger.Level;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
import com.simsilica.lemur.Button;
|
import com.simsilica.lemur.Button;
|
||||||
import com.simsilica.lemur.Container;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.Label;
|
import com.simsilica.lemur.Label;
|
||||||
@ -38,8 +39,9 @@ public class CreateGameMenu extends SimpleDialog {
|
|||||||
private final NetworkSupport network;
|
private final NetworkSupport network;
|
||||||
private final TextField host = new TextField(LOCALHOST);
|
private final TextField host = new TextField(LOCALHOST);
|
||||||
private final TextField port = new TextField(DEFAULT_PORT);
|
private final TextField port = new TextField(DEFAULT_PORT);
|
||||||
// private final Button serverButton = new Button(lookup("client.server-star"));
|
private final Button serverButton = new Button("Selber hosten");
|
||||||
private final Button serverButton = new Button(lookup("client.server-start"));
|
private final Button cancelButton = new Button("Abbrechen");
|
||||||
|
private final Button joinButton = new Button("Beitreten");
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private int portNumber;
|
private int portNumber;
|
||||||
private Future<Object> connectionFuture;
|
private Future<Object> connectionFuture;
|
||||||
@ -64,17 +66,20 @@ public class CreateGameMenu extends SimpleDialog {
|
|||||||
input.addChild(new Label(lookup("port.number") + ": "));
|
input.addChild(new Label(lookup("port.number") + ": "));
|
||||||
input.addChild(port, 1);
|
input.addChild(port, 1);
|
||||||
|
|
||||||
DialogBuilder.simple(app.getDialogManager())
|
addChild(input);
|
||||||
.setTitle(lookup("server.dialog"))
|
// "Abbrechen"-Button
|
||||||
.setExtension(d -> d.addChild(input))
|
cancelButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||||
.setOkButton(lookup("button.connect"), d -> connect())
|
cancelButton.addClickCommands(source -> new StartMenu(app).open());
|
||||||
.setNoButton(lookup("button.cancel"), app::closeApp)
|
addChild(cancelButton);
|
||||||
.setOkClose(false)
|
cancelButton.addClickCommands(s -> new StartMenu(app));
|
||||||
.setNoClose(false)
|
|
||||||
.build(this);
|
|
||||||
|
|
||||||
//Add the button to start the sever
|
// "Selber hosten"-Button
|
||||||
addChild(serverButton).addClickCommands(s -> ifTopDialog(this::startServerInThread));
|
addChild(serverButton).addClickCommands(s -> startServerInThread());
|
||||||
|
|
||||||
|
// "Beitreten"-Button
|
||||||
|
joinButton.setPreferredSize(new Vector3f(120, 40, 0));
|
||||||
|
addChild(joinButton);
|
||||||
|
joinButton.addClickCommands(s -> connect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,7 +151,7 @@ public class CreateGameMenu extends SimpleDialog {
|
|||||||
connectionFuture = null;
|
connectionFuture = null;
|
||||||
progressDialog.close();
|
progressDialog.close();
|
||||||
this.close();
|
this.close();
|
||||||
network.getApp().setInfoText(lookup("wait.for.an.opponent"));
|
new LobbyMenu(network.getApp()).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,5 +181,12 @@ public class CreateGameMenu extends SimpleDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
serverThread.start();
|
serverThread.start();
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
connect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,14 @@ import com.simsilica.lemur.component.SpringGridLayout;
|
|||||||
import com.simsilica.lemur.core.VersionedList;
|
import com.simsilica.lemur.core.VersionedList;
|
||||||
import com.simsilica.lemur.core.VersionedReference;
|
import com.simsilica.lemur.core.VersionedReference;
|
||||||
import com.simsilica.lemur.style.ElementId;
|
import com.simsilica.lemur.style.ElementId;
|
||||||
|
|
||||||
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.MonopolyApp;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
|
import pp.monopoly.message.client.PlayerReady;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class LobbyMenu {
|
public class LobbyMenu extends Dialog {
|
||||||
|
|
||||||
private final MonopolyApp app;
|
private final MonopolyApp app;
|
||||||
private final Container menuContainer;
|
private final Container menuContainer;
|
||||||
@ -35,7 +38,11 @@ public class LobbyMenu {
|
|||||||
private Container lowerLeftMenu;
|
private Container lowerLeftMenu;
|
||||||
private Container lowerRightMenu;
|
private Container lowerRightMenu;
|
||||||
|
|
||||||
|
private TextField playerInputField = new TextField("Spieler 1");
|
||||||
|
private TextField startingCapital = new TextField("15000");
|
||||||
|
|
||||||
public LobbyMenu(MonopolyApp app) {
|
public LobbyMenu(MonopolyApp app) {
|
||||||
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
// Entfernt das CreateGameMenu (inklusive Hintergrund)
|
// Entfernt das CreateGameMenu (inklusive Hintergrund)
|
||||||
@ -64,7 +71,7 @@ public class LobbyMenu {
|
|||||||
spacerBeforeInput.setPreferredSize(new Vector3f(20, 1, 0)); // Width of the spacer
|
spacerBeforeInput.setPreferredSize(new Vector3f(20, 1, 0)); // Width of the spacer
|
||||||
|
|
||||||
// Add an input field (TextField)
|
// Add an input field (TextField)
|
||||||
TextField startingCapital = horizontalContainer.addChild(new TextField("15 000"));
|
horizontalContainer.addChild(startingCapital);
|
||||||
startingCapital.setPreferredWidth(100); // Set the width of the input field
|
startingCapital.setPreferredWidth(100); // Set the width of the input field
|
||||||
startingCapital.setPreferredSize(new Vector3f(150, 50, 0));
|
startingCapital.setPreferredSize(new Vector3f(150, 50, 0));
|
||||||
startingCapital.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding around the text inside the field
|
startingCapital.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding around the text inside the field
|
||||||
@ -91,7 +98,6 @@ public class LobbyMenu {
|
|||||||
playerInputContainer.setBackground(null);
|
playerInputContainer.setBackground(null);
|
||||||
|
|
||||||
|
|
||||||
TextField playerInputField = new TextField("Spieler 1");
|
|
||||||
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
|
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
|
||||||
playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field
|
playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field
|
||||||
playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
|
playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
|
||||||
@ -129,7 +135,7 @@ public class LobbyMenu {
|
|||||||
Button cancelButton = new Button("Abbrechen");
|
Button cancelButton = new Button("Abbrechen");
|
||||||
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
|
||||||
cancelButton.setFontSize(18); // Adjust font size
|
cancelButton.setFontSize(18); // Adjust font size
|
||||||
cancelButton.addClickCommands(source -> goBackToCreateGame()); // Add functionality
|
cancelButton.addClickCommands(source -> close()); // Add functionality
|
||||||
lowerLeftMenu.addChild(cancelButton);
|
lowerLeftMenu.addChild(cancelButton);
|
||||||
|
|
||||||
// Position the container near the bottom-left corner
|
// Position the container near the bottom-left corner
|
||||||
@ -201,20 +207,12 @@ public class LobbyMenu {
|
|||||||
* Schaltet den "Bereit"-Status um.
|
* Schaltet den "Bereit"-Status um.
|
||||||
*/
|
*/
|
||||||
private void toggleReady(Label playersLabel) {
|
private void toggleReady(Label playersLabel) {
|
||||||
// Beispiel-Logik für das Umschalten des Status
|
app.getGameLogic().send(new PlayerReady(true, "Test", "flugzeug", 15000));;
|
||||||
playersLabel.setText("Spielerstatus aktualisiert."); // Beispieltext
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Geht zurück zum CreateGameMenu.
|
public void close() {
|
||||||
*/
|
super.close();
|
||||||
private void goBackToCreateGame() {
|
|
||||||
app.getGuiNode().detachChild(menuContainer);
|
|
||||||
app.getGuiNode().detachChild(background);
|
|
||||||
app.getGuiNode().detachChild(circle);
|
|
||||||
app.getGuiNode().detachChild(lowerLeftMenu);
|
|
||||||
app.getGuiNode().detachChild(lowerRightMenu);
|
|
||||||
// app.getServerConnection().connect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -269,7 +267,7 @@ public class LobbyMenu {
|
|||||||
System.out.println("Gamma selected");
|
System.out.println("Gamma selected");
|
||||||
break;
|
break;
|
||||||
case "[3]":
|
case "[3]":
|
||||||
goBackToCreateGame();
|
close();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("Unknown selection");
|
System.out.println("Unknown selection");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package pp.monopoly.client;
|
package pp.monopoly.client.gui;
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
@ -13,8 +13,7 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
|
|
||||||
import pp.dialog.Dialog;
|
import pp.dialog.Dialog;
|
||||||
import pp.monopoly.client.gui.CreateGameMenu;
|
import pp.monopoly.client.MonopolyApp;
|
||||||
import pp.monopoly.client.gui.SettingsMenu;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the startup menu dialog for the Monopoly application.
|
* Constructs the startup menu dialog for the Monopoly application.
|
||||||
@ -33,13 +32,7 @@ public class StartMenu extends Dialog {
|
|||||||
public StartMenu(MonopolyApp app) {
|
public StartMenu(MonopolyApp app) {
|
||||||
super(app.getDialogManager());
|
super(app.getDialogManager());
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and displays the Start Menu with buttons for starting the game,
|
|
||||||
* opening settings, and quitting the application.
|
|
||||||
*/
|
|
||||||
public static void createStartMenu(MonopolyApp app) {
|
|
||||||
int screenWidth = app.getContext().getSettings().getWidth();
|
int screenWidth = app.getContext().getSettings().getWidth();
|
||||||
int screenHeight = app.getContext().getSettings().getHeight();
|
int screenHeight = app.getContext().getSettings().getHeight();
|
||||||
|
|
||||||
@ -53,9 +46,6 @@ public class StartMenu extends Dialog {
|
|||||||
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
|
||||||
app.getGuiNode().attachChild(background);
|
app.getGuiNode().attachChild(background);
|
||||||
|
|
||||||
createMonopolyLogo(app);
|
|
||||||
createUnibwLogo(app);
|
|
||||||
|
|
||||||
// Center container for title and play button
|
// Center container for title and play button
|
||||||
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||||
|
|
||||||
@ -64,7 +54,7 @@ public class StartMenu extends Dialog {
|
|||||||
startButton.setFontSize(40); // Set the font size for the button text
|
startButton.setFontSize(40); // Set the font size for the button text
|
||||||
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
|
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
|
||||||
|
|
||||||
startButton.addClickCommands(source -> startGame(app));
|
startButton.addClickCommands(s -> app.connect());
|
||||||
centerMenu.addChild(startButton);
|
centerMenu.addChild(startButton);
|
||||||
|
|
||||||
// Position the center container in the middle of the screen
|
// Position the center container in the middle of the screen
|
||||||
@ -79,7 +69,7 @@ public class StartMenu extends Dialog {
|
|||||||
Button quitButton = new Button("Spiel beenden");
|
Button quitButton = new Button("Spiel beenden");
|
||||||
quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
|
quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
|
||||||
quitButton.setFontSize(18);
|
quitButton.setFontSize(18);
|
||||||
quitButton.addClickCommands(source -> quitGame());
|
quitButton.addClickCommands(source -> ifTopDialog(app::closeApp));
|
||||||
lowerLeftMenu.addChild(quitButton);
|
lowerLeftMenu.addChild(quitButton);
|
||||||
app.getGuiNode().attachChild(lowerLeftMenu);
|
app.getGuiNode().attachChild(lowerLeftMenu);
|
||||||
|
|
||||||
@ -89,17 +79,10 @@ public class StartMenu extends Dialog {
|
|||||||
Button settingsButton = new Button("Einstellungen");
|
Button settingsButton = new Button("Einstellungen");
|
||||||
settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
|
settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
|
||||||
settingsButton.setFontSize(18); // Increase the font size for the text
|
settingsButton.setFontSize(18); // Increase the font size for the text
|
||||||
settingsButton.addClickCommands(source -> openSettings(app));
|
settingsButton.addClickCommands(source -> new SettingsMenu(app).open());
|
||||||
lowerRightMenu.addChild(settingsButton);
|
lowerRightMenu.addChild(settingsButton);
|
||||||
app.getGuiNode().attachChild(lowerRightMenu);
|
app.getGuiNode().attachChild(lowerRightMenu);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and positions the Monopoly logo container in the center of the screen.
|
|
||||||
*/
|
|
||||||
private static void createMonopolyLogo(MonopolyApp app) {
|
|
||||||
int screenWidth = app.getContext().getSettings().getWidth();
|
|
||||||
int screenHeight = app.getContext().getSettings().getHeight();
|
|
||||||
|
|
||||||
// Load the Monopoly logo as a texture
|
// Load the Monopoly logo as a texture
|
||||||
Texture logoTexture = app.getAssetManager().loadTexture("Pictures/logo-monopoly.png");
|
Texture logoTexture = app.getAssetManager().loadTexture("Pictures/logo-monopoly.png");
|
||||||
@ -123,14 +106,6 @@ public class StartMenu extends Dialog {
|
|||||||
|
|
||||||
// Attach the container to the GUI node
|
// Attach the container to the GUI node
|
||||||
app.getGuiNode().attachChild(logoContainer);
|
app.getGuiNode().attachChild(logoContainer);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and positions the Unibw logo container in the center of the screen.
|
|
||||||
*/
|
|
||||||
private static void createUnibwLogo(MonopolyApp app) {
|
|
||||||
int screenWidth = app.getContext().getSettings().getWidth();
|
|
||||||
int screenHeight = app.getContext().getSettings().getHeight();
|
|
||||||
|
|
||||||
// Load the Unibw logo as a texture
|
// Load the Unibw logo as a texture
|
||||||
Texture unibwTexture = app.getAssetManager().loadTexture("Pictures/logo-unibw.png");
|
Texture unibwTexture = app.getAssetManager().loadTexture("Pictures/logo-unibw.png");
|
||||||
@ -156,26 +131,8 @@ public class StartMenu extends Dialog {
|
|||||||
app.getGuiNode().attachChild(unibwContainer);
|
app.getGuiNode().attachChild(unibwContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Starts the game by transitioning to the CreateGameMenu.
|
public void escape() {
|
||||||
*/
|
close();
|
||||||
private static void startGame(MonopolyApp app) {
|
|
||||||
app.getGuiNode().detachAllChildren();
|
|
||||||
// app.getServerConnection().connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens the settings menu.
|
|
||||||
*/
|
|
||||||
private static void openSettings(MonopolyApp app) {
|
|
||||||
app.getGuiNode().detachAllChildren();
|
|
||||||
new SettingsMenu(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Quits the game application.
|
|
||||||
*/
|
|
||||||
private static void quitGame() {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ public class MonopolyConfig extends Config {
|
|||||||
* The default port number for the Monopoly server.
|
* The default port number for the Monopoly server.
|
||||||
*/
|
*/
|
||||||
@Property("port")
|
@Property("port")
|
||||||
private int port = 4321;
|
private int port = 42069;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of the game map in terms of grid units.
|
* The width of the game map in terms of grid units.
|
||||||
|
@ -139,7 +139,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*
|
*
|
||||||
* @param msg the message to be sent
|
* @param msg the message to be sent
|
||||||
*/
|
*/
|
||||||
void send(ClientMessage msg) {
|
public void send(ClientMessage msg) {
|
||||||
if (clientSender == null) {
|
if (clientSender == null) {
|
||||||
LOGGER.log(Level.ERROR, "trying to send {0} with sender==null", msg); //NON-NLS
|
LOGGER.log(Level.ERROR, "trying to send {0} with sender==null", msg); //NON-NLS
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user