Development #34

Merged
j23f0779 merged 19 commits from development into dev/model 2024-12-05 17:58:51 +01:00
19 changed files with 340 additions and 102 deletions
Showing only changes of commit 71fc08a05c - Show all commits

View File

@@ -40,6 +40,8 @@ public class InputSynchronizer {
private CardControl hoverCard; private CardControl hoverCard;
private PieceControl hoverPiece; private PieceControl hoverPiece;
private boolean clickAllowed = true;
/** /**
* Constructor initializes the InputSynchronizer with the application context. * Constructor initializes the InputSynchronizer with the application context.
* Sets up input mappings and listeners for user interactions. * Sets up input mappings and listeners for user interactions.
@@ -94,6 +96,10 @@ public void onAction(String name, boolean isPressed, float tpf) {
rightMousePressed = isPressed; rightMousePressed = isPressed;
} }
if(name.equals("Click") && isPressed) { if(name.equals("Click") && isPressed) {
if(!clickAllowed) {
return;
}
if (app.getView() instanceof GameView gameView) { if (app.getView() instanceof GameView gameView) {
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class); DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class); CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
@@ -313,4 +319,12 @@ public void setRotation(float rotationAngle){
public int getScroll() { public int getScroll() {
return scrollValue; return scrollValue;
} }
public void setClickAllowed(boolean allowed) {
clickAllowed = allowed;
}
public boolean isClickAllowed() {
return clickAllowed;
}
} }

View File

@@ -145,4 +145,8 @@ public void enter(MdgaState state) {
public void setSwap(boolean swap){ public void setSwap(boolean swap){
this.swap = swap; this.swap = swap;
} }
public void force() {
}
} }

View File

@@ -19,11 +19,6 @@ public class NotificationSynchronizer {
this.app = app; this.app = app;
} }
public void addTestNotification(Notification n) {
notifications.add(n);
handleGame(n);
}
public void update() { public void update() {
Notification n = app.getGameLogic().getNotification(); Notification n = app.getGameLogic().getNotification();
while (n != null) { while (n != null) {
@@ -131,7 +126,7 @@ private void handleGame(Notification notification) {
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex()); boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
guiHandler.hideText(); guiHandler.hideText();
} else if (notification instanceof InterruptNotification) { } else if (notification instanceof InterruptNotification) {
app.enter(MdgaState.LOBBY); gameView.enterInterrupt();
} else if (notification instanceof MovePieceNotification n) { } else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) { if(n.isMoveStart()) {
//StartMove //StartMove
@@ -153,7 +148,7 @@ private void handleGame(Notification notification) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList()); boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName()); guiHandler.addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) { } else if (notification instanceof ResumeNotification) {
//TODO gameView.leaveInterrupt();
} else if (notification instanceof RollDiceNotification n) { } else if (notification instanceof RollDiceNotification n) {
gameView.getGuiHandler().hideText(); gameView.getGuiHandler().hideText();
if(n.getColor() == gameView.getOwnColor()){ if(n.getColor() == gameView.getOwnColor()){

View File

@@ -1,4 +1,43 @@
package pp.mdga.client.dialog; package pp.mdga.client.dialog;
public class InterruptDialog { 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.ButtonRight;
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MdgaView;
public class InterruptDialog extends Dialog {
private ButtonRight forceButton;
private LabelButton label;
public InterruptDialog(MdgaApp app, Node node) {
super(app, node);
forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
label = new LabelButton(app, node, "Warte auf Spieler...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
float offset = 2.8f;
label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
}
@Override
protected void onShow() {
if(app.getGameLogic().isHost()) {
forceButton.show();
}
label.show();
}
@Override
protected void onHide() {
forceButton.hide();
label.hide();
}
} }

View File

@@ -1,31 +1,16 @@
package pp.mdga.client.view; package pp.mdga.client.view;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import pp.mdga.client.MdgaState; import com.jme3.scene.Node;
import pp.mdga.client.acoustic.MdgaSound; import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.board.BoardHandler; import pp.mdga.client.board.BoardHandler;
import pp.mdga.client.board.CameraHandler; import pp.mdga.client.board.CameraHandler;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.ButtonLeft; import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight; import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.dialog.InterruptDialog;
import pp.mdga.client.gui.GuiHandler; import pp.mdga.client.gui.GuiHandler;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.GameNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayerInGameNotification;
import pp.mdga.notification.RollDiceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.SelectableSwapNotification;
import pp.mdga.notification.ShieldActiveNotification;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class GameView extends MdgaView { public class GameView extends MdgaView {
private BoardHandler boardHandler; private BoardHandler boardHandler;
@@ -37,26 +22,33 @@ public class GameView extends MdgaView {
private Color ownColor = null; private Color ownColor = null;
private InterruptDialog interruptDialog;
private FilterPostProcessor fpp; private FilterPostProcessor fpp;
private Node guiHandlerNode = new Node();
public GameView(MdgaApp app) { public GameView(MdgaApp app) {
super(app); super(app);
leaveButton = new ButtonLeft(app, overlayNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1); leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1); confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
interruptDialog = new InterruptDialog(app, guiNode);
fpp = new FilterPostProcessor(app.getAssetManager()); fpp = new FilterPostProcessor(app.getAssetManager());
this.camera = new CameraHandler(app, fpp); this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, rootNode, fpp); this.boardHandler = new BoardHandler(app, rootNode, fpp);
guiHandler = new GuiHandler(app, guiNode); guiHandler = new GuiHandler(app, guiHandlerNode);
guiNode.attachChild(guiHandlerNode);
} }
@Override @Override
public void onEnter() { public void onEnter() {
// setOwnColor(Color.AIRFORCE); setOwnColor(Color.AIRFORCE);
camera.init(ownColor); camera.init(ownColor);
boardHandler.init(); boardHandler.init();
guiHandler.init(ownColor); guiHandler.init(ownColor);
@@ -64,14 +56,6 @@ public void onEnter() {
app.getViewPort().addProcessor(fpp); app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START); app.getAcousticHandler().playSound(MdgaSound.START);
// guiHandler.addPlayer(Color.AIRFORCE, "Cedric");
// guiHandler.addPlayer(Color.ARMY, "Ben");
// guiHandler.addPlayer(Color.CYBER, "Felix");
// guiHandler.addPlayer(Color.NAVY, "Daniel");
} }
@Override @Override
@@ -132,4 +116,26 @@ public void needConfirm() {
public void noConfirm() { public void noConfirm() {
confirmButton.hide(); confirmButton.hide();
} }
public void enterInterrupt() {
enterOverlay(Overlay.INTERRUPT);
guiNode.detachChild(guiHandlerNode);
app.getGuiNode().attachChild(guiNode);
app.getInputSynchronize().setClickAllowed(false);
interruptDialog.show();
}
public void leaveInterrupt() {
leaveOverlay(Overlay.INTERRUPT);
app.getGuiNode().detachChild(guiNode);
guiNode.attachChild(guiHandlerNode);
app.getInputSynchronize().setClickAllowed(true);
interruptDialog.hide();
}
} }

View File

@@ -1,19 +1,12 @@
package pp.mdga.client.view; package pp.mdga.client.view;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import pp.mdga.client.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.acoustic.MdgaSound; import pp.mdga.client.acoustic.MdgaSound;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.dialog.HostDialog; import pp.mdga.client.dialog.HostDialog;
import pp.mdga.client.dialog.JoinDialog; import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.dialog.StartDialog; import pp.mdga.client.dialog.StartDialog;
import java.net.Inet4Address;
import java.net.UnknownHostException;
public class MainView extends MdgaView { public class MainView extends MdgaView {
private enum SubState { private enum SubState {
HOST, HOST,
@@ -67,12 +60,12 @@ public void onUpdate(float tpf) {
@Override @Override
protected void onEnterOverlay(Overlay overlay) { protected void onEnterOverlay(Overlay overlay) {
guiNode.detachChild(background); guiNode.detachChild(background);
overlayNode.attachChild(background); settingsNode.attachChild(background);
} }
@Override @Override
protected void onLeaveOverlay(Overlay overlay) { protected void onLeaveOverlay(Overlay overlay) {
overlayNode.detachChild(background); settingsNode.detachChild(background);
guiNode.attachChild(background); guiNode.attachChild(background);
} }

View File

@@ -25,7 +25,7 @@ public enum Overlay {
protected MdgaApp app; protected MdgaApp app;
protected Node rootNode = new Node("View Root"); protected Node rootNode = new Node("View Root");
protected Node guiNode = new Node("View Root GUI"); protected Node guiNode = new Node("View Root GUI");
protected Node overlayNode = new Node("View Root Overlay"); protected Node settingsNode = new Node("View Root Overlay");
private SettingsButton settingsButton; private SettingsButton settingsButton;
@@ -42,9 +42,9 @@ public MdgaView(MdgaApp app) {
this.app = app; this.app = app;
settingsButton = new SettingsButton(app, guiNode, this::enterSettings); settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
settingsDialog = new SettingsDialog(app, overlayNode, this); settingsDialog = new SettingsDialog(app, settingsNode, this);
videoSettingsDialog = new VideoSettingsDialog(app, overlayNode, this); videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this);
audioSettingsDialog = new AudioSettingsDialog(app, overlayNode, this); audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this);
} }
public void enter() { public void enter() {
@@ -124,7 +124,7 @@ protected Geometry createBackground(String texturePath) {
public void enterSettings() { public void enterSettings() {
enterOverlay(Overlay.SETTINGS); enterOverlay(Overlay.SETTINGS);
app.getGuiNode().attachChild(overlayNode); app.getGuiNode().attachChild(settingsNode);
settingsDialog.show(); settingsDialog.show();
@@ -134,7 +134,7 @@ public void enterSettings() {
public void leaveSettings() { public void leaveSettings() {
leaveOverlay(Overlay.SETTINGS); leaveOverlay(Overlay.SETTINGS);
app.getGuiNode().detachChild(overlayNode); app.getGuiNode().detachChild(settingsNode);
settingsDialog.hide(); settingsDialog.hide();