diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java index 3525708..23cd942 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/MonopolyApp.java @@ -16,6 +16,7 @@ import com.simsilica.lemur.style.BaseStyles; import pp.dialog.DialogBuilder; import pp.dialog.DialogManager; import pp.graphics.Draw; +import pp.monopoly.client.gui.SettingsMenu; import pp.monopoly.game.client.ClientGameLogic; import pp.monopoly.game.client.MonopolyClient; import pp.monopoly.game.client.ServerConnection; @@ -27,10 +28,10 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga private final ServerConnection serverConnection; private final ClientGameLogic logic; private final MonopolyAppConfig config; - private final ActionListener escapeListener = (name, isPressed, tpf) -> escape(isPressed); + private final ActionListener escapeListener = (name, isPressed, tpf) -> handleEscape(isPressed); private final DialogManager dialogManager = new DialogManager(this); private final ExecutorService executor = Executors.newCachedThreadPool(); - + private SettingsMenu settingsMenu; private final Draw draw; public static void main(String[] args) { @@ -67,9 +68,8 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga @Override public void simpleInitApp() { - stateManager.detach(stateManager.getState(com.jme3.app.StatsAppState.class)); //FPS-Anzeige - GuiGlobals.initialize(this); // Lemur initialisieren - BaseStyles.loadGlassStyle(); // Beispielstil für Lemur + GuiGlobals.initialize(this); + BaseStyles.loadGlassStyle(); GuiGlobals.getInstance().getStyles().setDefaultStyle("glass"); setupInput(); @@ -91,9 +91,15 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga inputManager.addListener(escapeListener, "ESC"); } - private void escape(boolean isPressed) { - if (!isPressed) return; - new StartMenu(this); + private void handleEscape(boolean isPressed) { + if (isPressed) { + if (settingsMenu != null && guiNode.hasChild(settingsMenu.getContainer())) { + settingsMenu.close(); + } else { + settingsMenu = new SettingsMenu(this); + settingsMenu.open(); + } + } } void setInfoText(String text) { diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java index ffe4be1..a583641 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/SettingsMenu.java @@ -2,69 +2,50 @@ package pp.monopoly.client.gui; import com.jme3.math.Vector3f; import com.simsilica.lemur.Button; -import com.simsilica.lemur.Checkbox; import com.simsilica.lemur.Container; import com.simsilica.lemur.Label; import pp.dialog.Dialog; -import pp.monopoly.client.GameSound; import pp.monopoly.client.MonopolyApp; -import pp.monopoly.client.StartMenu; -/** - * Settings menu for the Monopoly application, where users can configure preferences. - */ public class SettingsMenu extends Dialog { private final MonopolyApp app; + private final Container settingsContainer; - /** - * Constructs the SettingsMenu dialog for the Monopoly application. - * - * @param app the MonopolyApp instance - */ public SettingsMenu(MonopolyApp app) { super(app.getDialogManager()); this.app = app; - initializeMenu(); + settingsContainer = new Container(); } - /** - * Sets up the layout and elements for the settings menu. - */ - private void initializeMenu() { - Container settingsContainer = new Container(); - settingsContainer.setLocalTranslation(new Vector3f(300, 300, 0)); // Positionierung des Menüs + public void open() { + settingsContainer.setLocalTranslation(new Vector3f(300, 300, 0)); - // Titel des Menüs + // Titel des Einstellungsmenüs settingsContainer.addChild(new Label("Einstellungen")); - // Beispiel-Einstellung: Sound aktivieren/deaktivieren - Checkbox soundCheckbox = settingsContainer.addChild(new Checkbox("Sound aktivieren")); - soundCheckbox.setChecked(GameSound.enabledInPreferences()); - soundCheckbox.addClickCommands(source -> toggleSound(soundCheckbox.isChecked())); + // Beispiel: Button zum Umschalten einer Option + Label soundLabel = settingsContainer.addChild(new Label("Sound")); + Button toggleSoundButton = settingsContainer.addChild(new Button("An/Aus")); + toggleSoundButton.addClickCommands(source -> toggleSound()); - // Zurück-Button zum Startmenü + // Zurück-Button, um das Menü zu schließen Button backButton = settingsContainer.addChild(new Button("Zurück")); - backButton.addClickCommands(source -> returnToStartMenu()); + backButton.addClickCommands(source -> close()); + // Container dem GUI-Knoten hinzufügen app.getGuiNode().attachChild(settingsContainer); } - /** - * Toggles the sound setting and saves the preference. - * - * @param enabled true if sound should be enabled; false otherwise. - */ - private void toggleSound(boolean enabled) { - GameSound.enabledInPreferences(); // Speichert die Einstellung in den Preferences - System.out.println("Sound " + (enabled ? "aktiviert" : "deaktiviert")); + public void close() { + app.getGuiNode().detachChild(settingsContainer); } - /** - * Returns to the StartMenu. - */ - private void returnToStartMenu() { - app.getGuiNode().detachAllChildren(); // Schließt das SettingsMenu - StartMenu.createStartMenu(app); // Zeigt das Startmenü erneut an + private void toggleSound() { + System.out.println("Sound umgeschaltet!"); + } + + public Container getContainer() { + return settingsContainer; } } diff --git a/Projekte/monopoly/client/src/main/resources/Pictures/board.png b/Projekte/monopoly/client/src/main/resources/Pictures/board.png new file mode 100644 index 0000000..6e3afea Binary files /dev/null and b/Projekte/monopoly/client/src/main/resources/Pictures/board.png differ