From 7b91a679f58cdaa6d4f325703f7971939e24eadc Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Tue, 26 Nov 2024 00:57:22 +0100 Subject: [PATCH] abbrechen button in chossePatner --- .../pp/monopoly/client/gui/ChoosePartner.java | 28 +++++++++++-------- .../java/pp/monopoly/client/gui/Toolbar.java | 1 - 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java index aa23fcf..d320ae7 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/ChoosePartner.java @@ -1,7 +1,5 @@ package pp.monopoly.client.gui; -import com.jme3.app.Application; -import com.jme3.app.state.BaseAppState; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; @@ -11,20 +9,16 @@ import com.jme3.texture.Texture; import com.simsilica.lemur.Axis; import com.simsilica.lemur.Button; import com.simsilica.lemur.Container; -import com.simsilica.lemur.Insets3f; import com.simsilica.lemur.Label; import com.simsilica.lemur.Selector; -import com.simsilica.lemur.TextField; import com.simsilica.lemur.component.QuadBackgroundComponent; 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.notification.Sound; -import java.util.Set; public class ChoosePartner extends Dialog { private final MonopolyApp app; private Selector playerSelector; @@ -33,6 +27,7 @@ public class ChoosePartner extends Dialog { private final Container mainContainer; private Container lowerLeftMenu; private Container lowerRightMenu; + private Geometry background; QuadBackgroundComponent translucentWhiteBackground = new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)); @@ -70,7 +65,7 @@ public class ChoosePartner extends Dialog { mainContainer.setLocalTranslation( (app.getCamera().getWidth() - mainContainer.getPreferredSize().x) / 2, (app.getCamera().getHeight() + mainContainer.getPreferredSize().y) / 2, - 3 + 4 ); } @@ -116,8 +111,7 @@ public class ChoosePartner extends Dialog { cancelButton.setFontSize(30); cancelButton.addClickCommands(s -> ifTopDialog(() -> { app.getGameLogic().playSound(Sound.BUTTON); - this.close(); - new Toolbar(app).open(); + close(); })); lowerLeftMenu.addChild(cancelButton); @@ -134,7 +128,7 @@ public class ChoosePartner extends Dialog { app.getGameLogic().playSound(Sound.BUTTON); String selectedPlayer = playerSelector.getSelectedItem(); System.out.println("Selected player: " + selectedPlayer); - this.close(); + close(); // TODO: Open trade menu or next step })); lowerRightMenu.addChild(confirmButton); @@ -153,11 +147,11 @@ public class ChoosePartner extends Dialog { private void addBackgroundImage() { Texture backgroundImage = app.getAssetManager().loadTexture("Pictures/unibw-Bib2.png"); Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight()); - Geometry background = new Geometry("Background", quad); + background = new Geometry("Background", quad); Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); backgroundMaterial.setTexture("ColorMap", backgroundImage); background.setMaterial(backgroundMaterial); - background.setLocalTranslation(0, 0, 1); // Position behind other GUI elements + background.setLocalTranslation(0, 0, 3); // Position behind other GUI elements app.getGuiNode().attachChild(background); } @@ -178,6 +172,16 @@ public class ChoosePartner extends Dialog { public void update(float delta) { // Periodic updates (if needed) can be implemented here } + + @Override + public void close() { + app.getGuiNode().detachChild(playerSelector); + app.getGuiNode().detachChild(lowerLeftMenu); + app.getGuiNode().detachChild(lowerRightMenu); + app.getGuiNode().detachChild(mainContainer); + app.getGuiNode().detachChild(background); + super.close(); + } } diff --git a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java index 35546eb..989a44e 100644 --- a/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java +++ b/Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/Toolbar.java @@ -166,7 +166,6 @@ public class Toolbar extends Dialog { tradebutton.setPreferredSize(new Vector3f(150, 50, 0)); // Größe des Buttons tradebutton.addClickCommands(s -> ifTopDialog( () -> { app.getGameLogic().playSound(Sound.BUTTON); - this.close(); new ChoosePartner(app).open(); })); return tradebutton;