Development #34
@@ -40,6 +40,8 @@ public class InputSynchronizer {
|
||||
private CardControl hoverCard;
|
||||
private PieceControl hoverPiece;
|
||||
|
||||
private boolean clickAllowed = true;
|
||||
|
||||
/**
|
||||
* Constructor initializes the InputSynchronizer with the application context.
|
||||
* Sets up input mappings and listeners for user interactions.
|
||||
@@ -94,6 +96,10 @@ public void onAction(String name, boolean isPressed, float tpf) {
|
||||
rightMousePressed = isPressed;
|
||||
}
|
||||
if(name.equals("Click") && isPressed) {
|
||||
if(!clickAllowed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (app.getView() instanceof GameView gameView) {
|
||||
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
|
||||
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
|
||||
@@ -313,4 +319,12 @@ public void setRotation(float rotationAngle){
|
||||
public int getScroll() {
|
||||
return scrollValue;
|
||||
}
|
||||
|
||||
public void setClickAllowed(boolean allowed) {
|
||||
clickAllowed = allowed;
|
||||
}
|
||||
|
||||
public boolean isClickAllowed() {
|
||||
return clickAllowed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,4 +145,8 @@ public void enter(MdgaState state) {
|
||||
public void setSwap(boolean swap){
|
||||
this.swap = swap;
|
||||
}
|
||||
|
||||
public void force() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,6 @@ public class NotificationSynchronizer {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public void addTestNotification(Notification n) {
|
||||
notifications.add(n);
|
||||
handleGame(n);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
Notification n = app.getGameLogic().getNotification();
|
||||
while (n != null) {
|
||||
@@ -131,7 +126,7 @@ private void handleGame(Notification notification) {
|
||||
boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
|
||||
guiHandler.hideText();
|
||||
} else if (notification instanceof InterruptNotification) {
|
||||
app.enter(MdgaState.LOBBY);
|
||||
gameView.enterInterrupt();
|
||||
} else if (notification instanceof MovePieceNotification n) {
|
||||
if(n.isMoveStart()) {
|
||||
//StartMove
|
||||
@@ -153,7 +148,7 @@ private void handleGame(Notification notification) {
|
||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||
guiHandler.addPlayer(n.getColor(),n.getName());
|
||||
} else if (notification instanceof ResumeNotification) {
|
||||
//TODO
|
||||
gameView.leaveInterrupt();
|
||||
} else if (notification instanceof RollDiceNotification n) {
|
||||
gameView.getGuiHandler().hideText();
|
||||
if(n.getColor() == gameView.getOwnColor()){
|
||||
|
||||
@@ -1,4 +1,43 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,16 @@
|
||||
package pp.mdga.client.view;
|
||||
|
||||
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.board.BoardHandler;
|
||||
import pp.mdga.client.board.CameraHandler;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.button.ButtonLeft;
|
||||
import pp.mdga.client.button.ButtonRight;
|
||||
import pp.mdga.client.dialog.InterruptDialog;
|
||||
import pp.mdga.client.gui.GuiHandler;
|
||||
import pp.mdga.game.BonusCard;
|
||||
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 {
|
||||
private BoardHandler boardHandler;
|
||||
@@ -37,26 +22,33 @@ public class GameView extends MdgaView {
|
||||
|
||||
private Color ownColor = null;
|
||||
|
||||
private InterruptDialog interruptDialog;
|
||||
|
||||
private FilterPostProcessor fpp;
|
||||
|
||||
private Node guiHandlerNode = new Node();
|
||||
|
||||
public GameView(MdgaApp 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);
|
||||
|
||||
interruptDialog = new InterruptDialog(app, guiNode);
|
||||
|
||||
fpp = new FilterPostProcessor(app.getAssetManager());
|
||||
this.camera = new CameraHandler(app, fpp);
|
||||
this.boardHandler = new BoardHandler(app, rootNode, fpp);
|
||||
|
||||
guiHandler = new GuiHandler(app, guiNode);
|
||||
guiHandler = new GuiHandler(app, guiHandlerNode);
|
||||
|
||||
guiNode.attachChild(guiHandlerNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnter() {
|
||||
// setOwnColor(Color.AIRFORCE);
|
||||
setOwnColor(Color.AIRFORCE);
|
||||
camera.init(ownColor);
|
||||
boardHandler.init();
|
||||
guiHandler.init(ownColor);
|
||||
@@ -64,14 +56,6 @@ public void onEnter() {
|
||||
app.getViewPort().addProcessor(fpp);
|
||||
|
||||
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
|
||||
@@ -132,4 +116,26 @@ public void needConfirm() {
|
||||
public void noConfirm() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
package pp.mdga.client.view;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
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.JoinDialog;
|
||||
import pp.mdga.client.dialog.StartDialog;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class MainView extends MdgaView {
|
||||
private enum SubState {
|
||||
HOST,
|
||||
@@ -67,12 +60,12 @@ public void onUpdate(float tpf) {
|
||||
@Override
|
||||
protected void onEnterOverlay(Overlay overlay) {
|
||||
guiNode.detachChild(background);
|
||||
overlayNode.attachChild(background);
|
||||
settingsNode.attachChild(background);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeaveOverlay(Overlay overlay) {
|
||||
overlayNode.detachChild(background);
|
||||
settingsNode.detachChild(background);
|
||||
guiNode.attachChild(background);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public enum Overlay {
|
||||
protected MdgaApp app;
|
||||
protected Node rootNode = new Node("View Root");
|
||||
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;
|
||||
|
||||
@@ -42,9 +42,9 @@ public MdgaView(MdgaApp app) {
|
||||
this.app = app;
|
||||
settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
|
||||
|
||||
settingsDialog = new SettingsDialog(app, overlayNode, this);
|
||||
videoSettingsDialog = new VideoSettingsDialog(app, overlayNode, this);
|
||||
audioSettingsDialog = new AudioSettingsDialog(app, overlayNode, this);
|
||||
settingsDialog = new SettingsDialog(app, settingsNode, this);
|
||||
videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this);
|
||||
audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this);
|
||||
}
|
||||
|
||||
public void enter() {
|
||||
@@ -124,7 +124,7 @@ protected Geometry createBackground(String texturePath) {
|
||||
public void enterSettings() {
|
||||
enterOverlay(Overlay.SETTINGS);
|
||||
|
||||
app.getGuiNode().attachChild(overlayNode);
|
||||
app.getGuiNode().attachChild(settingsNode);
|
||||
|
||||
settingsDialog.show();
|
||||
|
||||
@@ -134,7 +134,7 @@ public void enterSettings() {
|
||||
public void leaveSettings() {
|
||||
leaveOverlay(Overlay.SETTINGS);
|
||||
|
||||
app.getGuiNode().detachChild(overlayNode);
|
||||
app.getGuiNode().detachChild(settingsNode);
|
||||
|
||||
settingsDialog.hide();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user