tried merge with dev/client
This commit is contained in:
		@@ -1,17 +0,0 @@
 | 
			
		||||
<component name="ProjectRunConfigurationManager">
 | 
			
		||||
  <configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
 | 
			
		||||
    <option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
 | 
			
		||||
    <module name="Projekte.mdga.client.main" />
 | 
			
		||||
    <option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
 | 
			
		||||
    <option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
 | 
			
		||||
    <extension name="coverage">
 | 
			
		||||
      <pattern>
 | 
			
		||||
        <option name="PATTERN" value="pp.mdga.client.board.Outline.*" />
 | 
			
		||||
        <option name="ENABLED" value="true" />
 | 
			
		||||
      </pattern>
 | 
			
		||||
    </extension>
 | 
			
		||||
    <method v="2">
 | 
			
		||||
      <option name="Make" enabled="true" />
 | 
			
		||||
    </method>
 | 
			
		||||
  </configuration>
 | 
			
		||||
</component>
 | 
			
		||||
@@ -43,6 +43,7 @@ public class InputSynchronizer {
 | 
			
		||||
 | 
			
		||||
    private void setupInput() {
 | 
			
		||||
        inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
 | 
			
		||||
        inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
 | 
			
		||||
 | 
			
		||||
        inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
 | 
			
		||||
        inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
 | 
			
		||||
@@ -54,7 +55,7 @@ private void setupInput() {
 | 
			
		||||
        inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        inputManager.addListener(actionListener, "Settings", "RotateRightMouse", "Click", "Test");
 | 
			
		||||
        inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Test");
 | 
			
		||||
        inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -66,6 +67,9 @@ public void onAction(String name, boolean isPressed, float tpf) {
 | 
			
		||||
            if (name.equals("Settings") && isPressed) {
 | 
			
		||||
                app.getView().pressEscape();
 | 
			
		||||
            }
 | 
			
		||||
            if (name.equals("Forward") && isPressed) {
 | 
			
		||||
                app.getView().pressForward();
 | 
			
		||||
            }
 | 
			
		||||
            if (name.equals("RotateRightMouse")) {
 | 
			
		||||
                rightMousePressed = isPressed;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,107 +6,63 @@
 | 
			
		||||
import pp.mdga.client.animation.AnimationHandler;
 | 
			
		||||
import com.jme3.system.AppSettings;
 | 
			
		||||
import pp.mdga.client.view.*;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public class MdgaApp extends SimpleApplication {
 | 
			
		||||
    private AnimationHandler animationHandler;
 | 
			
		||||
    private AcousticHandler acousticHandler;
 | 
			
		||||
    private NotificationSynchronizer notificationSynchronizer;
 | 
			
		||||
    private InputSynchronizer inputSynchronizer;
 | 
			
		||||
    private ModelSynchronizer modelSynchronizer;
 | 
			
		||||
    private ModelSyncronizer modelSyncronizer;
 | 
			
		||||
 | 
			
		||||
    MdgaView view = null;
 | 
			
		||||
    private MdgaState state = MdgaState.GAME;
 | 
			
		||||
    private MdgaState state = null;
 | 
			
		||||
 | 
			
		||||
    private static float resolutionFactor = 1.2f;
 | 
			
		||||
    private static float imageScale = 1.5f;
 | 
			
		||||
 | 
			
		||||
    private MdgaView mainView;
 | 
			
		||||
    private MdgaView lobbyView;
 | 
			
		||||
    private MdgaView gameView;
 | 
			
		||||
    private MdgaView ceremonyView;
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        AppSettings settings = new AppSettings(true);
 | 
			
		||||
        settings.setSamples(128);
 | 
			
		||||
        settings.setCenterWindow(true);
 | 
			
		||||
 | 
			
		||||
        int width = (int)(1280 * resolutionFactor);
 | 
			
		||||
        int height = (int)(720 * resolutionFactor);
 | 
			
		||||
 | 
			
		||||
        settings.setWidth(width);
 | 
			
		||||
        settings.setHeight(height);
 | 
			
		||||
 | 
			
		||||
        settings.setWidth(1920);
 | 
			
		||||
        settings.setHeight(1080);
 | 
			
		||||
        settings.setVSync(false);
 | 
			
		||||
 | 
			
		||||
        MdgaApp app = new MdgaApp();
 | 
			
		||||
        app.setSettings(settings);
 | 
			
		||||
        app.setShowSettings(false);
 | 
			
		||||
        app.setPauseOnLostFocus(false);
 | 
			
		||||
        app.start();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void simpleInitApp() {
 | 
			
		||||
        GuiGlobals.initialize(this);
 | 
			
		||||
 | 
			
		||||
        inputManager.deleteMapping("SIMPLEAPP_Exit");
 | 
			
		||||
 | 
			
		||||
        flyCam.setEnabled(false);
 | 
			
		||||
 | 
			
		||||
        animationHandler = new AnimationHandler(this);
 | 
			
		||||
        acousticHandler = new AcousticHandler(this);
 | 
			
		||||
        notificationSynchronizer = new NotificationSynchronizer(this);
 | 
			
		||||
        inputSynchronizer = new InputSynchronizer(this);
 | 
			
		||||
        modelSynchronizer = new ModelSynchronizer(this);
 | 
			
		||||
        modelSyncronizer = new ModelSyncronizer(this);
 | 
			
		||||
 | 
			
		||||
        inputManager.deleteMapping("SIMPLEAPP_Exit");
 | 
			
		||||
        flyCam.setEnabled(false);
 | 
			
		||||
        GuiGlobals.initialize(this);
 | 
			
		||||
        mainView = new MainView(this);
 | 
			
		||||
        lobbyView = new LobbyView(this);
 | 
			
		||||
        gameView = new GameView(this);
 | 
			
		||||
        ceremonyView = new CeremonyView(this);
 | 
			
		||||
 | 
			
		||||
        enter(state);
 | 
			
		||||
 | 
			
		||||
        List<UUID> test = new ArrayList<>();
 | 
			
		||||
        UUID player0 = UUID.randomUUID();
 | 
			
		||||
        test.add(player0);
 | 
			
		||||
        UUID player1 = UUID.randomUUID();
 | 
			
		||||
        test.add(player1);
 | 
			
		||||
        test.add(UUID.randomUUID());
 | 
			
		||||
        test.add(UUID.randomUUID());
 | 
			
		||||
 | 
			
		||||
        List<UUID> test_1 = new ArrayList<>();
 | 
			
		||||
        UUID player0_1 = UUID.randomUUID();
 | 
			
		||||
        test_1.add(player0_1);
 | 
			
		||||
        UUID player1_1 = UUID.randomUUID();
 | 
			
		||||
        test_1.add(player1_1);
 | 
			
		||||
        test_1.add(UUID.randomUUID());
 | 
			
		||||
        test_1.add(UUID.randomUUID());
 | 
			
		||||
 | 
			
		||||
        List<UUID> test_2 = new ArrayList<>();
 | 
			
		||||
        test_2.add(UUID.randomUUID());
 | 
			
		||||
        test_2.add(UUID.randomUUID());
 | 
			
		||||
        test_2.add(UUID.randomUUID());
 | 
			
		||||
        test_2.add(UUID.randomUUID());
 | 
			
		||||
 | 
			
		||||
        List<UUID> test_3 = new ArrayList<>();
 | 
			
		||||
        test_3.add(UUID.randomUUID());
 | 
			
		||||
        test_3.add(UUID.randomUUID());
 | 
			
		||||
        test_3.add(UUID.randomUUID());
 | 
			
		||||
        test_3.add(UUID.randomUUID());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        ((GameView) view).setOwnColor(Color.NAVY);
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, test, "Player 1"));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.NAVY, test_1, "Player 2"));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.ARMY, test_2, "Player 3"));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.CYBER, test_3, "Player 4"));
 | 
			
		||||
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new MovePieceNotification(player0, 0, true));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new MovePieceNotification(player0_1, 20, true));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new MovePieceNotification(player0_1, 20, 21));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new MovePieceNotification(player1, 0, true));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new MovePieceNotification(player0, 0, 7));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new SelectableMoveNotification(new ArrayList<>(List.of(player0, player1)), new ArrayList<>(List.of(7,3)), new ArrayList<>(List.of(false, true))));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new SwapPieceNotification(player0, player0_1));
 | 
			
		||||
//        notificationSynchronizer.addTestNotification(new SelectableSwapNotification(new ArrayList<>(List.of(player0, player1)), new ArrayList<>(List.of(player0_1))));
 | 
			
		||||
        enter(MdgaState.MAIN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void simpleUpdate(float tpf) {
 | 
			
		||||
        view.update();
 | 
			
		||||
        view.update(tpf);
 | 
			
		||||
        acousticHandler.update();
 | 
			
		||||
        notificationSynchronizer.update();
 | 
			
		||||
    }
 | 
			
		||||
@@ -120,16 +76,16 @@ public void enter(MdgaState state) {
 | 
			
		||||
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case MAIN:
 | 
			
		||||
                view = new MainView(this);
 | 
			
		||||
                view = mainView;
 | 
			
		||||
                break;
 | 
			
		||||
            case LOBBY:
 | 
			
		||||
                view = new LobbyView(this);
 | 
			
		||||
                view = lobbyView;
 | 
			
		||||
                break;
 | 
			
		||||
            case GAME:
 | 
			
		||||
                view = new GameView(this);
 | 
			
		||||
                view = gameView;
 | 
			
		||||
                break;
 | 
			
		||||
            case CEREMONY:
 | 
			
		||||
                view = new CeremonyView(this);
 | 
			
		||||
                view = ceremonyView;
 | 
			
		||||
                break;
 | 
			
		||||
            case NONE:
 | 
			
		||||
                throw new RuntimeException("cant enter state NONE");
 | 
			
		||||
@@ -140,10 +96,6 @@ public void enter(MdgaState state) {
 | 
			
		||||
        view.enter();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void afteGameCleanup() {
 | 
			
		||||
        //TODO
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public AnimationHandler getAnimationHandler() {
 | 
			
		||||
        return animationHandler;
 | 
			
		||||
    }
 | 
			
		||||
@@ -154,17 +106,19 @@ public AcousticHandler getAcousticHandler() {
 | 
			
		||||
 | 
			
		||||
    public MdgaState getState() {return state; }
 | 
			
		||||
 | 
			
		||||
    public float getResolutionFactor() {
 | 
			
		||||
        return resolutionFactor;
 | 
			
		||||
    public float getImageScale() {
 | 
			
		||||
        return imageScale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MdgaView getView() {
 | 
			
		||||
        return view;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ModelSynchronizer getModelSyncronizer() {
 | 
			
		||||
        return modelSynchronizer;
 | 
			
		||||
    public ModelSyncronizer getModelSyncronizer() {
 | 
			
		||||
        return modelSyncronizer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; }
 | 
			
		||||
 | 
			
		||||
    public NotificationSynchronizer getNotificationSynchronizer() { return  notificationSynchronizer; }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,72 +1,123 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.view.CeremonyView;
 | 
			
		||||
import pp.mdga.client.view.GameView;
 | 
			
		||||
import pp.mdga.client.view.LobbyView;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.notification.AcquireCardNotification;
 | 
			
		||||
import pp.mdga.notification.DrawCardNotification;
 | 
			
		||||
import pp.mdga.notification.TskSelectNotification;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
import java.util.logging.Logger;
 | 
			
		||||
 | 
			
		||||
public class ModelSynchronizer {
 | 
			
		||||
    private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName());
 | 
			
		||||
    private MdgaApp app;
 | 
			
		||||
 | 
			
		||||
    ModelSynchronizer(MdgaApp app) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectPiece() {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("selectPiece");
 | 
			
		||||
    public void animationEnd() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectCard() {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("selectCard");
 | 
			
		||||
    public void selectSwap(UUID a, UUID b) {
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "selectPiece");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectPiece(UUID piece) {
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "selectPiece");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectCard(BonusCard card) {
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "selectCard");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void confirm() {
 | 
			
		||||
        LOGGER.log(Level.INFO, "confirm");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectTsk(Color color) {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("selectTsk: " + color);
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "selectTsk: {0}", color);
 | 
			
		||||
        LobbyView view = (LobbyView) app.getView();
 | 
			
		||||
        view.setTaken(color, true, true, "OwnPlayerName");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void unselectTsk() {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("unselectTsk");
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "unselectTsk");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void rolledDice() {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("rolledDice");
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "rolledDice");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("setName:" + name);
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "setName: {0}", name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setReady() {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("setReady");
 | 
			
		||||
        app.enter(MdgaState.GAME);
 | 
			
		||||
        LOGGER.log(Level.INFO, "setReady");
 | 
			
		||||
        enter(MdgaState.GAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHost(int port) {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("setHost: " + port);
 | 
			
		||||
        app.enter(MdgaState.LOBBY);
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "setHost: {0}", port);
 | 
			
		||||
        enter(MdgaState.LOBBY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setJoin(String ip, int port) {
 | 
			
		||||
        //TODO call from somewhere
 | 
			
		||||
        System.out.println("setJoin");
 | 
			
		||||
        app.enter(MdgaState.LOBBY);
 | 
			
		||||
        // TODO call from somewhere
 | 
			
		||||
        LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port});
 | 
			
		||||
        enter(MdgaState.LOBBY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void leave() {
 | 
			
		||||
        System.out.println("leave");
 | 
			
		||||
        app.enter(MdgaState.MAIN);
 | 
			
		||||
        LOGGER.log(Level.INFO, "leave");
 | 
			
		||||
        enter(MdgaState.MAIN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void enter(MdgaState state) {
 | 
			
		||||
        System.out.println("enter:" + state);
 | 
			
		||||
        LOGGER.log(Level.INFO, "enter: {0}", state);
 | 
			
		||||
        app.enter(state);
 | 
			
		||||
 | 
			
		||||
        if (state == MdgaState.CEREMONY) {
 | 
			
		||||
            CeremonyView ceremonyView = (CeremonyView) app.getView();
 | 
			
		||||
            ceremonyView.addCeremonyParticipant(Color.AIRFORCE, 1, "ugidffdg");
 | 
			
		||||
            ceremonyView.addCeremonyParticipant(Color.ARMY, 2, "ugidffdg");
 | 
			
		||||
            ceremonyView.addCeremonyParticipant(Color.NAVY, 3, "ugidffdg");
 | 
			
		||||
            ceremonyView.addCeremonyParticipant(Color.CYBER, 4, "ugidffdg");
 | 
			
		||||
 | 
			
		||||
            ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
 | 
			
		||||
            ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
 | 
			
		||||
            ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
 | 
			
		||||
            ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
 | 
			
		||||
            ceremonyView.addStatisticsRow("Gesamt", 1, 2, 3, 4, 5, 6);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (state == MdgaState.GAME) {
 | 
			
		||||
            GameView gameView = (GameView) app.getView();
 | 
			
		||||
 | 
			
		||||
            app.getNotificationSynchronizer().addTestNotification(new DrawCardNotification(Color.AIRFORCE, BonusCard.SHIELD));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (state == MdgaState.LOBBY) {
 | 
			
		||||
            LobbyView lobbyView = (LobbyView) app.getView();
 | 
			
		||||
 | 
			
		||||
            app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.CYBER, "blablabupp", false));
 | 
			
		||||
            app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.ARMY, "Spieler 2", false));
 | 
			
		||||
            lobbyView.setReady(Color.ARMY, true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,8 +2,10 @@
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.board.BoardHandler;
 | 
			
		||||
import pp.mdga.client.gui.GuiHandler;
 | 
			
		||||
import pp.mdga.client.view.CeremonyView;
 | 
			
		||||
import pp.mdga.client.view.GameView;
 | 
			
		||||
import pp.mdga.client.view.LobbyView;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
@@ -59,6 +61,8 @@ private void handleLobby(Notification notification) {
 | 
			
		||||
            lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
 | 
			
		||||
        } else if (notification instanceof TskUnselectNotification n) {
 | 
			
		||||
            lobbyView.setTaken(n.getColor(), false, false, null);
 | 
			
		||||
            //} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
 | 
			
		||||
        //    lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
 | 
			
		||||
        } else if (notification instanceof GameNotification) {
 | 
			
		||||
            app.enter(MdgaState.GAME);
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -75,8 +79,33 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            guiHandler.addCard(n.getBonusCard());
 | 
			
		||||
        } else if (notification instanceof ActivePlayerNotification n) {
 | 
			
		||||
            guiHandler.setActivePlayer(n.getColor());
 | 
			
		||||
        } else if (notification instanceof CeremonyNotification) {
 | 
			
		||||
        } else if (notification instanceof CeremonyNotification n) {
 | 
			
		||||
            app.enter(MdgaState.CEREMONY);
 | 
			
		||||
            CeremonyView ceremonyView = (CeremonyView) app.getView();
 | 
			
		||||
            int size = n.getNames().size();
 | 
			
		||||
 | 
			
		||||
            if (n.getPiecesThrown().size() != size ||
 | 
			
		||||
                n.getPiecesLost().size() != size ||
 | 
			
		||||
                n.getBonusCardsPlayed().size() != size ||
 | 
			
		||||
                n.getSixes().size() != size ||
 | 
			
		||||
                n.getNodesMoved().size() != size ||
 | 
			
		||||
                n.getBonusNodes().size() != size) {
 | 
			
		||||
                throw new IllegalArgumentException("All data lists in CeremonyNotification must have the same size.");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < size; i++) {
 | 
			
		||||
                Color color = n.getColors().get(i);
 | 
			
		||||
                String name = n.getNames().get(i);
 | 
			
		||||
                int v1 = n.getPiecesThrown().get(i);
 | 
			
		||||
                int v2 = n.getPiecesLost().get(i);
 | 
			
		||||
                int v3 = n.getBonusCardsPlayed().get(i);
 | 
			
		||||
                int v4 = n.getSixes().get(i);
 | 
			
		||||
                int v5 = n.getNodesMoved().get(i);
 | 
			
		||||
                int v6 = n.getBonusNodes().get(i);
 | 
			
		||||
 | 
			
		||||
                ceremonyView.addCeremonyParticipant(color, i, name);
 | 
			
		||||
                ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
 | 
			
		||||
            }
 | 
			
		||||
        } else if (notification instanceof DiceNowNotification) {
 | 
			
		||||
            guiHandler.showDice();
 | 
			
		||||
        } else if (notification instanceof DicingNotification n) {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.prefs.Preferences;
 | 
			
		||||
 | 
			
		||||
public class AcousticHandler {
 | 
			
		||||
    private MdgaApp app;
 | 
			
		||||
@@ -23,14 +24,20 @@ public class AcousticHandler {
 | 
			
		||||
    private GameMusic scheduled = null; // Scheduled track to play next
 | 
			
		||||
    private GameMusic old = null; // Old track being faded out
 | 
			
		||||
 | 
			
		||||
    private float mainVolume = 1.0f;
 | 
			
		||||
    private float mainVolume = 0.0f;
 | 
			
		||||
    private float musicVolume = 1.0f;
 | 
			
		||||
    private float soundVolume = 1.0f;
 | 
			
		||||
 | 
			
		||||
    private ArrayList<GameSound> sounds = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    private Preferences prefs = Preferences.userNodeForPackage(AcousticHandler.class);
 | 
			
		||||
 | 
			
		||||
    public AcousticHandler(MdgaApp app) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
 | 
			
		||||
        mainVolume = prefs.getFloat("mainVolume", 1.0f);
 | 
			
		||||
        musicVolume = prefs.getFloat("musicVolume", 1.0f);
 | 
			
		||||
        soundVolume = prefs.getFloat("soundVolume", 1.0f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -67,7 +74,19 @@ public void playSound(MdgaSound sound) {
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.LOST, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case VICTORY:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.VICTORY, 1.0f, 2.0f));
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.VICTORY, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case BUTTON_PRESSED:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.BUTTON_PRESS, 0.7f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case WRONG_INPUT:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.ERROR, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case UI_CLICK:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.UI_CLICK, 0.8f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case START:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.START, 0.8f, 0.2f));
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
 | 
			
		||||
@@ -362,6 +381,7 @@ public float getSoundVolume() {
 | 
			
		||||
     */
 | 
			
		||||
    public void setMainVolume(float mainVolume) {
 | 
			
		||||
        this.mainVolume = mainVolume;
 | 
			
		||||
        prefs.putFloat("mainVolume", mainVolume);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -371,6 +391,7 @@ public void setMainVolume(float mainVolume) {
 | 
			
		||||
     */
 | 
			
		||||
    public void setMusicVolume(float musicVolume) {
 | 
			
		||||
        this.musicVolume = musicVolume;
 | 
			
		||||
        prefs.putFloat("musicVolume", musicVolume);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -380,6 +401,7 @@ public void setMusicVolume(float musicVolume) {
 | 
			
		||||
     */
 | 
			
		||||
    public void setSoundVolume(float soundVolume) {
 | 
			
		||||
        this.soundVolume = soundVolume;
 | 
			
		||||
        prefs.putFloat("soundVolume", soundVolume);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -19,5 +19,9 @@ public enum MdgaSound {
 | 
			
		||||
    DESELECT,
 | 
			
		||||
    HURRY,
 | 
			
		||||
    VICTORY,
 | 
			
		||||
    LOST
 | 
			
		||||
    LOST,
 | 
			
		||||
    BUTTON_PRESSED,
 | 
			
		||||
    WRONG_INPUT,
 | 
			
		||||
    UI_CLICK,
 | 
			
		||||
    START,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,11 @@ enum SoundAsset {
 | 
			
		||||
    DESELECT(""),
 | 
			
		||||
    HURRY(""),
 | 
			
		||||
    VICTORY("LevelUp2.wav"),
 | 
			
		||||
    LOST("GameOver.wav");
 | 
			
		||||
    LOST("GameOver.wav"),
 | 
			
		||||
    BUTTON_PRESS("menu_button.ogg"),
 | 
			
		||||
    ERROR("error_sound.ogg"),
 | 
			
		||||
    UI_CLICK("uiclick.ogg"),
 | 
			
		||||
    START("gamestart.ogg");
 | 
			
		||||
 | 
			
		||||
    private final String path;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,10 @@
 | 
			
		||||
import com.jme3.light.DirectionalLight;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.FastMath;
 | 
			
		||||
import com.jme3.math.Quaternion;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.post.FilterPostProcessor;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.jme3.shadow.DirectionalLightShadowFilter;
 | 
			
		||||
import com.jme3.shadow.EdgeFilteringMode;
 | 
			
		||||
import com.jme3.util.SkyFactory;
 | 
			
		||||
@@ -20,8 +22,21 @@ public class CameraHandler {
 | 
			
		||||
 | 
			
		||||
    private static final int SHADOWMAP_SIZE = 1024 * 8;
 | 
			
		||||
 | 
			
		||||
    public CameraHandler(MdgaApp app, FilterPostProcessor fpp){
 | 
			
		||||
    private Vector3f defaultCameraPosition;
 | 
			
		||||
    private Quaternion defaultCameraRotation;
 | 
			
		||||
 | 
			
		||||
    FilterPostProcessor fpp;
 | 
			
		||||
    DirectionalLightShadowFilter dlsf;
 | 
			
		||||
 | 
			
		||||
    Spatial sky;
 | 
			
		||||
 | 
			
		||||
    public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        this.fpp = fpp;
 | 
			
		||||
 | 
			
		||||
        // Save the default camera state
 | 
			
		||||
        this.defaultCameraPosition = app.getCamera().getLocation().clone();
 | 
			
		||||
        this.defaultCameraRotation = app.getCamera().getRotation().clone();
 | 
			
		||||
 | 
			
		||||
        sun = new DirectionalLight();
 | 
			
		||||
        sun.setColor(ColorRGBA.White);
 | 
			
		||||
@@ -30,24 +45,35 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp){
 | 
			
		||||
        ambient = new AmbientLight();
 | 
			
		||||
        ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
 | 
			
		||||
 | 
			
		||||
        DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 4);
 | 
			
		||||
        dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 4);
 | 
			
		||||
        dlsf.setLight(sun);
 | 
			
		||||
        dlsf.setEnabled(true);
 | 
			
		||||
        dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
 | 
			
		||||
        dlsf.setShadowIntensity(0.7f);
 | 
			
		||||
        fpp.addFilter(dlsf);
 | 
			
		||||
 | 
			
		||||
        app.getRootNode().attachChild(SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f));
 | 
			
		||||
        sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void init() {
 | 
			
		||||
        app.getRootNode().addLight(sun);
 | 
			
		||||
        app.getRootNode().addLight(ambient);
 | 
			
		||||
        app.getRootNode().attachChild(sky);
 | 
			
		||||
        fpp.addFilter(dlsf);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void shutdown() {
 | 
			
		||||
        app.getRootNode().removeLight(sun);
 | 
			
		||||
        app.getRootNode().removeLight(ambient);
 | 
			
		||||
        app.getRootNode().detachChild(sky);
 | 
			
		||||
 | 
			
		||||
        // Reset the camera to its default state
 | 
			
		||||
        app.getCamera().setLocation(defaultCameraPosition);
 | 
			
		||||
        app.getCamera().setRotation(defaultCameraRotation);
 | 
			
		||||
 | 
			
		||||
        fpp.removeFilter(dlsf);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update(float scroll, float rotation) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,12 @@
 | 
			
		||||
package pp.mdga.client.board.Outline;
 | 
			
		||||
 | 
			
		||||
import com.jme3.asset.AssetManager;
 | 
			
		||||
import com.jme3.material.Material;
 | 
			
		||||
import com.jme3.material.RenderState;
 | 
			
		||||
import com.jme3.material.RenderState.BlendMode;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.post.Filter;
 | 
			
		||||
import com.jme3.post.FilterPostProcessor;
 | 
			
		||||
import com.jme3.renderer.Camera;
 | 
			
		||||
import com.jme3.renderer.RenderManager;
 | 
			
		||||
import com.jme3.renderer.ViewPort;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
public class SelectObjectOutliner {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,56 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.font.BitmapFont;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public abstract class AbstractButton {
 | 
			
		||||
    public static final ColorRGBA BUTTON_NORMAL = ColorRGBA.fromRGBA255(169, 165, 104, 255);
 | 
			
		||||
    public static final ColorRGBA BUTTON_PRESSED = ColorRGBA.fromRGBA255(105, 117, 89, 255);
 | 
			
		||||
    public static final ColorRGBA TEXT_NORMAL = ColorRGBA.Black;
 | 
			
		||||
    public static final ColorRGBA TEXT_PRESSED = ColorRGBA.fromRGBA255( 	180, 195, 191, 255);
 | 
			
		||||
 | 
			
		||||
    public static final float HORIZONTAL = 16;
 | 
			
		||||
    public static final float VERTICAL = 9;
 | 
			
		||||
 | 
			
		||||
    protected BitmapFont font;
 | 
			
		||||
 | 
			
		||||
    protected final MdgaApp app;
 | 
			
		||||
    protected final Node node;
 | 
			
		||||
 | 
			
		||||
    protected Vector2f pos;
 | 
			
		||||
    protected float fontSizeFactor = 1.0f;
 | 
			
		||||
 | 
			
		||||
    protected float fontSize;
 | 
			
		||||
    protected float horizontalStep;
 | 
			
		||||
    protected float verticalStep;
 | 
			
		||||
    protected float heightStep;
 | 
			
		||||
    protected float widthStep;
 | 
			
		||||
 | 
			
		||||
    protected boolean adjust = false;
 | 
			
		||||
 | 
			
		||||
    public AbstractButton(MdgaApp app, Node node) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        this.node = node;
 | 
			
		||||
 | 
			
		||||
        font = app.getAssetManager().loadFont("Fonts/Gunplay.fnt");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public abstract void show();
 | 
			
		||||
    public abstract void hide();
 | 
			
		||||
 | 
			
		||||
    public void setPos(Vector2f pos) {
 | 
			
		||||
        this.pos = pos;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void calculateRelative() {
 | 
			
		||||
        fontSize = fontSizeFactor * 15 * (float)app.getCamera().getWidth() / 720;
 | 
			
		||||
 | 
			
		||||
        horizontalStep = (float)app.getCamera().getWidth() / HORIZONTAL;
 | 
			
		||||
        verticalStep = (float)app.getCamera().getHeight() / VERTICAL;
 | 
			
		||||
        heightStep = verticalStep / 2;
 | 
			
		||||
        widthStep = horizontalStep / 2;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class ButtonLeft extends ClickButton {
 | 
			
		||||
    public ButtonLeft(MdgaApp app, Node node, Runnable action, String label, int narrowFactor) {
 | 
			
		||||
        super(app, node, action, label, new Vector2f( 5, 2), new Vector2f(0.5f * narrowFactor, 1.8f));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,23 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class ButtonRight extends ClickButton {
 | 
			
		||||
    public ButtonRight(MdgaApp app, Node node, Runnable action, String label, int narrowFactor) {
 | 
			
		||||
        super(app, node, action, label, new Vector2f( 5, 2), new Vector2f(HORIZONTAL - 0.5f * narrowFactor, 1.8f));
 | 
			
		||||
 | 
			
		||||
        adjust = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,178 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.material.Material;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Quaternion;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.renderer.queue.RenderQueue;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.Asset;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
public class CeremonyButton extends ClickButton {
 | 
			
		||||
    public enum Pos {
 | 
			
		||||
        FIRST,
 | 
			
		||||
        SECOND,
 | 
			
		||||
        THIRD,
 | 
			
		||||
        LOST,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static final float WIDTH = 4.0f;
 | 
			
		||||
 | 
			
		||||
    private final Node node3d;
 | 
			
		||||
 | 
			
		||||
    private boolean rotate = false;
 | 
			
		||||
    private Spatial model;
 | 
			
		||||
    private float rot = 180;
 | 
			
		||||
 | 
			
		||||
    private LobbyButton.Taken taken = LobbyButton.Taken.NOT;
 | 
			
		||||
 | 
			
		||||
    private LabelButton label;
 | 
			
		||||
 | 
			
		||||
    public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, String name) {
 | 
			
		||||
        super(app, node, () -> {} , "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
 | 
			
		||||
 | 
			
		||||
        this.node3d = node3d;
 | 
			
		||||
 | 
			
		||||
        label = new LabelButton(app, node, name, new Vector2f( WIDTH, 1), new Vector2f(0, 0));
 | 
			
		||||
 | 
			
		||||
        final float mid = HORIZONTAL / 2;
 | 
			
		||||
        final float uiSpacing = 1.4f;
 | 
			
		||||
        final float figSpacingX = 0.9f;
 | 
			
		||||
        final float figSpacingY = 0.25f;
 | 
			
		||||
 | 
			
		||||
        float uiX = mid;
 | 
			
		||||
        float uiY = 6;
 | 
			
		||||
        float figX = 0;
 | 
			
		||||
        float figY = -0.32f;
 | 
			
		||||
 | 
			
		||||
        Asset asset = switch (tsk) {
 | 
			
		||||
            case CYBER -> {
 | 
			
		||||
                instance.setText("CIR");
 | 
			
		||||
                yield Asset.cir;
 | 
			
		||||
            }
 | 
			
		||||
            case AIRFORCE -> {
 | 
			
		||||
                instance.setText("Luftwaffe");
 | 
			
		||||
                yield Asset.lw;
 | 
			
		||||
            }
 | 
			
		||||
            case ARMY -> {
 | 
			
		||||
                instance.setText("Heer");
 | 
			
		||||
                yield Asset.heer;
 | 
			
		||||
            }
 | 
			
		||||
            case NAVY -> {
 | 
			
		||||
                instance.setText("Marine");
 | 
			
		||||
                yield Asset.marine;
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        switch (pos) {
 | 
			
		||||
            case FIRST:
 | 
			
		||||
                rotate = true;
 | 
			
		||||
                uiX = 0;
 | 
			
		||||
                uiY -= 0;
 | 
			
		||||
                figX = 0;
 | 
			
		||||
                figY -= 1 * figSpacingY;
 | 
			
		||||
                break;
 | 
			
		||||
            case SECOND:
 | 
			
		||||
                adjust = true;
 | 
			
		||||
                label.adjust = true;
 | 
			
		||||
                uiX -= uiSpacing;
 | 
			
		||||
                uiY -= 1;
 | 
			
		||||
                figX -= figSpacingX;
 | 
			
		||||
                figY -= 2 * figSpacingY;
 | 
			
		||||
                figY -= 0.1f;
 | 
			
		||||
                break;
 | 
			
		||||
            case THIRD:
 | 
			
		||||
                uiX += uiSpacing;
 | 
			
		||||
                uiY -= 1.5f;
 | 
			
		||||
                figX += figSpacingX;
 | 
			
		||||
                figY -= 3 * figSpacingY;
 | 
			
		||||
                figY -= 0.07f;
 | 
			
		||||
                break;
 | 
			
		||||
            case LOST:
 | 
			
		||||
                adjust = true;
 | 
			
		||||
                label.adjust = true;
 | 
			
		||||
                uiX -= 1 * uiSpacing + 0.4f;
 | 
			
		||||
                uiX -= WIDTH / 2;
 | 
			
		||||
                uiY -= 2;
 | 
			
		||||
                figX -= 2 * figSpacingX;
 | 
			
		||||
                figY -= 4 * figSpacingY;
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setPos(new Vector2f(uiX, uiY));
 | 
			
		||||
        label.setPos(new Vector2f(uiX, uiY + 1));
 | 
			
		||||
 | 
			
		||||
        createModel(asset, new Vector3f(figX, figY, 6));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onHover() {
 | 
			
		||||
        ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
 | 
			
		||||
        buttonNormal.a = 0.01f;
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnHover() {
 | 
			
		||||
        ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
 | 
			
		||||
        buttonNormal.a = 0.01f;
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        release();
 | 
			
		||||
 | 
			
		||||
        calculateRelative();
 | 
			
		||||
        setRelative();
 | 
			
		||||
 | 
			
		||||
        node.attachChild(instance);
 | 
			
		||||
        node3d.attachChild(model);
 | 
			
		||||
 | 
			
		||||
        label.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        node.detachChild(instance);
 | 
			
		||||
        node3d.detachChild(model);
 | 
			
		||||
 | 
			
		||||
        label.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update(float tpf) {
 | 
			
		||||
        if(rotate) {
 | 
			
		||||
            rot += 140.0f * tpf;
 | 
			
		||||
            rot %= 360;
 | 
			
		||||
        } else {
 | 
			
		||||
            rot = 180;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        model.setLocalRotation(new Quaternion().fromAngles((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void createModel(Asset asset, Vector3f pos) {
 | 
			
		||||
        String modelName = asset.getModelPath();
 | 
			
		||||
        String texName = asset.getDiffPath();
 | 
			
		||||
 | 
			
		||||
        model = app.getAssetManager().loadModel(modelName);
 | 
			
		||||
        model.scale(asset.getSize() / 2);
 | 
			
		||||
        model.rotate((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180));
 | 
			
		||||
        model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
 | 
			
		||||
 | 
			
		||||
        model.setLocalTranslation(pos);
 | 
			
		||||
 | 
			
		||||
        Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
 | 
			
		||||
        mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
 | 
			
		||||
        model.setMaterial(mat);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,108 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.Button;
 | 
			
		||||
import com.simsilica.lemur.HAlignment;
 | 
			
		||||
import com.simsilica.lemur.VAlignment;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
 | 
			
		||||
public abstract class ClickButton extends AbstractButton {
 | 
			
		||||
    protected final Runnable action;
 | 
			
		||||
 | 
			
		||||
    protected String label;
 | 
			
		||||
    protected Vector2f size;
 | 
			
		||||
 | 
			
		||||
    protected Button instance;
 | 
			
		||||
 | 
			
		||||
    ClickButton(MdgaApp app, Node node, Runnable action, String label, Vector2f size, Vector2f pos) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        this.action = action;
 | 
			
		||||
        this.label = label;
 | 
			
		||||
        this.pos = pos;
 | 
			
		||||
        this.size = size;
 | 
			
		||||
 | 
			
		||||
        instance = new Button(label);
 | 
			
		||||
 | 
			
		||||
        instance.addClickCommands((button) -> { app.getAcousticHandler().playSound(MdgaSound.BUTTON_PRESSED); action.run(); });
 | 
			
		||||
        instance.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        instance.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        instance.addCommands(Button.ButtonAction.HighlightOn, (button) -> click());
 | 
			
		||||
        instance.addCommands(Button.ButtonAction.HighlightOff, (button) -> release());
 | 
			
		||||
 | 
			
		||||
        instance.setFont(font);
 | 
			
		||||
        instance.setFocusColor(TEXT_NORMAL);
 | 
			
		||||
 | 
			
		||||
        calculateRelative();
 | 
			
		||||
        setRelative();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        release();
 | 
			
		||||
 | 
			
		||||
        calculateRelative();
 | 
			
		||||
        setRelative();
 | 
			
		||||
 | 
			
		||||
        node.attachChild(instance);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        node.detachChild(instance);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected abstract void onHover();
 | 
			
		||||
    protected abstract void onUnHover();
 | 
			
		||||
 | 
			
		||||
    protected void click() {
 | 
			
		||||
        instance.setColor(TEXT_PRESSED);
 | 
			
		||||
        instance.setHighlightColor(TEXT_PRESSED);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_PRESSED);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.UI_CLICK);
 | 
			
		||||
 | 
			
		||||
        onHover();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    protected void release() {
 | 
			
		||||
        instance.setColor(TEXT_NORMAL);
 | 
			
		||||
        instance.setHighlightColor(TEXT_NORMAL);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        onUnHover();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    protected void setRelative() {
 | 
			
		||||
        instance.setFontSize(fontSize);
 | 
			
		||||
 | 
			
		||||
        instance.setPreferredSize(new Vector3f(size.x * widthStep, size.y * heightStep, 0));
 | 
			
		||||
 | 
			
		||||
        float xAdjust = 0.0f;
 | 
			
		||||
        if(adjust) {
 | 
			
		||||
            xAdjust = instance.getPreferredSize().x;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        instance.setLocalTranslation(pos.x * horizontalStep - xAdjust, pos.y * verticalStep, -1);
 | 
			
		||||
 | 
			
		||||
        final float horizontalMid = ((float)app.getCamera().getWidth() / 2) - (instance.getPreferredSize().x / 2);
 | 
			
		||||
        final float verticalMid = ((float)app.getCamera().getHeight() / 2) - instance.getPreferredSize().y / 2;
 | 
			
		||||
 | 
			
		||||
        if(0 == pos.x) {
 | 
			
		||||
            instance.setLocalTranslation(horizontalMid, instance.getLocalTranslation().y, instance.getLocalTranslation().z);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(0 == pos.y) {
 | 
			
		||||
            instance.setLocalTranslation(instance.getLocalTranslation().x, verticalMid, instance.getLocalTranslation().z);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,102 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.*;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class InputButton extends AbstractButton {
 | 
			
		||||
    private Label label;
 | 
			
		||||
    private TextField field;
 | 
			
		||||
 | 
			
		||||
    private Container container = new Container();
 | 
			
		||||
 | 
			
		||||
    private final int maxLenght;
 | 
			
		||||
 | 
			
		||||
    protected Vector2f size;
 | 
			
		||||
 | 
			
		||||
    public InputButton(MdgaApp app, Node node, String label, int maxLenght) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        this.label = new Label(label);
 | 
			
		||||
        this.maxLenght = maxLenght;
 | 
			
		||||
 | 
			
		||||
        this.label.setColor(TEXT_NORMAL);
 | 
			
		||||
 | 
			
		||||
        field = new TextField("");
 | 
			
		||||
        field.setColor(TEXT_NORMAL);
 | 
			
		||||
        field.setTextHAlignment(HAlignment.Left);
 | 
			
		||||
        field.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
			
		||||
        field.setBackground(grayBackground);
 | 
			
		||||
 | 
			
		||||
        this.label.setFont(font);
 | 
			
		||||
        field.setFont(font);
 | 
			
		||||
 | 
			
		||||
        pos = new Vector2f( 0, 0);
 | 
			
		||||
        size = new Vector2f(5.5f, 1);
 | 
			
		||||
 | 
			
		||||
        container.addChild(this.label);
 | 
			
		||||
        container.addChild(field);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        calculateRelative();
 | 
			
		||||
        setRelative();
 | 
			
		||||
 | 
			
		||||
        node.attachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        node.detachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        String text = field.getText();
 | 
			
		||||
        int length = text.length();
 | 
			
		||||
 | 
			
		||||
        if (length > maxLenght) {
 | 
			
		||||
            field.setText(text.substring(0, maxLenght));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setRelative() {
 | 
			
		||||
        this.label.setFontSize(fontSize);
 | 
			
		||||
        field.setFontSize(fontSize);
 | 
			
		||||
 | 
			
		||||
        field.setPreferredSize(new Vector3f(size.x * widthStep, size.y * heightStep, 0));
 | 
			
		||||
 | 
			
		||||
        float xAdjust = 0.0f;
 | 
			
		||||
        if(adjust) {
 | 
			
		||||
            xAdjust = container.getPreferredSize().x;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(pos.x * horizontalStep - xAdjust, pos.y * verticalStep, -1);
 | 
			
		||||
 | 
			
		||||
        final float horizontalMid = ((float)app.getCamera().getWidth() / 2) - (container.getPreferredSize().x / 2);
 | 
			
		||||
        final float verticalMid = ((float)app.getCamera().getHeight() / 2) - container.getPreferredSize().y / 2;
 | 
			
		||||
 | 
			
		||||
        if(0 == pos.x) {
 | 
			
		||||
            container.setLocalTranslation(horizontalMid, container.getLocalTranslation().y, -1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(0 == pos.y) {
 | 
			
		||||
            container.setLocalTranslation(container.getLocalTranslation().x, verticalMid, -1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getString() {
 | 
			
		||||
        return field.getText();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setString(String string) { field.setText(string); }
 | 
			
		||||
 | 
			
		||||
    public void reset() {
 | 
			
		||||
        field.setText("");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,63 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class LabelButton extends ClickButton{
 | 
			
		||||
    private ColorRGBA text = TEXT_NORMAL;
 | 
			
		||||
    private ColorRGBA button = BUTTON_NORMAL;
 | 
			
		||||
 | 
			
		||||
    public LabelButton(MdgaApp app, Node node, String label, Vector2f size, Vector2f pos) {
 | 
			
		||||
        super(app, node, () -> {}, label, size, pos);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        release();
 | 
			
		||||
 | 
			
		||||
        calculateRelative();
 | 
			
		||||
        setRelative();
 | 
			
		||||
 | 
			
		||||
        instance.setFontSize(fontSize / 2);
 | 
			
		||||
 | 
			
		||||
        node.attachChild(instance);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        node.detachChild(instance);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onHover() {
 | 
			
		||||
        instance.setColor(text);
 | 
			
		||||
        instance.setHighlightColor(text);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(button);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnHover() {
 | 
			
		||||
        instance.setColor(text);
 | 
			
		||||
        instance.setHighlightColor(text);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(button);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setText(String text) {
 | 
			
		||||
        instance.setText(text);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setColor(ColorRGBA text, ColorRGBA button) {
 | 
			
		||||
        this.text = text;
 | 
			
		||||
        this.button = button;
 | 
			
		||||
 | 
			
		||||
        hide();
 | 
			
		||||
        show();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,218 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.light.AmbientLight;
 | 
			
		||||
import com.jme3.material.Material;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Quaternion;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.renderer.queue.RenderQueue;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.Asset;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
public class LobbyButton extends ClickButton {
 | 
			
		||||
    public enum Taken {
 | 
			
		||||
        NOT,
 | 
			
		||||
        SELF,
 | 
			
		||||
        OTHER,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static final ColorRGBA LOBBY_TAKEN = ColorRGBA.fromRGBA255(193,58,59, 25);
 | 
			
		||||
    static final ColorRGBA LOBBY_READY = ColorRGBA.fromRGBA255(55,172,190, 25);
 | 
			
		||||
    static final ColorRGBA LOBBY_READY_HOVER = ColorRGBA.fromRGBA255(17,211,218, 25);
 | 
			
		||||
    static final ColorRGBA LOBBY_SELF_NORMAL = ColorRGBA.fromRGBA255(34,103,24, 25);
 | 
			
		||||
    static final ColorRGBA LOBBY_SELF_HOVER = ColorRGBA.fromRGBA255(42,151,19, 25);
 | 
			
		||||
 | 
			
		||||
    static final float WIDTH = 4.0f;
 | 
			
		||||
 | 
			
		||||
    private final Node node3d;
 | 
			
		||||
 | 
			
		||||
    private boolean rotate = false;
 | 
			
		||||
    private Spatial model;
 | 
			
		||||
    private float rot = 180;
 | 
			
		||||
 | 
			
		||||
    private Taken taken = Taken.NOT;
 | 
			
		||||
 | 
			
		||||
    private LabelButton label;
 | 
			
		||||
 | 
			
		||||
    private boolean isReady = false;
 | 
			
		||||
 | 
			
		||||
    public LobbyButton(MdgaApp app, Node node, Node node3d, Runnable action, Color tsk) {
 | 
			
		||||
        super(app, node, action, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
 | 
			
		||||
 | 
			
		||||
        this.node3d = node3d;
 | 
			
		||||
 | 
			
		||||
        label = new LabelButton(app, node, "- leer -", new Vector2f( WIDTH, 1), new Vector2f(0, 0));
 | 
			
		||||
 | 
			
		||||
        final float mid = HORIZONTAL / 2;
 | 
			
		||||
        final float uiSpacing = 0.4f;
 | 
			
		||||
        final float figSpacing = 0.51f;
 | 
			
		||||
 | 
			
		||||
        float uiX = mid;
 | 
			
		||||
        float figX = 0;
 | 
			
		||||
        Asset asset = null;
 | 
			
		||||
 | 
			
		||||
        switch (tsk) {
 | 
			
		||||
            case CYBER:
 | 
			
		||||
                adjust = true;
 | 
			
		||||
                label.adjust = true;
 | 
			
		||||
                uiX -= 3 * uiSpacing;
 | 
			
		||||
                uiX -= WIDTH / 2;
 | 
			
		||||
                asset = Asset.cir;
 | 
			
		||||
                figX -= 3 * figSpacing;
 | 
			
		||||
                instance.setText("CIR");
 | 
			
		||||
                break;
 | 
			
		||||
            case AIRFORCE:
 | 
			
		||||
                adjust = true;
 | 
			
		||||
                label.adjust = true;
 | 
			
		||||
                uiX -= uiSpacing;
 | 
			
		||||
                asset = Asset.lw;
 | 
			
		||||
                figX -= figSpacing;
 | 
			
		||||
                instance.setText("Luftwaffe");
 | 
			
		||||
                break;
 | 
			
		||||
            case ARMY:
 | 
			
		||||
                uiX += uiSpacing;
 | 
			
		||||
                asset = Asset.heer;
 | 
			
		||||
                figX += figSpacing;
 | 
			
		||||
                instance.setText("Heer");
 | 
			
		||||
                break;
 | 
			
		||||
            case NAVY:
 | 
			
		||||
                uiX += 3 * uiSpacing;
 | 
			
		||||
                uiX += WIDTH / 2;
 | 
			
		||||
                asset = Asset.marine;
 | 
			
		||||
                figX += 3 * figSpacing;
 | 
			
		||||
                instance.setText("Marine");
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setPos(new Vector2f(uiX, 6));
 | 
			
		||||
        label.setPos(new Vector2f(uiX, 7));
 | 
			
		||||
 | 
			
		||||
        createModel(asset, new Vector3f(figX, -0.55f, 6));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onHover() {
 | 
			
		||||
        ColorRGBA buttonPressed = BUTTON_PRESSED.clone();
 | 
			
		||||
 | 
			
		||||
        switch (taken) {
 | 
			
		||||
            case NOT:
 | 
			
		||||
                buttonPressed.a = 0.3f;
 | 
			
		||||
                break;
 | 
			
		||||
            case SELF:
 | 
			
		||||
                buttonPressed = LOBBY_SELF_HOVER;
 | 
			
		||||
                break;
 | 
			
		||||
            case OTHER:
 | 
			
		||||
                buttonPressed = LOBBY_TAKEN;
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(isReady) {
 | 
			
		||||
            buttonPressed = LOBBY_READY_HOVER;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(buttonPressed);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        rotate = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnHover() {
 | 
			
		||||
        ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
 | 
			
		||||
 | 
			
		||||
        switch (taken) {
 | 
			
		||||
            case NOT:
 | 
			
		||||
                buttonNormal.a = 0.1f;
 | 
			
		||||
                break;
 | 
			
		||||
            case SELF:
 | 
			
		||||
                buttonNormal = LOBBY_SELF_NORMAL;
 | 
			
		||||
                break;
 | 
			
		||||
            case OTHER:
 | 
			
		||||
                buttonNormal = LOBBY_TAKEN;
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(isReady) {
 | 
			
		||||
            buttonNormal = LOBBY_READY;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal);
 | 
			
		||||
        instance.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        rotate = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        release();
 | 
			
		||||
 | 
			
		||||
        calculateRelative();
 | 
			
		||||
        setRelative();
 | 
			
		||||
 | 
			
		||||
        node.attachChild(instance);
 | 
			
		||||
        node3d.attachChild(model);
 | 
			
		||||
 | 
			
		||||
        label.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        node.detachChild(instance);
 | 
			
		||||
        node3d.detachChild(model);
 | 
			
		||||
 | 
			
		||||
        label.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update(float tpf) {
 | 
			
		||||
        if(rotate) {
 | 
			
		||||
            rot += 140.0f * tpf;
 | 
			
		||||
            rot %= 360;
 | 
			
		||||
        } else {
 | 
			
		||||
            rot = 180;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        model.setLocalRotation(new Quaternion().fromAngles((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void createModel(Asset asset, Vector3f pos) {
 | 
			
		||||
        String modelName = asset.getModelPath();
 | 
			
		||||
        String texName = asset.getDiffPath();
 | 
			
		||||
 | 
			
		||||
        model = app.getAssetManager().loadModel(modelName);
 | 
			
		||||
        model.scale(asset.getSize() / 2);
 | 
			
		||||
        model.rotate((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180));
 | 
			
		||||
        model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
 | 
			
		||||
 | 
			
		||||
        model.setLocalTranslation(pos);
 | 
			
		||||
 | 
			
		||||
        Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
 | 
			
		||||
        mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
 | 
			
		||||
        model.setMaterial(mat);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Taken getTaken() {
 | 
			
		||||
        return taken;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTaken(Taken taken, String name) {
 | 
			
		||||
        this.taken = taken;
 | 
			
		||||
 | 
			
		||||
        if(taken == Taken.NOT) {
 | 
			
		||||
            label.setText("- leer -");
 | 
			
		||||
            isReady = false;
 | 
			
		||||
        } else {
 | 
			
		||||
            label.setText(name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        onUnHover();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setReady(boolean isReady) {
 | 
			
		||||
        this.isReady = isReady;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class MenuButton extends ClickButton {
 | 
			
		||||
    public MenuButton(MdgaApp app, Node node, Runnable action, String label) {
 | 
			
		||||
        super(app, node, action, label, new Vector2f( 5.5f, 2), new Vector2f(0, 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,34 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.HAlignment;
 | 
			
		||||
import com.simsilica.lemur.VAlignment;
 | 
			
		||||
import com.simsilica.lemur.component.IconComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SettingsButton extends ClickButton {
 | 
			
		||||
    private IconComponent icon;
 | 
			
		||||
 | 
			
		||||
    public SettingsButton(MdgaApp app, Node node, Runnable action) {
 | 
			
		||||
        super(app, node, action, "", new Vector2f(2, 2), new Vector2f(HORIZONTAL - 0.5f, VERTICAL - 0.5f));
 | 
			
		||||
 | 
			
		||||
        adjust = true;
 | 
			
		||||
 | 
			
		||||
        icon = new IconComponent("Images/zahnrad.png");
 | 
			
		||||
        icon.setIconScale(0.1f * app.getImageScale());
 | 
			
		||||
        icon.setHAlignment(HAlignment.Center);
 | 
			
		||||
        icon.setVAlignment(VAlignment.Center);
 | 
			
		||||
        instance.setIcon(icon);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnHover() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,109 @@
 | 
			
		||||
package pp.mdga.client.button;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.*;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SliderButton extends AbstractButton {
 | 
			
		||||
    private Label label;
 | 
			
		||||
 | 
			
		||||
    private Slider slider;
 | 
			
		||||
 | 
			
		||||
    private Container container = new Container();
 | 
			
		||||
 | 
			
		||||
    protected Vector2f size;
 | 
			
		||||
 | 
			
		||||
    public SliderButton(MdgaApp app, Node node, String label) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        this.label = new Label(label);
 | 
			
		||||
 | 
			
		||||
        this.label.setColor(TEXT_NORMAL);
 | 
			
		||||
 | 
			
		||||
        slider = new Slider("slider");
 | 
			
		||||
 | 
			
		||||
        slider.getDecrementButton().setText(" - ");
 | 
			
		||||
        slider.getDecrementButton().setFont(font);
 | 
			
		||||
        slider.getDecrementButton().setFocusColor(TEXT_NORMAL);
 | 
			
		||||
        slider.getDecrementButton().setTextVAlignment(VAlignment.Bottom);
 | 
			
		||||
        slider.getDecrementButton().setColor(TEXT_NORMAL);
 | 
			
		||||
        slider.getDecrementButton().setHighlightColor(TEXT_NORMAL);
 | 
			
		||||
 | 
			
		||||
        slider.getIncrementButton().setText(" + ");
 | 
			
		||||
        slider.getIncrementButton().setFont(font);
 | 
			
		||||
        slider.getIncrementButton().setFocusColor(TEXT_NORMAL);
 | 
			
		||||
        slider.getIncrementButton().setTextVAlignment(VAlignment.Bottom);
 | 
			
		||||
        slider.getIncrementButton().setColor(TEXT_NORMAL);
 | 
			
		||||
        slider.getIncrementButton().setHighlightColor(TEXT_NORMAL);
 | 
			
		||||
 | 
			
		||||
        slider.getThumbButton().setText("X");
 | 
			
		||||
        slider.getThumbButton().setFont(font);
 | 
			
		||||
        slider.getThumbButton().setFocusColor(TEXT_NORMAL);
 | 
			
		||||
        slider.getThumbButton().setColor(TEXT_NORMAL);
 | 
			
		||||
        slider.getThumbButton().setHighlightColor(TEXT_NORMAL);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
			
		||||
        slider.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        this.label.setFont(font);
 | 
			
		||||
 | 
			
		||||
        pos = new Vector2f( 0, 0);
 | 
			
		||||
        size = new Vector2f(5.5f, 1);
 | 
			
		||||
 | 
			
		||||
        container.addChild(this.label);
 | 
			
		||||
 | 
			
		||||
        container.addChild(slider);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        calculateRelative();
 | 
			
		||||
        setRelative();
 | 
			
		||||
 | 
			
		||||
        node.attachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        node.detachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setRelative() {
 | 
			
		||||
        this.label.setFontSize(fontSize);
 | 
			
		||||
 | 
			
		||||
        slider.getDecrementButton().setFontSize(fontSize);
 | 
			
		||||
        slider.getIncrementButton().setFontSize(fontSize);
 | 
			
		||||
        slider.getThumbButton().setFontSize(fontSize);
 | 
			
		||||
 | 
			
		||||
        slider.setPreferredSize(new Vector3f(size.x * widthStep, size.y * heightStep, 0));
 | 
			
		||||
 | 
			
		||||
        float xAdjust = 0.0f;
 | 
			
		||||
        if(adjust) {
 | 
			
		||||
            xAdjust = container.getPreferredSize().x;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(pos.x * horizontalStep - xAdjust, pos.y * verticalStep, -1);
 | 
			
		||||
 | 
			
		||||
        final float horizontalMid = ((float)app.getCamera().getWidth() / 2) - (container.getPreferredSize().x / 2);
 | 
			
		||||
        final float verticalMid = ((float)app.getCamera().getHeight() / 2) - container.getPreferredSize().y / 2;
 | 
			
		||||
 | 
			
		||||
        if(0 == pos.x) {
 | 
			
		||||
            container.setLocalTranslation(horizontalMid, container.getLocalTranslation().y, -1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(0 == pos.y) {
 | 
			
		||||
            container.setLocalTranslation(container.getLocalTranslation().x, verticalMid, -1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public float getPercent() {
 | 
			
		||||
        return (float) slider.getModel().getPercent();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPercent(float percent) {
 | 
			
		||||
        slider.getModel().setPercent(percent);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,82 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.button.SliderButton;
 | 
			
		||||
import pp.mdga.client.view.MdgaView;
 | 
			
		||||
 | 
			
		||||
public class AudioSettingsDialog extends Dialog {
 | 
			
		||||
    private final MdgaView view;
 | 
			
		||||
 | 
			
		||||
    private SliderButton mainVolume;
 | 
			
		||||
    private SliderButton musicVolume;
 | 
			
		||||
    private SliderButton soundVolume;
 | 
			
		||||
 | 
			
		||||
    private MenuButton backButton;
 | 
			
		||||
 | 
			
		||||
    private boolean active = false;
 | 
			
		||||
 | 
			
		||||
    public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        this.view = view;
 | 
			
		||||
 | 
			
		||||
        mainVolume = new SliderButton(app, node, "Gesamt Lautstärke");
 | 
			
		||||
        musicVolume = new SliderButton(app, node, "Musik Lautstärke");
 | 
			
		||||
        soundVolume = new SliderButton(app, node, "Effekt Lautstärke");
 | 
			
		||||
 | 
			
		||||
        backButton = new MenuButton(app, node, view::leaveAudioSettings, "Zurück");
 | 
			
		||||
 | 
			
		||||
        float offset = 1.0f;
 | 
			
		||||
 | 
			
		||||
        mainVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.75f;
 | 
			
		||||
 | 
			
		||||
        musicVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.75f;
 | 
			
		||||
 | 
			
		||||
        soundVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.75f * 1.3f;
 | 
			
		||||
 | 
			
		||||
        backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.75f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        active = true;
 | 
			
		||||
 | 
			
		||||
        mainVolume.setPercent(app.getAcousticHandler().getMainVolume());
 | 
			
		||||
        musicVolume.setPercent(app.getAcousticHandler().getMusicVolume());
 | 
			
		||||
        soundVolume.setPercent(app.getAcousticHandler().getSoundVolume());
 | 
			
		||||
 | 
			
		||||
        backButton.show();
 | 
			
		||||
 | 
			
		||||
        mainVolume.show();
 | 
			
		||||
        musicVolume.show();
 | 
			
		||||
        soundVolume.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        active = false;
 | 
			
		||||
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
 | 
			
		||||
        mainVolume.hide();
 | 
			
		||||
        musicVolume.hide();
 | 
			
		||||
        soundVolume.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        if(!active) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().setMainVolume(mainVolume.getPercent());
 | 
			
		||||
        app.getAcousticHandler().setMusicVolume(musicVolume.getPercent());
 | 
			
		||||
        app.getAcousticHandler().setSoundVolume(soundVolume.getPercent());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,105 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.button.AbstractButton;
 | 
			
		||||
import pp.mdga.client.button.LabelButton;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
public class CeremonyDialog extends Dialog {
 | 
			
		||||
    private ArrayList<ArrayList<LabelButton>> labels;
 | 
			
		||||
 | 
			
		||||
    float offsetX;
 | 
			
		||||
 | 
			
		||||
    public CeremonyDialog(MdgaApp app, Node node) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        prepare();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        for (ArrayList<LabelButton> row : labels) {
 | 
			
		||||
            for (LabelButton b : row) {
 | 
			
		||||
                b.show();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        for (ArrayList<LabelButton> row : labels) {
 | 
			
		||||
            for (LabelButton b : row) {
 | 
			
		||||
                b.hide();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
 | 
			
		||||
        float offsetYSmall = 0.5f;
 | 
			
		||||
 | 
			
		||||
        ArrayList<LabelButton> row = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        Vector2f sizeSmall = new Vector2f(4, 1.2f);
 | 
			
		||||
        row.add(new LabelButton(app, node, name, sizeSmall, new Vector2f()));
 | 
			
		||||
        row.add(new LabelButton(app, node, "" + v1, sizeSmall, new Vector2f()));
 | 
			
		||||
        row.add(new LabelButton(app, node, "" + v2, sizeSmall, new Vector2f()));
 | 
			
		||||
        row.add(new LabelButton(app, node, "" + v3, sizeSmall, new Vector2f()));
 | 
			
		||||
        row.add(new LabelButton(app, node, "" + v4, sizeSmall, new Vector2f()));
 | 
			
		||||
        row.add(new LabelButton(app, node, "" + v5, sizeSmall, new Vector2f()));
 | 
			
		||||
        row.add(new LabelButton(app, node, "" + v6, sizeSmall, new Vector2f()));
 | 
			
		||||
 | 
			
		||||
        ColorRGBA colorText = AbstractButton.TEXT_NORMAL.clone();
 | 
			
		||||
        colorText.a = 0.1f;
 | 
			
		||||
 | 
			
		||||
        ColorRGBA colorButton = AbstractButton.BUTTON_NORMAL.clone();
 | 
			
		||||
        colorButton.a = 0.1f;
 | 
			
		||||
 | 
			
		||||
        int j = 0;
 | 
			
		||||
        for (LabelButton b : row) {
 | 
			
		||||
            if(j > 0) {
 | 
			
		||||
                b.setColor(colorText, colorButton);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetYSmall));
 | 
			
		||||
            offsetYSmall += 0.8f;
 | 
			
		||||
 | 
			
		||||
            j++;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        offsetX += 2.3f;
 | 
			
		||||
 | 
			
		||||
        labels.add(row);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void prepare() {
 | 
			
		||||
        offsetX = 0.5f;
 | 
			
		||||
 | 
			
		||||
        labels = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        ArrayList<LabelButton> first = new ArrayList<>();
 | 
			
		||||
        Vector2f size = new Vector2f(4, 1.2f);
 | 
			
		||||
        first.add(new LabelButton(app, node, "", size, new Vector2f()));
 | 
			
		||||
        first.add(new LabelButton(app, node, "Figuren geworfen", size, new Vector2f()));
 | 
			
		||||
        first.add(new LabelButton(app, node, "Figuren verloren", size, new Vector2f()));
 | 
			
		||||
        first.add(new LabelButton(app, node, "Verwendete Bonuskarten", size, new Vector2f()));
 | 
			
		||||
        first.add(new LabelButton(app, node, "Gewürfelte 6en", size, new Vector2f()));
 | 
			
		||||
        first.add(new LabelButton(app, node, "Gelaufene Felder", size, new Vector2f()));
 | 
			
		||||
        first.add(new LabelButton(app, node, "Bonusfeldern erreicht", size, new Vector2f()));
 | 
			
		||||
 | 
			
		||||
        float offsetY = 0.5f;
 | 
			
		||||
 | 
			
		||||
        for (LabelButton b : first) {
 | 
			
		||||
            b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY));
 | 
			
		||||
            offsetY += 0.8f;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        offsetX += 2.3f;
 | 
			
		||||
 | 
			
		||||
        labels.add(first);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,82 +1,32 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.Button;
 | 
			
		||||
import com.simsilica.lemur.Container;
 | 
			
		||||
import com.simsilica.lemur.HAlignment;
 | 
			
		||||
import com.simsilica.lemur.VAlignment;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
import static com.jme3.math.FastMath.floor;
 | 
			
		||||
 | 
			
		||||
public abstract class Dialog {
 | 
			
		||||
    protected final ColorRGBA COLOR_DEFAULT = ColorRGBA.Gray;
 | 
			
		||||
    protected final ColorRGBA COLOR_HOVER = ColorRGBA.DarkGray;
 | 
			
		||||
 | 
			
		||||
    protected Container container;
 | 
			
		||||
 | 
			
		||||
    protected final MdgaApp app;
 | 
			
		||||
    private final Node node;
 | 
			
		||||
    protected final Node node = new Node();
 | 
			
		||||
 | 
			
		||||
    protected final float vertical_step;
 | 
			
		||||
    protected final float horitontal_step;
 | 
			
		||||
    private final Node root;
 | 
			
		||||
 | 
			
		||||
    protected float fontSize = 35;
 | 
			
		||||
 | 
			
		||||
    public Dialog(MdgaApp app, Node node) {
 | 
			
		||||
    Dialog(MdgaApp app, Node node) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        this.node = node;
 | 
			
		||||
        this.container = new Container();
 | 
			
		||||
 | 
			
		||||
        this.horitontal_step = app.getCamera().getWidth() / 16;
 | 
			
		||||
        this.vertical_step = app.getCamera().getHeight() / 9;
 | 
			
		||||
 | 
			
		||||
        int val = (int) (32 * Math.min(app.getResolutionFactor() * 0.9f, 1));
 | 
			
		||||
        fontSize = val;
 | 
			
		||||
        this.root = node;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void show() {
 | 
			
		||||
        node.attachChild(container);
 | 
			
		||||
        root.attachChild(node);
 | 
			
		||||
 | 
			
		||||
        onShow();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hide () {
 | 
			
		||||
        node.detachChild(container);
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        root.detachChild(node);
 | 
			
		||||
 | 
			
		||||
        onHide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createButton(String label, Runnable action, Vector3f size) {
 | 
			
		||||
        Button button = new Button(label);
 | 
			
		||||
        button.addClickCommands(source -> action.run());
 | 
			
		||||
        button.setFontSize(fontSize);
 | 
			
		||||
        button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
        button.setColor(ColorRGBA.Black);
 | 
			
		||||
        button.setPreferredSize(size);
 | 
			
		||||
        button.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        button.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
        background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
 | 
			
		||||
            hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(hoverBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
            normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        container.addChild(button);
 | 
			
		||||
    }
 | 
			
		||||
    protected abstract void onShow();
 | 
			
		||||
    protected abstract void onHide ();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +0,0 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import java.util.function.Supplier;
 | 
			
		||||
 | 
			
		||||
public class GetPercentRunnable {
 | 
			
		||||
    private final Supplier<Float> action;
 | 
			
		||||
 | 
			
		||||
    public GetPercentRunnable(Supplier<Float> action) {
 | 
			
		||||
        this.action = action;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public float get() {
 | 
			
		||||
        return action.get();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,143 +1,68 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.texture.Texture;
 | 
			
		||||
import com.simsilica.lemur.*;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import com.simsilica.lemur.component.SpringGridLayout;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.button.ButtonLeft;
 | 
			
		||||
import pp.mdga.client.button.ButtonRight;
 | 
			
		||||
import pp.mdga.client.button.InputButton;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.view.MainView;
 | 
			
		||||
 | 
			
		||||
public class HostDialog extends Dialog {
 | 
			
		||||
    private TextField portInput;
 | 
			
		||||
import java.util.prefs.Preferences;
 | 
			
		||||
 | 
			
		||||
    public HostDialog(MdgaApp app, Node node, Runnable backAction) {
 | 
			
		||||
public class HostDialog  extends Dialog {
 | 
			
		||||
    private InputButton portInput;
 | 
			
		||||
 | 
			
		||||
    private ButtonRight hostButton;
 | 
			
		||||
    private ButtonLeft backButton;
 | 
			
		||||
 | 
			
		||||
    private final MainView view;
 | 
			
		||||
 | 
			
		||||
    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
			
		||||
 | 
			
		||||
    public HostDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
 | 
			
		||||
        quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
 | 
			
		||||
        container.setBackground(quad1);
 | 
			
		||||
        this.view = view;
 | 
			
		||||
 | 
			
		||||
        Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
 | 
			
		||||
        portInput = new InputButton(app, node, "Port: ", 5);
 | 
			
		||||
        portInput.setString(prefs.get("hostPort", "11111"));
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
 | 
			
		||||
        hostButton = new ButtonRight(app, node, view::forward, "Spiel hosten", 10);
 | 
			
		||||
        backButton = new ButtonLeft(app, node, view::back, "Zurück", 10);
 | 
			
		||||
 | 
			
		||||
        Panel imagePanel = new Panel();
 | 
			
		||||
        imagePanel.setBackground(b);
 | 
			
		||||
        float offset = 3.0f;
 | 
			
		||||
 | 
			
		||||
        container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4 * app.getResolutionFactor(), texture.getImage().getHeight() / 4 * app.getResolutionFactor(), 0));
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
 | 
			
		||||
        createTextField();
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
 | 
			
		||||
        Container sub = new Container(new SpringGridLayout(Axis.X, Axis.Y));
 | 
			
		||||
 | 
			
		||||
        createButton(sub, "Abbrechen", backAction, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
 | 
			
		||||
        sub.addChild(new Panel(40 * app.getResolutionFactor(), 0 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
 | 
			
		||||
        createButton(sub, "Starten", () -> tryStart(), new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
 | 
			
		||||
        container.addChild(sub);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void tryStart() {
 | 
			
		||||
        if (null == portInput.getText()) {
 | 
			
		||||
            portInput.setText("");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        int port = 0;
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            port = Integer.parseInt(portInput.getText());
 | 
			
		||||
        } catch (NumberFormatException e) {
 | 
			
		||||
            portInput.setText("");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(port >= 1 && port <= 65535) {
 | 
			
		||||
            app.getModelSyncronizer().setHost(port);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        portInput.setText("");
 | 
			
		||||
        portInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.5f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(
 | 
			
		||||
            app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
 | 
			
		||||
            app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
 | 
			
		||||
            0
 | 
			
		||||
        );
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        portInput.show();
 | 
			
		||||
        hostButton.show();
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        portInput.hide();
 | 
			
		||||
        hostButton.hide();
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void createTextField() {
 | 
			
		||||
        Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
 | 
			
		||||
 | 
			
		||||
        Label nameLabel = new Label("Port:\t");
 | 
			
		||||
        nameLabel.setFontSize(fontSize);
 | 
			
		||||
        nameLabel.setColor(ColorRGBA.Black);
 | 
			
		||||
 | 
			
		||||
        portInput = new TextField("");
 | 
			
		||||
 | 
			
		||||
        portInput.setColor(ColorRGBA.Black);
 | 
			
		||||
        portInput.setTextHAlignment(HAlignment.Left);
 | 
			
		||||
        portInput.setFontSize(fontSize);
 | 
			
		||||
        portInput.setSingleLine(true);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
 | 
			
		||||
        portInput.setBackground(grayBackground);
 | 
			
		||||
 | 
			
		||||
        subContainer.addChild(nameLabel);
 | 
			
		||||
        subContainer.addChild(portInput);
 | 
			
		||||
 | 
			
		||||
        container.addChild(subContainer);
 | 
			
		||||
    public void update() {
 | 
			
		||||
        portInput.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createButton(Container c, String label, Runnable action, Vector3f size) {
 | 
			
		||||
        Button button = new Button(label);
 | 
			
		||||
        button.addClickCommands(source -> action.run());
 | 
			
		||||
        button.setFontSize(fontSize);
 | 
			
		||||
        button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
        button.setColor(ColorRGBA.Black);
 | 
			
		||||
        button.setPreferredSize(size);
 | 
			
		||||
        button.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        button.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
    public String getPort() {
 | 
			
		||||
        prefs.put("hostPort", portInput.getString());
 | 
			
		||||
        return portInput.getString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
        background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
 | 
			
		||||
            hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(hoverBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
            normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        c.addChild(button);
 | 
			
		||||
    public void resetPort() {
 | 
			
		||||
        portInput.reset();
 | 
			
		||||
        prefs.put("hostPort", "11111");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,4 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
public class InterruptDialog {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,192 +1,88 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.texture.Texture;
 | 
			
		||||
import com.simsilica.lemur.*;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import com.simsilica.lemur.component.SpringGridLayout;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.acoustic.AcousticHandler;
 | 
			
		||||
import pp.mdga.client.button.ButtonLeft;
 | 
			
		||||
import pp.mdga.client.button.ButtonRight;
 | 
			
		||||
import pp.mdga.client.button.InputButton;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.view.MainView;
 | 
			
		||||
 | 
			
		||||
import java.util.regex.Pattern;
 | 
			
		||||
import java.util.prefs.Preferences;
 | 
			
		||||
 | 
			
		||||
public class JoinDialog extends Dialog {
 | 
			
		||||
    private TextField portInput;
 | 
			
		||||
    private TextField ipInput;
 | 
			
		||||
    private InputButton ipInput;
 | 
			
		||||
    private InputButton portInput;
 | 
			
		||||
 | 
			
		||||
    public JoinDialog(MdgaApp app, Node node, Runnable backAction) {
 | 
			
		||||
    private ButtonRight joinButton;
 | 
			
		||||
    private ButtonLeft backButton;
 | 
			
		||||
 | 
			
		||||
    private final MainView view;
 | 
			
		||||
 | 
			
		||||
    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
			
		||||
 | 
			
		||||
    public JoinDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
 | 
			
		||||
        quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
 | 
			
		||||
        container.setBackground(quad1);
 | 
			
		||||
        this.view = view;
 | 
			
		||||
 | 
			
		||||
        Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
 | 
			
		||||
        ipInput = new InputButton(app, node, "Ip: ", 15);
 | 
			
		||||
        portInput = new InputButton(app, node, "Port: ", 5);
 | 
			
		||||
        portInput.setString(prefs.get("joinPort", "11111"));
 | 
			
		||||
        ipInput.setString(prefs.get("joinIp", ""));
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
 | 
			
		||||
        joinButton = new ButtonRight(app, node, view::forward, "Spiel beitreten", 10);
 | 
			
		||||
        backButton = new ButtonLeft(app, node, view::back, "Zurück", 10);
 | 
			
		||||
 | 
			
		||||
        Panel imagePanel = new Panel();
 | 
			
		||||
        imagePanel.setBackground(b);
 | 
			
		||||
        float offset = 3.0f;
 | 
			
		||||
 | 
			
		||||
        container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4 * app.getResolutionFactor(), texture.getImage().getHeight() / 4 * app.getResolutionFactor(), 0));
 | 
			
		||||
        ipInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.5f;
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
 | 
			
		||||
        createIpField();
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
 | 
			
		||||
        createPortField();
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
 | 
			
		||||
        Container sub = new Container(new SpringGridLayout(Axis.X, Axis.Y));
 | 
			
		||||
 | 
			
		||||
        createButton(sub, "Abbrechen", backAction, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
 | 
			
		||||
        sub.addChild(new Panel(40 * app.getResolutionFactor(), 0 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
 | 
			
		||||
        createButton(sub, "Beitreten", () -> tryJoin(), new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
 | 
			
		||||
        container.addChild(sub);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void tryJoin() {
 | 
			
		||||
        if (null == portInput.getText()) {
 | 
			
		||||
            portInput.setText("");
 | 
			
		||||
            ipInput.setText("");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        int port = 0;
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            port = Integer.parseInt(portInput.getText());
 | 
			
		||||
        } catch (NumberFormatException e) {
 | 
			
		||||
            portInput.setText("");
 | 
			
		||||
            ipInput.setText("");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(!(port >= 1 && port <= 65535)) {
 | 
			
		||||
            portInput.setText("");
 | 
			
		||||
            ipInput.setText("");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (null == ipInput.getText()) {
 | 
			
		||||
            portInput.setText("");
 | 
			
		||||
            ipInput.setText("");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        String ipv4Pattern = "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
 | 
			
		||||
 | 
			
		||||
        if(!Pattern.matches(ipv4Pattern, ipInput.getText())) {
 | 
			
		||||
            portInput.setText("");
 | 
			
		||||
            ipInput.setText("");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        app.getModelSyncronizer().setJoin(ipInput.getText(), port);
 | 
			
		||||
        portInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.5f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(
 | 
			
		||||
            app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
 | 
			
		||||
            app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
 | 
			
		||||
            0
 | 
			
		||||
        );
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        ipInput.show();
 | 
			
		||||
        portInput.show();
 | 
			
		||||
        joinButton.show();
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        ipInput.hide();
 | 
			
		||||
        portInput.hide();
 | 
			
		||||
        joinButton.hide();
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void createPortField() {
 | 
			
		||||
        Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
 | 
			
		||||
 | 
			
		||||
        Label nameLabel = new Label("Port:\t");
 | 
			
		||||
        nameLabel.setFontSize(fontSize);
 | 
			
		||||
        nameLabel.setColor(ColorRGBA.Black);
 | 
			
		||||
 | 
			
		||||
        portInput = new TextField("");
 | 
			
		||||
 | 
			
		||||
        portInput.setColor(ColorRGBA.Black);
 | 
			
		||||
        portInput.setTextHAlignment(HAlignment.Left);
 | 
			
		||||
        portInput.setFontSize(fontSize);
 | 
			
		||||
        portInput.setSingleLine(true);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
 | 
			
		||||
        portInput.setBackground(grayBackground);
 | 
			
		||||
 | 
			
		||||
        subContainer.addChild(nameLabel);
 | 
			
		||||
        subContainer.addChild(portInput);
 | 
			
		||||
 | 
			
		||||
        container.addChild(subContainer);
 | 
			
		||||
    public void update() {
 | 
			
		||||
        ipInput.update();
 | 
			
		||||
        portInput.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void createIpField() {
 | 
			
		||||
        Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
 | 
			
		||||
 | 
			
		||||
        Label nameLabel = new Label("Ip:\t");
 | 
			
		||||
        nameLabel.setFontSize(fontSize);
 | 
			
		||||
        nameLabel.setColor(ColorRGBA.Black);
 | 
			
		||||
 | 
			
		||||
        ipInput = new TextField("");
 | 
			
		||||
 | 
			
		||||
        ipInput.setColor(ColorRGBA.Black);
 | 
			
		||||
        ipInput.setTextHAlignment(HAlignment.Left);
 | 
			
		||||
        ipInput.setFontSize(fontSize);
 | 
			
		||||
        ipInput.setSingleLine(true);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
 | 
			
		||||
        ipInput.setBackground(grayBackground);
 | 
			
		||||
 | 
			
		||||
        subContainer.addChild(nameLabel);
 | 
			
		||||
        subContainer.addChild(ipInput);
 | 
			
		||||
 | 
			
		||||
        container.addChild(subContainer);
 | 
			
		||||
    public String getIpt() {
 | 
			
		||||
        prefs.put("joinIp", ipInput.getString());
 | 
			
		||||
        return ipInput.getString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createButton(Container c, String label, Runnable action, Vector3f size) {
 | 
			
		||||
        Button button = new Button(label);
 | 
			
		||||
        button.addClickCommands(source -> action.run());
 | 
			
		||||
        button.setFontSize(fontSize);
 | 
			
		||||
        button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
        button.setColor(ColorRGBA.Black);
 | 
			
		||||
        button.setPreferredSize(size);
 | 
			
		||||
        button.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        button.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
    public void resetIp() {
 | 
			
		||||
        ipInput.reset();
 | 
			
		||||
        prefs.put("joinIp", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
        background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
    public String getPort() {
 | 
			
		||||
        prefs.put("joinPort", portInput.getString());
 | 
			
		||||
        return portInput.getString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
 | 
			
		||||
            hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(hoverBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
            normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        c.addChild(button);
 | 
			
		||||
    public void resetPort() {
 | 
			
		||||
        portInput.reset();
 | 
			
		||||
        prefs.put("joinPort", "11111");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,165 +0,0 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.Button;
 | 
			
		||||
import com.simsilica.lemur.Command;
 | 
			
		||||
import com.simsilica.lemur.HAlignment;
 | 
			
		||||
import com.simsilica.lemur.VAlignment;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
public class LobbyButtonDialog extends Dialog {
 | 
			
		||||
    private final int pos;
 | 
			
		||||
 | 
			
		||||
    private Button button;
 | 
			
		||||
 | 
			
		||||
    private Command<Button> clickCommand;
 | 
			
		||||
 | 
			
		||||
    private boolean taken = false;
 | 
			
		||||
 | 
			
		||||
    private final String label;
 | 
			
		||||
 | 
			
		||||
    private int val;
 | 
			
		||||
 | 
			
		||||
    public LobbyButtonDialog(MdgaApp app, Node node, String label, int pos) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        clickCommand = (Button source) -> {
 | 
			
		||||
            toggleButton();
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        this.pos = pos;
 | 
			
		||||
 | 
			
		||||
        this.label = label;
 | 
			
		||||
        this.button = new Button(label);
 | 
			
		||||
        this.button.setFontSize(fontSize);
 | 
			
		||||
 | 
			
		||||
        val = pos;
 | 
			
		||||
 | 
			
		||||
        createNotTakenButton(new Vector3f(170 * app.getResolutionFactor(), 250 * app.getResolutionFactor(), 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        float x = ((2 + (4 * pos)) * horitontal_step) - ((0.33333333f * pos) * container.getPreferredSize().x);
 | 
			
		||||
        float y = 6 * vertical_step;
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTaken(boolean isTaken, boolean self, String name) {
 | 
			
		||||
        taken = isTaken;
 | 
			
		||||
 | 
			
		||||
        if(isTaken) {
 | 
			
		||||
            createTakenButton(new Vector3f(170 * app.getResolutionFactor(), 250 * app.getResolutionFactor(), 0), self);
 | 
			
		||||
 | 
			
		||||
            button.setText(label + "\n\n" + name);
 | 
			
		||||
        } else {
 | 
			
		||||
            createNotTakenButton(new Vector3f(170 * app.getResolutionFactor(), 250 * app.getResolutionFactor(), 0));
 | 
			
		||||
 | 
			
		||||
            button.setText(label);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createNotTakenButton(Vector3f size) {
 | 
			
		||||
        button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
        button.setColor(ColorRGBA.Black);
 | 
			
		||||
        button.setPreferredSize(size);
 | 
			
		||||
        button.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        button.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        if(button.getClickCommands() != null) {
 | 
			
		||||
            button.removeClickCommands(clickCommand);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        button.addClickCommands(clickCommand);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
        background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
 | 
			
		||||
            hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(hoverBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
            normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        container.addChild(button);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void toggleButton() {
 | 
			
		||||
        if(taken) {
 | 
			
		||||
            app.getModelSyncronizer().unselectTsk();
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            app.getModelSyncronizer().selectTsk(Color.values()[val]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createTakenButton(Vector3f size, boolean self) {
 | 
			
		||||
        ColorRGBA color_a;
 | 
			
		||||
        ColorRGBA color_b;
 | 
			
		||||
 | 
			
		||||
        if(button.getClickCommands() != null) {
 | 
			
		||||
            button.removeClickCommands(clickCommand);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(!self) {
 | 
			
		||||
            color_a = ColorRGBA.Red;
 | 
			
		||||
            color_b = ColorRGBA.Red;
 | 
			
		||||
        } else {
 | 
			
		||||
            color_a = ColorRGBA.Green;
 | 
			
		||||
            color_b = ColorRGBA.Yellow;
 | 
			
		||||
 | 
			
		||||
            button.addClickCommands(clickCommand);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
        button.setColor(ColorRGBA.Black);
 | 
			
		||||
        button.setPreferredSize(size);
 | 
			
		||||
        button.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        button.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(color_a);
 | 
			
		||||
        background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(color_b);
 | 
			
		||||
            hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(hoverBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(color_a);
 | 
			
		||||
            normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        container.addChild(button);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,15 +0,0 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import java.util.function.Consumer;
 | 
			
		||||
 | 
			
		||||
public class PercentRunnable {
 | 
			
		||||
    private final Consumer<Float> action;
 | 
			
		||||
 | 
			
		||||
    public PercentRunnable(Consumer<Float> action) {
 | 
			
		||||
        this.action = action;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void run(float percent) {
 | 
			
		||||
        action.accept(percent);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,78 +0,0 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.texture.Texture;
 | 
			
		||||
import com.simsilica.lemur.Button;
 | 
			
		||||
import com.simsilica.lemur.HAlignment;
 | 
			
		||||
import com.simsilica.lemur.Panel;
 | 
			
		||||
import com.simsilica.lemur.VAlignment;
 | 
			
		||||
import com.simsilica.lemur.component.IconComponent;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SettingsButtonDialog extends Dialog {
 | 
			
		||||
    private IconComponent icon;
 | 
			
		||||
 | 
			
		||||
    public SettingsButtonDialog(MdgaApp app, Node node, String label, Runnable action) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        icon = new IconComponent("Images/zahnrad.png");
 | 
			
		||||
        icon.setIconScale(0.1f * app.getResolutionFactor());
 | 
			
		||||
 | 
			
		||||
        createButton(label, action, new Vector3f(60 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        float x = (15.5f * horitontal_step) - container.getPreferredSize().x;
 | 
			
		||||
        float y = 8.5f * vertical_step;
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void createButton(String label, Runnable action, Vector3f size) {
 | 
			
		||||
        Button button = new Button(label);
 | 
			
		||||
        button.addClickCommands(source -> action.run());
 | 
			
		||||
        button.setFontSize(fontSize);
 | 
			
		||||
        button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
        button.setColor(ColorRGBA.Black);
 | 
			
		||||
        button.setPreferredSize(size);
 | 
			
		||||
        button.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        button.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
        background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
        button.setIcon(icon);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
 | 
			
		||||
            hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(hoverBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
            button.setIcon(icon);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(COLOR_DEFAULT);
 | 
			
		||||
            normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
            button.setIcon(icon);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        container.addChild(button);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,112 +1,52 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.jme3.texture.Texture;
 | 
			
		||||
import com.simsilica.lemur.*;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import com.simsilica.lemur.component.SpringGridLayout;
 | 
			
		||||
import com.simsilica.lemur.event.CursorListener;
 | 
			
		||||
import com.simsilica.lemur.event.CursorMotionEvent;
 | 
			
		||||
import com.simsilica.lemur.event.MouseEventControl;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import com.simsilica.lemur.*;
 | 
			
		||||
import com.simsilica.lemur.style.*;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import pp.mdga.client.button.InputButton;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.view.MainView;
 | 
			
		||||
import pp.mdga.client.view.MdgaView;
 | 
			
		||||
 | 
			
		||||
public class SettingsDialog extends Dialog {
 | 
			
		||||
    private TextField nameInput;
 | 
			
		||||
    private MenuButton videoButton;
 | 
			
		||||
    private MenuButton audioButton;
 | 
			
		||||
    private MenuButton backButton;
 | 
			
		||||
 | 
			
		||||
    private HashMap<Slider, PercentRunnable> map = new HashMap<Slider, PercentRunnable>();
 | 
			
		||||
    private HashMap<Slider, GetPercentRunnable> map2 = new HashMap<Slider, GetPercentRunnable>();
 | 
			
		||||
    private final MdgaView view;
 | 
			
		||||
 | 
			
		||||
    public SettingsDialog(MdgaApp app, Node node, String path) {
 | 
			
		||||
    public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
 | 
			
		||||
        quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
 | 
			
		||||
        container.setBackground(quad1);
 | 
			
		||||
        this.view = view;
 | 
			
		||||
 | 
			
		||||
        Texture texture = app.getAssetManager().loadTexture(path);
 | 
			
		||||
        videoButton = new MenuButton(app, node, view::enterVideoSettings, "Video");
 | 
			
		||||
        audioButton = new MenuButton(app, node, view::enterAudioSettings, "Audio");
 | 
			
		||||
        backButton = new MenuButton(app, node, view::leaveSettings, "Zurück");
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
 | 
			
		||||
        float offset = 2.0f;
 | 
			
		||||
 | 
			
		||||
        Panel imagePanel = new Panel();
 | 
			
		||||
        imagePanel.setBackground(b);
 | 
			
		||||
        videoButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.25f;
 | 
			
		||||
 | 
			
		||||
        container.addChild(imagePanel).setPreferredSize(new Vector3f((texture.getImage().getWidth() / 2) * app.getResolutionFactor(), (texture.getImage().getHeight() / 2) * app.getResolutionFactor(), 0));
 | 
			
		||||
        audioButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.25f;
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(80 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
        backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.25f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(
 | 
			
		||||
            app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
 | 
			
		||||
            app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
 | 
			
		||||
            0
 | 
			
		||||
        );
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        videoButton.show();
 | 
			
		||||
        audioButton.show();
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addButton(String label, Runnable action, Vector3f size) {
 | 
			
		||||
        createButton(label, action, size);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addSlider(String label, PercentRunnable action, GetPercentRunnable action2, Vector3f size, int start) {
 | 
			
		||||
        Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
 | 
			
		||||
 | 
			
		||||
        Slider slider = new Slider("slider");
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(ColorRGBA.DarkGray);
 | 
			
		||||
        slider.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        slider.setPreferredSize(size);
 | 
			
		||||
        slider.setModel(new DefaultRangedValueModel(0, 100, start));
 | 
			
		||||
        slider.setPreferredSize(new Vector3f(150 * app.getResolutionFactor(), 30 * app.getResolutionFactor(), 0));
 | 
			
		||||
        slider.getDecrementButton().setText(" - ");
 | 
			
		||||
        slider.getIncrementButton().setText(" + ");
 | 
			
		||||
        slider.getDecrementButton().setFontSize(25 * app.getResolutionFactor());
 | 
			
		||||
        slider.getIncrementButton().setFontSize(25 * app.getResolutionFactor());
 | 
			
		||||
 | 
			
		||||
        Label nameLabel = new Label(label);
 | 
			
		||||
        nameLabel.setFontSize(fontSize);
 | 
			
		||||
        nameLabel.setColor(ColorRGBA.Black);
 | 
			
		||||
        nameLabel.setPreferredSize(new Vector3f(150 * app.getResolutionFactor(), 10 * app.getResolutionFactor(), 0));
 | 
			
		||||
 | 
			
		||||
        subContainer.addChild(nameLabel);
 | 
			
		||||
        subContainer.addChild(slider);
 | 
			
		||||
 | 
			
		||||
        container.addChild(subContainer);
 | 
			
		||||
 | 
			
		||||
        map.put(slider, action);
 | 
			
		||||
        map2.put(slider, action2);
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(20 * app.getResolutionFactor(), 10 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void initVolume() {
 | 
			
		||||
        map2.forEach((slider, runnable) -> {
 | 
			
		||||
            double val = (double) runnable.get();
 | 
			
		||||
            slider.getModel().setPercent(val);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        map.forEach((slider, runnable) -> {
 | 
			
		||||
            float val = (float) slider.getModel().getPercent();
 | 
			
		||||
            runnable.run(val);
 | 
			
		||||
        });
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        videoButton.hide();
 | 
			
		||||
        audioButton.hide();
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,28 +0,0 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SingleButtonLeftDialog extends Dialog {
 | 
			
		||||
    public SingleButtonLeftDialog(MdgaApp app, Node node, String label, Runnable action) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        createButton(label, action, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        float x = 2 * horitontal_step;
 | 
			
		||||
        float y = 1.8f * vertical_step;
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,28 +0,0 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SingleButtonRightDialog extends Dialog {
 | 
			
		||||
    public SingleButtonRightDialog(MdgaApp app, Node node, String label, Runnable action) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        createButton(label, action, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        float x = (14 * horitontal_step) - container.getPreferredSize().x;
 | 
			
		||||
        float y = 1.8f * vertical_step;
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,66 +0,0 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.simsilica.lemur.Button;
 | 
			
		||||
import com.simsilica.lemur.HAlignment;
 | 
			
		||||
import com.simsilica.lemur.VAlignment;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
public class SingleButtonTopRight extends Dialog {
 | 
			
		||||
    public SingleButtonTopRight(MdgaApp app, Node node, String label, Runnable action) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        createButton(label, action, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
 | 
			
		||||
        float x = (14 * horitontal_step) - container.getPreferredSize().x;
 | 
			
		||||
        float y = 8.5f * vertical_step;
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(x, y, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createButton(String label, Runnable action, Vector3f size) {
 | 
			
		||||
        Button button = new Button(label);
 | 
			
		||||
        button.addClickCommands(source -> action.run());
 | 
			
		||||
        button.setFontSize(fontSize);
 | 
			
		||||
        button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
        button.setColor(ColorRGBA.Black);
 | 
			
		||||
        button.setPreferredSize(size);
 | 
			
		||||
        button.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
        button.setTextVAlignment(VAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(ColorRGBA.Red);
 | 
			
		||||
        background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(ColorRGBA.Yellow);
 | 
			
		||||
            hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(hoverBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(ColorRGBA.Red);
 | 
			
		||||
            normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        container.addChild(button);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,86 +1,189 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.texture.Texture;
 | 
			
		||||
import com.simsilica.lemur.*;
 | 
			
		||||
import com.simsilica.lemur.Container;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import com.simsilica.lemur.component.SpringGridLayout;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.button.InputButton;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.view.MainView;
 | 
			
		||||
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
import java.util.random.RandomGenerator;
 | 
			
		||||
 | 
			
		||||
public class StartDialog extends Dialog {
 | 
			
		||||
    private TextField nameInput;
 | 
			
		||||
    private InputButton nameInput;
 | 
			
		||||
 | 
			
		||||
    public StartDialog(MdgaApp app, Node node) {
 | 
			
		||||
    private MenuButton hostButton;
 | 
			
		||||
    private MenuButton joinButton;
 | 
			
		||||
    private MenuButton endButton;
 | 
			
		||||
 | 
			
		||||
    private final MainView view;
 | 
			
		||||
 | 
			
		||||
    public StartDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
 | 
			
		||||
        quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
 | 
			
		||||
        container.setBackground(quad1);
 | 
			
		||||
        this.view = view;
 | 
			
		||||
 | 
			
		||||
        Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
 | 
			
		||||
        nameInput = new InputButton(app, node, "Name: ", 16);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
 | 
			
		||||
        hostButton = new MenuButton(app, node, () -> view.forward(true), "Spiel hosten");
 | 
			
		||||
        joinButton = new MenuButton(app, node, () -> view.forward(false), "Spiel beitreten");
 | 
			
		||||
        endButton = new MenuButton(app, node, app::stop, "Spiel beenden");
 | 
			
		||||
 | 
			
		||||
        Panel imagePanel = new Panel();
 | 
			
		||||
        imagePanel.setBackground(b);
 | 
			
		||||
        float offset = 2.0f;
 | 
			
		||||
 | 
			
		||||
        container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4, texture.getImage().getHeight() / 4, 0));
 | 
			
		||||
        nameInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.5f;
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
        hostButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.25f;
 | 
			
		||||
 | 
			
		||||
        createTextField();
 | 
			
		||||
        joinButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.25f;
 | 
			
		||||
 | 
			
		||||
        //abstandshalter
 | 
			
		||||
        container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
 | 
			
		||||
        endButton.setPos(new Vector2f(0, MenuButton.VERTICAL -offset));
 | 
			
		||||
        offset += 1.25f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void show() {
 | 
			
		||||
        super.show();
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        nameInput.show();
 | 
			
		||||
 | 
			
		||||
        container.setLocalTranslation(
 | 
			
		||||
            app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
 | 
			
		||||
            app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
 | 
			
		||||
            0
 | 
			
		||||
        );
 | 
			
		||||
        hostButton.show();
 | 
			
		||||
        joinButton.show();
 | 
			
		||||
        endButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        super.hide();
 | 
			
		||||
    protected void onHide ()
 | 
			
		||||
    {
 | 
			
		||||
        nameInput.hide();
 | 
			
		||||
 | 
			
		||||
        hostButton.hide();
 | 
			
		||||
        joinButton.hide();
 | 
			
		||||
        endButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addButton(String label, Runnable action, Vector3f size) {
 | 
			
		||||
        createButton(label, action, size);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void createTextField() {
 | 
			
		||||
        Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
 | 
			
		||||
 | 
			
		||||
        Label nameLabel = new Label("Name:\t");
 | 
			
		||||
        nameLabel.setFontSize(fontSize);
 | 
			
		||||
        nameLabel.setColor(ColorRGBA.Black);
 | 
			
		||||
 | 
			
		||||
        nameInput = new TextField("");
 | 
			
		||||
 | 
			
		||||
        nameInput.setColor(ColorRGBA.Black);
 | 
			
		||||
        nameInput.setTextHAlignment(HAlignment.Left);
 | 
			
		||||
        nameInput.setFontSize(fontSize);
 | 
			
		||||
        nameInput.setSingleLine(true);
 | 
			
		||||
 | 
			
		||||
        QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
 | 
			
		||||
        nameInput.setBackground(grayBackground);
 | 
			
		||||
 | 
			
		||||
        subContainer.addChild(nameLabel);
 | 
			
		||||
        subContainer.addChild(nameInput);
 | 
			
		||||
 | 
			
		||||
        container.addChild(subContainer);
 | 
			
		||||
    public void update() {
 | 
			
		||||
        nameInput.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return nameInput.getText();
 | 
			
		||||
        String name = nameInput.getString();
 | 
			
		||||
 | 
			
		||||
        if (name == null || name.trim().isEmpty()) {
 | 
			
		||||
            String[] names = {
 | 
			
		||||
                "PixelPirat",
 | 
			
		||||
                "NoobJäger",
 | 
			
		||||
                "LagMeister",
 | 
			
		||||
                "KnopfDrücker",
 | 
			
		||||
                "SpawnCamper",
 | 
			
		||||
                "AFKHeld",
 | 
			
		||||
                "RageQuitter",
 | 
			
		||||
                "GameOverPro",
 | 
			
		||||
                "Checkpoint",
 | 
			
		||||
                "RespawnHeld",
 | 
			
		||||
                "Teebeutel",
 | 
			
		||||
                "GlitchHexer",
 | 
			
		||||
                "QuickScope",
 | 
			
		||||
                "LootSammler",
 | 
			
		||||
                "EpicLauch",
 | 
			
		||||
                "KartoffelPro",
 | 
			
		||||
                "StilleKlinge",
 | 
			
		||||
                "TastenHeld",
 | 
			
		||||
                "PixelKrieger",
 | 
			
		||||
                "HacknSlash",
 | 
			
		||||
                "JoystickJoe",
 | 
			
		||||
                "SpawnFalle",
 | 
			
		||||
                "OneHitWanda",
 | 
			
		||||
                "CamperKing",
 | 
			
		||||
                "GameGenie",
 | 
			
		||||
                "HighPing",
 | 
			
		||||
                "CheesePro",
 | 
			
		||||
                "Speedy",
 | 
			
		||||
                "GigaGamer",
 | 
			
		||||
                "LevelNoob",
 | 
			
		||||
                "SkillTobi",
 | 
			
		||||
                "HeadshotMax",
 | 
			
		||||
                "PentaPaul",
 | 
			
		||||
                "CritKarl",
 | 
			
		||||
                "ManaLeerer",
 | 
			
		||||
                "Nachlader",
 | 
			
		||||
                "ClutchKönig",
 | 
			
		||||
                "FriendlyFe",
 | 
			
		||||
                "ZonenHeld",
 | 
			
		||||
                "SchleichKatze",
 | 
			
		||||
                "ShotgunPro",
 | 
			
		||||
                "SniperUdo",
 | 
			
		||||
                "BossHunter",
 | 
			
		||||
                "HeldenNoob",
 | 
			
		||||
                "KillFranz",
 | 
			
		||||
                "FragKarl",
 | 
			
		||||
                "TeamNiete",
 | 
			
		||||
                "LootPaul",
 | 
			
		||||
                "UltraNoob",
 | 
			
		||||
                "ProfiScout",
 | 
			
		||||
                "PunkteKlaus",
 | 
			
		||||
                "KrüppelKill",
 | 
			
		||||
                "PixelNinja",
 | 
			
		||||
                "NoobCrusher",
 | 
			
		||||
                "LagBoss",
 | 
			
		||||
                "SpawnKing",
 | 
			
		||||
                "AFKSlayer",
 | 
			
		||||
                "RespawnPro",
 | 
			
		||||
                "Killjoy",
 | 
			
		||||
                "GameBreaker",
 | 
			
		||||
                "FastFingers",
 | 
			
		||||
                "LootKing",
 | 
			
		||||
                "QuickFlick",
 | 
			
		||||
                "SilentShot",
 | 
			
		||||
                "HackGod",
 | 
			
		||||
                "GlitchHero",
 | 
			
		||||
                "SpeedyBot",
 | 
			
		||||
                "AimWizard",
 | 
			
		||||
                "FragMaster",
 | 
			
		||||
                "OneTapPro",
 | 
			
		||||
                "KnifeLord",
 | 
			
		||||
                "MetaHunter",
 | 
			
		||||
                "PingWarrior",
 | 
			
		||||
                "KeyBash",
 | 
			
		||||
                "ClutchPro",
 | 
			
		||||
                "ScopeBot",
 | 
			
		||||
                "TrollMage",
 | 
			
		||||
                "PowerLooter",
 | 
			
		||||
                "TankHero",
 | 
			
		||||
                "CampLord",
 | 
			
		||||
                "SmurfSlayer",
 | 
			
		||||
                "SkillThief",
 | 
			
		||||
                "SniperGod",
 | 
			
		||||
                "LevelHack",
 | 
			
		||||
                "GhostAim",
 | 
			
		||||
                "BossTamer",
 | 
			
		||||
                "ShotgunJoe",
 | 
			
		||||
                "AimRider",
 | 
			
		||||
                "KillCount",
 | 
			
		||||
                "PixelManiac",
 | 
			
		||||
                "TrollOver",
 | 
			
		||||
                "SneakPro",
 | 
			
		||||
                "ReloadKing",
 | 
			
		||||
                "SpawnTrap",
 | 
			
		||||
                "LagLover",
 | 
			
		||||
                "MetaHater",
 | 
			
		||||
                "BoomMaker",
 | 
			
		||||
                "WipeLord",
 | 
			
		||||
                "CarryPro",
 | 
			
		||||
                "ProBaiter",
 | 
			
		||||
                "GameWarden",
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            Random random = new Random();
 | 
			
		||||
            name = names[random.nextInt(names.length)];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,48 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.view.MdgaView;
 | 
			
		||||
 | 
			
		||||
public class VideoSettingsDialog extends Dialog {
 | 
			
		||||
    private MenuButton backButton;
 | 
			
		||||
 | 
			
		||||
    private final MdgaView view;
 | 
			
		||||
 | 
			
		||||
    private boolean active = false;
 | 
			
		||||
 | 
			
		||||
    public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        this.view = view;
 | 
			
		||||
 | 
			
		||||
        backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
 | 
			
		||||
 | 
			
		||||
        float offset = 2.0f;
 | 
			
		||||
 | 
			
		||||
        backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
        offset += 1.25f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        active = true;
 | 
			
		||||
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        active = false;
 | 
			
		||||
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        if(!active) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -11,7 +11,6 @@
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.jme3.scene.control.AbstractControl;
 | 
			
		||||
import pp.mdga.client.Asset;
 | 
			
		||||
import pp.mdga.message.server.Dice;
 | 
			
		||||
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
 | 
			
		||||
@@ -168,4 +167,5 @@ public void create(Vector3f pos, float scale, boolean shadow){
 | 
			
		||||
    public void setPos(Vector3f pos){
 | 
			
		||||
        spatial.setLocalTranslation(pos);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -34,16 +34,27 @@ public class PlayerNameHandler {
 | 
			
		||||
    private static final ColorRGBA ACTIVE_COLOR = ColorRGBA.Blue;
 | 
			
		||||
    private static final ColorRGBA OWN_COLOR = ColorRGBA.Cyan;
 | 
			
		||||
 | 
			
		||||
    private final Node guiNode;
 | 
			
		||||
 | 
			
		||||
    public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
 | 
			
		||||
        this.guiNode = guiNode;
 | 
			
		||||
 | 
			
		||||
        playerFont = assetManager.loadFont("Fonts/Gunplay.fnt");
 | 
			
		||||
        playerNameNode = new Node("player name node");
 | 
			
		||||
        playerOrder = new ArrayList<>();
 | 
			
		||||
        colorNameMap = new HashMap<>();
 | 
			
		||||
        guiNode.attachChild(playerNameNode);
 | 
			
		||||
        this.appSettings = appSettings;
 | 
			
		||||
        this.assetManager = assetManager;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void show() {
 | 
			
		||||
        guiNode.attachChild(playerNameNode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        guiNode.detachChild(playerNameNode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void drawPlayers(){
 | 
			
		||||
        playerNameNode.detachAllChildren();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -144,6 +144,4 @@ private float easeInOut(float t) {
 | 
			
		||||
    private float easeIn(float t) {
 | 
			
		||||
        return t * t * t * t;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,235 @@
 | 
			
		||||
package pp.mdga.client.server;
 | 
			
		||||
 | 
			
		||||
import com.jme3.network.*;
 | 
			
		||||
import com.jme3.network.serializing.Serializer;
 | 
			
		||||
import pp.mdga.game.Game;
 | 
			
		||||
import pp.mdga.game.Player;
 | 
			
		||||
import pp.mdga.message.client.*;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
import pp.mdga.server.ServerSender;
 | 
			
		||||
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.lang.System.Logger;
 | 
			
		||||
import java.lang.System.Logger.Level;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.concurrent.BlockingQueue;
 | 
			
		||||
import java.util.concurrent.LinkedBlockingQueue;
 | 
			
		||||
import java.util.logging.LogManager;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Server implementing the visitor pattern as MessageReceiver for ClientMessages
 | 
			
		||||
 */
 | 
			
		||||
public class MdgaServer implements MessageListener<HostedConnection>, ConnectionListener, ServerSender {
 | 
			
		||||
    private static final Logger LOGGER = System.getLogger(MdgaServer.class.getName());
 | 
			
		||||
 | 
			
		||||
    private Server myServer;
 | 
			
		||||
    private final ServerGameLogic logic;
 | 
			
		||||
    private final BlockingQueue<ReceivedMessage> pendingMessages = new LinkedBlockingQueue<>();
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        // Configure logging
 | 
			
		||||
        LogManager manager = LogManager.getLogManager();
 | 
			
		||||
        try {
 | 
			
		||||
            manager.readConfiguration(new FileInputStream("logging.properties"));
 | 
			
		||||
            LOGGER.log(Level.INFO, "Successfully read logging properties"); //NON-NLS
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            LOGGER.log(Level.INFO, e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Starts the Battleships server.
 | 
			
		||||
     */
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        new MdgaServer().run();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a new MdgaServer.
 | 
			
		||||
     */
 | 
			
		||||
    public MdgaServer() {
 | 
			
		||||
        LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
 | 
			
		||||
        logic = new ServerGameLogic(this, new Game());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void run() {
 | 
			
		||||
        startServer();
 | 
			
		||||
        this.connectionAdded(myServer, myServer.getConnection(0));
 | 
			
		||||
        while (true)
 | 
			
		||||
            processNextMessage();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void startServer() {
 | 
			
		||||
        try {
 | 
			
		||||
            LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
 | 
			
		||||
            myServer = Network.createServer(1234);
 | 
			
		||||
 | 
			
		||||
            initializeSerializables();
 | 
			
		||||
            myServer.start();
 | 
			
		||||
            registerListeners();
 | 
			
		||||
            LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS
 | 
			
		||||
            exit(1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void processNextMessage() {
 | 
			
		||||
        try {
 | 
			
		||||
            pendingMessages.take().process(logic);
 | 
			
		||||
        } catch (InterruptedException ex) {
 | 
			
		||||
            LOGGER.log(Level.INFO, "Interrupted while waiting for messages"); //NON-NLS
 | 
			
		||||
            Thread.currentThread().interrupt();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void initializeSerializables() {
 | 
			
		||||
        Serializer.registerClass(AnimationEnd.class);
 | 
			
		||||
        Serializer.registerClass(ClientStartGame.class);
 | 
			
		||||
        Serializer.registerClass(DeselectTSK.class);
 | 
			
		||||
        Serializer.registerClass(ForceContinueGame.class);
 | 
			
		||||
        Serializer.registerClass(StartGame.class);
 | 
			
		||||
        Serializer.registerClass(JoinServer.class);
 | 
			
		||||
        Serializer.registerClass(LeaveGame.class);
 | 
			
		||||
        Serializer.registerClass(LobbyNotReady.class);
 | 
			
		||||
        Serializer.registerClass(LobbyReady.class);
 | 
			
		||||
        Serializer.registerClass(NoPowerCard.class);
 | 
			
		||||
        Serializer.registerClass(RequestBriefing.class);
 | 
			
		||||
        Serializer.registerClass(RequestDie.class);
 | 
			
		||||
        Serializer.registerClass(RequestMove.class);
 | 
			
		||||
        Serializer.registerClass(RequestPlayCard.class);
 | 
			
		||||
        Serializer.registerClass(SelectCard.class);
 | 
			
		||||
        Serializer.registerClass(SelectedPieces.class);
 | 
			
		||||
        Serializer.registerClass(SelectTSK.class);
 | 
			
		||||
 | 
			
		||||
        Serializer.registerClass(ActivePlayer.class);
 | 
			
		||||
        Serializer.registerClass(AnyPiece.class);
 | 
			
		||||
        Serializer.registerClass(Briefing.class);
 | 
			
		||||
        Serializer.registerClass(CeremonyMessage.class);
 | 
			
		||||
        Serializer.registerClass(Die.class);
 | 
			
		||||
        Serializer.registerClass(DiceAgain.class);
 | 
			
		||||
        Serializer.registerClass(DiceNow.class);
 | 
			
		||||
        Serializer.registerClass(EndOfTurn.class);
 | 
			
		||||
        Serializer.registerClass(LobbyAccept.class);
 | 
			
		||||
        Serializer.registerClass(LobbyDeny.class);
 | 
			
		||||
        Serializer.registerClass(LobbyPlayerJoin.class);
 | 
			
		||||
        Serializer.registerClass(LobbyPlayerLeave.class);
 | 
			
		||||
        Serializer.registerClass(MoveMessage.class);
 | 
			
		||||
        Serializer.registerClass(NoTurn.class);
 | 
			
		||||
        Serializer.registerClass(PauseGame.class);
 | 
			
		||||
        Serializer.registerClass(PlayCard.class);
 | 
			
		||||
        Serializer.registerClass(PossibleCard.class);
 | 
			
		||||
        Serializer.registerClass(PossiblePiece.class);
 | 
			
		||||
        Serializer.registerClass(RankingResponse.class);
 | 
			
		||||
        Serializer.registerClass(RankingRollAgain.class);
 | 
			
		||||
        Serializer.registerClass(ReconnectBriefing.class);
 | 
			
		||||
        Serializer.registerClass(ResumeGame.class);
 | 
			
		||||
        Serializer.registerClass(ServerStartGame.class);
 | 
			
		||||
        Serializer.registerClass(StartPiece.class);
 | 
			
		||||
        Serializer.registerClass(UpdateReady.class);
 | 
			
		||||
        Serializer.registerClass(UpdateTSK.class);
 | 
			
		||||
        Serializer.registerClass(WaitPiece.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void registerListeners() {
 | 
			
		||||
        myServer.addMessageListener(this, AnimationEnd.class);
 | 
			
		||||
        myServer.addMessageListener(this, ClientStartGame.class);
 | 
			
		||||
        myServer.addMessageListener(this, DeselectTSK.class);
 | 
			
		||||
        myServer.addMessageListener(this, ForceContinueGame.class);
 | 
			
		||||
        myServer.addMessageListener(this, StartGame.class);
 | 
			
		||||
        myServer.addMessageListener(this, JoinServer.class);
 | 
			
		||||
        myServer.addMessageListener(this, LeaveGame.class);
 | 
			
		||||
        myServer.addMessageListener(this, LobbyNotReady.class);
 | 
			
		||||
        myServer.addMessageListener(this, LobbyReady.class);
 | 
			
		||||
        myServer.addMessageListener(this, NoPowerCard.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestBriefing.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestDie.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestMove.class);
 | 
			
		||||
        myServer.addMessageListener(this, RequestPlayCard.class);
 | 
			
		||||
        myServer.addMessageListener(this, SelectCard.class);
 | 
			
		||||
        myServer.addMessageListener(this, SelectedPieces.class);
 | 
			
		||||
        myServer.addMessageListener(this, SelectTSK.class);
 | 
			
		||||
        myServer.addConnectionListener(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public void messageReceived(HostedConnection source, ClientMessage message) {
 | 
			
		||||
        LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
 | 
			
		||||
        pendingMessages.add(new ReceivedMessage(message, source.getId()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void connectionAdded(Server server, HostedConnection hostedConnection) {
 | 
			
		||||
        LOGGER.log(Level.INFO, "new connection {0}", hostedConnection); //NON-NLS
 | 
			
		||||
        // ToDo: Synchronize data between server and client.
 | 
			
		||||
        logic.getGame().addPlayer(hostedConnection.getId(), new Player());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void connectionRemoved(Server server, HostedConnection hostedConnection) {
 | 
			
		||||
        LOGGER.log(Level.INFO, "connection closed: {0}", hostedConnection); //NON-NLS
 | 
			
		||||
        final Player player = logic.getGame().getPlayerById(hostedConnection.getId());
 | 
			
		||||
        if (player == null)
 | 
			
		||||
            LOGGER.log(Level.INFO, "closed connection does not belong to an active player"); //NON-NLS
 | 
			
		||||
        else { //NON-NLS
 | 
			
		||||
            LOGGER.log(Level.INFO, "closed connection belongs to {0}", player); //NON-NLS
 | 
			
		||||
            // exit(0);
 | 
			
		||||
            this.handleDisconnect(hostedConnection.getId());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to handle unintentional disconnections from players.
 | 
			
		||||
     *
 | 
			
		||||
     * @param id as the id of the disconnected player.
 | 
			
		||||
     */
 | 
			
		||||
    public void handleDisconnect(int id) {
 | 
			
		||||
        this.logic.received(new Disconnected(), id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void exit(int exitValue) { //NON-NLS
 | 
			
		||||
        LOGGER.log(Level.INFO, "close request"); //NON-NLS
 | 
			
		||||
        if (myServer != null)
 | 
			
		||||
            for (HostedConnection client : myServer.getConnections()) //NON-NLS
 | 
			
		||||
                if (client != null) client.close("Game over"); //NON-NLS
 | 
			
		||||
        System.exit(exitValue);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Send the specified message to the specified connection.
 | 
			
		||||
     *
 | 
			
		||||
     * @param id      the connection id
 | 
			
		||||
     * @param message the message
 | 
			
		||||
     */
 | 
			
		||||
    public void send(int id, ServerMessage message) {
 | 
			
		||||
        if (myServer == null || !myServer.isRunning()) {
 | 
			
		||||
            LOGGER.log(Level.ERROR, "no server running when trying to send {0}", message); //NON-NLS
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        final HostedConnection connection = myServer.getConnection(id);
 | 
			
		||||
        if (connection != null)
 | 
			
		||||
            connection.send(message);
 | 
			
		||||
        else
 | 
			
		||||
            LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to send the given message parameter to all connected players which are saved inside the
 | 
			
		||||
     * players attribute of Game class.
 | 
			
		||||
     *
 | 
			
		||||
     * @param message as the message which will be sent to all players as a ServerMessage.
 | 
			
		||||
     */
 | 
			
		||||
    public void broadcast(ServerMessage message) {
 | 
			
		||||
        for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
 | 
			
		||||
            this.send(entry.getKey(), message);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //TODO:
 | 
			
		||||
    @Override
 | 
			
		||||
    public void messageReceived(HostedConnection source, Message m) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
package pp.mdga.client.server;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.message.client.ClientInterpreter;
 | 
			
		||||
import pp.mdga.message.client.ClientMessage;
 | 
			
		||||
 | 
			
		||||
public record ReceivedMessage(ClientMessage msg, int from) {
 | 
			
		||||
    void process(ClientInterpreter interpreter) {
 | 
			
		||||
        msg.accept(interpreter, from);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,13 +1,20 @@
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.light.AmbientLight;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
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;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
import pp.mdga.client.button.ButtonLeft;
 | 
			
		||||
import pp.mdga.client.button.ButtonRight;
 | 
			
		||||
import pp.mdga.client.button.CeremonyButton;
 | 
			
		||||
import pp.mdga.client.dialog.CeremonyDialog;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
public class CeremonyView extends MdgaView {
 | 
			
		||||
 | 
			
		||||
    private enum SubState {
 | 
			
		||||
        AWARD_CEREMONY,
 | 
			
		||||
        STATISTICS,
 | 
			
		||||
@@ -15,54 +22,100 @@ private enum SubState {
 | 
			
		||||
 | 
			
		||||
    private SubState state;
 | 
			
		||||
 | 
			
		||||
    private SingleButtonRightDialog continueButton;
 | 
			
		||||
    private SingleButtonLeftDialog backButton;
 | 
			
		||||
 | 
			
		||||
    private Geometry background;
 | 
			
		||||
 | 
			
		||||
    private ButtonLeft backButton;
 | 
			
		||||
    private ButtonRight continueButton;
 | 
			
		||||
 | 
			
		||||
    private ArrayList<CeremonyButton> ceremonyButtons;
 | 
			
		||||
 | 
			
		||||
    private CeremonyDialog ceremonyDialog;
 | 
			
		||||
 | 
			
		||||
    private AmbientLight ambient = new AmbientLight();
 | 
			
		||||
 | 
			
		||||
    public CeremonyView(MdgaApp app) {
 | 
			
		||||
        super(app);
 | 
			
		||||
 | 
			
		||||
        continueButton = new SingleButtonRightDialog(app, node, "Weiter", () -> forward());
 | 
			
		||||
        backButton = new SingleButtonLeftDialog(app, node, "Zurück", () -> back());
 | 
			
		||||
        backButton = new ButtonLeft(app, guiNode, this::back, "Zurück", 1);
 | 
			
		||||
        continueButton = new ButtonRight(app, guiNode, this::forward, "Weiter", 1);
 | 
			
		||||
 | 
			
		||||
        ceremonyButtons = new ArrayList<>(4);
 | 
			
		||||
 | 
			
		||||
        ceremonyDialog = new CeremonyDialog(app, guiNode);
 | 
			
		||||
 | 
			
		||||
        ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onEnter() {
 | 
			
		||||
        enterSub(SubState.AWARD_CEREMONY);
 | 
			
		||||
 | 
			
		||||
        rootNode.addLight(ambient);
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.VICTORY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onLeave() {
 | 
			
		||||
        continueButton.hide();
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
        continueButton.hide();
 | 
			
		||||
 | 
			
		||||
        if(null != background) {
 | 
			
		||||
            guiNode.detachChild(background);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ceremonyButtons.clear();
 | 
			
		||||
 | 
			
		||||
        rootNode.removeLight(ambient);
 | 
			
		||||
 | 
			
		||||
        ceremonyDialog.prepare();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onEnterOverlay(Overlay overlay) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onLeaveOverlay(Overlay overlay) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onUpdate(float tpf) {
 | 
			
		||||
        for (CeremonyButton c : ceremonyButtons) {
 | 
			
		||||
            c.update(tpf);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void awardCeremony() {
 | 
			
		||||
        background = createBackground("Images/b1.png");
 | 
			
		||||
        node.attachChild(background);
 | 
			
		||||
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
 | 
			
		||||
        for (CeremonyButton c : ceremonyButtons) {
 | 
			
		||||
            c.show();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void statistics() {
 | 
			
		||||
        background = createBackground("Images/b2.png");
 | 
			
		||||
        node.attachChild(background);
 | 
			
		||||
        //background = createBackground("Images/b2.png");
 | 
			
		||||
        //guiNode.attachChild(background);
 | 
			
		||||
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
        backButton.show();
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
        ceremonyDialog.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void enterSub(SubState state) {
 | 
			
		||||
        this.state = state;
 | 
			
		||||
 | 
			
		||||
        if(null != background) {
 | 
			
		||||
            node.detachChild(background);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
        continueButton.hide();
 | 
			
		||||
        for (CeremonyButton c : ceremonyButtons) {
 | 
			
		||||
            c.hide();
 | 
			
		||||
        }
 | 
			
		||||
        ceremonyDialog.hide();
 | 
			
		||||
 | 
			
		||||
        if(null != background) {
 | 
			
		||||
            guiNode.detachChild(background);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case AWARD_CEREMONY:
 | 
			
		||||
@@ -74,7 +127,7 @@ private void enterSub(SubState state) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void forward() {
 | 
			
		||||
    public void forward() {
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case AWARD_CEREMONY:
 | 
			
		||||
                enterSub(SubState.STATISTICS);
 | 
			
		||||
@@ -95,4 +148,18 @@ private void back() {
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addCeremonyParticipant(Color color, int pos, String name) {
 | 
			
		||||
        CeremonyButton button = new CeremonyButton(app, guiNode, rootNode, color, CeremonyButton.Pos.values()[pos - 1], name);
 | 
			
		||||
 | 
			
		||||
        ceremonyButtons.add(button);
 | 
			
		||||
 | 
			
		||||
        if(state.equals(SubState.AWARD_CEREMONY)) {
 | 
			
		||||
            button.show();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
 | 
			
		||||
        ceremonyDialog.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,26 @@
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.input.KeyInput;
 | 
			
		||||
import com.jme3.input.MouseInput;
 | 
			
		||||
import com.jme3.input.controls.ActionListener;
 | 
			
		||||
import com.jme3.input.controls.KeyTrigger;
 | 
			
		||||
import com.jme3.input.controls.MouseButtonTrigger;
 | 
			
		||||
import com.jme3.post.FilterPostProcessor;
 | 
			
		||||
import com.jme3.post.filters.ComposeFilter;
 | 
			
		||||
import com.jme3.renderer.ViewPort;
 | 
			
		||||
import com.jme3.shadow.DirectionalLightShadowFilter;
 | 
			
		||||
import com.jme3.shadow.EdgeFilteringMode;
 | 
			
		||||
import com.jme3.texture.FrameBuffer;
 | 
			
		||||
import com.jme3.texture.Image;
 | 
			
		||||
import com.jme3.texture.Texture2D;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
import pp.mdga.client.board.BoardHandler;
 | 
			
		||||
import pp.mdga.client.board.CameraHandler;
 | 
			
		||||
import pp.mdga.client.dialog.SingleButtonLeftDialog;
 | 
			
		||||
import pp.mdga.client.dialog.SingleButtonRightDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
import pp.mdga.client.button.ButtonLeft;
 | 
			
		||||
import pp.mdga.client.button.ButtonRight;
 | 
			
		||||
import pp.mdga.client.button.SettingsButton;
 | 
			
		||||
import pp.mdga.client.gui.GuiHandler;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
@@ -18,19 +29,26 @@ public class GameView extends MdgaView {
 | 
			
		||||
    private CameraHandler camera;
 | 
			
		||||
    private GuiHandler guiHandler;
 | 
			
		||||
 | 
			
		||||
    private SingleButtonLeftDialog leaveButton;
 | 
			
		||||
    private SingleButtonRightDialog continueButton;
 | 
			
		||||
    private ButtonRight cheatButton; //TODO
 | 
			
		||||
 | 
			
		||||
    private ButtonLeft leaveButton;
 | 
			
		||||
    private ButtonRight confirmButton;
 | 
			
		||||
 | 
			
		||||
    private Color ownColor = null;
 | 
			
		||||
 | 
			
		||||
    private FilterPostProcessor fpp;
 | 
			
		||||
 | 
			
		||||
    public GameView(MdgaApp app) {
 | 
			
		||||
        super(app);
 | 
			
		||||
 | 
			
		||||
        //Filter für Outline: Reihenfolge CameraHandler(dlsf) -> BoardHandler -> viewPort.addProcessor einhalten!
 | 
			
		||||
        FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
 | 
			
		||||
        cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY), "CHEAT", 1);
 | 
			
		||||
 | 
			
		||||
        leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSyncronizer().leave(), "Spiel verlassen", 1);
 | 
			
		||||
        confirmButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().confirm(), "Bestätigen", 1);
 | 
			
		||||
 | 
			
		||||
        fpp = new FilterPostProcessor(app.getAssetManager());
 | 
			
		||||
        this.camera = new CameraHandler(app, fpp);
 | 
			
		||||
        this.boardHandler = new BoardHandler(app, fpp);
 | 
			
		||||
        app.getViewPort().addProcessor(fpp);
 | 
			
		||||
        this.boardHandler = new BoardHandler(app, rootNode, fpp);
 | 
			
		||||
 | 
			
		||||
        FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
 | 
			
		||||
        Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
 | 
			
		||||
@@ -38,11 +56,8 @@ public GameView(MdgaApp app) {
 | 
			
		||||
        backFrameBuffer.addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(backTexture));
 | 
			
		||||
        app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
 | 
			
		||||
 | 
			
		||||
        this.guiHandler = new GuiHandler(app, backTexture, ownColor);
 | 
			
		||||
 | 
			
		||||
        leaveButton = new SingleButtonLeftDialog(app, settingsNode, "Verlassen", () -> leaveGame());
 | 
			
		||||
 | 
			
		||||
        continueButton = new SingleButtonRightDialog(app, node, "Weiter", () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY));
 | 
			
		||||
        guiHandler = new GuiHandler(app, guiNode, backTexture, ownColor);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -50,38 +65,44 @@ public void onEnter() {
 | 
			
		||||
        camera.init();
 | 
			
		||||
        boardHandler.init();
 | 
			
		||||
        guiHandler.init();
 | 
			
		||||
        continueButton.show();
 | 
			
		||||
 | 
			
		||||
        app.getViewPort().addProcessor(fpp);
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.START);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onLeave() {
 | 
			
		||||
        continueButton.hide();
 | 
			
		||||
 | 
			
		||||
        camera.shutdown();
 | 
			
		||||
        boardHandler.shutdown();
 | 
			
		||||
        guiHandler.shutdown();
 | 
			
		||||
 | 
			
		||||
        app.getViewPort().removeProcessor(fpp);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUpdate() {
 | 
			
		||||
    public void onUpdate(float tpf) {
 | 
			
		||||
        camera.update(app.getInputSyncronizer().getScroll(), app.getInputSyncronizer().getRotation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void enterExtendedSettings() {
 | 
			
		||||
        leaveButton.show();
 | 
			
		||||
    protected void onEnterOverlay(Overlay overlay) {
 | 
			
		||||
        if(overlay == Overlay.SETTINGS) {
 | 
			
		||||
            leaveButton.show();
 | 
			
		||||
            cheatButton.show();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void leaveExtendedSettings() {
 | 
			
		||||
        leaveButton.hide();
 | 
			
		||||
    protected void onLeaveOverlay(Overlay overlay) {
 | 
			
		||||
        if(overlay == Overlay.SETTINGS) {
 | 
			
		||||
            leaveButton.hide();
 | 
			
		||||
            cheatButton.hide();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void leaveGame() {
 | 
			
		||||
        leaveSettings(false);
 | 
			
		||||
 | 
			
		||||
        app.getModelSyncronizer().leave();
 | 
			
		||||
 | 
			
		||||
        app.afteGameCleanup();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BoardHandler getBoardHandler() {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,59 +1,199 @@
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.asset.TextureKey;
 | 
			
		||||
import com.jme3.light.AmbientLight;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.renderer.Camera;
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import pp.mdga.client.dialog.LobbyButtonDialog;
 | 
			
		||||
import pp.mdga.client.dialog.SingleButtonLeftDialog;
 | 
			
		||||
import pp.mdga.client.dialog.SingleButtonRightDialog;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.jme3.texture.Texture;
 | 
			
		||||
import com.jme3.util.SkyFactory;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
import pp.mdga.client.button.ButtonLeft;
 | 
			
		||||
import pp.mdga.client.button.ButtonRight;
 | 
			
		||||
import pp.mdga.client.button.LobbyButton;
 | 
			
		||||
import pp.mdga.client.button.SettingsButton;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
public class LobbyView extends MdgaView {
 | 
			
		||||
    private Geometry background;
 | 
			
		||||
 | 
			
		||||
    private SingleButtonRightDialog readyButton;
 | 
			
		||||
    private SingleButtonLeftDialog leaveButton;
 | 
			
		||||
    private ButtonLeft leaveButton;
 | 
			
		||||
    private ButtonRight readyButton;
 | 
			
		||||
 | 
			
		||||
    private ArrayList<LobbyButtonDialog> lobbyButtons = new ArrayList<>();
 | 
			
		||||
    private LobbyButton cyberButton;
 | 
			
		||||
    private LobbyButton airforceButton;
 | 
			
		||||
    private LobbyButton armyButton;
 | 
			
		||||
    private LobbyButton navyButton;
 | 
			
		||||
 | 
			
		||||
    private AmbientLight ambient = new AmbientLight();
 | 
			
		||||
 | 
			
		||||
    public LobbyView(MdgaApp app) {
 | 
			
		||||
        super(app);
 | 
			
		||||
 | 
			
		||||
        background = createBackground("Images/lobby.png");
 | 
			
		||||
        node.attachChild(background);
 | 
			
		||||
        //TextureKey key = new TextureKey("lobby.png", false);
 | 
			
		||||
        //Texture skyTexture = app.getAssetManager().loadTexture(key);
 | 
			
		||||
        //Spatial sky = SkyFactory.createSky(app.getAssetManager(), skyTexture, SkyFactory.EnvMapType.SphereMap);
 | 
			
		||||
        //rootNode.attachChild(sky);
 | 
			
		||||
 | 
			
		||||
        readyButton = new SingleButtonRightDialog(app, node, "Fertig", () -> app.getModelSyncronizer().setReady());
 | 
			
		||||
        leaveButton = new SingleButtonLeftDialog(app, node, "Verlassen", () -> app.getModelSyncronizer().leave());
 | 
			
		||||
        leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1);
 | 
			
		||||
        readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 1);
 | 
			
		||||
 | 
			
		||||
        lobbyButtons.add(new LobbyButtonDialog(app, node, "HEER", 0));
 | 
			
		||||
        lobbyButtons.add(new LobbyButtonDialog(app, node, "MARINE", 1));
 | 
			
		||||
        lobbyButtons.add(new LobbyButtonDialog(app, node, "CIR", 2));
 | 
			
		||||
        lobbyButtons.add(new LobbyButtonDialog(app, node, "LUFTWAFFE", 3));
 | 
			
		||||
        cyberButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.CYBER), Color.CYBER);
 | 
			
		||||
        airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
 | 
			
		||||
        armyButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.ARMY), Color.ARMY);
 | 
			
		||||
        navyButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.NAVY), Color.NAVY);
 | 
			
		||||
 | 
			
		||||
        ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onEnter() {
 | 
			
		||||
        readyButton.show();
 | 
			
		||||
        leaveButton.show();
 | 
			
		||||
        app.getCamera().setParallelProjection(true);
 | 
			
		||||
        float aspect = (float) app.getCamera().getWidth() / app.getCamera().getHeight();
 | 
			
		||||
        float size = 1.65f;
 | 
			
		||||
        app.getCamera().setFrustum(-1000, 1000, -aspect * size, aspect * size, size, -size);
 | 
			
		||||
 | 
			
		||||
        for (LobbyButtonDialog b : lobbyButtons) {
 | 
			
		||||
            b.show();
 | 
			
		||||
        }
 | 
			
		||||
        leaveButton.show();
 | 
			
		||||
        readyButton.show();
 | 
			
		||||
 | 
			
		||||
        cyberButton.show();
 | 
			
		||||
        airforceButton.show();
 | 
			
		||||
        armyButton.show();
 | 
			
		||||
        navyButton.show();
 | 
			
		||||
 | 
			
		||||
        rootNode.addLight(ambient);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onLeave() {
 | 
			
		||||
        for (LobbyButtonDialog b : lobbyButtons) {
 | 
			
		||||
            b.hide();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        readyButton.hide();
 | 
			
		||||
        leaveButton.hide();
 | 
			
		||||
        readyButton.hide();
 | 
			
		||||
 | 
			
		||||
        airforceButton.hide();
 | 
			
		||||
        armyButton.hide();
 | 
			
		||||
        navyButton.hide();
 | 
			
		||||
        cyberButton.hide();
 | 
			
		||||
 | 
			
		||||
        rootNode.removeLight(ambient);
 | 
			
		||||
 | 
			
		||||
        app.getCamera().setParallelProjection(false);
 | 
			
		||||
 | 
			
		||||
        app.getCamera().setFrustumPerspective(
 | 
			
		||||
            45.0f,
 | 
			
		||||
            (float) app.getCamera().getWidth() / app.getCamera().getHeight(),
 | 
			
		||||
            0.1f,
 | 
			
		||||
            1000.0f
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        app.getCamera().setLocation(new Vector3f(0, 0, 10));
 | 
			
		||||
        app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onUpdate(float tpf) {
 | 
			
		||||
        airforceButton.update(tpf);
 | 
			
		||||
        armyButton.update(tpf);
 | 
			
		||||
        navyButton.update(tpf);
 | 
			
		||||
        cyberButton.update(tpf);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onEnterOverlay(Overlay overlay) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onLeaveOverlay(Overlay overlay)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTaken(Color color, boolean isTaken, boolean isSelf, String name) {
 | 
			
		||||
        lobbyButtons.get(color.ordinal()).setTaken(isTaken, isSelf, name);
 | 
			
		||||
        LobbyButton.Taken taken;
 | 
			
		||||
 | 
			
		||||
        if(isTaken) {
 | 
			
		||||
            if(isSelf) {
 | 
			
		||||
                taken = LobbyButton.Taken.SELF;
 | 
			
		||||
            } else {
 | 
			
		||||
                taken = LobbyButton.Taken.OTHER;
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            taken = LobbyButton.Taken.NOT;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switch (color) {
 | 
			
		||||
            case CYBER:
 | 
			
		||||
                cyberButton.setTaken(taken, name);
 | 
			
		||||
                break;
 | 
			
		||||
            case AIRFORCE:
 | 
			
		||||
                airforceButton.setTaken(taken, name);
 | 
			
		||||
                break;
 | 
			
		||||
            case ARMY:
 | 
			
		||||
                armyButton.setTaken(taken, name);
 | 
			
		||||
                break;
 | 
			
		||||
            case NAVY:
 | 
			
		||||
                navyButton.setTaken(taken, name);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setReady(Color color, boolean isReady) {
 | 
			
		||||
        switch (color) {
 | 
			
		||||
            case CYBER:
 | 
			
		||||
                cyberButton.setReady(isReady);
 | 
			
		||||
                break;
 | 
			
		||||
            case AIRFORCE:
 | 
			
		||||
                airforceButton.setReady(isReady);
 | 
			
		||||
                break;
 | 
			
		||||
            case ARMY:
 | 
			
		||||
                armyButton.setReady(isReady);
 | 
			
		||||
                break;
 | 
			
		||||
            case NAVY:
 | 
			
		||||
                navyButton.setReady(isReady);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void toggleTsk(Color color) {
 | 
			
		||||
        LobbyButton.Taken taken = LobbyButton.Taken.NOT;
 | 
			
		||||
 | 
			
		||||
        switch (color) {
 | 
			
		||||
            case CYBER:
 | 
			
		||||
                taken = cyberButton.getTaken();
 | 
			
		||||
                break;
 | 
			
		||||
            case AIRFORCE:
 | 
			
		||||
                taken = airforceButton.getTaken();
 | 
			
		||||
                break;
 | 
			
		||||
            case ARMY:
 | 
			
		||||
                taken = armyButton.getTaken();
 | 
			
		||||
                break;
 | 
			
		||||
            case NAVY:
 | 
			
		||||
                taken = navyButton.getTaken();
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switch (taken) {
 | 
			
		||||
            case NOT:
 | 
			
		||||
                app.getModelSyncronizer().selectTsk(color);
 | 
			
		||||
                break;
 | 
			
		||||
            case SELF:
 | 
			
		||||
                app.getModelSyncronizer().unselectTsk();
 | 
			
		||||
                break;
 | 
			
		||||
            case OTHER:
 | 
			
		||||
                //nothing
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void ready() {
 | 
			
		||||
        app.getModelSyncronizer().setReady();
 | 
			
		||||
        //TODO: playSound
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void leaveLobby() {
 | 
			
		||||
        app.getModelSyncronizer().leave();
 | 
			
		||||
        //TODO: playSound
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,79 +1,220 @@
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import pp.mdga.client.dialog.Dialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
import pp.mdga.client.button.ButtonRight;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.button.SettingsButton;
 | 
			
		||||
import pp.mdga.client.dialog.HostDialog;
 | 
			
		||||
import pp.mdga.client.dialog.JoinDialog;
 | 
			
		||||
import pp.mdga.client.dialog.StartDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
 | 
			
		||||
public class MainView extends MdgaView {
 | 
			
		||||
    private enum SubState {
 | 
			
		||||
        HOST,
 | 
			
		||||
        JOIN,
 | 
			
		||||
        MAIN,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private SubState state;
 | 
			
		||||
 | 
			
		||||
    private Geometry background;
 | 
			
		||||
 | 
			
		||||
    private StartDialog dialog;
 | 
			
		||||
    private Dialog subDialog;
 | 
			
		||||
    private StartDialog startDialog;
 | 
			
		||||
    private JoinDialog joinDialog;
 | 
			
		||||
    private HostDialog hostDialog;
 | 
			
		||||
 | 
			
		||||
    public MainView(MdgaApp app) {
 | 
			
		||||
        super(app);
 | 
			
		||||
 | 
			
		||||
        background = createBackground("Images/powercards.png");
 | 
			
		||||
        node.attachChild(background);
 | 
			
		||||
 | 
			
		||||
        Vector3f size = new Vector3f(280, 60, 0);
 | 
			
		||||
        dialog = new StartDialog(app, node);
 | 
			
		||||
        dialog.addButton("Spiel beitreten", () -> enterJoin(), size);
 | 
			
		||||
        dialog.addButton("Spiel hosten", () -> enterHost(), size);
 | 
			
		||||
        dialog.addButton("Einstellungen", () -> enterSettings(false), size);
 | 
			
		||||
        dialog.addButton("Spiel beenden", () -> app.stop(), size);
 | 
			
		||||
        startDialog = new StartDialog(app, guiNode, this);
 | 
			
		||||
        joinDialog = new JoinDialog(app, guiNode, this);
 | 
			
		||||
        hostDialog = new HostDialog(app, guiNode, this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onEnter() {
 | 
			
		||||
        dialog.show();
 | 
			
		||||
        background = createBackground("Images/main.png");
 | 
			
		||||
        guiNode.attachChild(background);
 | 
			
		||||
 | 
			
		||||
        enterSub(SubState.MAIN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onLeave() {
 | 
			
		||||
        dialog.hide();
 | 
			
		||||
        startDialog.hide();
 | 
			
		||||
        joinDialog.hide();
 | 
			
		||||
        hostDialog.hide();
 | 
			
		||||
 | 
			
		||||
        if(subDialog != null) {
 | 
			
		||||
            subDialog.hide();
 | 
			
		||||
            subDialog = null;
 | 
			
		||||
        guiNode.detachChild(background);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUpdate(float tpf) {
 | 
			
		||||
        startDialog.update();
 | 
			
		||||
        joinDialog.update();
 | 
			
		||||
        hostDialog.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onEnterOverlay(Overlay overlay) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onLeaveOverlay(Overlay overlay)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void joinMenu() {
 | 
			
		||||
        startDialog.hide();
 | 
			
		||||
        hostDialog.hide();
 | 
			
		||||
 | 
			
		||||
        joinDialog.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void hostMenu() {
 | 
			
		||||
        startDialog.hide();
 | 
			
		||||
        joinDialog.hide();
 | 
			
		||||
 | 
			
		||||
        hostDialog.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void mainMenu() {
 | 
			
		||||
        joinDialog.hide();
 | 
			
		||||
        hostDialog.hide();
 | 
			
		||||
 | 
			
		||||
        startDialog.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void tryHost() {
 | 
			
		||||
        int port = 0;
 | 
			
		||||
        String text = hostDialog.getPort();
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            port = Integer.parseInt(text);
 | 
			
		||||
 | 
			
		||||
            if(port >= 1 && port <= 65535) {
 | 
			
		||||
                app.getModelSyncronizer().setName(startDialog.getName());
 | 
			
		||||
                app.getModelSyncronizer().setHost(port);
 | 
			
		||||
                //app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        } catch (NumberFormatException e) {
 | 
			
		||||
            //nothing
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        hostDialog.resetPort();
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void tryJoin() {
 | 
			
		||||
        int port = 0;
 | 
			
		||||
        String ip = joinDialog.getIpt();
 | 
			
		||||
        String portText = hostDialog.getPort();
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            // Validate the port
 | 
			
		||||
            port = Integer.parseInt(portText);
 | 
			
		||||
            if (port < 1 || port > 65535) {
 | 
			
		||||
                throw new IllegalArgumentException("Invalid port");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Validate the IP address
 | 
			
		||||
            if (isValidIpAddress(ip)) {
 | 
			
		||||
                app.getModelSyncronizer().setName(startDialog.getName());
 | 
			
		||||
                app.getModelSyncronizer().setJoin(ip, port);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        } catch (IllegalArgumentException e) {
 | 
			
		||||
            // Invalid input, fall through to reset
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        hostDialog.resetPort();
 | 
			
		||||
        joinDialog.resetIp();
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean isValidIpAddress(String ip) {
 | 
			
		||||
        String ipRegex =
 | 
			
		||||
            "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
 | 
			
		||||
                "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
 | 
			
		||||
                "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
 | 
			
		||||
                "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$";
 | 
			
		||||
 | 
			
		||||
        return ip != null && ip.matches(ipRegex);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void enterSub(SubState state) {
 | 
			
		||||
        this.state = state;
 | 
			
		||||
 | 
			
		||||
        if(null != background) {
 | 
			
		||||
            rootNode.detachChild(background);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case HOST:
 | 
			
		||||
                hostMenu();
 | 
			
		||||
                break;
 | 
			
		||||
            case JOIN:
 | 
			
		||||
                joinMenu();
 | 
			
		||||
                break;
 | 
			
		||||
            case MAIN:
 | 
			
		||||
                mainMenu();
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void enterJoin() {
 | 
			
		||||
        app.getModelSyncronizer().setName(dialog.getName());
 | 
			
		||||
 | 
			
		||||
        subDialog = new JoinDialog(app, node, () -> leaveJoin());
 | 
			
		||||
 | 
			
		||||
        dialog.hide();
 | 
			
		||||
        subDialog.show();
 | 
			
		||||
    public void forward() {
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case HOST:
 | 
			
		||||
                tryHost();
 | 
			
		||||
                break;
 | 
			
		||||
            case JOIN:
 | 
			
		||||
                tryJoin();
 | 
			
		||||
                break;
 | 
			
		||||
            case MAIN:
 | 
			
		||||
                throw new RuntimeException("call forward(boolean host) insted of forward()");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void leaveJoin() {
 | 
			
		||||
        subDialog.hide();
 | 
			
		||||
        dialog.show();
 | 
			
		||||
 | 
			
		||||
        subDialog = null;
 | 
			
		||||
    public void forward(boolean host) {
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case HOST:
 | 
			
		||||
                tryHost();
 | 
			
		||||
                break;
 | 
			
		||||
            case JOIN:
 | 
			
		||||
                tryJoin();
 | 
			
		||||
                break;
 | 
			
		||||
            case MAIN:
 | 
			
		||||
                if(host) {
 | 
			
		||||
                    enterSub(SubState.HOST);
 | 
			
		||||
                    //TODO playSound
 | 
			
		||||
                } else {
 | 
			
		||||
                    enterSub(SubState.JOIN);
 | 
			
		||||
                    //TODO: playSound
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void enterHost() {
 | 
			
		||||
        app.getModelSyncronizer().setName(dialog.getName());
 | 
			
		||||
 | 
			
		||||
        subDialog = new HostDialog(app, node, () -> leaveHost());
 | 
			
		||||
 | 
			
		||||
        dialog.hide();
 | 
			
		||||
        subDialog.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void leaveHost() {
 | 
			
		||||
        subDialog.hide();
 | 
			
		||||
        dialog.show();
 | 
			
		||||
 | 
			
		||||
        subDialog = null;
 | 
			
		||||
    public void back() {
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case HOST:
 | 
			
		||||
                enterSub(SubState.MAIN);
 | 
			
		||||
                //TODO: playSound
 | 
			
		||||
                break;
 | 
			
		||||
            case JOIN:
 | 
			
		||||
                enterSub(SubState.MAIN);
 | 
			
		||||
                //TODO: playSound
 | 
			
		||||
                break;
 | 
			
		||||
            case MAIN:
 | 
			
		||||
                //nothing
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,83 +2,49 @@
 | 
			
		||||
 | 
			
		||||
import com.jme3.asset.TextureKey;
 | 
			
		||||
import com.jme3.material.Material;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.math.Vector2f;
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.shape.Quad;
 | 
			
		||||
import com.jme3.texture.Texture;
 | 
			
		||||
import pp.mdga.client.dialog.GetPercentRunnable;
 | 
			
		||||
import pp.mdga.client.dialog.PercentRunnable;
 | 
			
		||||
import pp.mdga.client.dialog.SettingsButtonDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
import pp.mdga.client.button.*;
 | 
			
		||||
import pp.mdga.client.dialog.AudioSettingsDialog;
 | 
			
		||||
import pp.mdga.client.dialog.SettingsDialog;
 | 
			
		||||
import pp.mdga.client.dialog.VideoSettingsDialog;
 | 
			
		||||
 | 
			
		||||
public abstract class MdgaView {
 | 
			
		||||
    public enum Overlay {
 | 
			
		||||
        INTERRUPT,
 | 
			
		||||
        SETTINGS,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected MdgaApp app;
 | 
			
		||||
    protected Node node;
 | 
			
		||||
    protected Node rootNode = new Node();
 | 
			
		||||
    protected Node guiNode = new Node();
 | 
			
		||||
    protected Node settingsNode = new Node();
 | 
			
		||||
 | 
			
		||||
    protected int depth = 0;
 | 
			
		||||
    private boolean isVideo = false;
 | 
			
		||||
    private boolean isAudio = false;
 | 
			
		||||
    private SettingsButton settingsButton;
 | 
			
		||||
 | 
			
		||||
    protected Node settingsNode;
 | 
			
		||||
    protected Node audioSettingsNode;
 | 
			
		||||
    protected Node videoSettingsNode;
 | 
			
		||||
    private SettingsDialog settingsDialog;
 | 
			
		||||
    private VideoSettingsDialog videoSettingsDialog;
 | 
			
		||||
    private AudioSettingsDialog audioSettingsDialog;
 | 
			
		||||
 | 
			
		||||
    private SettingsButtonDialog settingsButton;
 | 
			
		||||
 | 
			
		||||
    private Geometry settingsBackground;
 | 
			
		||||
    private Geometry audioBackground;
 | 
			
		||||
    private Geometry videoBackground;
 | 
			
		||||
 | 
			
		||||
    private SettingsDialog settings;
 | 
			
		||||
    private SettingsDialog audio;
 | 
			
		||||
    private SettingsDialog video;
 | 
			
		||||
 | 
			
		||||
    private static final String IMAGE_ROOT = "Images/";
 | 
			
		||||
    private int settingsDepth = 0;
 | 
			
		||||
 | 
			
		||||
    public MdgaView(MdgaApp app) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        this.node = new Node();
 | 
			
		||||
        settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
 | 
			
		||||
 | 
			
		||||
        this.settingsNode = new Node();
 | 
			
		||||
        this.audioSettingsNode = new Node();
 | 
			
		||||
        this.videoSettingsNode = new Node();
 | 
			
		||||
 | 
			
		||||
        this.settingsButton = new SettingsButtonDialog(app, node, "", () -> enterSettings(false));
 | 
			
		||||
 | 
			
		||||
        this.settingsBackground = createBackground(IMAGE_ROOT + "background/zahnräder.png");
 | 
			
		||||
        settingsNode.attachChild(settingsBackground);
 | 
			
		||||
 | 
			
		||||
        this.audioBackground = createBackground(IMAGE_ROOT + "background/lautsprecher.png");
 | 
			
		||||
        audioSettingsNode.attachChild(audioBackground);
 | 
			
		||||
 | 
			
		||||
        this.videoBackground = createBackground(IMAGE_ROOT + "background/monitors.png");
 | 
			
		||||
        videoSettingsNode.attachChild(videoBackground);
 | 
			
		||||
 | 
			
		||||
        Vector3f size = new Vector3f(280, 60, 0);
 | 
			
		||||
 | 
			
		||||
        this.settings = new SettingsDialog(app, settingsNode, IMAGE_ROOT + "zahnrad.png");
 | 
			
		||||
        this.settings.addButton("Video", () -> enterVideo(), size);
 | 
			
		||||
        this.settings.addButton("Audio", () -> enterAudio(), size);
 | 
			
		||||
        this.settings.addButton("Zurück", () -> leaveSettings(false), size);
 | 
			
		||||
 | 
			
		||||
        this.audio = new SettingsDialog(app, audioSettingsNode, IMAGE_ROOT + "audio_icon.png");
 | 
			
		||||
        this.audio.addSlider("Lautstärke", new PercentRunnable(app.getAcousticHandler()::setMainVolume), new GetPercentRunnable(app.getAcousticHandler()::getMainVolume), size, (int) app.getAcousticHandler().getMainVolume() * 100);
 | 
			
		||||
        this.audio.addSlider("Musik", new PercentRunnable(app.getAcousticHandler()::setMusicVolume), new GetPercentRunnable(app.getAcousticHandler()::getMusicVolume), size, (int) app.getAcousticHandler().getMusicVolume() * 100);
 | 
			
		||||
        this.audio.addSlider("Sound", new PercentRunnable(app.getAcousticHandler()::setSoundVolume), new GetPercentRunnable(app.getAcousticHandler()::getSoundVolume), size, (int) app.getAcousticHandler().getSoundVolume() * 100);
 | 
			
		||||
        this.audio.addButton("Zurück", () -> leaveAudio(), size);
 | 
			
		||||
 | 
			
		||||
        this.video = new SettingsDialog(app, videoSettingsNode, IMAGE_ROOT + "monitor.png");
 | 
			
		||||
        this.video.addButton("A", () -> System.out.println("A"), size);
 | 
			
		||||
        this.video.addButton("B", () -> System.out.println("B"), size);
 | 
			
		||||
        this.video.addButton("Zurück", () -> leaveVideo(), size);
 | 
			
		||||
        settingsDialog = new SettingsDialog(app, settingsNode, this);
 | 
			
		||||
        videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this);
 | 
			
		||||
        audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        app.getGuiNode().attachChild(node);
 | 
			
		||||
 | 
			
		||||
        audio.initVolume();
 | 
			
		||||
        app.getRootNode().attachChild(rootNode);
 | 
			
		||||
        app.getGuiNode().attachChild(guiNode);
 | 
			
		||||
 | 
			
		||||
        settingsButton.show();
 | 
			
		||||
 | 
			
		||||
@@ -86,123 +52,139 @@ public void enter() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void leave() {
 | 
			
		||||
        onLeave();
 | 
			
		||||
        app.getRootNode().detachChild(rootNode);
 | 
			
		||||
        app.getGuiNode().detachChild(guiNode);
 | 
			
		||||
 | 
			
		||||
        settingsButton.hide();
 | 
			
		||||
 | 
			
		||||
        app.getGuiNode().detachChild(node);
 | 
			
		||||
        while (settingsDepth > 0) {
 | 
			
		||||
            pressEscape();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        onLeave();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        audio.update();
 | 
			
		||||
        onUpdate();
 | 
			
		||||
    public void enterOverlay(Overlay overlay) {
 | 
			
		||||
        app.getGuiNode().detachChild(guiNode);
 | 
			
		||||
 | 
			
		||||
        onEnterOverlay(overlay);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void leaveOverlay(Overlay overlay) {
 | 
			
		||||
        app.getGuiNode().attachChild(guiNode);
 | 
			
		||||
 | 
			
		||||
        onLeaveOverlay(overlay);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update(float tpf) {
 | 
			
		||||
        videoSettingsDialog.update();
 | 
			
		||||
        audioSettingsDialog.update();
 | 
			
		||||
 | 
			
		||||
        onUpdate(tpf);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected abstract void onEnter();
 | 
			
		||||
    protected abstract void onLeave();
 | 
			
		||||
    protected void onUpdate() {}
 | 
			
		||||
    protected void onUpdate(float tpf) {}
 | 
			
		||||
 | 
			
		||||
    protected abstract void onEnterOverlay(Overlay overlay);
 | 
			
		||||
    protected abstract void onLeaveOverlay(Overlay overlay);
 | 
			
		||||
 | 
			
		||||
    protected Geometry createBackground(String texturePath) {
 | 
			
		||||
        TextureKey key = new TextureKey(texturePath, true);
 | 
			
		||||
        Texture backgroundTexture = app.getAssetManager().loadTexture(key);
 | 
			
		||||
        Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
 | 
			
		||||
        Geometry background = new Geometry("Background", quad);
 | 
			
		||||
 | 
			
		||||
        Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
 | 
			
		||||
        mat.setTexture("ColorMap", backgroundTexture);
 | 
			
		||||
 | 
			
		||||
        Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
 | 
			
		||||
 | 
			
		||||
        Geometry background = new Geometry("Background", quad);
 | 
			
		||||
        background.setMaterial(mat);
 | 
			
		||||
        background.setLocalTranslation(0, 0, -1);
 | 
			
		||||
        background.setLocalTranslation(0, 0, -2);
 | 
			
		||||
 | 
			
		||||
        return background;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void enterExtendedSettings() {}
 | 
			
		||||
    protected void leaveExtendedSettings() {}
 | 
			
		||||
 | 
			
		||||
    protected void enterSettings(boolean soft) {
 | 
			
		||||
        leave();
 | 
			
		||||
    public void enterSettings() {
 | 
			
		||||
        enterOverlay(Overlay.SETTINGS);
 | 
			
		||||
 | 
			
		||||
        app.getGuiNode().attachChild(settingsNode);
 | 
			
		||||
        settingsDialog.show();
 | 
			
		||||
 | 
			
		||||
        if(!soft) {
 | 
			
		||||
            depth++;
 | 
			
		||||
 | 
			
		||||
            enterExtendedSettings();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        settings.show();
 | 
			
		||||
        settingsDepth++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void leaveSettings(boolean soft) {
 | 
			
		||||
        settings.hide();
 | 
			
		||||
    public void leaveSettings() {
 | 
			
		||||
        leaveOverlay(Overlay.SETTINGS);
 | 
			
		||||
 | 
			
		||||
        app.getGuiNode().detachChild(settingsNode);
 | 
			
		||||
        settingsDialog.hide();
 | 
			
		||||
 | 
			
		||||
        if(!soft) {
 | 
			
		||||
            leaveExtendedSettings();
 | 
			
		||||
            enter();
 | 
			
		||||
            depth--;
 | 
			
		||||
        }
 | 
			
		||||
        settingsDepth--;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void enterAudio() {
 | 
			
		||||
        leaveSettings(true);
 | 
			
		||||
    public void enterVideoSettings() {
 | 
			
		||||
        settingsDialog.hide();
 | 
			
		||||
        videoSettingsDialog.show();
 | 
			
		||||
 | 
			
		||||
        depth++;
 | 
			
		||||
        isAudio = true;
 | 
			
		||||
 | 
			
		||||
        app.getGuiNode().attachChild(audioSettingsNode);
 | 
			
		||||
 | 
			
		||||
        audio.show();
 | 
			
		||||
        settingsDepth++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void leaveAudio() {
 | 
			
		||||
        audio.hide();
 | 
			
		||||
    public void leaveVideoSettings() {
 | 
			
		||||
        settingsDialog.show();
 | 
			
		||||
        videoSettingsDialog.hide();
 | 
			
		||||
 | 
			
		||||
        app.getGuiNode().detachChild(audioSettingsNode);
 | 
			
		||||
 | 
			
		||||
        isAudio = false;
 | 
			
		||||
        depth--;
 | 
			
		||||
 | 
			
		||||
        enterSettings(true);
 | 
			
		||||
        settingsDepth--;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void enterVideo() {
 | 
			
		||||
        leaveSettings(true);
 | 
			
		||||
    public void enterAudioSettings() {
 | 
			
		||||
        settingsDialog.hide();
 | 
			
		||||
        audioSettingsDialog.show();
 | 
			
		||||
 | 
			
		||||
        app.getGuiNode().attachChild(videoSettingsNode);
 | 
			
		||||
 | 
			
		||||
        depth++;
 | 
			
		||||
 | 
			
		||||
        isVideo = true;
 | 
			
		||||
 | 
			
		||||
        video.show();
 | 
			
		||||
        settingsDepth++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void leaveVideo() {
 | 
			
		||||
        video.hide();
 | 
			
		||||
    public void leaveAudioSettings() {
 | 
			
		||||
        settingsDialog.show();
 | 
			
		||||
        audioSettingsDialog.hide();
 | 
			
		||||
 | 
			
		||||
        app.getGuiNode().detachChild(videoSettingsNode);
 | 
			
		||||
        settingsDepth--;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        depth--;
 | 
			
		||||
        isVideo = false;
 | 
			
		||||
 | 
			
		||||
        enterSettings(true);
 | 
			
		||||
    private void leaveAdvanced() {
 | 
			
		||||
        settingsDialog.show();
 | 
			
		||||
        audioSettingsDialog.hide();
 | 
			
		||||
        videoSettingsDialog.hide();
 | 
			
		||||
        settingsDepth--;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void pressEscape() {
 | 
			
		||||
        if(depth == 0) {
 | 
			
		||||
            enterSettings(false);
 | 
			
		||||
        } else if(depth == 1) {
 | 
			
		||||
            leaveSettings(false);
 | 
			
		||||
        }
 | 
			
		||||
        else if (depth == 2){
 | 
			
		||||
            if(isVideo) {
 | 
			
		||||
                leaveVideo();
 | 
			
		||||
            }
 | 
			
		||||
            if(isAudio) {
 | 
			
		||||
                leaveAudio();
 | 
			
		||||
            }
 | 
			
		||||
        if(settingsDepth == 0) {
 | 
			
		||||
            enterSettings();
 | 
			
		||||
        } else if(settingsDepth == 1) {
 | 
			
		||||
            leaveSettings();
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new RuntimeException();
 | 
			
		||||
            leaveAdvanced();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void pressForward() {
 | 
			
		||||
        if(this instanceof MainView mainView) {
 | 
			
		||||
            mainView.forward(false);
 | 
			
		||||
            app.getAcousticHandler().playSound(MdgaSound.BUTTON_PRESSED);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(this instanceof LobbyView lobbyView) {
 | 
			
		||||
            app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(this instanceof GameView gameView) {
 | 
			
		||||
            app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(this instanceof CeremonyView ceremonyView) {
 | 
			
		||||
            ceremonyView.forward();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 3.1 MiB  | 
| 
		 Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB  | 
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/error_sound.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/error_sound.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/gamestart.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/gamestart.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/menu_button.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/menu_button.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/uiclick.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/uiclick.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Animation extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class AudioSettings extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Ceremony extends ClientState {
 | 
			
		||||
    private final CeremonyStateMachine ceremonyStateMachine = new CeremonyStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class CeremonyStateMachine extends ClientStateMachine {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ChoosePiece extends ClientState {
 | 
			
		||||
    private final ChoosePieceStateMachine choosePieceStateMachine = new ChoosePieceStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ChoosePieceStateMachine extends ClientStateMachine{
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ChoosePowerCard extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ClientAutomaton extends ClientStateMachine {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class ClientGameLogic {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public abstract class ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public abstract class ClientStateMachine extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class DetermineStartPlayer extends ClientState {
 | 
			
		||||
    private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class DetermineStartPlayerStateMachine extends ClientStateMachine{
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Dialogs extends ClientState {
 | 
			
		||||
    private final DialogsStateMachine dialogsStateMachine = new DialogsStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class DialogsStateMachine extends ClientStateMachine {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class GameState extends ClientState {
 | 
			
		||||
    private final GameStateMachine gameStateMachine = new GameStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class GameStateMachine extends ClientStateMachine {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Interrupt extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Lobby extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class MainSettings extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class MovePiece extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class NetworkDialog extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class NoPiece extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class PlayPowerCard extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Podium extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class PowerCard extends ClientState {
 | 
			
		||||
    private final PowerCardStateMachine powerCardStateMachine = new PowerCardStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class PowerCardStateMachine extends ClientStateMachine {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class RollDice extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class RollRankingDice extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class SelectPiece extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Settings extends ClientState {
 | 
			
		||||
    private final SettingsStateMachine settingsStateMachine = new SettingsStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class SettingsStateMachine extends ClientStateMachine {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Shield extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Spectator extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class StartDialog extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class StartPiece extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Statistics extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Swap extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Turn extends ClientState {
 | 
			
		||||
    private final TurnStateMachine turnStateMachine = new TurnStateMachine();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class TurnStateMachine extends ClientStateMachine {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class VideoSettings extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class WaitRanking extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class Waiting extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +0,0 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
public class WaitingPiece extends ClientState {
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +0,0 @@
 | 
			
		||||
package pp.mdga.game;
 | 
			
		||||
 | 
			
		||||
public enum Color {
 | 
			
		||||
    ARMY,
 | 
			
		||||
    NAVY,
 | 
			
		||||
    CYBER,
 | 
			
		||||
    AIRFORCE
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,13 +0,0 @@
 | 
			
		||||
package pp.mdga.message.client;
 | 
			
		||||
 | 
			
		||||
public class AnimationEnd extends ClientMessage {
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "null";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void accept(ClientInterpreter interpreter, int from) {
 | 
			
		||||
        interpreter.received(this, from);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
package pp.mdga.message.client;
 | 
			
		||||
 | 
			
		||||
public interface ClientInterpreter {
 | 
			
		||||
    void received(AnimationEnd animationEnd, int from);
 | 
			
		||||
 | 
			
		||||
    void received(DeselectTSK deselectTSK , int from);
 | 
			
		||||
 | 
			
		||||
    void received(ForceStartGame forceStartGame, int from);
 | 
			
		||||
 | 
			
		||||
    void received(JoinServer joinServer , int from);
 | 
			
		||||
 | 
			
		||||
    void received(LeaveGame leaveGame , int from);
 | 
			
		||||
 | 
			
		||||
    void received(LobbyNotReady lobbyNotReady , int from);
 | 
			
		||||
 | 
			
		||||
    void received(LobbyReady lobbyReady , int from);
 | 
			
		||||
 | 
			
		||||
    void received(RequestBriefing requestBriefing , int from);
 | 
			
		||||
 | 
			
		||||
    void received(RequestDice requestDice , int from);
 | 
			
		||||
 | 
			
		||||
    void received(RequestMove requestMove , int from);
 | 
			
		||||
 | 
			
		||||
    void received(RequestPlayCard requestPlayCard , int from);
 | 
			
		||||
 | 
			
		||||
    void received(SelectCard selectCard , int from);
 | 
			
		||||
 | 
			
		||||
    void received(SelectTSK selectTSK , int from);
 | 
			
		||||
 | 
			
		||||
    void received(ForceContinueGame forceContinueGame, int from);
 | 
			
		||||
 | 
			
		||||
    void received(ClientStartGame clientStartGame, int from);
 | 
			
		||||
 | 
			
		||||
    void received(NoPowerCard noPowerCard, int from);
 | 
			
		||||
 | 
			
		||||
    void received(SelectedPieces selectedPieces, int from);
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user