Merge work #7

Merged
fkoppe merged 31 commits from dev/client_koppe into dev/client 2024-11-20 13:50:01 +01:00
Showing only changes of commit 728530a8f2 - Show all commits

View File

@@ -1,18 +1,17 @@
package pp.mdga.client.View; package pp.mdga.client.View;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Quad;
import com.simsilica.lemur.Container; import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label; import com.simsilica.lemur.Label;
import com.simsilica.lemur.Button; import com.simsilica.lemur.Button;
import pp.mdga.client.Dialog.MdgaButton;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.MdgaState; import pp.mdga.client.MdgaState;
/**
* The CeremonyView manages two sub-states: the Award Ceremony and the Statistics screen.
*/
public class CeremonyView extends MdgaView { public class CeremonyView extends MdgaView {
private enum SubState { private enum SubState {
@@ -20,38 +19,24 @@ private enum SubState {
STATISTICS 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) { public CeremonyView(MdgaApp app) {
super(app); super(app);
} }
@Override @Override
public void onEnter() { public void onEnter() {
// Initialize sub-states
setupAwardCeremony();
setupStatistics();
// Start with the Award Ceremony state
switchToSubState(SubState.AWARD_CEREMONY); switchToSubState(SubState.AWARD_CEREMONY);
} }
@Override @Override
public void onLeave() {} public void onLeave() {}
/** private void awardCeremony() {
* Sets up the Award Ceremony sub-state. node.detachAllChildren();
*/
private void setupAwardCeremony() {
awardCeremonyNode = new Node("AwardCeremonyNode");
// Add a background for the award ceremony
Geometry background = createBackground("b1.png"); Geometry background = createBackground("b1.png");
awardCeremonyNode.attachChild(background); node.attachChild(background);
// Create a container for the UI elements
Container container = new Container(); Container container = new Container();
container.setLocalTranslation(300, app.getCamera().getHeight() - 100, 0); 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 2 auf Platz 2"));
container.addChild(new Label("Spieler 3 auf Platz 3")); container.addChild(new Label("Spieler 3 auf Platz 3"));
Button continueButton = container.addChild(new Button("Weiter")); MdgaButton button = new MdgaButton("Weiter", () -> switchToSubState(SubState.STATISTICS), new Vector3f(150, 200, 0));
continueButton.addClickCommands(source -> switchToSubState(SubState.STATISTICS)); button.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 200, 100, 0));
awardCeremonyNode.attachChild(container); node.attachChild(button.getButton());
node.attachChild(container);
} }
/** private void statistics() {
* Sets up the Statistics sub-state. node.detachAllChildren();
*/
private void setupStatistics() {
statisticsNode = new Node("StatisticsNode");
// Add a background for the statistics
Geometry background = createBackground("b2.png"); Geometry background = createBackground("b2.png");
statisticsNode.attachChild(background); node.attachChild(background);
// Create a container for the statistics UI
Container container = new Container(); Container container = new Container();
container.setLocalTranslation(200, app.getCamera().getHeight() - 100, 0); 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 2: Punkte 80"));
container.addChild(new Label("Spieler 3: Punkte 60")); container.addChild(new Label("Spieler 3: Punkte 60"));
Button exitButton = container.addChild(new Button("Verlassen")); MdgaButton button = new MdgaButton("Weiter", () -> app.enter(MdgaState.MAIN), new Vector3f(150, 200, 0));
exitButton.addClickCommands(source -> app.enter(MdgaState.MAIN)); 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) { private void switchToSubState(SubState subState) {
//rootNode.detachAllChildren();
currentSubState = subState;
switch (subState) { switch (subState) {
case AWARD_CEREMONY: case AWARD_CEREMONY:
node.attachChild(awardCeremonyNode); awardCeremony();
break; break;
case STATISTICS: case STATISTICS:
node.attachChild(statisticsNode); statistics();
break; break;
} }
//app.getGuiNode().attachChild(rootNode);
} }
} }