diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/Dialog/Dialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/Dialog/Dialog.java deleted file mode 100644 index 96df3bf3..00000000 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/Dialog/Dialog.java +++ /dev/null @@ -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); - } -} - diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java index 23ae8051..c0eb3456 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java @@ -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); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java index a062844e..9979371f 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java @@ -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()); } } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java similarity index 100% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardView.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/board/BoardHandler.java diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/Dialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/Dialog.java index a39a2634..96df3bf3 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/Dialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/Dialog.java @@ -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); + } } + diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/CeremonyView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java similarity index 94% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/View/CeremonyView.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java index 07125ebc..718f1add 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/CeremonyView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/CeremonyView.java @@ -1,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; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/GameView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java similarity index 87% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/View/GameView.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java index a949b3a8..db98fe77 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/GameView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/GameView.java @@ -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; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/LobbyView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java similarity index 94% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/View/LobbyView.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java index 7026adcb..7da1098f 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/LobbyView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/LobbyView.java @@ -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; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/MainView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java similarity index 92% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/View/MainView.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java index f12882a3..8b52e2ee 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/MainView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java @@ -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; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/MdgaView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MdgaView.java similarity index 98% rename from Projekte/mdga/client/src/main/java/pp/mdga/client/View/MdgaView.java rename to Projekte/mdga/client/src/main/java/pp/mdga/client/view/MdgaView.java index 10039ad8..6c565fb9 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/View/MdgaView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MdgaView.java @@ -1,4 +1,4 @@ -package pp.mdga.client.View; +package pp.mdga.client.view; import com.jme3.asset.TextureKey; import com.jme3.material.Material;