From 728530a8f2dad7542d7a5f15dfa47878afba9f78 Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 18 Nov 2024 16:16:56 +0100 Subject: [PATCH] Finish loop --- .../pp/mdga/client/View/CeremonyView.java | 64 ++++++------------- 1 file changed, 18 insertions(+), 46 deletions(-) diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/CeremonyView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/View/CeremonyView.java index 847f867d..87c70536 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/CeremonyView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/View/CeremonyView.java @@ -1,18 +1,17 @@ package pp.mdga.client.View; import com.jme3.material.Material; +import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.shape.Quad; import com.simsilica.lemur.Container; import com.simsilica.lemur.Label; import com.simsilica.lemur.Button; +import pp.mdga.client.Dialog.MdgaButton; import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaState; -/** - * The CeremonyView manages two sub-states: the Award Ceremony and the Statistics screen. - */ public class CeremonyView extends MdgaView { private enum SubState { @@ -20,38 +19,24 @@ private enum SubState { STATISTICS } - private SubState currentSubState; // Tracks the current sub-state - private Node awardCeremonyNode; // Node for the award ceremony UI - private Node statisticsNode; // Node for the statistics UI - public CeremonyView(MdgaApp app) { super(app); } @Override public void onEnter() { - // Initialize sub-states - setupAwardCeremony(); - setupStatistics(); - - // Start with the Award Ceremony state switchToSubState(SubState.AWARD_CEREMONY); } @Override public void onLeave() {} - /** - * Sets up the Award Ceremony sub-state. - */ - private void setupAwardCeremony() { - awardCeremonyNode = new Node("AwardCeremonyNode"); + private void awardCeremony() { + node.detachAllChildren(); - // Add a background for the award ceremony Geometry background = createBackground("b1.png"); - awardCeremonyNode.attachChild(background); + node.attachChild(background); - // Create a container for the UI elements Container container = new Container(); container.setLocalTranslation(300, app.getCamera().getHeight() - 100, 0); @@ -60,23 +45,19 @@ private void setupAwardCeremony() { container.addChild(new Label("Spieler 2 auf Platz 2")); container.addChild(new Label("Spieler 3 auf Platz 3")); - Button continueButton = container.addChild(new Button("Weiter")); - continueButton.addClickCommands(source -> switchToSubState(SubState.STATISTICS)); + MdgaButton button = new MdgaButton("Weiter", () -> switchToSubState(SubState.STATISTICS), new Vector3f(150, 200, 0)); + button.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 200, 100, 0)); - awardCeremonyNode.attachChild(container); + node.attachChild(button.getButton()); + node.attachChild(container); } - /** - * Sets up the Statistics sub-state. - */ - private void setupStatistics() { - statisticsNode = new Node("StatisticsNode"); + private void statistics() { + node.detachAllChildren(); - // Add a background for the statistics Geometry background = createBackground("b2.png"); - statisticsNode.attachChild(background); + node.attachChild(background); - // Create a container for the statistics UI Container container = new Container(); container.setLocalTranslation(200, app.getCamera().getHeight() - 100, 0); @@ -85,30 +66,21 @@ private void setupStatistics() { container.addChild(new Label("Spieler 2: Punkte 80")); container.addChild(new Label("Spieler 3: Punkte 60")); - Button exitButton = container.addChild(new Button("Verlassen")); - exitButton.addClickCommands(source -> app.enter(MdgaState.MAIN)); + MdgaButton button = new MdgaButton("Weiter", () -> app.enter(MdgaState.MAIN), new Vector3f(150, 200, 0)); + button.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 200, 100, 0)); + node.attachChild(button.getButton()); - statisticsNode.attachChild(container); + node.attachChild(container); } - /** - * Switches between the Award Ceremony and Statistics sub-states. - * - * @param subState The target sub-state. - */ private void switchToSubState(SubState subState) { - //rootNode.detachAllChildren(); - currentSubState = subState; - switch (subState) { case AWARD_CEREMONY: - node.attachChild(awardCeremonyNode); + awardCeremony(); break; case STATISTICS: - node.attachChild(statisticsNode); + statistics(); break; } - - //app.getGuiNode().attachChild(rootNode); } }