Implement notificationSyncronizer
This commit is contained in:
		@@ -1,75 +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.Container;
 | 
			
		||||
import com.simsilica.lemur.HAlignment;
 | 
			
		||||
import com.simsilica.lemur.VAlignment;
 | 
			
		||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
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 float vertical_step;
 | 
			
		||||
    protected final float horitontal_step;
 | 
			
		||||
 | 
			
		||||
    public 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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void show() {
 | 
			
		||||
        node.attachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hide () {
 | 
			
		||||
        node.detachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createButton(String label, Runnable action, Vector3f size) {
 | 
			
		||||
        Button button = new Button(label);
 | 
			
		||||
        button.addClickCommands(source -> action.run());
 | 
			
		||||
        button.setFontSize(35);
 | 
			
		||||
        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, 5);
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
 | 
			
		||||
            hoverBackground.setMargin(5, 5);
 | 
			
		||||
            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, 5);
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        container.addChild(button);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1,16 +1,16 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import com.jme3.app.SimpleApplication;
 | 
			
		||||
import com.jme3.system.NanoTimer;
 | 
			
		||||
import com.simsilica.lemur.GuiGlobals;
 | 
			
		||||
import pp.mdga.client.Acoustic.AcousticHandler;
 | 
			
		||||
import pp.mdga.client.Animation.AnimationHandler;
 | 
			
		||||
import pp.mdga.client.acoustic.AcousticHandler;
 | 
			
		||||
import pp.mdga.client.animation.AnimationHandler;
 | 
			
		||||
import com.jme3.system.AppSettings;
 | 
			
		||||
import pp.mdga.client.View.*;
 | 
			
		||||
import pp.mdga.client.view.*;
 | 
			
		||||
 | 
			
		||||
public class MdgaApp extends SimpleApplication {
 | 
			
		||||
    private AnimationHandler animationHandler;
 | 
			
		||||
    private AcousticHandler acousticHandler;
 | 
			
		||||
    private NotificationSynchronizer notificationSynchronizer;
 | 
			
		||||
 | 
			
		||||
    MdgaView view = null;
 | 
			
		||||
    private MdgaState state = MdgaState.MAIN;
 | 
			
		||||
@@ -33,6 +33,7 @@ public static void main(String[] args) {
 | 
			
		||||
    public void simpleInitApp() {
 | 
			
		||||
        animationHandler = new AnimationHandler(this);
 | 
			
		||||
        acousticHandler = new AcousticHandler(this);
 | 
			
		||||
        notificationSynchronizer = new NotificationSynchronizer(this);
 | 
			
		||||
 | 
			
		||||
        GuiGlobals.initialize(this);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.Acoustic.MusicAsset;
 | 
			
		||||
import pp.mdga.notification.Notification;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
@@ -19,30 +18,102 @@ void update() {
 | 
			
		||||
        for (Notification n : notifications) {
 | 
			
		||||
            switch (app.getState()) {
 | 
			
		||||
                case MAIN:
 | 
			
		||||
 | 
			
		||||
                    handleMain(n);
 | 
			
		||||
                    break;
 | 
			
		||||
                case LOBBY:
 | 
			
		||||
 | 
			
		||||
                    handleLobby(n);
 | 
			
		||||
                    break;
 | 
			
		||||
                case GAME:
 | 
			
		||||
 | 
			
		||||
                    handleGame(n);
 | 
			
		||||
                    break;
 | 
			
		||||
                case CEREMONY:
 | 
			
		||||
 | 
			
		||||
                    handleCeremony(n);
 | 
			
		||||
                    break;
 | 
			
		||||
                case NONE:
 | 
			
		||||
                    throw new RuntimeException("no notification expected");
 | 
			
		||||
                    throw new RuntimeException("no notification expected: " + n.toString());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void handleMain(Notification notification) {
 | 
			
		||||
        throw new RuntimeException("no notification expected in state: MAIN");
 | 
			
		||||
        if (notification instanceof LobbyDialogNotification) {
 | 
			
		||||
            app.enter(MdgaState.LOBBY);
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new RuntimeException("notification not expected: " + notification.toString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void handleLobby(Notification notification) {
 | 
			
		||||
        if (notification instanceof TskSelectNotification) {
 | 
			
		||||
 | 
			
		||||
        } else if (notification instanceof TskUnselectNotification) {
 | 
			
		||||
 | 
			
		||||
        } else if (notification instanceof GameNotification) {
 | 
			
		||||
            app.enter(MdgaState.GAME);
 | 
			
		||||
        } else if (notification instanceof InterruptNotification) {
 | 
			
		||||
            //TODO gibt es einen intterupt in der lobby?????
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new RuntimeException("notification not expected: " + notification.toString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void handleGame(Notification notification) {
 | 
			
		||||
        if(notification instanceof ) {
 | 
			
		||||
        if (notification instanceof AcquireCardNotification) {
 | 
			
		||||
            // Handle AcquireCardNotification
 | 
			
		||||
        } else if (notification instanceof ActivePlayerNotification) {
 | 
			
		||||
            // Handle ActivePlayerNotification
 | 
			
		||||
        } else if (notification instanceof CeremonyNotification) {
 | 
			
		||||
            app.enter(MdgaState.CEREMONY);
 | 
			
		||||
        } else if (notification instanceof DiceNowNotification) {
 | 
			
		||||
            // Handle DiceNowNotification
 | 
			
		||||
        } else if (notification instanceof DicingNotification) {
 | 
			
		||||
            // Handle DicingNotification
 | 
			
		||||
        } else if (notification instanceof DrawCardNotification) {
 | 
			
		||||
            // Handle DrawCardNotification
 | 
			
		||||
        } else if (notification instanceof HomeMoveNotification) {
 | 
			
		||||
            // Handle HomeMoveNotification
 | 
			
		||||
        } else if (notification instanceof InterruptNotification) {
 | 
			
		||||
            // Handle InterruptNotification
 | 
			
		||||
        } else if (notification instanceof MovePieceNotification) {
 | 
			
		||||
            // Handle MovePieceNotification
 | 
			
		||||
        } else if (notification instanceof MoveThrowPieceNotification) {
 | 
			
		||||
            // Handle MoveThrowPieceNotification
 | 
			
		||||
        } else if (notification instanceof NoShieldNotification) {
 | 
			
		||||
            // Handle NoShieldNotification
 | 
			
		||||
        } else if (notification instanceof PieceInGameNotification) {
 | 
			
		||||
            // Handle PieceInGameNotification
 | 
			
		||||
        } else if (notification instanceof PlayCardNotification) {
 | 
			
		||||
            // Handle PlayCardNotification
 | 
			
		||||
        } else if (notification instanceof PlayerInGameNotification) {
 | 
			
		||||
            // Handle PlayerInGameNotification
 | 
			
		||||
        } else if (notification instanceof ResumeNotification) {
 | 
			
		||||
            // Handle ResumeNotification
 | 
			
		||||
        } else if (notification instanceof RollDiceNotification) {
 | 
			
		||||
            // Handle RollDiceNotification
 | 
			
		||||
        } else if (notification instanceof SelectableCardsNotification) {
 | 
			
		||||
            // Handle SelectableCardsNotification
 | 
			
		||||
        } else if (notification instanceof SelectablePiecesNotification) {
 | 
			
		||||
            // Handle SelectablePiecesNotification
 | 
			
		||||
        } else if (notification instanceof ShieldActiveNotification) {
 | 
			
		||||
            // Handle ShieldActiveNotification
 | 
			
		||||
        } else if (notification instanceof ShieldSuppressedNotification) {
 | 
			
		||||
            // Handle ShieldSuppressedNotification
 | 
			
		||||
        } else if (notification instanceof StartDialogNotification) {
 | 
			
		||||
            // Handle StartDialogNotification
 | 
			
		||||
        } else if (notification instanceof SwapPieceNotification) {
 | 
			
		||||
            // Handle SwapPieceNotification
 | 
			
		||||
        } else if (notification instanceof WaitMoveNotification) {
 | 
			
		||||
            // Handle WaitMoveNotification
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new RuntimeException("notification not expected: " + notification.toString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void handleCeremony(Notification notification) {
 | 
			
		||||
        if (notification instanceof StartDialogNotification) {
 | 
			
		||||
            app.enter(MdgaState.MAIN);
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new RuntimeException("notification not expected: " + notification.toString());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,75 @@
 | 
			
		||||
package pp.mdga.client.dialog;
 | 
			
		||||
package pp.mdga.client.Dialog;
 | 
			
		||||
 | 
			
		||||
public class 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;
 | 
			
		||||
 | 
			
		||||
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 float vertical_step;
 | 
			
		||||
    protected final float horitontal_step;
 | 
			
		||||
 | 
			
		||||
    public 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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void show() {
 | 
			
		||||
        node.attachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hide () {
 | 
			
		||||
        node.detachChild(container);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void createButton(String label, Runnable action, Vector3f size) {
 | 
			
		||||
        Button button = new Button(label);
 | 
			
		||||
        button.addClickCommands(source -> action.run());
 | 
			
		||||
        button.setFontSize(35);
 | 
			
		||||
        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, 5);
 | 
			
		||||
        button.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
 | 
			
		||||
            QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
 | 
			
		||||
            hoverBackground.setMargin(5, 5);
 | 
			
		||||
            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, 5);
 | 
			
		||||
            source.setBackground(normalBackground);
 | 
			
		||||
            button.setHighlightColor(ColorRGBA.White);
 | 
			
		||||
            button.setColor(ColorRGBA.Black);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        container.addChild(button);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,6 @@
 | 
			
		||||
package pp.mdga.client.View;
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import com.simsilica.lemur.Container;
 | 
			
		||||
import com.simsilica.lemur.Label;
 | 
			
		||||
import pp.mdga.client.Dialog.SingleButtonLeftDialog;
 | 
			
		||||
import pp.mdga.client.Dialog.SingleButtonRightDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package pp.mdga.client.View;
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import pp.mdga.client.Board.BoardHandler;
 | 
			
		||||
import pp.mdga.client.board.BoardHandler;
 | 
			
		||||
import pp.mdga.client.Dialog.SingleButtonRightDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
@@ -1,13 +1,11 @@
 | 
			
		||||
package pp.mdga.client.View;
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import pp.mdga.client.Dialog.LobbyButtonDialog;
 | 
			
		||||
import pp.mdga.client.Dialog.SettingsButtonDialog;
 | 
			
		||||
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.game.Color;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
@@ -1,8 +1,7 @@
 | 
			
		||||
package pp.mdga.client.View;
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.scene.Geometry;
 | 
			
		||||
import pp.mdga.client.Dialog.InputButtonDialog;
 | 
			
		||||
import pp.mdga.client.Dialog.SettingsButtonDialog;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.MdgaState;
 | 
			
		||||
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.View;
 | 
			
		||||
package pp.mdga.client.view;
 | 
			
		||||
 | 
			
		||||
import com.jme3.asset.TextureKey;
 | 
			
		||||
import com.jme3.material.Material;
 | 
			
		||||
		Reference in New Issue
	
	Block a user