Add left/right buttons
This commit is contained in:
		@@ -1,4 +1,30 @@
 | 
			
		||||
package pp.mdga.client.Dialog;
 | 
			
		||||
 | 
			
		||||
public class SingleButtonLeftDialog {
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SingleButtonLeftDialog extends Dialog {
 | 
			
		||||
    public SingleButtonLeftDialog(MdgaApp app, String label, Runnable action) {
 | 
			
		||||
        super(app);
 | 
			
		||||
 | 
			
		||||
        createButton(label, action, new Vector3f(1, 1, 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        float vertical = app.getCamera().getWidth() / 16 - container.getPreferredSize().x / 16;
 | 
			
		||||
        float horitontal = app.getCamera().getHeight() / 12 + container.getPreferredSize().y / 12;
 | 
			
		||||
 | 
			
		||||
        float x = 2 * vertical;
 | 
			
		||||
        float y = 2 * horitontal;
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@
 | 
			
		||||
import com.simsilica.lemur.core.GuiLayout;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SingleButtonRightDialog extends Dialog{
 | 
			
		||||
public class SingleButtonRightDialog extends Dialog {
 | 
			
		||||
    public SingleButtonRightDialog(MdgaApp app, String label, Runnable action) {
 | 
			
		||||
        super(app);
 | 
			
		||||
 | 
			
		||||
@@ -19,10 +19,10 @@ public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        float vertical = app.getCamera().getWidth() / 16 - container.getPreferredSize().x / 16;
 | 
			
		||||
        float horitontal = app.getCamera().getHeight() / 9 + container.getPreferredSize().y / 9;
 | 
			
		||||
        float horitontal = app.getCamera().getHeight() / 12 + container.getPreferredSize().y / 12;
 | 
			
		||||
 | 
			
		||||
        float x = 12 * vertical;
 | 
			
		||||
        float y = 1 * horitontal;
 | 
			
		||||
        float x = 14 * vertical;
 | 
			
		||||
        float y = 2 * horitontal;
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,4 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ModelSyncronizer {
 | 
			
		||||
}
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import com.simsilica.lemur.Container;
 | 
			
		||||
import com.simsilica.lemur.Label;
 | 
			
		||||
import pp.mdga.client.Dialog.SingleButtonLeftDialog;
 | 
			
		||||
import pp.mdga.client.Dialog.SingleButtonRightDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
@@ -13,29 +14,29 @@ public class CeremonyView extends MdgaView {
 | 
			
		||||
    private enum SubState {
 | 
			
		||||
        AWARD_CEREMONY,
 | 
			
		||||
        STATISTICS,
 | 
			
		||||
        MAIN,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private SubState state;
 | 
			
		||||
 | 
			
		||||
    private SingleButtonRightDialog continueButton;
 | 
			
		||||
    private SingleButtonLeftDialog backButton;
 | 
			
		||||
 | 
			
		||||
    public CeremonyView(MdgaApp app) {
 | 
			
		||||
        super(app);
 | 
			
		||||
 | 
			
		||||
        continueButton = new SingleButtonRightDialog(app, "Weiter", () -> next());
 | 
			
		||||
        continueButton = new SingleButtonRightDialog(app, "Weiter", () -> forward());
 | 
			
		||||
        backButton = new SingleButtonLeftDialog(app, "Zurück", () -> back());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onEnter() {
 | 
			
		||||
        state = SubState.AWARD_CEREMONY;
 | 
			
		||||
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
        enterSub(SubState.AWARD_CEREMONY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onLeave() {
 | 
			
		||||
        continueButton.hide();
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void awardCeremony() {
 | 
			
		||||
@@ -44,7 +45,8 @@ private void awardCeremony() {
 | 
			
		||||
        Geometry background = createBackground("b1.png");
 | 
			
		||||
        node.attachChild(background);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void statistics() {
 | 
			
		||||
@@ -53,10 +55,13 @@ private void statistics() {
 | 
			
		||||
        Geometry background = createBackground("b2.png");
 | 
			
		||||
        node.attachChild(background);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void into() {
 | 
			
		||||
    private void enterSub(SubState state) {
 | 
			
		||||
        this.state = state;
 | 
			
		||||
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case AWARD_CEREMONY:
 | 
			
		||||
                awardCeremony();
 | 
			
		||||
@@ -64,22 +69,27 @@ private void into() {
 | 
			
		||||
            case STATISTICS:
 | 
			
		||||
                statistics();
 | 
			
		||||
                break;
 | 
			
		||||
            case MAIN:
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void forward() {
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case AWARD_CEREMONY:
 | 
			
		||||
                enterSub(SubState.STATISTICS);
 | 
			
		||||
                break;
 | 
			
		||||
            case STATISTICS:
 | 
			
		||||
                app.enter(MdgaState.MAIN);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void next() {
 | 
			
		||||
    private void back() {
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case AWARD_CEREMONY:
 | 
			
		||||
 | 
			
		||||
                //nothing
 | 
			
		||||
                break;
 | 
			
		||||
            case STATISTICS:
 | 
			
		||||
 | 
			
		||||
                break;
 | 
			
		||||
            case MAIN:
 | 
			
		||||
                app.enter(MdgaState.MAIN);
 | 
			
		||||
                enterSub(SubState.AWARD_CEREMONY);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package pp.mdga.client.View;
 | 
			
		||||
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import pp.mdga.client.Dialog.SingleButtonLeftDialog;
 | 
			
		||||
import pp.mdga.client.Dialog.SingleButtonRightDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
@@ -9,7 +10,8 @@
 | 
			
		||||
public class LobbyView extends MdgaView {
 | 
			
		||||
    private Geometry background;
 | 
			
		||||
 | 
			
		||||
    private SingleButtonRightDialog continueButton;
 | 
			
		||||
    private SingleButtonRightDialog readyButton;
 | 
			
		||||
    private SingleButtonLeftDialog leaveButton;
 | 
			
		||||
 | 
			
		||||
    public LobbyView(MdgaApp app) {
 | 
			
		||||
        super(app);
 | 
			
		||||
@@ -17,17 +19,20 @@ public LobbyView(MdgaApp app) {
 | 
			
		||||
        background = createBackground("lobby.png");
 | 
			
		||||
        node.attachChild(background);
 | 
			
		||||
 | 
			
		||||
        continueButton = new SingleButtonRightDialog(app, "Weiter", () -> app.enter(MdgaState.GAME));
 | 
			
		||||
        readyButton = new SingleButtonRightDialog(app, "Fertig", () -> app.enter(MdgaState.GAME));
 | 
			
		||||
        leaveButton = new SingleButtonLeftDialog(app, "Verlassen", () -> app.enter(MdgaState.MAIN));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onEnter() {
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
        readyButton.show();
 | 
			
		||||
        leaveButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onLeave() {
 | 
			
		||||
        continueButton.hide();
 | 
			
		||||
        readyButton.hide();
 | 
			
		||||
        leaveButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user