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 fc972ef0..8e903e1b 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 @@ -57,7 +57,7 @@ public void simpleInitApp() { gameView = new GameView(this); ceremonyView = new CeremonyView(this); - enter(MdgaState.MAIN); + enter(MdgaState.LOBBY); } @Override diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java index dc419bb7..6049063f 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java @@ -6,6 +6,7 @@ import pp.mdga.client.view.LobbyView; import pp.mdga.game.BonusCard; import pp.mdga.game.Color; +import pp.mdga.message.client.LobbyReadyMessage; import pp.mdga.notification.AcquireCardNotification; import pp.mdga.notification.DrawCardNotification; import pp.mdga.notification.TskSelectNotification; @@ -26,6 +27,9 @@ public class ModelSynchronizer { this.app = app; } + private Color testColor; + private int test = 0; + public void animationEnd() { } @@ -98,6 +102,7 @@ public void selectTsk(Color color) { LOGGER.log(Level.INFO, "selectTsk: {0}", color); LobbyView view = (LobbyView) app.getView(); view.setTaken(color, true, true, "OwnPlayerName"); + testColor = color; } public void unselectTsk() { @@ -115,9 +120,16 @@ public void setName(String name) { LOGGER.log(Level.INFO, "setName: {0}", name); } - public void setReady() { + public void setReady(boolean ready) { LOGGER.log(Level.INFO, "setReady"); - enter(MdgaState.GAME); + LobbyView view = (LobbyView) app.getView(); + view.setReady(testColor, ready); + test++; + + if(test > 2) { + test = 0; + enter(MdgaState.GAME); + } } public void setHost(int port) { 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 70b0a2bd..5da02093 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 @@ -59,7 +59,7 @@ private void handleLobby(Notification notification) { if (notification instanceof TskSelectNotification n) { //lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName()); - lobbyView.setTaken(n.getColor(), true, true, n.getName()); + lobbyView.setTaken(n.getColor(), true, false, n.getName()); } else if (notification instanceof TskUnselectNotification n) { lobbyView.setTaken(n.getColor(), false, false, null); //} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) { diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java index de37adc1..0e2b091c 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/AbstractButton.java @@ -4,14 +4,18 @@ import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; import com.jme3.scene.Node; +import com.jme3.ui.Picture; 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_NORMAL = ColorRGBA.fromRGBA255(233, 236, 239, 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); + protected Picture pictureNormal = new Picture("normalButton"); + protected Picture pictureHover = new Picture("normalButton"); + public static final float HORIZONTAL = 16; public static final float VERTICAL = 9; @@ -35,6 +39,9 @@ public AbstractButton(MdgaApp app, Node node) { this.app = app; this.node = node; + pictureNormal.setImage(app.getAssetManager(), "Images/General_Button_normal.png", true); + pictureHover.setImage(app.getAssetManager(), "Images/General_Button_hover.png", true); + font = app.getAssetManager().loadFont("Fonts/Gunplay.fnt"); } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ButtonLeft.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ButtonLeft.java index 16933f5f..b60cd8cc 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ButtonLeft.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ButtonLeft.java @@ -3,6 +3,7 @@ import com.jme3.math.Vector2f; import com.jme3.scene.Node; import pp.mdga.client.MdgaApp; +import com.jme3.ui.Picture; public class ButtonLeft extends ClickButton { public ButtonLeft(MdgaApp app, Node node, Runnable action, String label, int narrowFactor) { diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java index 4b207f0b..b7b8f8d6 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/CeremonyButton.java @@ -38,7 +38,7 @@ public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, S this.node3d = node3d; - label = new LabelButton(app, node, name, new Vector2f( WIDTH, 1), new Vector2f(0, 0)); + label = new LabelButton(app, node, name, new Vector2f( WIDTH, 1), new Vector2f(0, 0), true); final float mid = HORIZONTAL / 2; final float uiSpacing = 1.4f; @@ -96,11 +96,11 @@ public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, S case LOST: adjust = true; label.adjust = true; - uiX -= 1 * uiSpacing + 0.4f; + uiX -= 2 * uiSpacing + 0.4f; uiX -= WIDTH / 2; - uiY -= 2; - figX -= 2 * figSpacingX; - figY -= 4 * figSpacingY; + uiY -= 2.0f; + figX -= 2.5f * figSpacingX + 0.05f; + figY -= 4.5f * figSpacingY; break; } @@ -112,8 +112,8 @@ public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, S @Override public void onHover() { - ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone(); - buttonNormal.a = 0.01f; + ColorRGBA buttonNormal = BUTTON_NORMAL.clone(); + buttonNormal.a = 0.1f; QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal); instance.setBackground(background); @@ -121,8 +121,8 @@ public void onHover() { @Override public void onUnHover() { - ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone(); - buttonNormal.a = 0.01f; + ColorRGBA buttonNormal = BUTTON_NORMAL.clone(); + buttonNormal.a = 0.1f; QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal); instance.setBackground(background); diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java index 08fb544d..cd13b787 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/ClickButton.java @@ -3,6 +3,7 @@ import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.scene.Node; +import com.jme3.ui.Picture; import com.simsilica.lemur.Button; import com.simsilica.lemur.HAlignment; import com.simsilica.lemur.VAlignment; @@ -44,10 +45,12 @@ public abstract class ClickButton extends AbstractButton { @Override public void show() { + node.attachChild(pictureNormal); release(); calculateRelative(); setRelative(); + setImageRelative(pictureNormal); node.attachChild(instance); } @@ -55,6 +58,13 @@ public void show() { @Override public void hide() { node.detachChild(instance); + + if(node.hasChild(pictureNormal)) { + node.detachChild(pictureNormal); + } + if(node.hasChild(pictureHover)) { + node.detachChild(pictureHover); + } } protected abstract void onHover(); @@ -69,6 +79,12 @@ protected void click() { app.getAcousticHandler().playSound(MdgaSound.UI_CLICK); + if(node.hasChild(pictureNormal)) { + node.detachChild(pictureNormal); + setImageRelative(pictureHover); + node.attachChild(pictureHover); + } + onHover(); }; @@ -79,6 +95,12 @@ protected void release() { QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL); instance.setBackground(background); + if(node.hasChild(pictureHover)) { + node.detachChild(pictureHover); + setImageRelative(pictureNormal); + node.attachChild(pictureNormal); + } + onUnHover(); }; @@ -105,4 +127,21 @@ protected void setRelative() { instance.setLocalTranslation(instance.getLocalTranslation().x, verticalMid, instance.getLocalTranslation().z); } } + + protected void setImageRelative(Picture picture) { + if(null == picture) { + return; + } + + final float LARGER = 10; + + picture.setWidth(instance.getPreferredSize().x + LARGER); + picture.setHeight(instance.getPreferredSize().y + LARGER); + + picture.setLocalTranslation( + instance.getLocalTranslation().x - LARGER / 2, + (instance.getLocalTranslation().y - picture.getHeight()) + LARGER / 2, + instance.getLocalTranslation().z + 0.01f + ); + } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java index 1740a954..1a80818f 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LabelButton.java @@ -10,16 +10,26 @@ 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) { + private boolean isButton; + + public LabelButton(MdgaApp app, Node node, String label, Vector2f size, Vector2f pos, boolean isButton) { super(app, node, () -> {}, label, size, pos); + + this.isButton = isButton; + + pictureHover = pictureNormal; } @Override public void show() { + if(isButton) { + node.attachChild(pictureNormal); + } release(); calculateRelative(); setRelative(); + setImageRelative(pictureNormal); instance.setFontSize(fontSize / 2); @@ -29,6 +39,13 @@ public void show() { @Override public void hide() { node.detachChild(instance); + + if(node.hasChild(pictureNormal)) { + node.detachChild(pictureNormal); + } + if(node.hasChild(pictureHover)) { + node.detachChild(pictureHover); + } } @Override diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java index 3867835f..84fe0b02 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/LobbyButton.java @@ -7,8 +7,11 @@ import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.renderer.queue.RenderQueue; +import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.Spatial; +import com.jme3.scene.shape.Quad; +import com.jme3.texture.Texture; import com.simsilica.lemur.component.QuadBackgroundComponent; import pp.mdga.client.Asset; import pp.mdga.client.MdgaApp; @@ -21,11 +24,13 @@ public enum Taken { 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 ColorRGBA LOBBY_TAKEN = ColorRGBA.fromRGBA255(193,58,59, 100); + + static final ColorRGBA LOBBY_READY = ColorRGBA.fromRGBA255(55,172,190, 100); + static final ColorRGBA LOBBY_READY_HOVER = ColorRGBA.fromRGBA255(17,211,218, 100); + + static final ColorRGBA LOBBY_SELF_NORMAL = ColorRGBA.fromRGBA255(0,151,19, 100); + static final ColorRGBA LOBBY_SELF_HOVER = ColorRGBA.fromRGBA255(0,230,19, 100); static final float WIDTH = 4.0f; @@ -46,7 +51,7 @@ public LobbyButton(MdgaApp app, Node node, Node node3d, Runnable action, Color t this.node3d = node3d; - label = new LabelButton(app, node, "- leer -", new Vector2f( WIDTH, 1), new Vector2f(0, 0)); + label = new LabelButton(app, node, "- leer -", new Vector2f( WIDTH, 1), new Vector2f(0, 0), true); final float mid = HORIZONTAL / 2; final float uiSpacing = 0.4f; @@ -123,11 +128,11 @@ public void onHover() { @Override public void onUnHover() { - ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone(); + ColorRGBA buttonNormal = BUTTON_NORMAL.clone(); switch (taken) { case NOT: - buttonNormal.a = 0.1f; + buttonNormal.a = 0.3f; break; case SELF: buttonNormal = LOBBY_SELF_NORMAL; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/SettingsButton.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/SettingsButton.java index eef5c263..af0e257d 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/button/SettingsButton.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/button/SettingsButton.java @@ -14,21 +14,36 @@ 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 show() { + release(); + + calculateRelative(); + setRelative(); + setImageRelative(pictureNormal); + + node.attachChild(instance); } @Override public void onHover() { + icon = new IconComponent("Images/Settings_Button_hover.png"); + icon.setIconScale(0.02f * app.getImageScale()); + icon.setHAlignment(HAlignment.Center); + icon.setVAlignment(VAlignment.Center); + instance.setIcon(icon); } @Override public void onUnHover() { + icon = new IconComponent("Images/Settings_Button_normal.png"); + icon.setIconScale(0.02f * app.getImageScale()); + icon.setHAlignment(HAlignment.Center); + icon.setVAlignment(VAlignment.Center); + instance.setIcon(icon); } } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/AudioSettingsDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/AudioSettingsDialog.java index 5a1dd930..80f5bf4f 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/AudioSettingsDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/AudioSettingsDialog.java @@ -29,19 +29,17 @@ public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) { backButton = new MenuButton(app, node, view::leaveAudioSettings, "Zurück"); - float offset = 1.0f; + float offset = 2.8f; mainVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.75f; + offset += 1.0f; musicVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.75f; + offset += 1.0f; soundVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.75f * 1.3f; - backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.75f; + backButton.setPos(new Vector2f(0, 1.8f)); } @Override diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java index d21296d0..97c47e10 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/CeremonyDialog.java @@ -45,19 +45,19 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5 ArrayList 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())); + row.add(new LabelButton(app, node, name, sizeSmall, new Vector2f(), true)); + row.add(new LabelButton(app, node, "" + v1, sizeSmall, new Vector2f(), false)); + row.add(new LabelButton(app, node, "" + v2, sizeSmall, new Vector2f(), false)); + row.add(new LabelButton(app, node, "" + v3, sizeSmall, new Vector2f(), false)); + row.add(new LabelButton(app, node, "" + v4, sizeSmall, new Vector2f(), false)); + row.add(new LabelButton(app, node, "" + v5, sizeSmall, new Vector2f(), false)); + row.add(new LabelButton(app, node, "" + v6, sizeSmall, new Vector2f(), false)); ColorRGBA colorText = AbstractButton.TEXT_NORMAL.clone(); - colorText.a = 0.1f; + colorText.a = 0.2f; ColorRGBA colorButton = AbstractButton.BUTTON_NORMAL.clone(); - colorButton.a = 0.1f; + colorButton.a = 0.2f; int j = 0; for (LabelButton b : row) { @@ -83,13 +83,13 @@ public void prepare() { ArrayList 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())); + first.add(new LabelButton(app, node, "", size, new Vector2f(), true)); + first.add(new LabelButton(app, node, "Figuren geworfen", size, new Vector2f(), true)); + first.add(new LabelButton(app, node, "Figuren verloren", size, new Vector2f(), true)); + first.add(new LabelButton(app, node, "Gespielte Bonuskarten", size, new Vector2f(), true)); + first.add(new LabelButton(app, node, "Gewürfelte 6en", size, new Vector2f(), true)); + first.add(new LabelButton(app, node, "Gelaufene Felder", size, new Vector2f(), true)); + first.add(new LabelButton(app, node, "Bonusfeldern erreicht", size, new Vector2f(), true)); float offsetY = 0.5f; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/HostDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/HostDialog.java index 240a27a1..674d74f2 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/HostDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/HostDialog.java @@ -32,7 +32,7 @@ public HostDialog(MdgaApp app, Node node, MainView view) { hostButton = new ButtonRight(app, node, view::forward, "Spiel hosten", 10); backButton = new ButtonLeft(app, node, view::back, "Zurück", 10); - float offset = 3.0f; + float offset = 2.8f; portInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); offset += 1.5f; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java index 0cc6b74f..6e830e2a 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java @@ -36,7 +36,7 @@ public JoinDialog(MdgaApp app, Node node, MainView view) { joinButton = new ButtonRight(app, node, view::forward, "Spiel beitreten", 10); backButton = new ButtonLeft(app, node, view::back, "Zurück", 10); - float offset = 3.0f; + float offset = 2.8f; ipInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); offset += 1.5f; diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/SettingsDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/SettingsDialog.java index 99d34840..455abfb9 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/SettingsDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/SettingsDialog.java @@ -24,16 +24,14 @@ public SettingsDialog(MdgaApp app, Node node, MdgaView view) { audioButton = new MenuButton(app, node, view::enterAudioSettings, "Audio"); backButton = new MenuButton(app, node, view::leaveSettings, "Zurück"); - float offset = 2.0f; + float offset = 2.8f; videoButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); offset += 1.25f; audioButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.25f; - backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.25f; + backButton.setPos(new Vector2f(0, 1.8f)); } @Override diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/StartDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/StartDialog.java index cba9d6e2..5f70f4d6 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/StartDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/StartDialog.java @@ -34,10 +34,10 @@ public StartDialog(MdgaApp app, Node node, MainView view) { joinButton = new MenuButton(app, node, () -> view.forward(false), "Spiel beitreten"); endButton = new MenuButton(app, node, app::stop, "Spiel beenden"); - float offset = 2.0f; + float offset = 2.8f; nameInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.5f; + offset += 1.15f; hostButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); offset += 1.25f; @@ -45,8 +45,7 @@ public StartDialog(MdgaApp app, Node node, MainView view) { joinButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); offset += 1.25f; - endButton.setPos(new Vector2f(0, MenuButton.VERTICAL -offset)); - offset += 1.25f; + endButton.setPos(new Vector2f(0, 1.8f)); } @Override diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/VideoSettingsDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/VideoSettingsDialog.java index d602b3e4..f1268243 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/VideoSettingsDialog.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/VideoSettingsDialog.java @@ -20,10 +20,9 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) { backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück"); - float offset = 2.0f; + float offset = 2.8f; - backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset)); - offset += 1.25f; + backButton.setPos(new Vector2f(0, 1.8f)); } @Override 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 index d4cde73d..31bda387 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,8 +1,13 @@ package pp.mdga.client.view; +import com.jme3.asset.TextureKey; import com.jme3.light.AmbientLight; +import com.jme3.material.Material; +import com.jme3.material.RenderState; import com.jme3.math.ColorRGBA; import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Quad; +import com.jme3.texture.Texture; import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaState; import pp.mdga.client.acoustic.MdgaSound; @@ -23,6 +28,7 @@ private enum SubState { private SubState state; private Geometry background; + private Geometry podest; private ButtonLeft backButton; private ButtonRight continueButton; @@ -48,11 +54,48 @@ public CeremonyView(MdgaApp app) { @Override public void onEnter() { - enterSub(SubState.AWARD_CEREMONY); - rootNode.addLight(ambient); app.getAcousticHandler().playSound(MdgaSound.VICTORY); + + float screenWidth = app.getCamera().getWidth(); + float screenHeight = app.getCamera().getHeight(); + float aspectRatio = screenWidth / screenHeight; + + float scale = 3.5f; + + float distanceFromCamera = 5f; + float verticalSize = (float) (2 * Math.tan(Math.toRadians(app.getCamera().getFov() / 2)) * distanceFromCamera * scale); + float horizontalSize = verticalSize * aspectRatio; + + Quad backgroundQuad = new Quad(horizontalSize, verticalSize); + background = new Geometry("LobbyBackground", backgroundQuad); + + TextureKey backgroundKey = new TextureKey("Images/lobby.png", true); + Texture backgroundTexture = app.getAssetManager().loadTexture(backgroundKey); + Material backgroundMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + backgroundMaterial.setTexture("ColorMap", backgroundTexture); + background.setMaterial(backgroundMaterial); + background.setLocalTranslation(-horizontalSize / 2, -verticalSize / 2, -distanceFromCamera); + rootNode.attachChild(background); + + verticalSize *= 0.99f; + + Quad overlayQuad = new Quad(horizontalSize, verticalSize * 0.8f); + podest = new Geometry("TransparentOverlay", overlayQuad); + + TextureKey overlayKey = new TextureKey("Images/Ceremony.png", true); + Texture overlayTexture = app.getAssetManager().loadTexture(overlayKey); + Material overlayMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + overlayMaterial.setTexture("ColorMap", overlayTexture); + + overlayMaterial.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); + podest.setMaterial(overlayMaterial); + + float overlayDistance = distanceFromCamera - 0.1f; + podest.setLocalTranslation(-horizontalSize / 2, -verticalSize * 0.415f, -overlayDistance); + + enterSub(SubState.AWARD_CEREMONY); } @Override @@ -69,14 +112,20 @@ public void onLeave() { rootNode.removeLight(ambient); ceremonyDialog.prepare(); + + rootNode.detachChild(background); } @Override protected void onEnterOverlay(Overlay overlay) { + if(rootNode.hasChild(podest)) { + rootNode.detachChild(podest); + } } @Override protected void onLeaveOverlay(Overlay overlay) { + enterSub(state); } @Override @@ -89,6 +138,8 @@ protected void onUpdate(float tpf) { private void awardCeremony() { continueButton.show(); + rootNode.attachChild(podest); + for (CeremonyButton c : ceremonyButtons) { c.show(); } @@ -106,6 +157,10 @@ private void statistics() { private void enterSub(SubState state) { this.state = state; + if(rootNode.hasChild(podest)) { + rootNode.detachChild(podest); + } + backButton.hide(); continueButton.hide(); for (CeremonyButton c : ceremonyButtons) { @@ -113,10 +168,6 @@ private void enterSub(SubState state) { } ceremonyDialog.hide(); - if(null != background) { - guiNode.detachChild(background); - } - switch (state) { case AWARD_CEREMONY: awardCeremony(); 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 index 32a87c19..8c4be754 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,18 +1,6 @@ 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; @@ -20,14 +8,9 @@ import pp.mdga.client.MdgaApp; 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; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - public class GameView extends MdgaView { private BoardHandler boardHandler; private CameraHandler camera; @@ -45,8 +28,8 @@ public class GameView extends MdgaView { public GameView(MdgaApp app) { super(app); - cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSynchronize().enter(MdgaState.CEREMONY), "CHEAT", 1); - leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1); + cheatButton = new ButtonRight(app, overlayNode, () -> app.getModelSynchronize().enter(MdgaState.CEREMONY), "CHEAT", 1); + leaveButton = new ButtonLeft(app, overlayNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1); confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1); @@ -74,6 +57,8 @@ public void onLeave() { boardHandler.shutdown(); guiHandler.shutdown(); + confirmButton.hide(); + app.getViewPort().removeProcessor(fpp); } 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 index baa2dc2d..6262e93f 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 @@ -2,11 +2,13 @@ import com.jme3.asset.TextureKey; import com.jme3.light.AmbientLight; +import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; +import com.jme3.scene.shape.Quad; import com.jme3.texture.Texture; import com.jme3.util.SkyFactory; import pp.mdga.client.MdgaApp; @@ -30,14 +32,13 @@ public class LobbyView extends MdgaView { private AmbientLight ambient = new AmbientLight(); + private boolean isReady = false; + + private Color own = null; + public LobbyView(MdgaApp app) { super(app); - //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); - leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1); readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 1); @@ -65,6 +66,28 @@ public void onEnter() { navyButton.show(); rootNode.addLight(ambient); + + float screenWidth = app.getCamera().getWidth(); + float screenHeight = app.getCamera().getHeight(); + + float aspectRatio = screenWidth / screenHeight; + float scale = 3.5f; + + float quadWidth = scale * aspectRatio; + float quadHeight = scale; + + Quad quad = new Quad(quadWidth, quadHeight); + background = new Geometry("LobbyBackground", quad); + + TextureKey key = new TextureKey("Images/lobby.png", true); + Texture texture = app.getAssetManager().loadTexture(key); + Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + material.setTexture("ColorMap", texture); + background.setMaterial(material); + + background.setLocalTranslation(-quadWidth / 2, -quadHeight / 2, -5); + + rootNode.attachChild(background); } @Override @@ -100,6 +123,8 @@ public void onLeave() { armyButton.setTaken(LobbyButton.Taken.NOT, null); navyButton.setTaken(LobbyButton.Taken.NOT, null); cyberButton.setTaken(LobbyButton.Taken.NOT, null); + + rootNode.detachChild(background); } @Override @@ -126,11 +151,16 @@ public void setTaken(Color color, boolean isTaken, boolean isSelf, String name) if(isTaken) { if(isSelf) { + own = color; taken = LobbyButton.Taken.SELF; } else { taken = LobbyButton.Taken.OTHER; } } else { + if(isSelf) { + own = null; + } + taken = LobbyButton.Taken.NOT; } @@ -160,6 +190,10 @@ public void setReady(Color color, boolean isReady) { button.setReady(isReady); + if (button.getTaken() == LobbyButton.Taken.SELF) { + this.isReady = isReady; + } + if(!isReady) { app.getAcousticHandler().playSound(MdgaSound.NOT_READY); } else { @@ -200,9 +234,17 @@ private void toggleTsk(Color color) { } } - private void ready() { - app.getModelSynchronize().setReady(); - app.getAcousticHandler().playSound(MdgaSound.SELF_READY); + public void ready() { + if(own == null) { + app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); + return; + } + + if(!isReady) { + app.getAcousticHandler().playSound(MdgaSound.SELF_READY); + } + + app.getModelSynchronize().setReady(!isReady); } private void leaveLobby() { 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 index 7b724bc9..be472b55 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 @@ -28,11 +28,12 @@ public MainView(MdgaApp app) { startDialog = new StartDialog(app, guiNode, this); joinDialog = new JoinDialog(app, guiNode, this); hostDialog = new HostDialog(app, guiNode, this); + + background = createBackground("Images/startmenu.png"); } @Override public void onEnter() { - background = createBackground("Images/main.png"); guiNode.attachChild(background); enterSub(SubState.MAIN); @@ -56,13 +57,14 @@ public void onUpdate(float tpf) { @Override protected void onEnterOverlay(Overlay overlay) { - + guiNode.detachChild(background); + overlayNode.attachChild(background); } @Override - protected void onLeaveOverlay(Overlay overlay) - { - + protected void onLeaveOverlay(Overlay overlay) { + overlayNode.detachChild(background); + guiNode.attachChild(background); } private void joinMenu() { 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 index b2546e3a..f146324f 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 @@ -2,7 +2,6 @@ import com.jme3.asset.TextureKey; import com.jme3.material.Material; -import com.jme3.math.Vector2f; import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.shape.Quad; @@ -23,7 +22,7 @@ public enum Overlay { protected MdgaApp app; protected Node rootNode = new Node(); protected Node guiNode = new Node(); - protected Node settingsNode = new Node(); + protected Node overlayNode = new Node(); private SettingsButton settingsButton; @@ -37,9 +36,9 @@ public MdgaView(MdgaApp app) { this.app = app; settingsButton = new SettingsButton(app, guiNode, this::enterSettings); - settingsDialog = new SettingsDialog(app, settingsNode, this); - videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this); - audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this); + settingsDialog = new SettingsDialog(app, overlayNode, this); + videoSettingsDialog = new VideoSettingsDialog(app, overlayNode, this); + audioSettingsDialog = new AudioSettingsDialog(app, overlayNode, this); } public void enter() { @@ -109,7 +108,8 @@ protected Geometry createBackground(String texturePath) { public void enterSettings() { enterOverlay(Overlay.SETTINGS); - app.getGuiNode().attachChild(settingsNode); + app.getGuiNode().attachChild(overlayNode); + settingsDialog.show(); settingsDepth++; @@ -118,7 +118,8 @@ public void enterSettings() { public void leaveSettings() { leaveOverlay(Overlay.SETTINGS); - app.getGuiNode().detachChild(settingsNode); + app.getGuiNode().detachChild(overlayNode); + settingsDialog.hide(); settingsDepth--; @@ -176,7 +177,7 @@ public void pressForward() { } if(this instanceof LobbyView lobbyView) { - app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); + lobbyView.ready(); } if(this instanceof GameView gameView) { diff --git a/Projekte/mdga/client/src/main/resources/Images/Ceremony.png b/Projekte/mdga/client/src/main/resources/Images/Ceremony.png new file mode 100644 index 00000000..c625fed3 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/Ceremony.png differ diff --git a/Projekte/mdga/client/src/main/resources/Images/General_Button_hover.png b/Projekte/mdga/client/src/main/resources/Images/General_Button_hover.png new file mode 100644 index 00000000..a4702a08 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/General_Button_hover.png differ diff --git a/Projekte/mdga/client/src/main/resources/Images/General_Button_hover.png~ b/Projekte/mdga/client/src/main/resources/Images/General_Button_hover.png~ new file mode 100644 index 00000000..a4702a08 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/General_Button_hover.png~ differ diff --git a/Projekte/mdga/client/src/main/resources/Images/General_Button_normal.png b/Projekte/mdga/client/src/main/resources/Images/General_Button_normal.png new file mode 100644 index 00000000..fff6842c Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/General_Button_normal.png differ diff --git a/Projekte/mdga/client/src/main/resources/Images/General_Button_normal.png~ b/Projekte/mdga/client/src/main/resources/Images/General_Button_normal.png~ new file mode 100644 index 00000000..fff6842c Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/General_Button_normal.png~ differ diff --git a/Projekte/mdga/client/src/main/resources/Images/Settings_Button_hover.png b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_hover.png new file mode 100644 index 00000000..1e1ef742 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_hover.png differ diff --git a/Projekte/mdga/client/src/main/resources/Images/Settings_Button_hover.png~ b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_hover.png~ new file mode 100644 index 00000000..1e1ef742 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_hover.png~ differ diff --git a/Projekte/mdga/client/src/main/resources/Images/Settings_Button_normal.png b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_normal.png new file mode 100644 index 00000000..347af454 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_normal.png differ diff --git a/Projekte/mdga/client/src/main/resources/Images/Settings_Button_normal.png~ b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_normal.png~ new file mode 100644 index 00000000..347af454 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/Settings_Button_normal.png~ differ diff --git a/Projekte/mdga/client/src/main/resources/Images/startmenu.png b/Projekte/mdga/client/src/main/resources/Images/startmenu.png new file mode 100644 index 00000000..e88c73f7 Binary files /dev/null and b/Projekte/mdga/client/src/main/resources/Images/startmenu.png differ diff --git a/Projekte/mdga/client/src/main/resources/Images/zahnrad.png b/Projekte/mdga/client/src/main/resources/Images/zahnrad.png deleted file mode 100644 index 094c278b..00000000 Binary files a/Projekte/mdga/client/src/main/resources/Images/zahnrad.png and /dev/null differ