Compare commits

..

No commits in common. "dcf10e08198e81ab43521a9634f17acec9ca82bb" and "c2d5611ab9c72cfeddaff141c329e4855ec1ec56" have entirely different histories.

7 changed files with 88 additions and 63 deletions

View File

@ -24,10 +24,10 @@ overlay.top.color=1, 1, 1, 1
settings.show=false
#
# Specifies the width of the application window in pixels.
settings.resolution.width=1200
settings.resolution.width=1920
#
# Specifies the height of the application window in pixels.
settings.resolution.height=800
settings.resolution.height=1080
#
# Determines whether the application runs in full-screen mode.
settings.full-screen=false

View File

@ -22,7 +22,6 @@ import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.style.BaseStyles;
import pp.monopoly.game.client.MonopolyClient;
import pp.monopoly.client.gui.SettingsMenu;
import pp.monopoly.client.gui.StartMenu;
import pp.monopoly.game.client.ClientGameLogic;
import pp.monopoly.game.client.ServerConnection;
import pp.monopoly.notification.ClientStateEvent;
@ -219,7 +218,7 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
setupInput();
setupStates();
setupGui();
new StartMenu(this).open();
// serverConnection.connect();
}
/**
@ -319,13 +318,6 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
return draw;
}
/**
* Tries to connect
*/
public void connect() {
serverConnection.connect();
}
/**
* Handles a request to close the application.
* If the request is initiated by pressing ESC, this parameter is true.

View File

@ -1,4 +1,4 @@
package pp.monopoly.client.gui;
package pp.monopoly.client;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
@ -13,7 +13,8 @@ import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.component.SpringGridLayout;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.client.gui.CreateGameMenu;
import pp.monopoly.client.gui.SettingsMenu;
/**
* Constructs the startup menu dialog for the Monopoly application.
@ -32,7 +33,13 @@ public class StartMenu extends Dialog {
public StartMenu(MonopolyApp app) {
super(app.getDialogManager());
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 screenHeight = app.getContext().getSettings().getHeight();
@ -46,6 +53,9 @@ public class StartMenu extends Dialog {
background.setLocalTranslation(0, 0, -1); // Ensure it is behind other GUI elements
app.getGuiNode().attachChild(background);
createMonopolyLogo(app);
createUnibwLogo(app);
// Center container for title and play button
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X));
@ -54,7 +64,7 @@ public class StartMenu extends Dialog {
startButton.setFontSize(40); // Set the font size for the button text
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
startButton.addClickCommands(s -> app.connect());
startButton.addClickCommands(source -> startGame(app));
centerMenu.addChild(startButton);
// Position the center container in the middle of the screen
@ -69,7 +79,7 @@ public class StartMenu extends Dialog {
Button quitButton = new Button("Spiel beenden");
quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
quitButton.setFontSize(18);
quitButton.addClickCommands(source -> ifTopDialog(app::closeApp));
quitButton.addClickCommands(source -> quitGame());
lowerLeftMenu.addChild(quitButton);
app.getGuiNode().attachChild(lowerLeftMenu);
@ -79,10 +89,17 @@ public class StartMenu extends Dialog {
Button settingsButton = new Button("Einstellungen");
settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
settingsButton.setFontSize(18); // Increase the font size for the text
settingsButton.addClickCommands(source -> new SettingsMenu(app).open());
settingsButton.addClickCommands(source -> openSettings(app));
lowerRightMenu.addChild(settingsButton);
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
Texture logoTexture = app.getAssetManager().loadTexture("Pictures/logo-monopoly.png");
@ -106,6 +123,14 @@ public class StartMenu extends Dialog {
// Attach the container to the GUI node
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
Texture unibwTexture = app.getAssetManager().loadTexture("Pictures/logo-unibw.png");
@ -131,8 +156,26 @@ public class StartMenu extends Dialog {
app.getGuiNode().attachChild(unibwContainer);
}
@Override
public void escape() {
close();
/**
* Starts the game by transitioning to the CreateGameMenu.
*/
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);
}
}

View File

@ -12,7 +12,6 @@ import java.lang.System.Logger.Level;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import com.jme3.math.Vector3f;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
@ -39,9 +38,8 @@ public class CreateGameMenu extends SimpleDialog {
private final NetworkSupport network;
private final TextField host = new TextField(LOCALHOST);
private final TextField port = new TextField(DEFAULT_PORT);
private final Button serverButton = new Button("Selber hosten");
private final Button cancelButton = new Button("Abbrechen");
private final Button joinButton = new Button("Beitreten");
// private final Button serverButton = new Button(lookup("client.server-star"));
private final Button serverButton = new Button(lookup("client.server-start"));
private String hostname;
private int portNumber;
private Future<Object> connectionFuture;
@ -65,21 +63,18 @@ public class CreateGameMenu extends SimpleDialog {
input.addChild(host, 1);
input.addChild(new Label(lookup("port.number") + ": "));
input.addChild(port, 1);
DialogBuilder.simple(app.getDialogManager())
.setTitle(lookup("server.dialog"))
.setExtension(d -> d.addChild(input))
.setOkButton(lookup("button.connect"), d -> connect())
.setNoButton(lookup("button.cancel"), app::closeApp)
.setOkClose(false)
.setNoClose(false)
.build(this);
addChild(input);
// "Abbrechen"-Button
cancelButton.setPreferredSize(new Vector3f(120, 40, 0));
cancelButton.addClickCommands(source -> new StartMenu(app).open());
addChild(cancelButton);
cancelButton.addClickCommands(s -> new StartMenu(app));
// "Selber hosten"-Button
addChild(serverButton).addClickCommands(s -> startServerInThread());
// "Beitreten"-Button
joinButton.setPreferredSize(new Vector3f(120, 40, 0));
addChild(joinButton);
joinButton.addClickCommands(s -> connect());
//Add the button to start the sever
addChild(serverButton).addClickCommands(s -> ifTopDialog(this::startServerInThread));
}
/**
@ -151,7 +146,7 @@ public class CreateGameMenu extends SimpleDialog {
connectionFuture = null;
progressDialog.close();
this.close();
new LobbyMenu(network.getApp()).open();
network.getApp().setInfoText(lookup("wait.for.an.opponent"));
}
/**
@ -181,12 +176,5 @@ public class CreateGameMenu extends SimpleDialog {
}
});
serverThread.start();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
connect();
}
}

View File

@ -22,14 +22,11 @@ import com.simsilica.lemur.component.SpringGridLayout;
import com.simsilica.lemur.core.VersionedList;
import com.simsilica.lemur.core.VersionedReference;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.message.client.PlayerReady;
import java.util.Set;
public class LobbyMenu extends Dialog {
public class LobbyMenu {
private final MonopolyApp app;
private final Container menuContainer;
@ -38,11 +35,7 @@ public class LobbyMenu extends Dialog {
private Container lowerLeftMenu;
private Container lowerRightMenu;
private TextField playerInputField = new TextField("Spieler 1");
private TextField startingCapital = new TextField("15000");
public LobbyMenu(MonopolyApp app) {
super(app.getDialogManager());
this.app = app;
// Entfernt das CreateGameMenu (inklusive Hintergrund)
@ -71,7 +64,7 @@ public class LobbyMenu extends Dialog {
spacerBeforeInput.setPreferredSize(new Vector3f(20, 1, 0)); // Width of the spacer
// Add an input field (TextField)
horizontalContainer.addChild(startingCapital);
TextField startingCapital = horizontalContainer.addChild(new TextField("15 000"));
startingCapital.setPreferredWidth(100); // Set the width of the input field
startingCapital.setPreferredSize(new Vector3f(150, 50, 0));
startingCapital.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding around the text inside the field
@ -98,6 +91,7 @@ public class LobbyMenu extends Dialog {
playerInputContainer.setBackground(null);
TextField playerInputField = new TextField("Spieler 1");
playerInputField.setPreferredSize(new Vector3f(100, 20, 0));
playerInputField.setInsets(new Insets3f(5, 10, 5, 10)); // Add padding for the text inside the field
playerInputField.setBackground(new QuadBackgroundComponent(ColorRGBA.Black));
@ -135,7 +129,7 @@ public class LobbyMenu extends Dialog {
Button cancelButton = new Button("Abbrechen");
cancelButton.setPreferredSize(new Vector3f(200, 60, 0)); // Set size to match the appearance in the image
cancelButton.setFontSize(18); // Adjust font size
cancelButton.addClickCommands(source -> close()); // Add functionality
cancelButton.addClickCommands(source -> goBackToCreateGame()); // Add functionality
lowerLeftMenu.addChild(cancelButton);
// Position the container near the bottom-left corner
@ -207,12 +201,20 @@ public class LobbyMenu extends Dialog {
* Schaltet den "Bereit"-Status um.
*/
private void toggleReady(Label playersLabel) {
app.getGameLogic().send(new PlayerReady(true, "Test", "flugzeug", 15000));;
// Beispiel-Logik für das Umschalten des Status
playersLabel.setText("Spielerstatus aktualisiert."); // Beispieltext
}
@Override
public void close() {
super.close();
/**
* Geht zurück zum CreateGameMenu.
*/
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();
}
/**
@ -267,7 +269,7 @@ public class LobbyMenu extends Dialog {
System.out.println("Gamma selected");
break;
case "[3]":
close();
goBackToCreateGame();
break;
default:
System.out.println("Unknown selection");

View File

@ -28,7 +28,7 @@ public class MonopolyConfig extends Config {
* The default port number for the Monopoly server.
*/
@Property("port")
private int port = 42069;
private int port = 4321;
/**
* The width of the game map in terms of grid units.

View File

@ -139,7 +139,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
*
* @param msg the message to be sent
*/
public void send(ClientMessage msg) {
void send(ClientMessage msg) {
if (clientSender == null) {
LOGGER.log(Level.ERROR, "trying to send {0} with sender==null", msg); //NON-NLS
} else {