merge development into test #26
@@ -1,17 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
|
|
||||||
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
|
|
||||||
<module name="Projekte.mdga.client.main" />
|
|
||||||
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
|
|
||||||
<extension name="coverage">
|
|
||||||
<pattern>
|
|
||||||
<option name="PATTERN" value="pp.mdga.client.board.Outline.*" />
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</pattern>
|
|
||||||
</extension>
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@@ -43,6 +43,7 @@ public class InputSynchronizer {
|
|||||||
|
|
||||||
private void setupInput() {
|
private void setupInput() {
|
||||||
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
||||||
|
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
|
||||||
|
|
||||||
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
||||||
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
|
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
|
||||||
@@ -54,7 +55,7 @@ private void setupInput() {
|
|||||||
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||||
|
|
||||||
|
|
||||||
inputManager.addListener(actionListener, "Settings", "RotateRightMouse", "Click", "Test");
|
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Test");
|
||||||
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
|
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +67,9 @@ public void onAction(String name, boolean isPressed, float tpf) {
|
|||||||
if (name.equals("Settings") && isPressed) {
|
if (name.equals("Settings") && isPressed) {
|
||||||
app.getView().pressEscape();
|
app.getView().pressEscape();
|
||||||
}
|
}
|
||||||
|
if (name.equals("Forward") && isPressed) {
|
||||||
|
app.getView().pressForward();
|
||||||
|
}
|
||||||
if (name.equals("RotateRightMouse")) {
|
if (name.equals("RotateRightMouse")) {
|
||||||
rightMousePressed = isPressed;
|
rightMousePressed = isPressed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,107 +6,63 @@
|
|||||||
import pp.mdga.client.animation.AnimationHandler;
|
import pp.mdga.client.animation.AnimationHandler;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import pp.mdga.client.view.*;
|
import pp.mdga.client.view.*;
|
||||||
import pp.mdga.game.Color;
|
|
||||||
import pp.mdga.notification.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class MdgaApp extends SimpleApplication {
|
public class MdgaApp extends SimpleApplication {
|
||||||
private AnimationHandler animationHandler;
|
private AnimationHandler animationHandler;
|
||||||
private AcousticHandler acousticHandler;
|
private AcousticHandler acousticHandler;
|
||||||
private NotificationSynchronizer notificationSynchronizer;
|
private NotificationSynchronizer notificationSynchronizer;
|
||||||
private InputSynchronizer inputSynchronizer;
|
private InputSynchronizer inputSynchronizer;
|
||||||
private ModelSynchronizer modelSynchronizer;
|
private ModelSyncronizer modelSyncronizer;
|
||||||
|
|
||||||
MdgaView view = null;
|
MdgaView view = null;
|
||||||
private MdgaState state = MdgaState.GAME;
|
private MdgaState state = null;
|
||||||
|
|
||||||
private static float resolutionFactor = 1.2f;
|
private static float imageScale = 1.5f;
|
||||||
|
|
||||||
|
private MdgaView mainView;
|
||||||
|
private MdgaView lobbyView;
|
||||||
|
private MdgaView gameView;
|
||||||
|
private MdgaView ceremonyView;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AppSettings settings = new AppSettings(true);
|
AppSettings settings = new AppSettings(true);
|
||||||
settings.setSamples(128);
|
settings.setSamples(128);
|
||||||
settings.setCenterWindow(true);
|
settings.setCenterWindow(true);
|
||||||
|
settings.setWidth(1920);
|
||||||
int width = (int)(1280 * resolutionFactor);
|
settings.setHeight(1080);
|
||||||
int height = (int)(720 * resolutionFactor);
|
|
||||||
|
|
||||||
settings.setWidth(width);
|
|
||||||
settings.setHeight(height);
|
|
||||||
|
|
||||||
settings.setVSync(false);
|
settings.setVSync(false);
|
||||||
|
|
||||||
MdgaApp app = new MdgaApp();
|
MdgaApp app = new MdgaApp();
|
||||||
app.setSettings(settings);
|
app.setSettings(settings);
|
||||||
app.setShowSettings(false);
|
app.setShowSettings(false);
|
||||||
app.setPauseOnLostFocus(false);
|
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
|
GuiGlobals.initialize(this);
|
||||||
|
|
||||||
|
inputManager.deleteMapping("SIMPLEAPP_Exit");
|
||||||
|
|
||||||
|
flyCam.setEnabled(false);
|
||||||
|
|
||||||
animationHandler = new AnimationHandler(this);
|
animationHandler = new AnimationHandler(this);
|
||||||
acousticHandler = new AcousticHandler(this);
|
acousticHandler = new AcousticHandler(this);
|
||||||
notificationSynchronizer = new NotificationSynchronizer(this);
|
notificationSynchronizer = new NotificationSynchronizer(this);
|
||||||
inputSynchronizer = new InputSynchronizer(this);
|
inputSynchronizer = new InputSynchronizer(this);
|
||||||
modelSynchronizer = new ModelSynchronizer(this);
|
modelSyncronizer = new ModelSyncronizer(this);
|
||||||
|
|
||||||
inputManager.deleteMapping("SIMPLEAPP_Exit");
|
mainView = new MainView(this);
|
||||||
flyCam.setEnabled(false);
|
lobbyView = new LobbyView(this);
|
||||||
GuiGlobals.initialize(this);
|
gameView = new GameView(this);
|
||||||
|
ceremonyView = new CeremonyView(this);
|
||||||
|
|
||||||
enter(state);
|
enter(MdgaState.MAIN);
|
||||||
|
|
||||||
List<UUID> test = new ArrayList<>();
|
|
||||||
UUID player0 = UUID.randomUUID();
|
|
||||||
test.add(player0);
|
|
||||||
UUID player1 = UUID.randomUUID();
|
|
||||||
test.add(player1);
|
|
||||||
test.add(UUID.randomUUID());
|
|
||||||
test.add(UUID.randomUUID());
|
|
||||||
|
|
||||||
List<UUID> test_1 = new ArrayList<>();
|
|
||||||
UUID player0_1 = UUID.randomUUID();
|
|
||||||
test_1.add(player0_1);
|
|
||||||
UUID player1_1 = UUID.randomUUID();
|
|
||||||
test_1.add(player1_1);
|
|
||||||
test_1.add(UUID.randomUUID());
|
|
||||||
test_1.add(UUID.randomUUID());
|
|
||||||
|
|
||||||
List<UUID> test_2 = new ArrayList<>();
|
|
||||||
test_2.add(UUID.randomUUID());
|
|
||||||
test_2.add(UUID.randomUUID());
|
|
||||||
test_2.add(UUID.randomUUID());
|
|
||||||
test_2.add(UUID.randomUUID());
|
|
||||||
|
|
||||||
List<UUID> test_3 = new ArrayList<>();
|
|
||||||
test_3.add(UUID.randomUUID());
|
|
||||||
test_3.add(UUID.randomUUID());
|
|
||||||
test_3.add(UUID.randomUUID());
|
|
||||||
test_3.add(UUID.randomUUID());
|
|
||||||
|
|
||||||
|
|
||||||
((GameView) view).setOwnColor(Color.NAVY);
|
|
||||||
// notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, test, "Player 1"));
|
|
||||||
// notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.NAVY, test_1, "Player 2"));
|
|
||||||
// notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.ARMY, test_2, "Player 3"));
|
|
||||||
// notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.CYBER, test_3, "Player 4"));
|
|
||||||
|
|
||||||
// notificationSynchronizer.addTestNotification(new MovePieceNotification(player0, 0, true));
|
|
||||||
// notificationSynchronizer.addTestNotification(new MovePieceNotification(player0_1, 20, true));
|
|
||||||
// notificationSynchronizer.addTestNotification(new MovePieceNotification(player0_1, 20, 21));
|
|
||||||
// notificationSynchronizer.addTestNotification(new MovePieceNotification(player1, 0, true));
|
|
||||||
// notificationSynchronizer.addTestNotification(new MovePieceNotification(player0, 0, 7));
|
|
||||||
// notificationSynchronizer.addTestNotification(new SelectableMoveNotification(new ArrayList<>(List.of(player0, player1)), new ArrayList<>(List.of(7,3)), new ArrayList<>(List.of(false, true))));
|
|
||||||
// notificationSynchronizer.addTestNotification(new SwapPieceNotification(player0, player0_1));
|
|
||||||
// notificationSynchronizer.addTestNotification(new SelectableSwapNotification(new ArrayList<>(List.of(player0, player1)), new ArrayList<>(List.of(player0_1))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleUpdate(float tpf) {
|
public void simpleUpdate(float tpf) {
|
||||||
view.update();
|
view.update(tpf);
|
||||||
acousticHandler.update();
|
acousticHandler.update();
|
||||||
notificationSynchronizer.update();
|
notificationSynchronizer.update();
|
||||||
}
|
}
|
||||||
@@ -120,16 +76,16 @@ public void enter(MdgaState state) {
|
|||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case MAIN:
|
case MAIN:
|
||||||
view = new MainView(this);
|
view = mainView;
|
||||||
break;
|
break;
|
||||||
case LOBBY:
|
case LOBBY:
|
||||||
view = new LobbyView(this);
|
view = lobbyView;
|
||||||
break;
|
break;
|
||||||
case GAME:
|
case GAME:
|
||||||
view = new GameView(this);
|
view = gameView;
|
||||||
break;
|
break;
|
||||||
case CEREMONY:
|
case CEREMONY:
|
||||||
view = new CeremonyView(this);
|
view = ceremonyView;
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
throw new RuntimeException("cant enter state NONE");
|
throw new RuntimeException("cant enter state NONE");
|
||||||
@@ -140,10 +96,6 @@ public void enter(MdgaState state) {
|
|||||||
view.enter();
|
view.enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afteGameCleanup() {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
public AnimationHandler getAnimationHandler() {
|
public AnimationHandler getAnimationHandler() {
|
||||||
return animationHandler;
|
return animationHandler;
|
||||||
}
|
}
|
||||||
@@ -154,17 +106,19 @@ public AcousticHandler getAcousticHandler() {
|
|||||||
|
|
||||||
public MdgaState getState() {return state; }
|
public MdgaState getState() {return state; }
|
||||||
|
|
||||||
public float getResolutionFactor() {
|
public float getImageScale() {
|
||||||
return resolutionFactor;
|
return imageScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MdgaView getView() {
|
public MdgaView getView() {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelSynchronizer getModelSyncronizer() {
|
public ModelSyncronizer getModelSyncronizer() {
|
||||||
return modelSynchronizer;
|
return modelSyncronizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; }
|
public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; }
|
||||||
|
|
||||||
|
public NotificationSynchronizer getNotificationSynchronizer() { return notificationSynchronizer; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +1,123 @@
|
|||||||
package pp.mdga.client;
|
package pp.mdga.client;
|
||||||
|
|
||||||
|
import pp.mdga.client.view.CeremonyView;
|
||||||
|
import pp.mdga.client.view.GameView;
|
||||||
import pp.mdga.client.view.LobbyView;
|
import pp.mdga.client.view.LobbyView;
|
||||||
|
import pp.mdga.game.BonusCard;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
import pp.mdga.notification.AcquireCardNotification;
|
||||||
|
import pp.mdga.notification.DrawCardNotification;
|
||||||
|
import pp.mdga.notification.TskSelectNotification;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class ModelSynchronizer {
|
public class ModelSynchronizer {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName());
|
||||||
private MdgaApp app;
|
private MdgaApp app;
|
||||||
|
|
||||||
ModelSynchronizer(MdgaApp app) {
|
ModelSynchronizer(MdgaApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectPiece() {
|
public void animationEnd() {
|
||||||
//TODO call from somewhere
|
|
||||||
System.out.println("selectPiece");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectCard() {
|
public void selectSwap(UUID a, UUID b) {
|
||||||
//TODO call from somewhere
|
// TODO call from somewhere
|
||||||
System.out.println("selectCard");
|
LOGGER.log(Level.INFO, "selectPiece");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectPiece(UUID piece) {
|
||||||
|
// TODO call from somewhere
|
||||||
|
LOGGER.log(Level.INFO, "selectPiece");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectCard(BonusCard card) {
|
||||||
|
// TODO call from somewhere
|
||||||
|
LOGGER.log(Level.INFO, "selectCard");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void confirm() {
|
||||||
|
LOGGER.log(Level.INFO, "confirm");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectTsk(Color color) {
|
public void selectTsk(Color color) {
|
||||||
//TODO call from somewhere
|
// TODO call from somewhere
|
||||||
System.out.println("selectTsk: " + color);
|
LOGGER.log(Level.INFO, "selectTsk: {0}", color);
|
||||||
LobbyView view = (LobbyView) app.getView();
|
LobbyView view = (LobbyView) app.getView();
|
||||||
view.setTaken(color, true, true, "OwnPlayerName");
|
view.setTaken(color, true, true, "OwnPlayerName");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unselectTsk() {
|
public void unselectTsk() {
|
||||||
//TODO call from somewhere
|
// TODO call from somewhere
|
||||||
System.out.println("unselectTsk");
|
LOGGER.log(Level.INFO, "unselectTsk");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rolledDice() {
|
public void rolledDice() {
|
||||||
//TODO call from somewhere
|
// TODO call from somewhere
|
||||||
System.out.println("rolledDice");
|
LOGGER.log(Level.INFO, "rolledDice");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
//TODO call from somewhere
|
// TODO call from somewhere
|
||||||
System.out.println("setName:" + name);
|
LOGGER.log(Level.INFO, "setName: {0}", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReady() {
|
public void setReady() {
|
||||||
//TODO call from somewhere
|
LOGGER.log(Level.INFO, "setReady");
|
||||||
System.out.println("setReady");
|
enter(MdgaState.GAME);
|
||||||
app.enter(MdgaState.GAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHost(int port) {
|
public void setHost(int port) {
|
||||||
//TODO call from somewhere
|
// TODO call from somewhere
|
||||||
System.out.println("setHost: " + port);
|
LOGGER.log(Level.INFO, "setHost: {0}", port);
|
||||||
app.enter(MdgaState.LOBBY);
|
enter(MdgaState.LOBBY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJoin(String ip, int port) {
|
public void setJoin(String ip, int port) {
|
||||||
//TODO call from somewhere
|
// TODO call from somewhere
|
||||||
System.out.println("setJoin");
|
LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port});
|
||||||
app.enter(MdgaState.LOBBY);
|
enter(MdgaState.LOBBY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave() {
|
public void leave() {
|
||||||
System.out.println("leave");
|
LOGGER.log(Level.INFO, "leave");
|
||||||
app.enter(MdgaState.MAIN);
|
enter(MdgaState.MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enter(MdgaState state) {
|
public void enter(MdgaState state) {
|
||||||
System.out.println("enter:" + state);
|
LOGGER.log(Level.INFO, "enter: {0}", state);
|
||||||
app.enter(state);
|
app.enter(state);
|
||||||
|
|
||||||
|
if (state == MdgaState.CEREMONY) {
|
||||||
|
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
||||||
|
ceremonyView.addCeremonyParticipant(Color.AIRFORCE, 1, "ugidffdg");
|
||||||
|
ceremonyView.addCeremonyParticipant(Color.ARMY, 2, "ugidffdg");
|
||||||
|
ceremonyView.addCeremonyParticipant(Color.NAVY, 3, "ugidffdg");
|
||||||
|
ceremonyView.addCeremonyParticipant(Color.CYBER, 4, "ugidffdg");
|
||||||
|
|
||||||
|
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
|
||||||
|
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
|
||||||
|
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
|
||||||
|
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
|
||||||
|
ceremonyView.addStatisticsRow("Gesamt", 1, 2, 3, 4, 5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == MdgaState.GAME) {
|
||||||
|
GameView gameView = (GameView) app.getView();
|
||||||
|
|
||||||
|
app.getNotificationSynchronizer().addTestNotification(new DrawCardNotification(Color.AIRFORCE, BonusCard.SHIELD));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == MdgaState.LOBBY) {
|
||||||
|
LobbyView lobbyView = (LobbyView) app.getView();
|
||||||
|
|
||||||
|
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.CYBER, "blablabupp", false));
|
||||||
|
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.ARMY, "Spieler 2", false));
|
||||||
|
lobbyView.setReady(Color.ARMY, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
import pp.mdga.client.board.BoardHandler;
|
import pp.mdga.client.board.BoardHandler;
|
||||||
import pp.mdga.client.gui.GuiHandler;
|
import pp.mdga.client.gui.GuiHandler;
|
||||||
|
import pp.mdga.client.view.CeremonyView;
|
||||||
import pp.mdga.client.view.GameView;
|
import pp.mdga.client.view.GameView;
|
||||||
import pp.mdga.client.view.LobbyView;
|
import pp.mdga.client.view.LobbyView;
|
||||||
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.notification.*;
|
import pp.mdga.notification.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -59,6 +61,8 @@ private void handleLobby(Notification notification) {
|
|||||||
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
||||||
} else if (notification instanceof TskUnselectNotification n) {
|
} else if (notification instanceof TskUnselectNotification n) {
|
||||||
lobbyView.setTaken(n.getColor(), false, false, null);
|
lobbyView.setTaken(n.getColor(), false, false, null);
|
||||||
|
//} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
|
||||||
|
// lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
|
||||||
} else if (notification instanceof GameNotification) {
|
} else if (notification instanceof GameNotification) {
|
||||||
app.enter(MdgaState.GAME);
|
app.enter(MdgaState.GAME);
|
||||||
} else {
|
} else {
|
||||||
@@ -75,8 +79,33 @@ private void handleGame(Notification notification) {
|
|||||||
guiHandler.addCard(n.getBonusCard());
|
guiHandler.addCard(n.getBonusCard());
|
||||||
} else if (notification instanceof ActivePlayerNotification n) {
|
} else if (notification instanceof ActivePlayerNotification n) {
|
||||||
guiHandler.setActivePlayer(n.getColor());
|
guiHandler.setActivePlayer(n.getColor());
|
||||||
} else if (notification instanceof CeremonyNotification) {
|
} else if (notification instanceof CeremonyNotification n) {
|
||||||
app.enter(MdgaState.CEREMONY);
|
app.enter(MdgaState.CEREMONY);
|
||||||
|
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
||||||
|
int size = n.getNames().size();
|
||||||
|
|
||||||
|
if (n.getPiecesThrown().size() != size ||
|
||||||
|
n.getPiecesLost().size() != size ||
|
||||||
|
n.getBonusCardsPlayed().size() != size ||
|
||||||
|
n.getSixes().size() != size ||
|
||||||
|
n.getNodesMoved().size() != size ||
|
||||||
|
n.getBonusNodes().size() != size) {
|
||||||
|
throw new IllegalArgumentException("All data lists in CeremonyNotification must have the same size.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
Color color = n.getColors().get(i);
|
||||||
|
String name = n.getNames().get(i);
|
||||||
|
int v1 = n.getPiecesThrown().get(i);
|
||||||
|
int v2 = n.getPiecesLost().get(i);
|
||||||
|
int v3 = n.getBonusCardsPlayed().get(i);
|
||||||
|
int v4 = n.getSixes().get(i);
|
||||||
|
int v5 = n.getNodesMoved().get(i);
|
||||||
|
int v6 = n.getBonusNodes().get(i);
|
||||||
|
|
||||||
|
ceremonyView.addCeremonyParticipant(color, i, name);
|
||||||
|
ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
|
||||||
|
}
|
||||||
} else if (notification instanceof DiceNowNotification) {
|
} else if (notification instanceof DiceNowNotification) {
|
||||||
guiHandler.showDice();
|
guiHandler.showDice();
|
||||||
} else if (notification instanceof DicingNotification n) {
|
} else if (notification instanceof DicingNotification n) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import pp.mdga.client.MdgaState;
|
import pp.mdga.client.MdgaState;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
public class AcousticHandler {
|
public class AcousticHandler {
|
||||||
private MdgaApp app;
|
private MdgaApp app;
|
||||||
@@ -23,14 +24,20 @@ public class AcousticHandler {
|
|||||||
private GameMusic scheduled = null; // Scheduled track to play next
|
private GameMusic scheduled = null; // Scheduled track to play next
|
||||||
private GameMusic old = null; // Old track being faded out
|
private GameMusic old = null; // Old track being faded out
|
||||||
|
|
||||||
private float mainVolume = 1.0f;
|
private float mainVolume = 0.0f;
|
||||||
private float musicVolume = 1.0f;
|
private float musicVolume = 1.0f;
|
||||||
private float soundVolume = 1.0f;
|
private float soundVolume = 1.0f;
|
||||||
|
|
||||||
private ArrayList<GameSound> sounds = new ArrayList<>();
|
private ArrayList<GameSound> sounds = new ArrayList<>();
|
||||||
|
|
||||||
|
private Preferences prefs = Preferences.userNodeForPackage(AcousticHandler.class);
|
||||||
|
|
||||||
public AcousticHandler(MdgaApp app) {
|
public AcousticHandler(MdgaApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
|
mainVolume = prefs.getFloat("mainVolume", 1.0f);
|
||||||
|
musicVolume = prefs.getFloat("musicVolume", 1.0f);
|
||||||
|
soundVolume = prefs.getFloat("soundVolume", 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +74,19 @@ public void playSound(MdgaSound sound) {
|
|||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.LOST, 1.0f, 0.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.LOST, 1.0f, 0.0f));
|
||||||
break;
|
break;
|
||||||
case VICTORY:
|
case VICTORY:
|
||||||
assets.add(new SoundAssetDelayVolume(SoundAsset.VICTORY, 1.0f, 2.0f));
|
assets.add(new SoundAssetDelayVolume(SoundAsset.VICTORY, 1.0f, 0.0f));
|
||||||
|
break;
|
||||||
|
case BUTTON_PRESSED:
|
||||||
|
assets.add(new SoundAssetDelayVolume(SoundAsset.BUTTON_PRESS, 0.7f, 0.0f));
|
||||||
|
break;
|
||||||
|
case WRONG_INPUT:
|
||||||
|
assets.add(new SoundAssetDelayVolume(SoundAsset.ERROR, 1.0f, 0.0f));
|
||||||
|
break;
|
||||||
|
case UI_CLICK:
|
||||||
|
assets.add(new SoundAssetDelayVolume(SoundAsset.UI_CLICK, 0.8f, 0.0f));
|
||||||
|
break;
|
||||||
|
case START:
|
||||||
|
assets.add(new SoundAssetDelayVolume(SoundAsset.START, 0.8f, 0.2f));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
@@ -362,6 +381,7 @@ public float getSoundVolume() {
|
|||||||
*/
|
*/
|
||||||
public void setMainVolume(float mainVolume) {
|
public void setMainVolume(float mainVolume) {
|
||||||
this.mainVolume = mainVolume;
|
this.mainVolume = mainVolume;
|
||||||
|
prefs.putFloat("mainVolume", mainVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -371,6 +391,7 @@ public void setMainVolume(float mainVolume) {
|
|||||||
*/
|
*/
|
||||||
public void setMusicVolume(float musicVolume) {
|
public void setMusicVolume(float musicVolume) {
|
||||||
this.musicVolume = musicVolume;
|
this.musicVolume = musicVolume;
|
||||||
|
prefs.putFloat("musicVolume", musicVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -380,6 +401,7 @@ public void setMusicVolume(float musicVolume) {
|
|||||||
*/
|
*/
|
||||||
public void setSoundVolume(float soundVolume) {
|
public void setSoundVolume(float soundVolume) {
|
||||||
this.soundVolume = soundVolume;
|
this.soundVolume = soundVolume;
|
||||||
|
prefs.putFloat("soundVolume", soundVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,5 +19,9 @@ public enum MdgaSound {
|
|||||||
DESELECT,
|
DESELECT,
|
||||||
HURRY,
|
HURRY,
|
||||||
VICTORY,
|
VICTORY,
|
||||||
LOST
|
LOST,
|
||||||
|
BUTTON_PRESSED,
|
||||||
|
WRONG_INPUT,
|
||||||
|
UI_CLICK,
|
||||||
|
START,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ enum SoundAsset {
|
|||||||
DESELECT(""),
|
DESELECT(""),
|
||||||
HURRY(""),
|
HURRY(""),
|
||||||
VICTORY("LevelUp2.wav"),
|
VICTORY("LevelUp2.wav"),
|
||||||
LOST("GameOver.wav");
|
LOST("GameOver.wav"),
|
||||||
|
BUTTON_PRESS("menu_button.ogg"),
|
||||||
|
ERROR("error_sound.ogg"),
|
||||||
|
UI_CLICK("uiclick.ogg"),
|
||||||
|
START("gamestart.ogg");
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
import com.jme3.light.DirectionalLight;
|
import com.jme3.light.DirectionalLight;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.shadow.DirectionalLightShadowFilter;
|
import com.jme3.shadow.DirectionalLightShadowFilter;
|
||||||
import com.jme3.shadow.EdgeFilteringMode;
|
import com.jme3.shadow.EdgeFilteringMode;
|
||||||
import com.jme3.util.SkyFactory;
|
import com.jme3.util.SkyFactory;
|
||||||
@@ -20,8 +22,21 @@ public class CameraHandler {
|
|||||||
|
|
||||||
private static final int SHADOWMAP_SIZE = 1024 * 8;
|
private static final int SHADOWMAP_SIZE = 1024 * 8;
|
||||||
|
|
||||||
public CameraHandler(MdgaApp app, FilterPostProcessor fpp){
|
private Vector3f defaultCameraPosition;
|
||||||
|
private Quaternion defaultCameraRotation;
|
||||||
|
|
||||||
|
FilterPostProcessor fpp;
|
||||||
|
DirectionalLightShadowFilter dlsf;
|
||||||
|
|
||||||
|
Spatial sky;
|
||||||
|
|
||||||
|
public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
this.fpp = fpp;
|
||||||
|
|
||||||
|
// Save the default camera state
|
||||||
|
this.defaultCameraPosition = app.getCamera().getLocation().clone();
|
||||||
|
this.defaultCameraRotation = app.getCamera().getRotation().clone();
|
||||||
|
|
||||||
sun = new DirectionalLight();
|
sun = new DirectionalLight();
|
||||||
sun.setColor(ColorRGBA.White);
|
sun.setColor(ColorRGBA.White);
|
||||||
@@ -30,24 +45,35 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp){
|
|||||||
ambient = new AmbientLight();
|
ambient = new AmbientLight();
|
||||||
ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
|
ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
|
||||||
|
|
||||||
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 4);
|
dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 4);
|
||||||
dlsf.setLight(sun);
|
dlsf.setLight(sun);
|
||||||
dlsf.setEnabled(true);
|
dlsf.setEnabled(true);
|
||||||
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
||||||
dlsf.setShadowIntensity(0.7f);
|
dlsf.setShadowIntensity(0.7f);
|
||||||
fpp.addFilter(dlsf);
|
fpp.addFilter(dlsf);
|
||||||
|
|
||||||
app.getRootNode().attachChild(SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f));
|
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
app.getRootNode().addLight(sun);
|
app.getRootNode().addLight(sun);
|
||||||
app.getRootNode().addLight(ambient);
|
app.getRootNode().addLight(ambient);
|
||||||
|
app.getRootNode().attachChild(sky);
|
||||||
|
fpp.addFilter(dlsf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
app.getRootNode().removeLight(sun);
|
app.getRootNode().removeLight(sun);
|
||||||
app.getRootNode().removeLight(ambient);
|
app.getRootNode().removeLight(ambient);
|
||||||
|
app.getRootNode().detachChild(sky);
|
||||||
|
|
||||||
|
// Reset the camera to its default state
|
||||||
|
app.getCamera().setLocation(defaultCameraPosition);
|
||||||
|
app.getCamera().setRotation(defaultCameraRotation);
|
||||||
|
|
||||||
|
fpp.removeFilter(dlsf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float scroll, float rotation) {
|
public void update(float scroll, float rotation) {
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
package pp.mdga.client.board.Outline;
|
package pp.mdga.client.board.Outline;
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.material.RenderState;
|
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.post.Filter;
|
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class SelectObjectOutliner {
|
public class SelectObjectOutliner {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.font.BitmapFont;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
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_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);
|
||||||
|
|
||||||
|
public static final float HORIZONTAL = 16;
|
||||||
|
public static final float VERTICAL = 9;
|
||||||
|
|
||||||
|
protected BitmapFont font;
|
||||||
|
|
||||||
|
protected final MdgaApp app;
|
||||||
|
protected final Node node;
|
||||||
|
|
||||||
|
protected Vector2f pos;
|
||||||
|
protected float fontSizeFactor = 1.0f;
|
||||||
|
|
||||||
|
protected float fontSize;
|
||||||
|
protected float horizontalStep;
|
||||||
|
protected float verticalStep;
|
||||||
|
protected float heightStep;
|
||||||
|
protected float widthStep;
|
||||||
|
|
||||||
|
protected boolean adjust = false;
|
||||||
|
|
||||||
|
public AbstractButton(MdgaApp app, Node node) {
|
||||||
|
this.app = app;
|
||||||
|
this.node = node;
|
||||||
|
|
||||||
|
font = app.getAssetManager().loadFont("Fonts/Gunplay.fnt");
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void show();
|
||||||
|
public abstract void hide();
|
||||||
|
|
||||||
|
public void setPos(Vector2f pos) {
|
||||||
|
this.pos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void calculateRelative() {
|
||||||
|
fontSize = fontSizeFactor * 15 * (float)app.getCamera().getWidth() / 720;
|
||||||
|
|
||||||
|
horizontalStep = (float)app.getCamera().getWidth() / HORIZONTAL;
|
||||||
|
verticalStep = (float)app.getCamera().getHeight() / VERTICAL;
|
||||||
|
heightStep = verticalStep / 2;
|
||||||
|
widthStep = horizontalStep / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
public class ButtonLeft extends ClickButton {
|
||||||
|
public ButtonLeft(MdgaApp app, Node node, Runnable action, String label, int narrowFactor) {
|
||||||
|
super(app, node, action, label, new Vector2f( 5, 2), new Vector2f(0.5f * narrowFactor, 1.8f));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
public class ButtonRight extends ClickButton {
|
||||||
|
public ButtonRight(MdgaApp app, Node node, Runnable action, String label, int narrowFactor) {
|
||||||
|
super(app, node, action, label, new Vector2f( 5, 2), new Vector2f(HORIZONTAL - 0.5f * narrowFactor, 1.8f));
|
||||||
|
|
||||||
|
adjust = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
|
import pp.mdga.client.Asset;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
|
public class CeremonyButton extends ClickButton {
|
||||||
|
public enum Pos {
|
||||||
|
FIRST,
|
||||||
|
SECOND,
|
||||||
|
THIRD,
|
||||||
|
LOST,
|
||||||
|
}
|
||||||
|
|
||||||
|
static final float WIDTH = 4.0f;
|
||||||
|
|
||||||
|
private final Node node3d;
|
||||||
|
|
||||||
|
private boolean rotate = false;
|
||||||
|
private Spatial model;
|
||||||
|
private float rot = 180;
|
||||||
|
|
||||||
|
private LobbyButton.Taken taken = LobbyButton.Taken.NOT;
|
||||||
|
|
||||||
|
private LabelButton label;
|
||||||
|
|
||||||
|
public CeremonyButton(MdgaApp app, Node node, Node node3d, Color tsk, Pos pos, String name) {
|
||||||
|
super(app, node, () -> {} , "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
|
||||||
|
|
||||||
|
this.node3d = node3d;
|
||||||
|
|
||||||
|
label = new LabelButton(app, node, name, new Vector2f( WIDTH, 1), new Vector2f(0, 0));
|
||||||
|
|
||||||
|
final float mid = HORIZONTAL / 2;
|
||||||
|
final float uiSpacing = 1.4f;
|
||||||
|
final float figSpacingX = 0.9f;
|
||||||
|
final float figSpacingY = 0.25f;
|
||||||
|
|
||||||
|
float uiX = mid;
|
||||||
|
float uiY = 6;
|
||||||
|
float figX = 0;
|
||||||
|
float figY = -0.32f;
|
||||||
|
|
||||||
|
Asset asset = switch (tsk) {
|
||||||
|
case CYBER -> {
|
||||||
|
instance.setText("CIR");
|
||||||
|
yield Asset.cir;
|
||||||
|
}
|
||||||
|
case AIRFORCE -> {
|
||||||
|
instance.setText("Luftwaffe");
|
||||||
|
yield Asset.lw;
|
||||||
|
}
|
||||||
|
case ARMY -> {
|
||||||
|
instance.setText("Heer");
|
||||||
|
yield Asset.heer;
|
||||||
|
}
|
||||||
|
case NAVY -> {
|
||||||
|
instance.setText("Marine");
|
||||||
|
yield Asset.marine;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (pos) {
|
||||||
|
case FIRST:
|
||||||
|
rotate = true;
|
||||||
|
uiX = 0;
|
||||||
|
uiY -= 0;
|
||||||
|
figX = 0;
|
||||||
|
figY -= 1 * figSpacingY;
|
||||||
|
break;
|
||||||
|
case SECOND:
|
||||||
|
adjust = true;
|
||||||
|
label.adjust = true;
|
||||||
|
uiX -= uiSpacing;
|
||||||
|
uiY -= 1;
|
||||||
|
figX -= figSpacingX;
|
||||||
|
figY -= 2 * figSpacingY;
|
||||||
|
figY -= 0.1f;
|
||||||
|
break;
|
||||||
|
case THIRD:
|
||||||
|
uiX += uiSpacing;
|
||||||
|
uiY -= 1.5f;
|
||||||
|
figX += figSpacingX;
|
||||||
|
figY -= 3 * figSpacingY;
|
||||||
|
figY -= 0.07f;
|
||||||
|
break;
|
||||||
|
case LOST:
|
||||||
|
adjust = true;
|
||||||
|
label.adjust = true;
|
||||||
|
uiX -= 1 * uiSpacing + 0.4f;
|
||||||
|
uiX -= WIDTH / 2;
|
||||||
|
uiY -= 2;
|
||||||
|
figX -= 2 * figSpacingX;
|
||||||
|
figY -= 4 * figSpacingY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPos(new Vector2f(uiX, uiY));
|
||||||
|
label.setPos(new Vector2f(uiX, uiY + 1));
|
||||||
|
|
||||||
|
createModel(asset, new Vector3f(figX, figY, 6));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHover() {
|
||||||
|
ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
|
||||||
|
buttonNormal.a = 0.01f;
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal);
|
||||||
|
instance.setBackground(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnHover() {
|
||||||
|
ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
|
||||||
|
buttonNormal.a = 0.01f;
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal);
|
||||||
|
instance.setBackground(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
release();
|
||||||
|
|
||||||
|
calculateRelative();
|
||||||
|
setRelative();
|
||||||
|
|
||||||
|
node.attachChild(instance);
|
||||||
|
node3d.attachChild(model);
|
||||||
|
|
||||||
|
label.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
node.detachChild(instance);
|
||||||
|
node3d.detachChild(model);
|
||||||
|
|
||||||
|
label.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(float tpf) {
|
||||||
|
if(rotate) {
|
||||||
|
rot += 140.0f * tpf;
|
||||||
|
rot %= 360;
|
||||||
|
} else {
|
||||||
|
rot = 180;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.setLocalRotation(new Quaternion().fromAngles((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createModel(Asset asset, Vector3f pos) {
|
||||||
|
String modelName = asset.getModelPath();
|
||||||
|
String texName = asset.getDiffPath();
|
||||||
|
|
||||||
|
model = app.getAssetManager().loadModel(modelName);
|
||||||
|
model.scale(asset.getSize() / 2);
|
||||||
|
model.rotate((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180));
|
||||||
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
|
model.setLocalTranslation(pos);
|
||||||
|
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
||||||
|
model.setMaterial(mat);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.simsilica.lemur.Button;
|
||||||
|
import com.simsilica.lemur.HAlignment;
|
||||||
|
import com.simsilica.lemur.VAlignment;
|
||||||
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
|
||||||
|
public abstract class ClickButton extends AbstractButton {
|
||||||
|
protected final Runnable action;
|
||||||
|
|
||||||
|
protected String label;
|
||||||
|
protected Vector2f size;
|
||||||
|
|
||||||
|
protected Button instance;
|
||||||
|
|
||||||
|
ClickButton(MdgaApp app, Node node, Runnable action, String label, Vector2f size, Vector2f pos) {
|
||||||
|
super(app, node);
|
||||||
|
|
||||||
|
this.action = action;
|
||||||
|
this.label = label;
|
||||||
|
this.pos = pos;
|
||||||
|
this.size = size;
|
||||||
|
|
||||||
|
instance = new Button(label);
|
||||||
|
|
||||||
|
instance.addClickCommands((button) -> { app.getAcousticHandler().playSound(MdgaSound.BUTTON_PRESSED); action.run(); });
|
||||||
|
instance.setTextHAlignment(HAlignment.Center);
|
||||||
|
instance.setTextVAlignment(VAlignment.Center);
|
||||||
|
|
||||||
|
instance.addCommands(Button.ButtonAction.HighlightOn, (button) -> click());
|
||||||
|
instance.addCommands(Button.ButtonAction.HighlightOff, (button) -> release());
|
||||||
|
|
||||||
|
instance.setFont(font);
|
||||||
|
instance.setFocusColor(TEXT_NORMAL);
|
||||||
|
|
||||||
|
calculateRelative();
|
||||||
|
setRelative();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
release();
|
||||||
|
|
||||||
|
calculateRelative();
|
||||||
|
setRelative();
|
||||||
|
|
||||||
|
node.attachChild(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
node.detachChild(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void onHover();
|
||||||
|
protected abstract void onUnHover();
|
||||||
|
|
||||||
|
protected void click() {
|
||||||
|
instance.setColor(TEXT_PRESSED);
|
||||||
|
instance.setHighlightColor(TEXT_PRESSED);
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_PRESSED);
|
||||||
|
instance.setBackground(background);
|
||||||
|
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.UI_CLICK);
|
||||||
|
|
||||||
|
onHover();
|
||||||
|
};
|
||||||
|
|
||||||
|
protected void release() {
|
||||||
|
instance.setColor(TEXT_NORMAL);
|
||||||
|
instance.setHighlightColor(TEXT_NORMAL);
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
|
||||||
|
instance.setBackground(background);
|
||||||
|
|
||||||
|
onUnHover();
|
||||||
|
};
|
||||||
|
|
||||||
|
protected void setRelative() {
|
||||||
|
instance.setFontSize(fontSize);
|
||||||
|
|
||||||
|
instance.setPreferredSize(new Vector3f(size.x * widthStep, size.y * heightStep, 0));
|
||||||
|
|
||||||
|
float xAdjust = 0.0f;
|
||||||
|
if(adjust) {
|
||||||
|
xAdjust = instance.getPreferredSize().x;
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.setLocalTranslation(pos.x * horizontalStep - xAdjust, pos.y * verticalStep, -1);
|
||||||
|
|
||||||
|
final float horizontalMid = ((float)app.getCamera().getWidth() / 2) - (instance.getPreferredSize().x / 2);
|
||||||
|
final float verticalMid = ((float)app.getCamera().getHeight() / 2) - instance.getPreferredSize().y / 2;
|
||||||
|
|
||||||
|
if(0 == pos.x) {
|
||||||
|
instance.setLocalTranslation(horizontalMid, instance.getLocalTranslation().y, instance.getLocalTranslation().z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 == pos.y) {
|
||||||
|
instance.setLocalTranslation(instance.getLocalTranslation().x, verticalMid, instance.getLocalTranslation().z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.simsilica.lemur.*;
|
||||||
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
public class InputButton extends AbstractButton {
|
||||||
|
private Label label;
|
||||||
|
private TextField field;
|
||||||
|
|
||||||
|
private Container container = new Container();
|
||||||
|
|
||||||
|
private final int maxLenght;
|
||||||
|
|
||||||
|
protected Vector2f size;
|
||||||
|
|
||||||
|
public InputButton(MdgaApp app, Node node, String label, int maxLenght) {
|
||||||
|
super(app, node);
|
||||||
|
|
||||||
|
this.label = new Label(label);
|
||||||
|
this.maxLenght = maxLenght;
|
||||||
|
|
||||||
|
this.label.setColor(TEXT_NORMAL);
|
||||||
|
|
||||||
|
field = new TextField("");
|
||||||
|
field.setColor(TEXT_NORMAL);
|
||||||
|
field.setTextHAlignment(HAlignment.Left);
|
||||||
|
field.setTextVAlignment(VAlignment.Center);
|
||||||
|
|
||||||
|
QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(BUTTON_NORMAL);
|
||||||
|
field.setBackground(grayBackground);
|
||||||
|
|
||||||
|
this.label.setFont(font);
|
||||||
|
field.setFont(font);
|
||||||
|
|
||||||
|
pos = new Vector2f( 0, 0);
|
||||||
|
size = new Vector2f(5.5f, 1);
|
||||||
|
|
||||||
|
container.addChild(this.label);
|
||||||
|
container.addChild(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
calculateRelative();
|
||||||
|
setRelative();
|
||||||
|
|
||||||
|
node.attachChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
node.detachChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
String text = field.getText();
|
||||||
|
int length = text.length();
|
||||||
|
|
||||||
|
if (length > maxLenght) {
|
||||||
|
field.setText(text.substring(0, maxLenght));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setRelative() {
|
||||||
|
this.label.setFontSize(fontSize);
|
||||||
|
field.setFontSize(fontSize);
|
||||||
|
|
||||||
|
field.setPreferredSize(new Vector3f(size.x * widthStep, size.y * heightStep, 0));
|
||||||
|
|
||||||
|
float xAdjust = 0.0f;
|
||||||
|
if(adjust) {
|
||||||
|
xAdjust = container.getPreferredSize().x;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.setLocalTranslation(pos.x * horizontalStep - xAdjust, pos.y * verticalStep, -1);
|
||||||
|
|
||||||
|
final float horizontalMid = ((float)app.getCamera().getWidth() / 2) - (container.getPreferredSize().x / 2);
|
||||||
|
final float verticalMid = ((float)app.getCamera().getHeight() / 2) - container.getPreferredSize().y / 2;
|
||||||
|
|
||||||
|
if(0 == pos.x) {
|
||||||
|
container.setLocalTranslation(horizontalMid, container.getLocalTranslation().y, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 == pos.y) {
|
||||||
|
container.setLocalTranslation(container.getLocalTranslation().x, verticalMid, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString() {
|
||||||
|
return field.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setString(String string) { field.setText(string); }
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
field.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
super(app, node, () -> {}, label, size, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
release();
|
||||||
|
|
||||||
|
calculateRelative();
|
||||||
|
setRelative();
|
||||||
|
|
||||||
|
instance.setFontSize(fontSize / 2);
|
||||||
|
|
||||||
|
node.attachChild(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
node.detachChild(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHover() {
|
||||||
|
instance.setColor(text);
|
||||||
|
instance.setHighlightColor(text);
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(button);
|
||||||
|
instance.setBackground(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnHover() {
|
||||||
|
instance.setColor(text);
|
||||||
|
instance.setHighlightColor(text);
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(button);
|
||||||
|
instance.setBackground(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
instance.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(ColorRGBA text, ColorRGBA button) {
|
||||||
|
this.text = text;
|
||||||
|
this.button = button;
|
||||||
|
|
||||||
|
hide();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.light.AmbientLight;
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
|
import pp.mdga.client.Asset;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
|
public class LobbyButton extends ClickButton {
|
||||||
|
public enum Taken {
|
||||||
|
NOT,
|
||||||
|
SELF,
|
||||||
|
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 float WIDTH = 4.0f;
|
||||||
|
|
||||||
|
private final Node node3d;
|
||||||
|
|
||||||
|
private boolean rotate = false;
|
||||||
|
private Spatial model;
|
||||||
|
private float rot = 180;
|
||||||
|
|
||||||
|
private Taken taken = Taken.NOT;
|
||||||
|
|
||||||
|
private LabelButton label;
|
||||||
|
|
||||||
|
private boolean isReady = false;
|
||||||
|
|
||||||
|
public LobbyButton(MdgaApp app, Node node, Node node3d, Runnable action, Color tsk) {
|
||||||
|
super(app, node, action, "", new Vector2f(WIDTH, 7), new Vector2f(0, 0));
|
||||||
|
|
||||||
|
this.node3d = node3d;
|
||||||
|
|
||||||
|
label = new LabelButton(app, node, "- leer -", new Vector2f( WIDTH, 1), new Vector2f(0, 0));
|
||||||
|
|
||||||
|
final float mid = HORIZONTAL / 2;
|
||||||
|
final float uiSpacing = 0.4f;
|
||||||
|
final float figSpacing = 0.51f;
|
||||||
|
|
||||||
|
float uiX = mid;
|
||||||
|
float figX = 0;
|
||||||
|
Asset asset = null;
|
||||||
|
|
||||||
|
switch (tsk) {
|
||||||
|
case CYBER:
|
||||||
|
adjust = true;
|
||||||
|
label.adjust = true;
|
||||||
|
uiX -= 3 * uiSpacing;
|
||||||
|
uiX -= WIDTH / 2;
|
||||||
|
asset = Asset.cir;
|
||||||
|
figX -= 3 * figSpacing;
|
||||||
|
instance.setText("CIR");
|
||||||
|
break;
|
||||||
|
case AIRFORCE:
|
||||||
|
adjust = true;
|
||||||
|
label.adjust = true;
|
||||||
|
uiX -= uiSpacing;
|
||||||
|
asset = Asset.lw;
|
||||||
|
figX -= figSpacing;
|
||||||
|
instance.setText("Luftwaffe");
|
||||||
|
break;
|
||||||
|
case ARMY:
|
||||||
|
uiX += uiSpacing;
|
||||||
|
asset = Asset.heer;
|
||||||
|
figX += figSpacing;
|
||||||
|
instance.setText("Heer");
|
||||||
|
break;
|
||||||
|
case NAVY:
|
||||||
|
uiX += 3 * uiSpacing;
|
||||||
|
uiX += WIDTH / 2;
|
||||||
|
asset = Asset.marine;
|
||||||
|
figX += 3 * figSpacing;
|
||||||
|
instance.setText("Marine");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPos(new Vector2f(uiX, 6));
|
||||||
|
label.setPos(new Vector2f(uiX, 7));
|
||||||
|
|
||||||
|
createModel(asset, new Vector3f(figX, -0.55f, 6));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHover() {
|
||||||
|
ColorRGBA buttonPressed = BUTTON_PRESSED.clone();
|
||||||
|
|
||||||
|
switch (taken) {
|
||||||
|
case NOT:
|
||||||
|
buttonPressed.a = 0.3f;
|
||||||
|
break;
|
||||||
|
case SELF:
|
||||||
|
buttonPressed = LOBBY_SELF_HOVER;
|
||||||
|
break;
|
||||||
|
case OTHER:
|
||||||
|
buttonPressed = LOBBY_TAKEN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isReady) {
|
||||||
|
buttonPressed = LOBBY_READY_HOVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(buttonPressed);
|
||||||
|
instance.setBackground(background);
|
||||||
|
|
||||||
|
rotate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnHover() {
|
||||||
|
ColorRGBA buttonNormal = ColorRGBA.Gray.clone();// BUTTON_NORMAL.clone();
|
||||||
|
|
||||||
|
switch (taken) {
|
||||||
|
case NOT:
|
||||||
|
buttonNormal.a = 0.1f;
|
||||||
|
break;
|
||||||
|
case SELF:
|
||||||
|
buttonNormal = LOBBY_SELF_NORMAL;
|
||||||
|
break;
|
||||||
|
case OTHER:
|
||||||
|
buttonNormal = LOBBY_TAKEN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isReady) {
|
||||||
|
buttonNormal = LOBBY_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(buttonNormal);
|
||||||
|
instance.setBackground(background);
|
||||||
|
|
||||||
|
rotate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
release();
|
||||||
|
|
||||||
|
calculateRelative();
|
||||||
|
setRelative();
|
||||||
|
|
||||||
|
node.attachChild(instance);
|
||||||
|
node3d.attachChild(model);
|
||||||
|
|
||||||
|
label.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
node.detachChild(instance);
|
||||||
|
node3d.detachChild(model);
|
||||||
|
|
||||||
|
label.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(float tpf) {
|
||||||
|
if(rotate) {
|
||||||
|
rot += 140.0f * tpf;
|
||||||
|
rot %= 360;
|
||||||
|
} else {
|
||||||
|
rot = 180;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.setLocalRotation(new Quaternion().fromAngles((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createModel(Asset asset, Vector3f pos) {
|
||||||
|
String modelName = asset.getModelPath();
|
||||||
|
String texName = asset.getDiffPath();
|
||||||
|
|
||||||
|
model = app.getAssetManager().loadModel(modelName);
|
||||||
|
model.scale(asset.getSize() / 2);
|
||||||
|
model.rotate((float) Math.toRadians(90), (float) Math.toRadians(rot), (float) Math.toRadians(180));
|
||||||
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
|
model.setLocalTranslation(pos);
|
||||||
|
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
||||||
|
model.setMaterial(mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Taken getTaken() {
|
||||||
|
return taken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaken(Taken taken, String name) {
|
||||||
|
this.taken = taken;
|
||||||
|
|
||||||
|
if(taken == Taken.NOT) {
|
||||||
|
label.setText("- leer -");
|
||||||
|
isReady = false;
|
||||||
|
} else {
|
||||||
|
label.setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnHover();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReady(boolean isReady) {
|
||||||
|
this.isReady = isReady;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
public class MenuButton extends ClickButton {
|
||||||
|
public MenuButton(MdgaApp app, Node node, Runnable action, String label) {
|
||||||
|
super(app, node, action, label, new Vector2f( 5.5f, 2), new Vector2f(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.simsilica.lemur.HAlignment;
|
||||||
|
import com.simsilica.lemur.VAlignment;
|
||||||
|
import com.simsilica.lemur.component.IconComponent;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
public class SettingsButton extends ClickButton {
|
||||||
|
private IconComponent icon;
|
||||||
|
|
||||||
|
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 onHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnHover() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package pp.mdga.client.button;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.simsilica.lemur.*;
|
||||||
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
|
public class SliderButton extends AbstractButton {
|
||||||
|
private Label label;
|
||||||
|
|
||||||
|
private Slider slider;
|
||||||
|
|
||||||
|
private Container container = new Container();
|
||||||
|
|
||||||
|
protected Vector2f size;
|
||||||
|
|
||||||
|
public SliderButton(MdgaApp app, Node node, String label) {
|
||||||
|
super(app, node);
|
||||||
|
|
||||||
|
this.label = new Label(label);
|
||||||
|
|
||||||
|
this.label.setColor(TEXT_NORMAL);
|
||||||
|
|
||||||
|
slider = new Slider("slider");
|
||||||
|
|
||||||
|
slider.getDecrementButton().setText(" - ");
|
||||||
|
slider.getDecrementButton().setFont(font);
|
||||||
|
slider.getDecrementButton().setFocusColor(TEXT_NORMAL);
|
||||||
|
slider.getDecrementButton().setTextVAlignment(VAlignment.Bottom);
|
||||||
|
slider.getDecrementButton().setColor(TEXT_NORMAL);
|
||||||
|
slider.getDecrementButton().setHighlightColor(TEXT_NORMAL);
|
||||||
|
|
||||||
|
slider.getIncrementButton().setText(" + ");
|
||||||
|
slider.getIncrementButton().setFont(font);
|
||||||
|
slider.getIncrementButton().setFocusColor(TEXT_NORMAL);
|
||||||
|
slider.getIncrementButton().setTextVAlignment(VAlignment.Bottom);
|
||||||
|
slider.getIncrementButton().setColor(TEXT_NORMAL);
|
||||||
|
slider.getIncrementButton().setHighlightColor(TEXT_NORMAL);
|
||||||
|
|
||||||
|
slider.getThumbButton().setText("X");
|
||||||
|
slider.getThumbButton().setFont(font);
|
||||||
|
slider.getThumbButton().setFocusColor(TEXT_NORMAL);
|
||||||
|
slider.getThumbButton().setColor(TEXT_NORMAL);
|
||||||
|
slider.getThumbButton().setHighlightColor(TEXT_NORMAL);
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
|
||||||
|
slider.setBackground(background);
|
||||||
|
|
||||||
|
this.label.setFont(font);
|
||||||
|
|
||||||
|
pos = new Vector2f( 0, 0);
|
||||||
|
size = new Vector2f(5.5f, 1);
|
||||||
|
|
||||||
|
container.addChild(this.label);
|
||||||
|
|
||||||
|
container.addChild(slider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
calculateRelative();
|
||||||
|
setRelative();
|
||||||
|
|
||||||
|
node.attachChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
node.detachChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setRelative() {
|
||||||
|
this.label.setFontSize(fontSize);
|
||||||
|
|
||||||
|
slider.getDecrementButton().setFontSize(fontSize);
|
||||||
|
slider.getIncrementButton().setFontSize(fontSize);
|
||||||
|
slider.getThumbButton().setFontSize(fontSize);
|
||||||
|
|
||||||
|
slider.setPreferredSize(new Vector3f(size.x * widthStep, size.y * heightStep, 0));
|
||||||
|
|
||||||
|
float xAdjust = 0.0f;
|
||||||
|
if(adjust) {
|
||||||
|
xAdjust = container.getPreferredSize().x;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.setLocalTranslation(pos.x * horizontalStep - xAdjust, pos.y * verticalStep, -1);
|
||||||
|
|
||||||
|
final float horizontalMid = ((float)app.getCamera().getWidth() / 2) - (container.getPreferredSize().x / 2);
|
||||||
|
final float verticalMid = ((float)app.getCamera().getHeight() / 2) - container.getPreferredSize().y / 2;
|
||||||
|
|
||||||
|
if(0 == pos.x) {
|
||||||
|
container.setLocalTranslation(horizontalMid, container.getLocalTranslation().y, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 == pos.y) {
|
||||||
|
container.setLocalTranslation(container.getLocalTranslation().x, verticalMid, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPercent() {
|
||||||
|
return (float) slider.getModel().getPercent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPercent(float percent) {
|
||||||
|
slider.getModel().setPercent(percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
import pp.mdga.client.button.SliderButton;
|
||||||
|
import pp.mdga.client.view.MdgaView;
|
||||||
|
|
||||||
|
public class AudioSettingsDialog extends Dialog {
|
||||||
|
private final MdgaView view;
|
||||||
|
|
||||||
|
private SliderButton mainVolume;
|
||||||
|
private SliderButton musicVolume;
|
||||||
|
private SliderButton soundVolume;
|
||||||
|
|
||||||
|
private MenuButton backButton;
|
||||||
|
|
||||||
|
private boolean active = false;
|
||||||
|
|
||||||
|
public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||||
|
super(app, node);
|
||||||
|
|
||||||
|
this.view = view;
|
||||||
|
|
||||||
|
mainVolume = new SliderButton(app, node, "Gesamt Lautstärke");
|
||||||
|
musicVolume = new SliderButton(app, node, "Musik Lautstärke");
|
||||||
|
soundVolume = new SliderButton(app, node, "Effekt Lautstärke");
|
||||||
|
|
||||||
|
backButton = new MenuButton(app, node, view::leaveAudioSettings, "Zurück");
|
||||||
|
|
||||||
|
float offset = 1.0f;
|
||||||
|
|
||||||
|
mainVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.75f;
|
||||||
|
|
||||||
|
musicVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.75f;
|
||||||
|
|
||||||
|
soundVolume.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.75f * 1.3f;
|
||||||
|
|
||||||
|
backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.75f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onShow() {
|
||||||
|
active = true;
|
||||||
|
|
||||||
|
mainVolume.setPercent(app.getAcousticHandler().getMainVolume());
|
||||||
|
musicVolume.setPercent(app.getAcousticHandler().getMusicVolume());
|
||||||
|
soundVolume.setPercent(app.getAcousticHandler().getSoundVolume());
|
||||||
|
|
||||||
|
backButton.show();
|
||||||
|
|
||||||
|
mainVolume.show();
|
||||||
|
musicVolume.show();
|
||||||
|
soundVolume.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHide() {
|
||||||
|
active = false;
|
||||||
|
|
||||||
|
backButton.hide();
|
||||||
|
|
||||||
|
mainVolume.hide();
|
||||||
|
musicVolume.hide();
|
||||||
|
soundVolume.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if(!active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
app.getAcousticHandler().setMainVolume(mainVolume.getPercent());
|
||||||
|
app.getAcousticHandler().setMusicVolume(musicVolume.getPercent());
|
||||||
|
app.getAcousticHandler().setSoundVolume(soundVolume.getPercent());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
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.LabelButton;
|
||||||
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class CeremonyDialog extends Dialog {
|
||||||
|
private ArrayList<ArrayList<LabelButton>> labels;
|
||||||
|
|
||||||
|
float offsetX;
|
||||||
|
|
||||||
|
public CeremonyDialog(MdgaApp app, Node node) {
|
||||||
|
super(app, node);
|
||||||
|
|
||||||
|
prepare();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onShow() {
|
||||||
|
for (ArrayList<LabelButton> row : labels) {
|
||||||
|
for (LabelButton b : row) {
|
||||||
|
b.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHide() {
|
||||||
|
for (ArrayList<LabelButton> row : labels) {
|
||||||
|
for (LabelButton b : row) {
|
||||||
|
b.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
|
||||||
|
float offsetYSmall = 0.5f;
|
||||||
|
|
||||||
|
ArrayList<LabelButton> 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()));
|
||||||
|
|
||||||
|
ColorRGBA colorText = AbstractButton.TEXT_NORMAL.clone();
|
||||||
|
colorText.a = 0.1f;
|
||||||
|
|
||||||
|
ColorRGBA colorButton = AbstractButton.BUTTON_NORMAL.clone();
|
||||||
|
colorButton.a = 0.1f;
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
|
for (LabelButton b : row) {
|
||||||
|
if(j > 0) {
|
||||||
|
b.setColor(colorText, colorButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetYSmall));
|
||||||
|
offsetYSmall += 0.8f;
|
||||||
|
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
offsetX += 2.3f;
|
||||||
|
|
||||||
|
labels.add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void prepare() {
|
||||||
|
offsetX = 0.5f;
|
||||||
|
|
||||||
|
labels = new ArrayList<>();
|
||||||
|
|
||||||
|
ArrayList<LabelButton> 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()));
|
||||||
|
|
||||||
|
float offsetY = 0.5f;
|
||||||
|
|
||||||
|
for (LabelButton b : first) {
|
||||||
|
b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY));
|
||||||
|
offsetY += 0.8f;
|
||||||
|
}
|
||||||
|
|
||||||
|
offsetX += 2.3f;
|
||||||
|
|
||||||
|
labels.add(first);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,82 +1,32 @@
|
|||||||
package pp.mdga.client.dialog;
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.simsilica.lemur.Button;
|
|
||||||
import com.simsilica.lemur.Container;
|
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;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
import static com.jme3.math.FastMath.floor;
|
|
||||||
|
|
||||||
public abstract class Dialog {
|
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;
|
protected final MdgaApp app;
|
||||||
private final Node node;
|
protected final Node node = new Node();
|
||||||
|
|
||||||
protected final float vertical_step;
|
private final Node root;
|
||||||
protected final float horitontal_step;
|
|
||||||
|
|
||||||
protected float fontSize = 35;
|
Dialog(MdgaApp app, Node node) {
|
||||||
|
|
||||||
public Dialog(MdgaApp app, Node node) {
|
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.node = node;
|
this.root = node;
|
||||||
this.container = new Container();
|
|
||||||
|
|
||||||
this.horitontal_step = app.getCamera().getWidth() / 16;
|
|
||||||
this.vertical_step = app.getCamera().getHeight() / 9;
|
|
||||||
|
|
||||||
int val = (int) (32 * Math.min(app.getResolutionFactor() * 0.9f, 1));
|
|
||||||
fontSize = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
node.attachChild(container);
|
root.attachChild(node);
|
||||||
|
|
||||||
|
onShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide () {
|
public void hide() {
|
||||||
node.detachChild(container);
|
root.detachChild(node);
|
||||||
|
|
||||||
|
onHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createButton(String label, Runnable action, Vector3f size) {
|
protected abstract void onShow();
|
||||||
Button button = new Button(label);
|
protected abstract void onHide ();
|
||||||
button.addClickCommands(source -> action.run());
|
|
||||||
button.setFontSize(fontSize);
|
|
||||||
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 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
button.setBackground(background);
|
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
|
|
||||||
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
|
|
||||||
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
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 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(normalBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.addChild(button);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package pp.mdga.client.dialog;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class GetPercentRunnable {
|
|
||||||
private final Supplier<Float> action;
|
|
||||||
|
|
||||||
public GetPercentRunnable(Supplier<Float> action) {
|
|
||||||
this.action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float get() {
|
|
||||||
return action.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,143 +1,68 @@
|
|||||||
package pp.mdga.client.dialog;
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
import com.simsilica.lemur.*;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
|
import pp.mdga.client.button.ButtonRight;
|
||||||
|
import pp.mdga.client.button.InputButton;
|
||||||
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
import pp.mdga.client.view.MainView;
|
||||||
|
|
||||||
public class HostDialog extends Dialog {
|
import java.util.prefs.Preferences;
|
||||||
private TextField portInput;
|
|
||||||
|
|
||||||
public HostDialog(MdgaApp app, Node node, Runnable backAction) {
|
public class HostDialog extends Dialog {
|
||||||
|
private InputButton portInput;
|
||||||
|
|
||||||
|
private ButtonRight hostButton;
|
||||||
|
private ButtonLeft backButton;
|
||||||
|
|
||||||
|
private final MainView view;
|
||||||
|
|
||||||
|
private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
||||||
|
|
||||||
|
public HostDialog(MdgaApp app, Node node, MainView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
|
this.view = view;
|
||||||
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
|
|
||||||
container.setBackground(quad1);
|
|
||||||
|
|
||||||
Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
|
portInput = new InputButton(app, node, "Port: ", 5);
|
||||||
|
portInput.setString(prefs.get("hostPort", "11111"));
|
||||||
|
|
||||||
QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
|
hostButton = new ButtonRight(app, node, view::forward, "Spiel hosten", 10);
|
||||||
|
backButton = new ButtonLeft(app, node, view::back, "Zurück", 10);
|
||||||
|
|
||||||
Panel imagePanel = new Panel();
|
float offset = 3.0f;
|
||||||
imagePanel.setBackground(b);
|
|
||||||
|
|
||||||
container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4 * app.getResolutionFactor(), texture.getImage().getHeight() / 4 * app.getResolutionFactor(), 0));
|
portInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.5f;
|
||||||
//abstandshalter
|
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
|
||||||
|
|
||||||
createTextField();
|
|
||||||
|
|
||||||
//abstandshalter
|
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
|
||||||
|
|
||||||
Container sub = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
|
||||||
|
|
||||||
createButton(sub, "Abbrechen", backAction, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
|
|
||||||
sub.addChild(new Panel(40 * app.getResolutionFactor(), 0 * app.getResolutionFactor(), ColorRGBA.Gray));
|
|
||||||
|
|
||||||
createButton(sub, "Starten", () -> tryStart(), new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
|
|
||||||
container.addChild(sub);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tryStart() {
|
|
||||||
if (null == portInput.getText()) {
|
|
||||||
portInput.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int port = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
port = Integer.parseInt(portInput.getText());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
portInput.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(port >= 1 && port <= 65535) {
|
|
||||||
app.getModelSyncronizer().setHost(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
portInput.setText("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
protected void onShow() {
|
||||||
super.show();
|
portInput.show();
|
||||||
|
hostButton.show();
|
||||||
container.setLocalTranslation(
|
backButton.show();
|
||||||
app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
|
|
||||||
app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
protected void onHide() {
|
||||||
super.hide();
|
portInput.hide();
|
||||||
|
hostButton.hide();
|
||||||
|
backButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTextField() {
|
public void update() {
|
||||||
Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
portInput.update();
|
||||||
|
|
||||||
Label nameLabel = new Label("Port:\t");
|
|
||||||
nameLabel.setFontSize(fontSize);
|
|
||||||
nameLabel.setColor(ColorRGBA.Black);
|
|
||||||
|
|
||||||
portInput = new TextField("");
|
|
||||||
|
|
||||||
portInput.setColor(ColorRGBA.Black);
|
|
||||||
portInput.setTextHAlignment(HAlignment.Left);
|
|
||||||
portInput.setFontSize(fontSize);
|
|
||||||
portInput.setSingleLine(true);
|
|
||||||
|
|
||||||
QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
|
|
||||||
portInput.setBackground(grayBackground);
|
|
||||||
|
|
||||||
subContainer.addChild(nameLabel);
|
|
||||||
subContainer.addChild(portInput);
|
|
||||||
|
|
||||||
container.addChild(subContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createButton(Container c, String label, Runnable action, Vector3f size) {
|
public String getPort() {
|
||||||
Button button = new Button(label);
|
prefs.put("hostPort", portInput.getString());
|
||||||
button.addClickCommands(source -> action.run());
|
return portInput.getString();
|
||||||
button.setFontSize(fontSize);
|
}
|
||||||
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);
|
public void resetPort() {
|
||||||
background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
portInput.reset();
|
||||||
button.setBackground(background);
|
prefs.put("hostPort", "11111");
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
|
|
||||||
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
|
|
||||||
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
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 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(normalBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
});
|
|
||||||
|
|
||||||
c.addChild(button);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
|
public class InterruptDialog {
|
||||||
|
}
|
||||||
@@ -1,192 +1,88 @@
|
|||||||
package pp.mdga.client.dialog;
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
import com.simsilica.lemur.*;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.acoustic.AcousticHandler;
|
||||||
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
|
import pp.mdga.client.button.ButtonRight;
|
||||||
|
import pp.mdga.client.button.InputButton;
|
||||||
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
import pp.mdga.client.view.MainView;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
public class JoinDialog extends Dialog {
|
public class JoinDialog extends Dialog {
|
||||||
private TextField portInput;
|
private InputButton ipInput;
|
||||||
private TextField ipInput;
|
private InputButton portInput;
|
||||||
|
|
||||||
public JoinDialog(MdgaApp app, Node node, Runnable backAction) {
|
private ButtonRight joinButton;
|
||||||
|
private ButtonLeft backButton;
|
||||||
|
|
||||||
|
private final MainView view;
|
||||||
|
|
||||||
|
private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
|
||||||
|
|
||||||
|
public JoinDialog(MdgaApp app, Node node, MainView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
|
this.view = view;
|
||||||
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
|
|
||||||
container.setBackground(quad1);
|
|
||||||
|
|
||||||
Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
|
ipInput = new InputButton(app, node, "Ip: ", 15);
|
||||||
|
portInput = new InputButton(app, node, "Port: ", 5);
|
||||||
|
portInput.setString(prefs.get("joinPort", "11111"));
|
||||||
|
ipInput.setString(prefs.get("joinIp", ""));
|
||||||
|
|
||||||
QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
|
joinButton = new ButtonRight(app, node, view::forward, "Spiel beitreten", 10);
|
||||||
|
backButton = new ButtonLeft(app, node, view::back, "Zurück", 10);
|
||||||
|
|
||||||
Panel imagePanel = new Panel();
|
float offset = 3.0f;
|
||||||
imagePanel.setBackground(b);
|
|
||||||
|
|
||||||
container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4 * app.getResolutionFactor(), texture.getImage().getHeight() / 4 * app.getResolutionFactor(), 0));
|
ipInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.5f;
|
||||||
|
|
||||||
//abstandshalter
|
portInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
offset += 1.5f;
|
||||||
|
|
||||||
createIpField();
|
|
||||||
|
|
||||||
//abstandshalter
|
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
|
||||||
|
|
||||||
createPortField();
|
|
||||||
|
|
||||||
//abstandshalter
|
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
|
||||||
|
|
||||||
Container sub = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
|
||||||
|
|
||||||
createButton(sub, "Abbrechen", backAction, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
|
|
||||||
sub.addChild(new Panel(40 * app.getResolutionFactor(), 0 * app.getResolutionFactor(), ColorRGBA.Gray));
|
|
||||||
|
|
||||||
createButton(sub, "Beitreten", () -> tryJoin(), new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
|
|
||||||
container.addChild(sub);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tryJoin() {
|
|
||||||
if (null == portInput.getText()) {
|
|
||||||
portInput.setText("");
|
|
||||||
ipInput.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int port = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
port = Integer.parseInt(portInput.getText());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
portInput.setText("");
|
|
||||||
ipInput.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(port >= 1 && port <= 65535)) {
|
|
||||||
portInput.setText("");
|
|
||||||
ipInput.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null == ipInput.getText()) {
|
|
||||||
portInput.setText("");
|
|
||||||
ipInput.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String ipv4Pattern = "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
|
|
||||||
|
|
||||||
if(!Pattern.matches(ipv4Pattern, ipInput.getText())) {
|
|
||||||
portInput.setText("");
|
|
||||||
ipInput.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
app.getModelSyncronizer().setJoin(ipInput.getText(), port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
protected void onShow() {
|
||||||
super.show();
|
ipInput.show();
|
||||||
|
portInput.show();
|
||||||
container.setLocalTranslation(
|
joinButton.show();
|
||||||
app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
|
backButton.show();
|
||||||
app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
protected void onHide() {
|
||||||
super.hide();
|
ipInput.hide();
|
||||||
|
portInput.hide();
|
||||||
|
joinButton.hide();
|
||||||
|
backButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPortField() {
|
public void update() {
|
||||||
Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
ipInput.update();
|
||||||
|
portInput.update();
|
||||||
Label nameLabel = new Label("Port:\t");
|
|
||||||
nameLabel.setFontSize(fontSize);
|
|
||||||
nameLabel.setColor(ColorRGBA.Black);
|
|
||||||
|
|
||||||
portInput = new TextField("");
|
|
||||||
|
|
||||||
portInput.setColor(ColorRGBA.Black);
|
|
||||||
portInput.setTextHAlignment(HAlignment.Left);
|
|
||||||
portInput.setFontSize(fontSize);
|
|
||||||
portInput.setSingleLine(true);
|
|
||||||
|
|
||||||
QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
|
|
||||||
portInput.setBackground(grayBackground);
|
|
||||||
|
|
||||||
subContainer.addChild(nameLabel);
|
|
||||||
subContainer.addChild(portInput);
|
|
||||||
|
|
||||||
container.addChild(subContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createIpField() {
|
public String getIpt() {
|
||||||
Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
prefs.put("joinIp", ipInput.getString());
|
||||||
|
return ipInput.getString();
|
||||||
Label nameLabel = new Label("Ip:\t");
|
|
||||||
nameLabel.setFontSize(fontSize);
|
|
||||||
nameLabel.setColor(ColorRGBA.Black);
|
|
||||||
|
|
||||||
ipInput = new TextField("");
|
|
||||||
|
|
||||||
ipInput.setColor(ColorRGBA.Black);
|
|
||||||
ipInput.setTextHAlignment(HAlignment.Left);
|
|
||||||
ipInput.setFontSize(fontSize);
|
|
||||||
ipInput.setSingleLine(true);
|
|
||||||
|
|
||||||
QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
|
|
||||||
ipInput.setBackground(grayBackground);
|
|
||||||
|
|
||||||
subContainer.addChild(nameLabel);
|
|
||||||
subContainer.addChild(ipInput);
|
|
||||||
|
|
||||||
container.addChild(subContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createButton(Container c, String label, Runnable action, Vector3f size) {
|
public void resetIp() {
|
||||||
Button button = new Button(label);
|
ipInput.reset();
|
||||||
button.addClickCommands(source -> action.run());
|
prefs.put("joinIp", "");
|
||||||
button.setFontSize(fontSize);
|
}
|
||||||
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);
|
public String getPort() {
|
||||||
background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
prefs.put("joinPort", portInput.getString());
|
||||||
button.setBackground(background);
|
return portInput.getString();
|
||||||
|
}
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
|
public void resetPort() {
|
||||||
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
|
portInput.reset();
|
||||||
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
prefs.put("joinPort", "11111");
|
||||||
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 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(normalBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
});
|
|
||||||
|
|
||||||
c.addChild(button);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,165 +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.Command;
|
|
||||||
import com.simsilica.lemur.HAlignment;
|
|
||||||
import com.simsilica.lemur.VAlignment;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class LobbyButtonDialog extends Dialog {
|
|
||||||
private final int pos;
|
|
||||||
|
|
||||||
private Button button;
|
|
||||||
|
|
||||||
private Command<Button> clickCommand;
|
|
||||||
|
|
||||||
private boolean taken = false;
|
|
||||||
|
|
||||||
private final String label;
|
|
||||||
|
|
||||||
private int val;
|
|
||||||
|
|
||||||
public LobbyButtonDialog(MdgaApp app, Node node, String label, int pos) {
|
|
||||||
super(app, node);
|
|
||||||
|
|
||||||
clickCommand = (Button source) -> {
|
|
||||||
toggleButton();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.pos = pos;
|
|
||||||
|
|
||||||
this.label = label;
|
|
||||||
this.button = new Button(label);
|
|
||||||
this.button.setFontSize(fontSize);
|
|
||||||
|
|
||||||
val = pos;
|
|
||||||
|
|
||||||
createNotTakenButton(new Vector3f(170 * app.getResolutionFactor(), 250 * app.getResolutionFactor(), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
super.show();
|
|
||||||
|
|
||||||
float x = ((2 + (4 * pos)) * horitontal_step) - ((0.33333333f * pos) * container.getPreferredSize().x);
|
|
||||||
float y = 6 * vertical_step;
|
|
||||||
|
|
||||||
container.setLocalTranslation(x, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTaken(boolean isTaken, boolean self, String name) {
|
|
||||||
taken = isTaken;
|
|
||||||
|
|
||||||
if(isTaken) {
|
|
||||||
createTakenButton(new Vector3f(170 * app.getResolutionFactor(), 250 * app.getResolutionFactor(), 0), self);
|
|
||||||
|
|
||||||
button.setText(label + "\n\n" + name);
|
|
||||||
} else {
|
|
||||||
createNotTakenButton(new Vector3f(170 * app.getResolutionFactor(), 250 * app.getResolutionFactor(), 0));
|
|
||||||
|
|
||||||
button.setText(label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createNotTakenButton(Vector3f size) {
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
button.setPreferredSize(size);
|
|
||||||
button.setTextHAlignment(HAlignment.Center);
|
|
||||||
button.setTextVAlignment(VAlignment.Center);
|
|
||||||
|
|
||||||
if(button.getClickCommands() != null) {
|
|
||||||
button.removeClickCommands(clickCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
button.addClickCommands(clickCommand);
|
|
||||||
|
|
||||||
QuadBackgroundComponent background = new QuadBackgroundComponent(COLOR_DEFAULT);
|
|
||||||
background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
button.setBackground(background);
|
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
|
|
||||||
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
|
|
||||||
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
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 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(normalBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.addChild(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleButton() {
|
|
||||||
if(taken) {
|
|
||||||
app.getModelSyncronizer().unselectTsk();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
app.getModelSyncronizer().selectTsk(Color.values()[val]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createTakenButton(Vector3f size, boolean self) {
|
|
||||||
ColorRGBA color_a;
|
|
||||||
ColorRGBA color_b;
|
|
||||||
|
|
||||||
if(button.getClickCommands() != null) {
|
|
||||||
button.removeClickCommands(clickCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!self) {
|
|
||||||
color_a = ColorRGBA.Red;
|
|
||||||
color_b = ColorRGBA.Red;
|
|
||||||
} else {
|
|
||||||
color_a = ColorRGBA.Green;
|
|
||||||
color_b = ColorRGBA.Yellow;
|
|
||||||
|
|
||||||
button.addClickCommands(clickCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
button.setPreferredSize(size);
|
|
||||||
button.setTextHAlignment(HAlignment.Center);
|
|
||||||
button.setTextVAlignment(VAlignment.Center);
|
|
||||||
|
|
||||||
QuadBackgroundComponent background = new QuadBackgroundComponent(color_a);
|
|
||||||
background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
button.setBackground(background);
|
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
|
|
||||||
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(color_b);
|
|
||||||
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
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_a);
|
|
||||||
normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(normalBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.addChild(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package pp.mdga.client.dialog;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class PercentRunnable {
|
|
||||||
private final Consumer<Float> action;
|
|
||||||
|
|
||||||
public PercentRunnable(Consumer<Float> action) {
|
|
||||||
this.action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(float percent) {
|
|
||||||
action.accept(percent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package pp.mdga.client.dialog;
|
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
import com.simsilica.lemur.Button;
|
|
||||||
import com.simsilica.lemur.HAlignment;
|
|
||||||
import com.simsilica.lemur.Panel;
|
|
||||||
import com.simsilica.lemur.VAlignment;
|
|
||||||
import com.simsilica.lemur.component.IconComponent;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
|
|
||||||
public class SettingsButtonDialog extends Dialog {
|
|
||||||
private IconComponent icon;
|
|
||||||
|
|
||||||
public SettingsButtonDialog(MdgaApp app, Node node, String label, Runnable action) {
|
|
||||||
super(app, node);
|
|
||||||
|
|
||||||
icon = new IconComponent("Images/zahnrad.png");
|
|
||||||
icon.setIconScale(0.1f * app.getResolutionFactor());
|
|
||||||
|
|
||||||
createButton(label, action, new Vector3f(60 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
super.show();
|
|
||||||
|
|
||||||
float x = (15.5f * horitontal_step) - container.getPreferredSize().x;
|
|
||||||
float y = 8.5f * vertical_step;
|
|
||||||
|
|
||||||
container.setLocalTranslation(x, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createButton(String label, Runnable action, Vector3f size) {
|
|
||||||
Button button = new Button(label);
|
|
||||||
button.addClickCommands(source -> action.run());
|
|
||||||
button.setFontSize(fontSize);
|
|
||||||
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 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
button.setBackground(background);
|
|
||||||
button.setIcon(icon);
|
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
|
|
||||||
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(COLOR_HOVER);
|
|
||||||
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(hoverBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
button.setIcon(icon);
|
|
||||||
});
|
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
|
|
||||||
QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(COLOR_DEFAULT);
|
|
||||||
normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(normalBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
button.setIcon(icon);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.addChild(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,112 +1,52 @@
|
|||||||
package pp.mdga.client.dialog;
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
import com.simsilica.lemur.*;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
|
||||||
import com.simsilica.lemur.event.CursorListener;
|
|
||||||
import com.simsilica.lemur.event.CursorMotionEvent;
|
|
||||||
import com.simsilica.lemur.event.MouseEventControl;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import com.simsilica.lemur.*;
|
import pp.mdga.client.button.InputButton;
|
||||||
import com.simsilica.lemur.style.*;
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
import pp.mdga.client.view.MainView;
|
||||||
import java.util.HashMap;
|
import pp.mdga.client.view.MdgaView;
|
||||||
|
|
||||||
public class SettingsDialog extends Dialog {
|
public class SettingsDialog extends Dialog {
|
||||||
private TextField nameInput;
|
private MenuButton videoButton;
|
||||||
|
private MenuButton audioButton;
|
||||||
|
private MenuButton backButton;
|
||||||
|
|
||||||
private HashMap<Slider, PercentRunnable> map = new HashMap<Slider, PercentRunnable>();
|
private final MdgaView view;
|
||||||
private HashMap<Slider, GetPercentRunnable> map2 = new HashMap<Slider, GetPercentRunnable>();
|
|
||||||
|
|
||||||
public SettingsDialog(MdgaApp app, Node node, String path) {
|
public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
|
this.view = view;
|
||||||
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
|
|
||||||
container.setBackground(quad1);
|
|
||||||
|
|
||||||
Texture texture = app.getAssetManager().loadTexture(path);
|
videoButton = new MenuButton(app, node, view::enterVideoSettings, "Video");
|
||||||
|
audioButton = new MenuButton(app, node, view::enterAudioSettings, "Audio");
|
||||||
|
backButton = new MenuButton(app, node, view::leaveSettings, "Zurück");
|
||||||
|
|
||||||
QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
|
float offset = 2.0f;
|
||||||
|
|
||||||
Panel imagePanel = new Panel();
|
videoButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
imagePanel.setBackground(b);
|
offset += 1.25f;
|
||||||
|
|
||||||
container.addChild(imagePanel).setPreferredSize(new Vector3f((texture.getImage().getWidth() / 2) * app.getResolutionFactor(), (texture.getImage().getHeight() / 2) * app.getResolutionFactor(), 0));
|
audioButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.25f;
|
||||||
|
|
||||||
//abstandshalter
|
backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
container.addChild(new Panel(80 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
offset += 1.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
protected void onShow() {
|
||||||
super.show();
|
videoButton.show();
|
||||||
|
audioButton.show();
|
||||||
container.setLocalTranslation(
|
backButton.show();
|
||||||
app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
|
|
||||||
app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
protected void onHide() {
|
||||||
super.hide();
|
videoButton.hide();
|
||||||
}
|
audioButton.hide();
|
||||||
|
backButton.hide();
|
||||||
public void addButton(String label, Runnable action, Vector3f size) {
|
|
||||||
createButton(label, action, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSlider(String label, PercentRunnable action, GetPercentRunnable action2, Vector3f size, int start) {
|
|
||||||
Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
|
||||||
|
|
||||||
Slider slider = new Slider("slider");
|
|
||||||
|
|
||||||
QuadBackgroundComponent background = new QuadBackgroundComponent(ColorRGBA.DarkGray);
|
|
||||||
slider.setBackground(background);
|
|
||||||
|
|
||||||
slider.setPreferredSize(size);
|
|
||||||
slider.setModel(new DefaultRangedValueModel(0, 100, start));
|
|
||||||
slider.setPreferredSize(new Vector3f(150 * app.getResolutionFactor(), 30 * app.getResolutionFactor(), 0));
|
|
||||||
slider.getDecrementButton().setText(" - ");
|
|
||||||
slider.getIncrementButton().setText(" + ");
|
|
||||||
slider.getDecrementButton().setFontSize(25 * app.getResolutionFactor());
|
|
||||||
slider.getIncrementButton().setFontSize(25 * app.getResolutionFactor());
|
|
||||||
|
|
||||||
Label nameLabel = new Label(label);
|
|
||||||
nameLabel.setFontSize(fontSize);
|
|
||||||
nameLabel.setColor(ColorRGBA.Black);
|
|
||||||
nameLabel.setPreferredSize(new Vector3f(150 * app.getResolutionFactor(), 10 * app.getResolutionFactor(), 0));
|
|
||||||
|
|
||||||
subContainer.addChild(nameLabel);
|
|
||||||
subContainer.addChild(slider);
|
|
||||||
|
|
||||||
container.addChild(subContainer);
|
|
||||||
|
|
||||||
map.put(slider, action);
|
|
||||||
map2.put(slider, action2);
|
|
||||||
|
|
||||||
//abstandshalter
|
|
||||||
container.addChild(new Panel(20 * app.getResolutionFactor(), 10 * app.getResolutionFactor(), ColorRGBA.Gray));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initVolume() {
|
|
||||||
map2.forEach((slider, runnable) -> {
|
|
||||||
double val = (double) runnable.get();
|
|
||||||
slider.getModel().setPercent(val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
|
||||||
map.forEach((slider, runnable) -> {
|
|
||||||
float val = (float) slider.getModel().getPercent();
|
|
||||||
runnable.run(val);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package pp.mdga.client.dialog;
|
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
|
|
||||||
public class SingleButtonLeftDialog extends Dialog {
|
|
||||||
public SingleButtonLeftDialog(MdgaApp app, Node node, String label, Runnable action) {
|
|
||||||
super(app, node);
|
|
||||||
|
|
||||||
createButton(label, action, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
super.show();
|
|
||||||
|
|
||||||
float x = 2 * horitontal_step;
|
|
||||||
float y = 1.8f * vertical_step;
|
|
||||||
|
|
||||||
container.setLocalTranslation(x, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package pp.mdga.client.dialog;
|
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
|
|
||||||
public class SingleButtonRightDialog extends Dialog {
|
|
||||||
public SingleButtonRightDialog(MdgaApp app, Node node, String label, Runnable action) {
|
|
||||||
super(app, node);
|
|
||||||
|
|
||||||
createButton(label, action, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
super.show();
|
|
||||||
|
|
||||||
float x = (14 * horitontal_step) - container.getPreferredSize().x;
|
|
||||||
float y = 1.8f * vertical_step;
|
|
||||||
|
|
||||||
container.setLocalTranslation(x, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +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.HAlignment;
|
|
||||||
import com.simsilica.lemur.VAlignment;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
|
||||||
|
|
||||||
public class SingleButtonTopRight extends Dialog {
|
|
||||||
public SingleButtonTopRight(MdgaApp app, Node node, String label, Runnable action) {
|
|
||||||
super(app, node);
|
|
||||||
|
|
||||||
createButton(label, action, new Vector3f(170 * app.getResolutionFactor(), 60 * app.getResolutionFactor(), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
super.show();
|
|
||||||
|
|
||||||
float x = (14 * horitontal_step) - container.getPreferredSize().x;
|
|
||||||
float y = 8.5f * vertical_step;
|
|
||||||
|
|
||||||
container.setLocalTranslation(x, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createButton(String label, Runnable action, Vector3f size) {
|
|
||||||
Button button = new Button(label);
|
|
||||||
button.addClickCommands(source -> action.run());
|
|
||||||
button.setFontSize(fontSize);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
button.setPreferredSize(size);
|
|
||||||
button.setTextHAlignment(HAlignment.Center);
|
|
||||||
button.setTextVAlignment(VAlignment.Center);
|
|
||||||
|
|
||||||
QuadBackgroundComponent background = new QuadBackgroundComponent(ColorRGBA.Red);
|
|
||||||
background.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
button.setBackground(background);
|
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOn, (source) -> {
|
|
||||||
QuadBackgroundComponent hoverBackground = new QuadBackgroundComponent(ColorRGBA.Yellow);
|
|
||||||
hoverBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(hoverBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
});
|
|
||||||
|
|
||||||
button.addCommands(com.simsilica.lemur.Button.ButtonAction.HighlightOff, (source) -> {
|
|
||||||
QuadBackgroundComponent normalBackground = new QuadBackgroundComponent(ColorRGBA.Red);
|
|
||||||
normalBackground.setMargin(5 * app.getResolutionFactor(), 5 * app.getResolutionFactor());
|
|
||||||
source.setBackground(normalBackground);
|
|
||||||
button.setHighlightColor(ColorRGBA.White);
|
|
||||||
button.setColor(ColorRGBA.Black);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.addChild(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +1,189 @@
|
|||||||
package pp.mdga.client.dialog;
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.texture.Texture;
|
import com.simsilica.lemur.Container;
|
||||||
import com.simsilica.lemur.*;
|
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.button.InputButton;
|
||||||
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
import pp.mdga.client.view.MainView;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.random.RandomGenerator;
|
||||||
|
|
||||||
public class StartDialog extends Dialog {
|
public class StartDialog extends Dialog {
|
||||||
private TextField nameInput;
|
private InputButton nameInput;
|
||||||
|
|
||||||
public StartDialog(MdgaApp app, Node node) {
|
private MenuButton hostButton;
|
||||||
|
private MenuButton joinButton;
|
||||||
|
private MenuButton endButton;
|
||||||
|
|
||||||
|
private final MainView view;
|
||||||
|
|
||||||
|
public StartDialog(MdgaApp app, Node node, MainView view) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
|
this.view = view;
|
||||||
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
|
|
||||||
container.setBackground(quad1);
|
|
||||||
|
|
||||||
Texture texture = app.getAssetManager().loadTexture("Images/mdga_logo.png");
|
nameInput = new InputButton(app, node, "Name: ", 16);
|
||||||
|
|
||||||
QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
|
hostButton = new MenuButton(app, node, () -> view.forward(true), "Spiel hosten");
|
||||||
|
joinButton = new MenuButton(app, node, () -> view.forward(false), "Spiel beitreten");
|
||||||
|
endButton = new MenuButton(app, node, app::stop, "Spiel beenden");
|
||||||
|
|
||||||
Panel imagePanel = new Panel();
|
float offset = 2.0f;
|
||||||
imagePanel.setBackground(b);
|
|
||||||
|
|
||||||
container.addChild(imagePanel).setPreferredSize(new Vector3f(texture.getImage().getWidth() / 4, texture.getImage().getHeight() / 4, 0));
|
nameInput.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.5f;
|
||||||
|
|
||||||
//abstandshalter
|
hostButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
offset += 1.25f;
|
||||||
|
|
||||||
createTextField();
|
joinButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.25f;
|
||||||
|
|
||||||
//abstandshalter
|
endButton.setPos(new Vector2f(0, MenuButton.VERTICAL -offset));
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
offset += 1.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
protected void onShow() {
|
||||||
super.show();
|
nameInput.show();
|
||||||
|
|
||||||
container.setLocalTranslation(
|
hostButton.show();
|
||||||
app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
|
joinButton.show();
|
||||||
app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
|
endButton.show();
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
protected void onHide ()
|
||||||
super.hide();
|
{
|
||||||
|
nameInput.hide();
|
||||||
|
|
||||||
|
hostButton.hide();
|
||||||
|
joinButton.hide();
|
||||||
|
endButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addButton(String label, Runnable action, Vector3f size) {
|
public void update() {
|
||||||
createButton(label, action, size);
|
nameInput.update();
|
||||||
}
|
|
||||||
|
|
||||||
private void createTextField() {
|
|
||||||
Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
|
||||||
|
|
||||||
Label nameLabel = new Label("Name:\t");
|
|
||||||
nameLabel.setFontSize(fontSize);
|
|
||||||
nameLabel.setColor(ColorRGBA.Black);
|
|
||||||
|
|
||||||
nameInput = new TextField("");
|
|
||||||
|
|
||||||
nameInput.setColor(ColorRGBA.Black);
|
|
||||||
nameInput.setTextHAlignment(HAlignment.Left);
|
|
||||||
nameInput.setFontSize(fontSize);
|
|
||||||
nameInput.setSingleLine(true);
|
|
||||||
|
|
||||||
QuadBackgroundComponent grayBackground = new QuadBackgroundComponent(ColorRGBA.DarkGray);
|
|
||||||
nameInput.setBackground(grayBackground);
|
|
||||||
|
|
||||||
subContainer.addChild(nameLabel);
|
|
||||||
subContainer.addChild(nameInput);
|
|
||||||
|
|
||||||
container.addChild(subContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return nameInput.getText();
|
String name = nameInput.getString();
|
||||||
|
|
||||||
|
if (name == null || name.trim().isEmpty()) {
|
||||||
|
String[] names = {
|
||||||
|
"PixelPirat",
|
||||||
|
"NoobJäger",
|
||||||
|
"LagMeister",
|
||||||
|
"KnopfDrücker",
|
||||||
|
"SpawnCamper",
|
||||||
|
"AFKHeld",
|
||||||
|
"RageQuitter",
|
||||||
|
"GameOverPro",
|
||||||
|
"Checkpoint",
|
||||||
|
"RespawnHeld",
|
||||||
|
"Teebeutel",
|
||||||
|
"GlitchHexer",
|
||||||
|
"QuickScope",
|
||||||
|
"LootSammler",
|
||||||
|
"EpicLauch",
|
||||||
|
"KartoffelPro",
|
||||||
|
"StilleKlinge",
|
||||||
|
"TastenHeld",
|
||||||
|
"PixelKrieger",
|
||||||
|
"HacknSlash",
|
||||||
|
"JoystickJoe",
|
||||||
|
"SpawnFalle",
|
||||||
|
"OneHitWanda",
|
||||||
|
"CamperKing",
|
||||||
|
"GameGenie",
|
||||||
|
"HighPing",
|
||||||
|
"CheesePro",
|
||||||
|
"Speedy",
|
||||||
|
"GigaGamer",
|
||||||
|
"LevelNoob",
|
||||||
|
"SkillTobi",
|
||||||
|
"HeadshotMax",
|
||||||
|
"PentaPaul",
|
||||||
|
"CritKarl",
|
||||||
|
"ManaLeerer",
|
||||||
|
"Nachlader",
|
||||||
|
"ClutchKönig",
|
||||||
|
"FriendlyFe",
|
||||||
|
"ZonenHeld",
|
||||||
|
"SchleichKatze",
|
||||||
|
"ShotgunPro",
|
||||||
|
"SniperUdo",
|
||||||
|
"BossHunter",
|
||||||
|
"HeldenNoob",
|
||||||
|
"KillFranz",
|
||||||
|
"FragKarl",
|
||||||
|
"TeamNiete",
|
||||||
|
"LootPaul",
|
||||||
|
"UltraNoob",
|
||||||
|
"ProfiScout",
|
||||||
|
"PunkteKlaus",
|
||||||
|
"KrüppelKill",
|
||||||
|
"PixelNinja",
|
||||||
|
"NoobCrusher",
|
||||||
|
"LagBoss",
|
||||||
|
"SpawnKing",
|
||||||
|
"AFKSlayer",
|
||||||
|
"RespawnPro",
|
||||||
|
"Killjoy",
|
||||||
|
"GameBreaker",
|
||||||
|
"FastFingers",
|
||||||
|
"LootKing",
|
||||||
|
"QuickFlick",
|
||||||
|
"SilentShot",
|
||||||
|
"HackGod",
|
||||||
|
"GlitchHero",
|
||||||
|
"SpeedyBot",
|
||||||
|
"AimWizard",
|
||||||
|
"FragMaster",
|
||||||
|
"OneTapPro",
|
||||||
|
"KnifeLord",
|
||||||
|
"MetaHunter",
|
||||||
|
"PingWarrior",
|
||||||
|
"KeyBash",
|
||||||
|
"ClutchPro",
|
||||||
|
"ScopeBot",
|
||||||
|
"TrollMage",
|
||||||
|
"PowerLooter",
|
||||||
|
"TankHero",
|
||||||
|
"CampLord",
|
||||||
|
"SmurfSlayer",
|
||||||
|
"SkillThief",
|
||||||
|
"SniperGod",
|
||||||
|
"LevelHack",
|
||||||
|
"GhostAim",
|
||||||
|
"BossTamer",
|
||||||
|
"ShotgunJoe",
|
||||||
|
"AimRider",
|
||||||
|
"KillCount",
|
||||||
|
"PixelManiac",
|
||||||
|
"TrollOver",
|
||||||
|
"SneakPro",
|
||||||
|
"ReloadKing",
|
||||||
|
"SpawnTrap",
|
||||||
|
"LagLover",
|
||||||
|
"MetaHater",
|
||||||
|
"BoomMaker",
|
||||||
|
"WipeLord",
|
||||||
|
"CarryPro",
|
||||||
|
"ProBaiter",
|
||||||
|
"GameWarden",
|
||||||
|
};
|
||||||
|
|
||||||
|
Random random = new Random();
|
||||||
|
name = names[random.nextInt(names.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
import pp.mdga.client.view.MdgaView;
|
||||||
|
|
||||||
|
public class VideoSettingsDialog extends Dialog {
|
||||||
|
private MenuButton backButton;
|
||||||
|
|
||||||
|
private final MdgaView view;
|
||||||
|
|
||||||
|
private boolean active = false;
|
||||||
|
|
||||||
|
public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
||||||
|
super(app, node);
|
||||||
|
|
||||||
|
this.view = view;
|
||||||
|
|
||||||
|
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
|
||||||
|
|
||||||
|
float offset = 2.0f;
|
||||||
|
|
||||||
|
backButton.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
|
||||||
|
offset += 1.25f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onShow() {
|
||||||
|
active = true;
|
||||||
|
|
||||||
|
backButton.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHide() {
|
||||||
|
active = false;
|
||||||
|
|
||||||
|
backButton.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if(!active) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
import pp.mdga.client.Asset;
|
import pp.mdga.client.Asset;
|
||||||
import pp.mdga.message.server.Dice;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -168,4 +167,5 @@ public void create(Vector3f pos, float scale, boolean shadow){
|
|||||||
public void setPos(Vector3f pos){
|
public void setPos(Vector3f pos){
|
||||||
spatial.setLocalTranslation(pos);
|
spatial.setLocalTranslation(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,16 +34,27 @@ public class PlayerNameHandler {
|
|||||||
private static final ColorRGBA ACTIVE_COLOR = ColorRGBA.Blue;
|
private static final ColorRGBA ACTIVE_COLOR = ColorRGBA.Blue;
|
||||||
private static final ColorRGBA OWN_COLOR = ColorRGBA.Cyan;
|
private static final ColorRGBA OWN_COLOR = ColorRGBA.Cyan;
|
||||||
|
|
||||||
|
private final Node guiNode;
|
||||||
|
|
||||||
public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
|
public PlayerNameHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
|
||||||
|
this.guiNode = guiNode;
|
||||||
|
|
||||||
playerFont = assetManager.loadFont("Fonts/Gunplay.fnt");
|
playerFont = assetManager.loadFont("Fonts/Gunplay.fnt");
|
||||||
playerNameNode = new Node("player name node");
|
playerNameNode = new Node("player name node");
|
||||||
playerOrder = new ArrayList<>();
|
playerOrder = new ArrayList<>();
|
||||||
colorNameMap = new HashMap<>();
|
colorNameMap = new HashMap<>();
|
||||||
guiNode.attachChild(playerNameNode);
|
|
||||||
this.appSettings = appSettings;
|
this.appSettings = appSettings;
|
||||||
this.assetManager = assetManager;
|
this.assetManager = assetManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void show() {
|
||||||
|
guiNode.attachChild(playerNameNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hide() {
|
||||||
|
guiNode.detachChild(playerNameNode);
|
||||||
|
}
|
||||||
|
|
||||||
private void drawPlayers(){
|
private void drawPlayers(){
|
||||||
playerNameNode.detachAllChildren();
|
playerNameNode.detachAllChildren();
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,4 @@ private float easeInOut(float t) {
|
|||||||
private float easeIn(float t) {
|
private float easeIn(float t) {
|
||||||
return t * t * t * t;
|
return t * t * t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,235 @@
|
|||||||
|
package pp.mdga.client.server;
|
||||||
|
|
||||||
|
import com.jme3.network.*;
|
||||||
|
import com.jme3.network.serializing.Serializer;
|
||||||
|
import pp.mdga.game.Game;
|
||||||
|
import pp.mdga.game.Player;
|
||||||
|
import pp.mdga.message.client.*;
|
||||||
|
import pp.mdga.message.server.*;
|
||||||
|
import pp.mdga.server.ServerGameLogic;
|
||||||
|
import pp.mdga.server.ServerSender;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.System.Logger;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server implementing the visitor pattern as MessageReceiver for ClientMessages
|
||||||
|
*/
|
||||||
|
public class MdgaServer implements MessageListener<HostedConnection>, ConnectionListener, ServerSender {
|
||||||
|
private static final Logger LOGGER = System.getLogger(MdgaServer.class.getName());
|
||||||
|
|
||||||
|
private Server myServer;
|
||||||
|
private final ServerGameLogic logic;
|
||||||
|
private final BlockingQueue<ReceivedMessage> pendingMessages = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
// Configure logging
|
||||||
|
LogManager manager = LogManager.getLogManager();
|
||||||
|
try {
|
||||||
|
manager.readConfiguration(new FileInputStream("logging.properties"));
|
||||||
|
LOGGER.log(Level.INFO, "Successfully read logging properties"); //NON-NLS
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.log(Level.INFO, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the Battleships server.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new MdgaServer().run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new MdgaServer.
|
||||||
|
*/
|
||||||
|
public MdgaServer() {
|
||||||
|
LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
|
||||||
|
logic = new ServerGameLogic(this, new Game());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
startServer();
|
||||||
|
this.connectionAdded(myServer, myServer.getConnection(0));
|
||||||
|
while (true)
|
||||||
|
processNextMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startServer() {
|
||||||
|
try {
|
||||||
|
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
|
||||||
|
myServer = Network.createServer(1234);
|
||||||
|
|
||||||
|
initializeSerializables();
|
||||||
|
myServer.start();
|
||||||
|
registerListeners();
|
||||||
|
LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processNextMessage() {
|
||||||
|
try {
|
||||||
|
pendingMessages.take().process(logic);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
LOGGER.log(Level.INFO, "Interrupted while waiting for messages"); //NON-NLS
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeSerializables() {
|
||||||
|
Serializer.registerClass(AnimationEnd.class);
|
||||||
|
Serializer.registerClass(ClientStartGame.class);
|
||||||
|
Serializer.registerClass(DeselectTSK.class);
|
||||||
|
Serializer.registerClass(ForceContinueGame.class);
|
||||||
|
Serializer.registerClass(StartGame.class);
|
||||||
|
Serializer.registerClass(JoinServer.class);
|
||||||
|
Serializer.registerClass(LeaveGame.class);
|
||||||
|
Serializer.registerClass(LobbyNotReady.class);
|
||||||
|
Serializer.registerClass(LobbyReady.class);
|
||||||
|
Serializer.registerClass(NoPowerCard.class);
|
||||||
|
Serializer.registerClass(RequestBriefing.class);
|
||||||
|
Serializer.registerClass(RequestDie.class);
|
||||||
|
Serializer.registerClass(RequestMove.class);
|
||||||
|
Serializer.registerClass(RequestPlayCard.class);
|
||||||
|
Serializer.registerClass(SelectCard.class);
|
||||||
|
Serializer.registerClass(SelectedPieces.class);
|
||||||
|
Serializer.registerClass(SelectTSK.class);
|
||||||
|
|
||||||
|
Serializer.registerClass(ActivePlayer.class);
|
||||||
|
Serializer.registerClass(AnyPiece.class);
|
||||||
|
Serializer.registerClass(Briefing.class);
|
||||||
|
Serializer.registerClass(CeremonyMessage.class);
|
||||||
|
Serializer.registerClass(Die.class);
|
||||||
|
Serializer.registerClass(DiceAgain.class);
|
||||||
|
Serializer.registerClass(DiceNow.class);
|
||||||
|
Serializer.registerClass(EndOfTurn.class);
|
||||||
|
Serializer.registerClass(LobbyAccept.class);
|
||||||
|
Serializer.registerClass(LobbyDeny.class);
|
||||||
|
Serializer.registerClass(LobbyPlayerJoin.class);
|
||||||
|
Serializer.registerClass(LobbyPlayerLeave.class);
|
||||||
|
Serializer.registerClass(MoveMessage.class);
|
||||||
|
Serializer.registerClass(NoTurn.class);
|
||||||
|
Serializer.registerClass(PauseGame.class);
|
||||||
|
Serializer.registerClass(PlayCard.class);
|
||||||
|
Serializer.registerClass(PossibleCard.class);
|
||||||
|
Serializer.registerClass(PossiblePiece.class);
|
||||||
|
Serializer.registerClass(RankingResponse.class);
|
||||||
|
Serializer.registerClass(RankingRollAgain.class);
|
||||||
|
Serializer.registerClass(ReconnectBriefing.class);
|
||||||
|
Serializer.registerClass(ResumeGame.class);
|
||||||
|
Serializer.registerClass(ServerStartGame.class);
|
||||||
|
Serializer.registerClass(StartPiece.class);
|
||||||
|
Serializer.registerClass(UpdateReady.class);
|
||||||
|
Serializer.registerClass(UpdateTSK.class);
|
||||||
|
Serializer.registerClass(WaitPiece.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners() {
|
||||||
|
myServer.addMessageListener(this, AnimationEnd.class);
|
||||||
|
myServer.addMessageListener(this, ClientStartGame.class);
|
||||||
|
myServer.addMessageListener(this, DeselectTSK.class);
|
||||||
|
myServer.addMessageListener(this, ForceContinueGame.class);
|
||||||
|
myServer.addMessageListener(this, StartGame.class);
|
||||||
|
myServer.addMessageListener(this, JoinServer.class);
|
||||||
|
myServer.addMessageListener(this, LeaveGame.class);
|
||||||
|
myServer.addMessageListener(this, LobbyNotReady.class);
|
||||||
|
myServer.addMessageListener(this, LobbyReady.class);
|
||||||
|
myServer.addMessageListener(this, NoPowerCard.class);
|
||||||
|
myServer.addMessageListener(this, RequestBriefing.class);
|
||||||
|
myServer.addMessageListener(this, RequestDie.class);
|
||||||
|
myServer.addMessageListener(this, RequestMove.class);
|
||||||
|
myServer.addMessageListener(this, RequestPlayCard.class);
|
||||||
|
myServer.addMessageListener(this, SelectCard.class);
|
||||||
|
myServer.addMessageListener(this, SelectedPieces.class);
|
||||||
|
myServer.addMessageListener(this, SelectTSK.class);
|
||||||
|
myServer.addConnectionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void messageReceived(HostedConnection source, ClientMessage message) {
|
||||||
|
LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
|
||||||
|
pendingMessages.add(new ReceivedMessage(message, source.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionAdded(Server server, HostedConnection hostedConnection) {
|
||||||
|
LOGGER.log(Level.INFO, "new connection {0}", hostedConnection); //NON-NLS
|
||||||
|
// ToDo: Synchronize data between server and client.
|
||||||
|
logic.getGame().addPlayer(hostedConnection.getId(), new Player());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionRemoved(Server server, HostedConnection hostedConnection) {
|
||||||
|
LOGGER.log(Level.INFO, "connection closed: {0}", hostedConnection); //NON-NLS
|
||||||
|
final Player player = logic.getGame().getPlayerById(hostedConnection.getId());
|
||||||
|
if (player == null)
|
||||||
|
LOGGER.log(Level.INFO, "closed connection does not belong to an active player"); //NON-NLS
|
||||||
|
else { //NON-NLS
|
||||||
|
LOGGER.log(Level.INFO, "closed connection belongs to {0}", player); //NON-NLS
|
||||||
|
// exit(0);
|
||||||
|
this.handleDisconnect(hostedConnection.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be used to handle unintentional disconnections from players.
|
||||||
|
*
|
||||||
|
* @param id as the id of the disconnected player.
|
||||||
|
*/
|
||||||
|
public void handleDisconnect(int id) {
|
||||||
|
this.logic.received(new Disconnected(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exit(int exitValue) { //NON-NLS
|
||||||
|
LOGGER.log(Level.INFO, "close request"); //NON-NLS
|
||||||
|
if (myServer != null)
|
||||||
|
for (HostedConnection client : myServer.getConnections()) //NON-NLS
|
||||||
|
if (client != null) client.close("Game over"); //NON-NLS
|
||||||
|
System.exit(exitValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the specified message to the specified connection.
|
||||||
|
*
|
||||||
|
* @param id the connection id
|
||||||
|
* @param message the message
|
||||||
|
*/
|
||||||
|
public void send(int id, ServerMessage message) {
|
||||||
|
if (myServer == null || !myServer.isRunning()) {
|
||||||
|
LOGGER.log(Level.ERROR, "no server running when trying to send {0}", message); //NON-NLS
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final HostedConnection connection = myServer.getConnection(id);
|
||||||
|
if (connection != null)
|
||||||
|
connection.send(message);
|
||||||
|
else
|
||||||
|
LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be used to send the given message parameter to all connected players which are saved inside the
|
||||||
|
* players attribute of Game class.
|
||||||
|
*
|
||||||
|
* @param message as the message which will be sent to all players as a ServerMessage.
|
||||||
|
*/
|
||||||
|
public void broadcast(ServerMessage message) {
|
||||||
|
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
|
||||||
|
this.send(entry.getKey(), message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
@Override
|
||||||
|
public void messageReceived(HostedConnection source, Message m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package pp.mdga.client.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.client.ClientInterpreter;
|
||||||
|
import pp.mdga.message.client.ClientMessage;
|
||||||
|
|
||||||
|
public record ReceivedMessage(ClientMessage msg, int from) {
|
||||||
|
void process(ClientInterpreter interpreter) {
|
||||||
|
msg.accept(interpreter, from);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,20 @@
|
|||||||
package pp.mdga.client.view;
|
package pp.mdga.client.view;
|
||||||
|
|
||||||
|
import com.jme3.light.AmbientLight;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import pp.mdga.client.dialog.SingleButtonLeftDialog;
|
|
||||||
import pp.mdga.client.dialog.SingleButtonRightDialog;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.MdgaState;
|
import pp.mdga.client.MdgaState;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
|
import pp.mdga.client.button.ButtonRight;
|
||||||
|
import pp.mdga.client.button.CeremonyButton;
|
||||||
|
import pp.mdga.client.dialog.CeremonyDialog;
|
||||||
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CeremonyView extends MdgaView {
|
public class CeremonyView extends MdgaView {
|
||||||
|
|
||||||
private enum SubState {
|
private enum SubState {
|
||||||
AWARD_CEREMONY,
|
AWARD_CEREMONY,
|
||||||
STATISTICS,
|
STATISTICS,
|
||||||
@@ -15,54 +22,100 @@ private enum SubState {
|
|||||||
|
|
||||||
private SubState state;
|
private SubState state;
|
||||||
|
|
||||||
private SingleButtonRightDialog continueButton;
|
|
||||||
private SingleButtonLeftDialog backButton;
|
|
||||||
|
|
||||||
private Geometry background;
|
private Geometry background;
|
||||||
|
|
||||||
|
private ButtonLeft backButton;
|
||||||
|
private ButtonRight continueButton;
|
||||||
|
|
||||||
|
private ArrayList<CeremonyButton> ceremonyButtons;
|
||||||
|
|
||||||
|
private CeremonyDialog ceremonyDialog;
|
||||||
|
|
||||||
|
private AmbientLight ambient = new AmbientLight();
|
||||||
|
|
||||||
public CeremonyView(MdgaApp app) {
|
public CeremonyView(MdgaApp app) {
|
||||||
super(app);
|
super(app);
|
||||||
|
|
||||||
continueButton = new SingleButtonRightDialog(app, node, "Weiter", () -> forward());
|
backButton = new ButtonLeft(app, guiNode, this::back, "Zurück", 1);
|
||||||
backButton = new SingleButtonLeftDialog(app, node, "Zurück", () -> back());
|
continueButton = new ButtonRight(app, guiNode, this::forward, "Weiter", 1);
|
||||||
|
|
||||||
|
ceremonyButtons = new ArrayList<>(4);
|
||||||
|
|
||||||
|
ceremonyDialog = new CeremonyDialog(app, guiNode);
|
||||||
|
|
||||||
|
ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnter() {
|
public void onEnter() {
|
||||||
enterSub(SubState.AWARD_CEREMONY);
|
enterSub(SubState.AWARD_CEREMONY);
|
||||||
|
|
||||||
|
rootNode.addLight(ambient);
|
||||||
|
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.VICTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLeave() {
|
public void onLeave() {
|
||||||
continueButton.hide();
|
|
||||||
backButton.hide();
|
backButton.hide();
|
||||||
|
continueButton.hide();
|
||||||
|
|
||||||
|
if(null != background) {
|
||||||
|
guiNode.detachChild(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
ceremonyButtons.clear();
|
||||||
|
|
||||||
|
rootNode.removeLight(ambient);
|
||||||
|
|
||||||
|
ceremonyDialog.prepare();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEnterOverlay(Overlay overlay) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLeaveOverlay(Overlay overlay) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onUpdate(float tpf) {
|
||||||
|
for (CeremonyButton c : ceremonyButtons) {
|
||||||
|
c.update(tpf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void awardCeremony() {
|
private void awardCeremony() {
|
||||||
background = createBackground("Images/b1.png");
|
|
||||||
node.attachChild(background);
|
|
||||||
|
|
||||||
continueButton.show();
|
continueButton.show();
|
||||||
backButton.hide();
|
|
||||||
|
for (CeremonyButton c : ceremonyButtons) {
|
||||||
|
c.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void statistics() {
|
private void statistics() {
|
||||||
background = createBackground("Images/b2.png");
|
//background = createBackground("Images/b2.png");
|
||||||
node.attachChild(background);
|
//guiNode.attachChild(background);
|
||||||
|
|
||||||
continueButton.show();
|
|
||||||
backButton.show();
|
backButton.show();
|
||||||
|
continueButton.show();
|
||||||
|
ceremonyDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterSub(SubState state) {
|
private void enterSub(SubState state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
if(null != background) {
|
|
||||||
node.detachChild(background);
|
|
||||||
}
|
|
||||||
|
|
||||||
backButton.hide();
|
backButton.hide();
|
||||||
continueButton.hide();
|
continueButton.hide();
|
||||||
|
for (CeremonyButton c : ceremonyButtons) {
|
||||||
|
c.hide();
|
||||||
|
}
|
||||||
|
ceremonyDialog.hide();
|
||||||
|
|
||||||
|
if(null != background) {
|
||||||
|
guiNode.detachChild(background);
|
||||||
|
}
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AWARD_CEREMONY:
|
case AWARD_CEREMONY:
|
||||||
@@ -74,7 +127,7 @@ private void enterSub(SubState state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forward() {
|
public void forward() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AWARD_CEREMONY:
|
case AWARD_CEREMONY:
|
||||||
enterSub(SubState.STATISTICS);
|
enterSub(SubState.STATISTICS);
|
||||||
@@ -95,4 +148,18 @@ private void back() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCeremonyParticipant(Color color, int pos, String name) {
|
||||||
|
CeremonyButton button = new CeremonyButton(app, guiNode, rootNode, color, CeremonyButton.Pos.values()[pos - 1], name);
|
||||||
|
|
||||||
|
ceremonyButtons.add(button);
|
||||||
|
|
||||||
|
if(state.equals(SubState.AWARD_CEREMONY)) {
|
||||||
|
button.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
|
||||||
|
ceremonyDialog.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
package pp.mdga.client.view;
|
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.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.FrameBuffer;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Texture2D;
|
import com.jme3.texture.Texture2D;
|
||||||
|
import pp.mdga.client.MdgaState;
|
||||||
|
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.dialog.SingleButtonLeftDialog;
|
|
||||||
import pp.mdga.client.dialog.SingleButtonRightDialog;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.MdgaState;
|
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.client.gui.GuiHandler;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
@@ -18,19 +29,26 @@ public class GameView extends MdgaView {
|
|||||||
private CameraHandler camera;
|
private CameraHandler camera;
|
||||||
private GuiHandler guiHandler;
|
private GuiHandler guiHandler;
|
||||||
|
|
||||||
private SingleButtonLeftDialog leaveButton;
|
private ButtonRight cheatButton; //TODO
|
||||||
private SingleButtonRightDialog continueButton;
|
|
||||||
|
private ButtonLeft leaveButton;
|
||||||
|
private ButtonRight confirmButton;
|
||||||
|
|
||||||
private Color ownColor = null;
|
private Color ownColor = null;
|
||||||
|
|
||||||
|
private FilterPostProcessor fpp;
|
||||||
|
|
||||||
public GameView(MdgaApp app) {
|
public GameView(MdgaApp app) {
|
||||||
super(app);
|
super(app);
|
||||||
|
|
||||||
//Filter für Outline: Reihenfolge CameraHandler(dlsf) -> BoardHandler -> viewPort.addProcessor einhalten!
|
cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY), "CHEAT", 1);
|
||||||
FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
|
|
||||||
|
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSyncronizer().leave(), "Spiel verlassen", 1);
|
||||||
|
confirmButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().confirm(), "Bestätigen", 1);
|
||||||
|
|
||||||
|
fpp = new FilterPostProcessor(app.getAssetManager());
|
||||||
this.camera = new CameraHandler(app, fpp);
|
this.camera = new CameraHandler(app, fpp);
|
||||||
this.boardHandler = new BoardHandler(app, fpp);
|
this.boardHandler = new BoardHandler(app, rootNode, fpp);
|
||||||
app.getViewPort().addProcessor(fpp);
|
|
||||||
|
|
||||||
FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
|
FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
|
||||||
Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
|
Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
|
||||||
@@ -38,11 +56,8 @@ public GameView(MdgaApp app) {
|
|||||||
backFrameBuffer.addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(backTexture));
|
backFrameBuffer.addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(backTexture));
|
||||||
app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
|
app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
|
||||||
|
|
||||||
this.guiHandler = new GuiHandler(app, backTexture, ownColor);
|
|
||||||
|
|
||||||
leaveButton = new SingleButtonLeftDialog(app, settingsNode, "Verlassen", () -> leaveGame());
|
guiHandler = new GuiHandler(app, guiNode, backTexture, ownColor);
|
||||||
|
|
||||||
continueButton = new SingleButtonRightDialog(app, node, "Weiter", () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,38 +65,44 @@ public void onEnter() {
|
|||||||
camera.init();
|
camera.init();
|
||||||
boardHandler.init();
|
boardHandler.init();
|
||||||
guiHandler.init();
|
guiHandler.init();
|
||||||
continueButton.show();
|
|
||||||
|
app.getViewPort().addProcessor(fpp);
|
||||||
|
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.START);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLeave() {
|
public void onLeave() {
|
||||||
continueButton.hide();
|
|
||||||
|
|
||||||
camera.shutdown();
|
camera.shutdown();
|
||||||
boardHandler.shutdown();
|
boardHandler.shutdown();
|
||||||
|
guiHandler.shutdown();
|
||||||
|
|
||||||
|
app.getViewPort().removeProcessor(fpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate(float tpf) {
|
||||||
camera.update(app.getInputSyncronizer().getScroll(), app.getInputSyncronizer().getRotation());
|
camera.update(app.getInputSyncronizer().getScroll(), app.getInputSyncronizer().getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enterExtendedSettings() {
|
protected void onEnterOverlay(Overlay overlay) {
|
||||||
leaveButton.show();
|
if(overlay == Overlay.SETTINGS) {
|
||||||
|
leaveButton.show();
|
||||||
|
cheatButton.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void leaveExtendedSettings() {
|
protected void onLeaveOverlay(Overlay overlay) {
|
||||||
leaveButton.hide();
|
if(overlay == Overlay.SETTINGS) {
|
||||||
|
leaveButton.hide();
|
||||||
|
cheatButton.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void leaveGame() {
|
private void leaveGame() {
|
||||||
leaveSettings(false);
|
|
||||||
|
|
||||||
app.getModelSyncronizer().leave();
|
app.getModelSyncronizer().leave();
|
||||||
|
|
||||||
app.afteGameCleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoardHandler getBoardHandler() {
|
public BoardHandler getBoardHandler() {
|
||||||
|
|||||||
@@ -1,59 +1,199 @@
|
|||||||
package pp.mdga.client.view;
|
package pp.mdga.client.view;
|
||||||
|
|
||||||
|
import com.jme3.asset.TextureKey;
|
||||||
|
import com.jme3.light.AmbientLight;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import pp.mdga.client.dialog.LobbyButtonDialog;
|
import com.jme3.scene.Spatial;
|
||||||
import pp.mdga.client.dialog.SingleButtonLeftDialog;
|
import com.jme3.texture.Texture;
|
||||||
import pp.mdga.client.dialog.SingleButtonRightDialog;
|
import com.jme3.util.SkyFactory;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.MdgaState;
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
|
import pp.mdga.client.button.ButtonRight;
|
||||||
|
import pp.mdga.client.button.LobbyButton;
|
||||||
|
import pp.mdga.client.button.SettingsButton;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class LobbyView extends MdgaView {
|
public class LobbyView extends MdgaView {
|
||||||
private Geometry background;
|
private Geometry background;
|
||||||
|
|
||||||
private SingleButtonRightDialog readyButton;
|
private ButtonLeft leaveButton;
|
||||||
private SingleButtonLeftDialog leaveButton;
|
private ButtonRight readyButton;
|
||||||
|
|
||||||
private ArrayList<LobbyButtonDialog> lobbyButtons = new ArrayList<>();
|
private LobbyButton cyberButton;
|
||||||
|
private LobbyButton airforceButton;
|
||||||
|
private LobbyButton armyButton;
|
||||||
|
private LobbyButton navyButton;
|
||||||
|
|
||||||
|
private AmbientLight ambient = new AmbientLight();
|
||||||
|
|
||||||
public LobbyView(MdgaApp app) {
|
public LobbyView(MdgaApp app) {
|
||||||
super(app);
|
super(app);
|
||||||
|
|
||||||
background = createBackground("Images/lobby.png");
|
//TextureKey key = new TextureKey("lobby.png", false);
|
||||||
node.attachChild(background);
|
//Texture skyTexture = app.getAssetManager().loadTexture(key);
|
||||||
|
//Spatial sky = SkyFactory.createSky(app.getAssetManager(), skyTexture, SkyFactory.EnvMapType.SphereMap);
|
||||||
|
//rootNode.attachChild(sky);
|
||||||
|
|
||||||
readyButton = new SingleButtonRightDialog(app, node, "Fertig", () -> app.getModelSyncronizer().setReady());
|
leaveButton = new ButtonLeft(app, guiNode, this::leaveLobby, "Verlassen", 1);
|
||||||
leaveButton = new SingleButtonLeftDialog(app, node, "Verlassen", () -> app.getModelSyncronizer().leave());
|
readyButton = new ButtonRight(app, guiNode, this::ready, "Bereit", 1);
|
||||||
|
|
||||||
lobbyButtons.add(new LobbyButtonDialog(app, node, "HEER", 0));
|
cyberButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.CYBER), Color.CYBER);
|
||||||
lobbyButtons.add(new LobbyButtonDialog(app, node, "MARINE", 1));
|
airforceButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.AIRFORCE), Color.AIRFORCE);
|
||||||
lobbyButtons.add(new LobbyButtonDialog(app, node, "CIR", 2));
|
armyButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.ARMY), Color.ARMY);
|
||||||
lobbyButtons.add(new LobbyButtonDialog(app, node, "LUFTWAFFE", 3));
|
navyButton = new LobbyButton(app, guiNode, rootNode, () -> toggleTsk(Color.NAVY), Color.NAVY);
|
||||||
|
|
||||||
|
ambient.setColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnter() {
|
public void onEnter() {
|
||||||
readyButton.show();
|
app.getCamera().setParallelProjection(true);
|
||||||
leaveButton.show();
|
float aspect = (float) app.getCamera().getWidth() / app.getCamera().getHeight();
|
||||||
|
float size = 1.65f;
|
||||||
|
app.getCamera().setFrustum(-1000, 1000, -aspect * size, aspect * size, size, -size);
|
||||||
|
|
||||||
for (LobbyButtonDialog b : lobbyButtons) {
|
leaveButton.show();
|
||||||
b.show();
|
readyButton.show();
|
||||||
}
|
|
||||||
|
cyberButton.show();
|
||||||
|
airforceButton.show();
|
||||||
|
armyButton.show();
|
||||||
|
navyButton.show();
|
||||||
|
|
||||||
|
rootNode.addLight(ambient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLeave() {
|
public void onLeave() {
|
||||||
for (LobbyButtonDialog b : lobbyButtons) {
|
|
||||||
b.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
readyButton.hide();
|
|
||||||
leaveButton.hide();
|
leaveButton.hide();
|
||||||
|
readyButton.hide();
|
||||||
|
|
||||||
|
airforceButton.hide();
|
||||||
|
armyButton.hide();
|
||||||
|
navyButton.hide();
|
||||||
|
cyberButton.hide();
|
||||||
|
|
||||||
|
rootNode.removeLight(ambient);
|
||||||
|
|
||||||
|
app.getCamera().setParallelProjection(false);
|
||||||
|
|
||||||
|
app.getCamera().setFrustumPerspective(
|
||||||
|
45.0f,
|
||||||
|
(float) app.getCamera().getWidth() / app.getCamera().getHeight(),
|
||||||
|
0.1f,
|
||||||
|
1000.0f
|
||||||
|
);
|
||||||
|
|
||||||
|
app.getCamera().setLocation(new Vector3f(0, 0, 10));
|
||||||
|
app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onUpdate(float tpf) {
|
||||||
|
airforceButton.update(tpf);
|
||||||
|
armyButton.update(tpf);
|
||||||
|
navyButton.update(tpf);
|
||||||
|
cyberButton.update(tpf);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEnterOverlay(Overlay overlay) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLeaveOverlay(Overlay overlay)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaken(Color color, boolean isTaken, boolean isSelf, String name) {
|
public void setTaken(Color color, boolean isTaken, boolean isSelf, String name) {
|
||||||
lobbyButtons.get(color.ordinal()).setTaken(isTaken, isSelf, name);
|
LobbyButton.Taken taken;
|
||||||
|
|
||||||
|
if(isTaken) {
|
||||||
|
if(isSelf) {
|
||||||
|
taken = LobbyButton.Taken.SELF;
|
||||||
|
} else {
|
||||||
|
taken = LobbyButton.Taken.OTHER;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
taken = LobbyButton.Taken.NOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (color) {
|
||||||
|
case CYBER:
|
||||||
|
cyberButton.setTaken(taken, name);
|
||||||
|
break;
|
||||||
|
case AIRFORCE:
|
||||||
|
airforceButton.setTaken(taken, name);
|
||||||
|
break;
|
||||||
|
case ARMY:
|
||||||
|
armyButton.setTaken(taken, name);
|
||||||
|
break;
|
||||||
|
case NAVY:
|
||||||
|
navyButton.setTaken(taken, name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReady(Color color, boolean isReady) {
|
||||||
|
switch (color) {
|
||||||
|
case CYBER:
|
||||||
|
cyberButton.setReady(isReady);
|
||||||
|
break;
|
||||||
|
case AIRFORCE:
|
||||||
|
airforceButton.setReady(isReady);
|
||||||
|
break;
|
||||||
|
case ARMY:
|
||||||
|
armyButton.setReady(isReady);
|
||||||
|
break;
|
||||||
|
case NAVY:
|
||||||
|
navyButton.setReady(isReady);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleTsk(Color color) {
|
||||||
|
LobbyButton.Taken taken = LobbyButton.Taken.NOT;
|
||||||
|
|
||||||
|
switch (color) {
|
||||||
|
case CYBER:
|
||||||
|
taken = cyberButton.getTaken();
|
||||||
|
break;
|
||||||
|
case AIRFORCE:
|
||||||
|
taken = airforceButton.getTaken();
|
||||||
|
break;
|
||||||
|
case ARMY:
|
||||||
|
taken = armyButton.getTaken();
|
||||||
|
break;
|
||||||
|
case NAVY:
|
||||||
|
taken = navyButton.getTaken();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (taken) {
|
||||||
|
case NOT:
|
||||||
|
app.getModelSyncronizer().selectTsk(color);
|
||||||
|
break;
|
||||||
|
case SELF:
|
||||||
|
app.getModelSyncronizer().unselectTsk();
|
||||||
|
break;
|
||||||
|
case OTHER:
|
||||||
|
//nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ready() {
|
||||||
|
app.getModelSyncronizer().setReady();
|
||||||
|
//TODO: playSound
|
||||||
|
}
|
||||||
|
|
||||||
|
private void leaveLobby() {
|
||||||
|
app.getModelSyncronizer().leave();
|
||||||
|
//TODO: playSound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +1,220 @@
|
|||||||
package pp.mdga.client.view;
|
package pp.mdga.client.view;
|
||||||
|
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import pp.mdga.client.dialog.Dialog;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.MdgaState;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
import pp.mdga.client.button.ButtonRight;
|
||||||
|
import pp.mdga.client.button.MenuButton;
|
||||||
|
import pp.mdga.client.button.SettingsButton;
|
||||||
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 pp.mdga.client.MdgaApp;
|
|
||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
|
|
||||||
public class MainView extends MdgaView {
|
public class MainView extends MdgaView {
|
||||||
|
private enum SubState {
|
||||||
|
HOST,
|
||||||
|
JOIN,
|
||||||
|
MAIN,
|
||||||
|
}
|
||||||
|
|
||||||
|
private SubState state;
|
||||||
|
|
||||||
private Geometry background;
|
private Geometry background;
|
||||||
|
|
||||||
private StartDialog dialog;
|
private StartDialog startDialog;
|
||||||
private Dialog subDialog;
|
private JoinDialog joinDialog;
|
||||||
|
private HostDialog hostDialog;
|
||||||
|
|
||||||
public MainView(MdgaApp app) {
|
public MainView(MdgaApp app) {
|
||||||
super(app);
|
super(app);
|
||||||
|
|
||||||
background = createBackground("Images/powercards.png");
|
startDialog = new StartDialog(app, guiNode, this);
|
||||||
node.attachChild(background);
|
joinDialog = new JoinDialog(app, guiNode, this);
|
||||||
|
hostDialog = new HostDialog(app, guiNode, this);
|
||||||
Vector3f size = new Vector3f(280, 60, 0);
|
|
||||||
dialog = new StartDialog(app, node);
|
|
||||||
dialog.addButton("Spiel beitreten", () -> enterJoin(), size);
|
|
||||||
dialog.addButton("Spiel hosten", () -> enterHost(), size);
|
|
||||||
dialog.addButton("Einstellungen", () -> enterSettings(false), size);
|
|
||||||
dialog.addButton("Spiel beenden", () -> app.stop(), size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnter() {
|
public void onEnter() {
|
||||||
dialog.show();
|
background = createBackground("Images/main.png");
|
||||||
|
guiNode.attachChild(background);
|
||||||
|
|
||||||
|
enterSub(SubState.MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLeave() {
|
public void onLeave() {
|
||||||
dialog.hide();
|
startDialog.hide();
|
||||||
|
joinDialog.hide();
|
||||||
|
hostDialog.hide();
|
||||||
|
|
||||||
if(subDialog != null) {
|
guiNode.detachChild(background);
|
||||||
subDialog.hide();
|
}
|
||||||
subDialog = null;
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(float tpf) {
|
||||||
|
startDialog.update();
|
||||||
|
joinDialog.update();
|
||||||
|
hostDialog.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEnterOverlay(Overlay overlay) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLeaveOverlay(Overlay overlay)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void joinMenu() {
|
||||||
|
startDialog.hide();
|
||||||
|
hostDialog.hide();
|
||||||
|
|
||||||
|
joinDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hostMenu() {
|
||||||
|
startDialog.hide();
|
||||||
|
joinDialog.hide();
|
||||||
|
|
||||||
|
hostDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mainMenu() {
|
||||||
|
joinDialog.hide();
|
||||||
|
hostDialog.hide();
|
||||||
|
|
||||||
|
startDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryHost() {
|
||||||
|
int port = 0;
|
||||||
|
String text = hostDialog.getPort();
|
||||||
|
|
||||||
|
try {
|
||||||
|
port = Integer.parseInt(text);
|
||||||
|
|
||||||
|
if(port >= 1 && port <= 65535) {
|
||||||
|
app.getModelSyncronizer().setName(startDialog.getName());
|
||||||
|
app.getModelSyncronizer().setHost(port);
|
||||||
|
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
//nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
hostDialog.resetPort();
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryJoin() {
|
||||||
|
int port = 0;
|
||||||
|
String ip = joinDialog.getIpt();
|
||||||
|
String portText = hostDialog.getPort();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Validate the port
|
||||||
|
port = Integer.parseInt(portText);
|
||||||
|
if (port < 1 || port > 65535) {
|
||||||
|
throw new IllegalArgumentException("Invalid port");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the IP address
|
||||||
|
if (isValidIpAddress(ip)) {
|
||||||
|
app.getModelSyncronizer().setName(startDialog.getName());
|
||||||
|
app.getModelSyncronizer().setJoin(ip, port);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Invalid input, fall through to reset
|
||||||
|
}
|
||||||
|
|
||||||
|
hostDialog.resetPort();
|
||||||
|
joinDialog.resetIp();
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidIpAddress(String ip) {
|
||||||
|
String ipRegex =
|
||||||
|
"^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
|
||||||
|
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
|
||||||
|
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." +
|
||||||
|
"(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$";
|
||||||
|
|
||||||
|
return ip != null && ip.matches(ipRegex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enterSub(SubState state) {
|
||||||
|
this.state = state;
|
||||||
|
|
||||||
|
if(null != background) {
|
||||||
|
rootNode.detachChild(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case HOST:
|
||||||
|
hostMenu();
|
||||||
|
break;
|
||||||
|
case JOIN:
|
||||||
|
joinMenu();
|
||||||
|
break;
|
||||||
|
case MAIN:
|
||||||
|
mainMenu();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterJoin() {
|
public void forward() {
|
||||||
app.getModelSyncronizer().setName(dialog.getName());
|
switch (state) {
|
||||||
|
case HOST:
|
||||||
subDialog = new JoinDialog(app, node, () -> leaveJoin());
|
tryHost();
|
||||||
|
break;
|
||||||
dialog.hide();
|
case JOIN:
|
||||||
subDialog.show();
|
tryJoin();
|
||||||
|
break;
|
||||||
|
case MAIN:
|
||||||
|
throw new RuntimeException("call forward(boolean host) insted of forward()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void leaveJoin() {
|
public void forward(boolean host) {
|
||||||
subDialog.hide();
|
switch (state) {
|
||||||
dialog.show();
|
case HOST:
|
||||||
|
tryHost();
|
||||||
subDialog = null;
|
break;
|
||||||
|
case JOIN:
|
||||||
|
tryJoin();
|
||||||
|
break;
|
||||||
|
case MAIN:
|
||||||
|
if(host) {
|
||||||
|
enterSub(SubState.HOST);
|
||||||
|
//TODO playSound
|
||||||
|
} else {
|
||||||
|
enterSub(SubState.JOIN);
|
||||||
|
//TODO: playSound
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterHost() {
|
public void back() {
|
||||||
app.getModelSyncronizer().setName(dialog.getName());
|
switch (state) {
|
||||||
|
case HOST:
|
||||||
subDialog = new HostDialog(app, node, () -> leaveHost());
|
enterSub(SubState.MAIN);
|
||||||
|
//TODO: playSound
|
||||||
dialog.hide();
|
break;
|
||||||
subDialog.show();
|
case JOIN:
|
||||||
}
|
enterSub(SubState.MAIN);
|
||||||
|
//TODO: playSound
|
||||||
private void leaveHost() {
|
break;
|
||||||
subDialog.hide();
|
case MAIN:
|
||||||
dialog.show();
|
//nothing
|
||||||
|
break;
|
||||||
subDialog = null;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,83 +2,49 @@
|
|||||||
|
|
||||||
import com.jme3.asset.TextureKey;
|
import com.jme3.asset.TextureKey;
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.shape.Quad;
|
import com.jme3.scene.shape.Quad;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import pp.mdga.client.dialog.GetPercentRunnable;
|
|
||||||
import pp.mdga.client.dialog.PercentRunnable;
|
|
||||||
import pp.mdga.client.dialog.SettingsButtonDialog;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
import pp.mdga.client.button.*;
|
||||||
|
import pp.mdga.client.dialog.AudioSettingsDialog;
|
||||||
import pp.mdga.client.dialog.SettingsDialog;
|
import pp.mdga.client.dialog.SettingsDialog;
|
||||||
|
import pp.mdga.client.dialog.VideoSettingsDialog;
|
||||||
|
|
||||||
public abstract class MdgaView {
|
public abstract class MdgaView {
|
||||||
|
public enum Overlay {
|
||||||
|
INTERRUPT,
|
||||||
|
SETTINGS,
|
||||||
|
}
|
||||||
|
|
||||||
protected MdgaApp app;
|
protected MdgaApp app;
|
||||||
protected Node node;
|
protected Node rootNode = new Node();
|
||||||
|
protected Node guiNode = new Node();
|
||||||
|
protected Node settingsNode = new Node();
|
||||||
|
|
||||||
protected int depth = 0;
|
private SettingsButton settingsButton;
|
||||||
private boolean isVideo = false;
|
|
||||||
private boolean isAudio = false;
|
|
||||||
|
|
||||||
protected Node settingsNode;
|
private SettingsDialog settingsDialog;
|
||||||
protected Node audioSettingsNode;
|
private VideoSettingsDialog videoSettingsDialog;
|
||||||
protected Node videoSettingsNode;
|
private AudioSettingsDialog audioSettingsDialog;
|
||||||
|
|
||||||
private SettingsButtonDialog settingsButton;
|
private int settingsDepth = 0;
|
||||||
|
|
||||||
private Geometry settingsBackground;
|
|
||||||
private Geometry audioBackground;
|
|
||||||
private Geometry videoBackground;
|
|
||||||
|
|
||||||
private SettingsDialog settings;
|
|
||||||
private SettingsDialog audio;
|
|
||||||
private SettingsDialog video;
|
|
||||||
|
|
||||||
private static final String IMAGE_ROOT = "Images/";
|
|
||||||
|
|
||||||
public MdgaView(MdgaApp app) {
|
public MdgaView(MdgaApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.node = new Node();
|
settingsButton = new SettingsButton(app, guiNode, this::enterSettings);
|
||||||
|
|
||||||
this.settingsNode = new Node();
|
settingsDialog = new SettingsDialog(app, settingsNode, this);
|
||||||
this.audioSettingsNode = new Node();
|
videoSettingsDialog = new VideoSettingsDialog(app, settingsNode, this);
|
||||||
this.videoSettingsNode = new Node();
|
audioSettingsDialog = new AudioSettingsDialog(app, settingsNode, this);
|
||||||
|
|
||||||
this.settingsButton = new SettingsButtonDialog(app, node, "", () -> enterSettings(false));
|
|
||||||
|
|
||||||
this.settingsBackground = createBackground(IMAGE_ROOT + "background/zahnräder.png");
|
|
||||||
settingsNode.attachChild(settingsBackground);
|
|
||||||
|
|
||||||
this.audioBackground = createBackground(IMAGE_ROOT + "background/lautsprecher.png");
|
|
||||||
audioSettingsNode.attachChild(audioBackground);
|
|
||||||
|
|
||||||
this.videoBackground = createBackground(IMAGE_ROOT + "background/monitors.png");
|
|
||||||
videoSettingsNode.attachChild(videoBackground);
|
|
||||||
|
|
||||||
Vector3f size = new Vector3f(280, 60, 0);
|
|
||||||
|
|
||||||
this.settings = new SettingsDialog(app, settingsNode, IMAGE_ROOT + "zahnrad.png");
|
|
||||||
this.settings.addButton("Video", () -> enterVideo(), size);
|
|
||||||
this.settings.addButton("Audio", () -> enterAudio(), size);
|
|
||||||
this.settings.addButton("Zurück", () -> leaveSettings(false), size);
|
|
||||||
|
|
||||||
this.audio = new SettingsDialog(app, audioSettingsNode, IMAGE_ROOT + "audio_icon.png");
|
|
||||||
this.audio.addSlider("Lautstärke", new PercentRunnable(app.getAcousticHandler()::setMainVolume), new GetPercentRunnable(app.getAcousticHandler()::getMainVolume), size, (int) app.getAcousticHandler().getMainVolume() * 100);
|
|
||||||
this.audio.addSlider("Musik", new PercentRunnable(app.getAcousticHandler()::setMusicVolume), new GetPercentRunnable(app.getAcousticHandler()::getMusicVolume), size, (int) app.getAcousticHandler().getMusicVolume() * 100);
|
|
||||||
this.audio.addSlider("Sound", new PercentRunnable(app.getAcousticHandler()::setSoundVolume), new GetPercentRunnable(app.getAcousticHandler()::getSoundVolume), size, (int) app.getAcousticHandler().getSoundVolume() * 100);
|
|
||||||
this.audio.addButton("Zurück", () -> leaveAudio(), size);
|
|
||||||
|
|
||||||
this.video = new SettingsDialog(app, videoSettingsNode, IMAGE_ROOT + "monitor.png");
|
|
||||||
this.video.addButton("A", () -> System.out.println("A"), size);
|
|
||||||
this.video.addButton("B", () -> System.out.println("B"), size);
|
|
||||||
this.video.addButton("Zurück", () -> leaveVideo(), size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enter() {
|
public void enter() {
|
||||||
app.getGuiNode().attachChild(node);
|
app.getRootNode().attachChild(rootNode);
|
||||||
|
app.getGuiNode().attachChild(guiNode);
|
||||||
audio.initVolume();
|
|
||||||
|
|
||||||
settingsButton.show();
|
settingsButton.show();
|
||||||
|
|
||||||
@@ -86,123 +52,139 @@ public void enter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void leave() {
|
public void leave() {
|
||||||
onLeave();
|
app.getRootNode().detachChild(rootNode);
|
||||||
|
app.getGuiNode().detachChild(guiNode);
|
||||||
|
|
||||||
settingsButton.hide();
|
settingsButton.hide();
|
||||||
|
|
||||||
app.getGuiNode().detachChild(node);
|
while (settingsDepth > 0) {
|
||||||
|
pressEscape();
|
||||||
|
}
|
||||||
|
|
||||||
|
onLeave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void enterOverlay(Overlay overlay) {
|
||||||
audio.update();
|
app.getGuiNode().detachChild(guiNode);
|
||||||
onUpdate();
|
|
||||||
|
onEnterOverlay(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void leaveOverlay(Overlay overlay) {
|
||||||
|
app.getGuiNode().attachChild(guiNode);
|
||||||
|
|
||||||
|
onLeaveOverlay(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(float tpf) {
|
||||||
|
videoSettingsDialog.update();
|
||||||
|
audioSettingsDialog.update();
|
||||||
|
|
||||||
|
onUpdate(tpf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void onEnter();
|
protected abstract void onEnter();
|
||||||
protected abstract void onLeave();
|
protected abstract void onLeave();
|
||||||
protected void onUpdate() {}
|
protected void onUpdate(float tpf) {}
|
||||||
|
|
||||||
|
protected abstract void onEnterOverlay(Overlay overlay);
|
||||||
|
protected abstract void onLeaveOverlay(Overlay overlay);
|
||||||
|
|
||||||
protected Geometry createBackground(String texturePath) {
|
protected Geometry createBackground(String texturePath) {
|
||||||
TextureKey key = new TextureKey(texturePath, true);
|
TextureKey key = new TextureKey(texturePath, true);
|
||||||
Texture backgroundTexture = app.getAssetManager().loadTexture(key);
|
Texture backgroundTexture = app.getAssetManager().loadTexture(key);
|
||||||
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
|
||||||
Geometry background = new Geometry("Background", quad);
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", backgroundTexture);
|
mat.setTexture("ColorMap", backgroundTexture);
|
||||||
|
|
||||||
|
Quad quad = new Quad(app.getCamera().getWidth(), app.getCamera().getHeight());
|
||||||
|
|
||||||
|
Geometry background = new Geometry("Background", quad);
|
||||||
background.setMaterial(mat);
|
background.setMaterial(mat);
|
||||||
background.setLocalTranslation(0, 0, -1);
|
background.setLocalTranslation(0, 0, -2);
|
||||||
|
|
||||||
return background;
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void enterExtendedSettings() {}
|
public void enterSettings() {
|
||||||
protected void leaveExtendedSettings() {}
|
enterOverlay(Overlay.SETTINGS);
|
||||||
|
|
||||||
protected void enterSettings(boolean soft) {
|
|
||||||
leave();
|
|
||||||
|
|
||||||
app.getGuiNode().attachChild(settingsNode);
|
app.getGuiNode().attachChild(settingsNode);
|
||||||
|
settingsDialog.show();
|
||||||
|
|
||||||
if(!soft) {
|
settingsDepth++;
|
||||||
depth++;
|
|
||||||
|
|
||||||
enterExtendedSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void leaveSettings(boolean soft) {
|
public void leaveSettings() {
|
||||||
settings.hide();
|
leaveOverlay(Overlay.SETTINGS);
|
||||||
|
|
||||||
app.getGuiNode().detachChild(settingsNode);
|
app.getGuiNode().detachChild(settingsNode);
|
||||||
|
settingsDialog.hide();
|
||||||
|
|
||||||
if(!soft) {
|
settingsDepth--;
|
||||||
leaveExtendedSettings();
|
|
||||||
enter();
|
|
||||||
depth--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void enterAudio() {
|
public void enterVideoSettings() {
|
||||||
leaveSettings(true);
|
settingsDialog.hide();
|
||||||
|
videoSettingsDialog.show();
|
||||||
|
|
||||||
depth++;
|
settingsDepth++;
|
||||||
isAudio = true;
|
|
||||||
|
|
||||||
app.getGuiNode().attachChild(audioSettingsNode);
|
|
||||||
|
|
||||||
audio.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void leaveAudio() {
|
public void leaveVideoSettings() {
|
||||||
audio.hide();
|
settingsDialog.show();
|
||||||
|
videoSettingsDialog.hide();
|
||||||
|
|
||||||
app.getGuiNode().detachChild(audioSettingsNode);
|
settingsDepth--;
|
||||||
|
|
||||||
isAudio = false;
|
|
||||||
depth--;
|
|
||||||
|
|
||||||
enterSettings(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void enterVideo() {
|
public void enterAudioSettings() {
|
||||||
leaveSettings(true);
|
settingsDialog.hide();
|
||||||
|
audioSettingsDialog.show();
|
||||||
|
|
||||||
app.getGuiNode().attachChild(videoSettingsNode);
|
settingsDepth++;
|
||||||
|
|
||||||
depth++;
|
|
||||||
|
|
||||||
isVideo = true;
|
|
||||||
|
|
||||||
video.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void leaveVideo() {
|
public void leaveAudioSettings() {
|
||||||
video.hide();
|
settingsDialog.show();
|
||||||
|
audioSettingsDialog.hide();
|
||||||
|
|
||||||
app.getGuiNode().detachChild(videoSettingsNode);
|
settingsDepth--;
|
||||||
|
}
|
||||||
|
|
||||||
depth--;
|
private void leaveAdvanced() {
|
||||||
isVideo = false;
|
settingsDialog.show();
|
||||||
|
audioSettingsDialog.hide();
|
||||||
enterSettings(true);
|
videoSettingsDialog.hide();
|
||||||
|
settingsDepth--;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pressEscape() {
|
public void pressEscape() {
|
||||||
if(depth == 0) {
|
if(settingsDepth == 0) {
|
||||||
enterSettings(false);
|
enterSettings();
|
||||||
} else if(depth == 1) {
|
} else if(settingsDepth == 1) {
|
||||||
leaveSettings(false);
|
leaveSettings();
|
||||||
}
|
|
||||||
else if (depth == 2){
|
|
||||||
if(isVideo) {
|
|
||||||
leaveVideo();
|
|
||||||
}
|
|
||||||
if(isAudio) {
|
|
||||||
leaveAudio();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException();
|
leaveAdvanced();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pressForward() {
|
||||||
|
if(this instanceof MainView mainView) {
|
||||||
|
mainView.forward(false);
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.BUTTON_PRESSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this instanceof LobbyView lobbyView) {
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this instanceof GameView gameView) {
|
||||||
|
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this instanceof CeremonyView ceremonyView) {
|
||||||
|
ceremonyView.forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 3.1 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
BIN
Projekte/mdga/client/src/main/resources/Sounds/error_sound.ogg
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/error_sound.ogg
Normal file
Binary file not shown.
BIN
Projekte/mdga/client/src/main/resources/Sounds/gamestart.ogg
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/gamestart.ogg
Normal file
Binary file not shown.
BIN
Projekte/mdga/client/src/main/resources/Sounds/menu_button.ogg
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/menu_button.ogg
Normal file
Binary file not shown.
BIN
Projekte/mdga/client/src/main/resources/Sounds/uiclick.ogg
Normal file
BIN
Projekte/mdga/client/src/main/resources/Sounds/uiclick.ogg
Normal file
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Animation extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class AudioSettings extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Ceremony extends ClientState {
|
|
||||||
private final CeremonyStateMachine ceremonyStateMachine = new CeremonyStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class CeremonyStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ChoosePiece extends ClientState {
|
|
||||||
private final ChoosePieceStateMachine choosePieceStateMachine = new ChoosePieceStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ChoosePieceStateMachine extends ClientStateMachine{
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ChoosePowerCard extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ClientAutomaton extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ClientGameLogic {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public abstract class ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public abstract class ClientStateMachine extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class DetermineStartPlayer extends ClientState {
|
|
||||||
private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class DetermineStartPlayerStateMachine extends ClientStateMachine{
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Dialogs extends ClientState {
|
|
||||||
private final DialogsStateMachine dialogsStateMachine = new DialogsStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class DialogsStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class GameState extends ClientState {
|
|
||||||
private final GameStateMachine gameStateMachine = new GameStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class GameStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Interrupt extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Lobby extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class MainSettings extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class MovePiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class NetworkDialog extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class NoPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class PlayPowerCard extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Podium extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class PowerCard extends ClientState {
|
|
||||||
private final PowerCardStateMachine powerCardStateMachine = new PowerCardStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class PowerCardStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class RollDice extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class RollRankingDice extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class SelectPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Settings extends ClientState {
|
|
||||||
private final SettingsStateMachine settingsStateMachine = new SettingsStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class SettingsStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Shield extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Spectator extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class StartDialog extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class StartPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Statistics extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Swap extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Turn extends ClientState {
|
|
||||||
private final TurnStateMachine turnStateMachine = new TurnStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class TurnStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class VideoSettings extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class WaitRanking extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Waiting extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class WaitingPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package pp.mdga.game;
|
|
||||||
|
|
||||||
public enum Color {
|
|
||||||
ARMY,
|
|
||||||
NAVY,
|
|
||||||
CYBER,
|
|
||||||
AIRFORCE
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class AnimationEnd extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public interface ClientInterpreter {
|
|
||||||
void received(AnimationEnd animationEnd, int from);
|
|
||||||
|
|
||||||
void received(DeselectTSK deselectTSK , int from);
|
|
||||||
|
|
||||||
void received(ForceStartGame forceStartGame, int from);
|
|
||||||
|
|
||||||
void received(JoinServer joinServer , int from);
|
|
||||||
|
|
||||||
void received(LeaveGame leaveGame , int from);
|
|
||||||
|
|
||||||
void received(LobbyNotReady lobbyNotReady , int from);
|
|
||||||
|
|
||||||
void received(LobbyReady lobbyReady , int from);
|
|
||||||
|
|
||||||
void received(RequestBriefing requestBriefing , int from);
|
|
||||||
|
|
||||||
void received(RequestDice requestDice , int from);
|
|
||||||
|
|
||||||
void received(RequestMove requestMove , int from);
|
|
||||||
|
|
||||||
void received(RequestPlayCard requestPlayCard , int from);
|
|
||||||
|
|
||||||
void received(SelectCard selectCard , int from);
|
|
||||||
|
|
||||||
void received(SelectTSK selectTSK , int from);
|
|
||||||
|
|
||||||
void received(ForceContinueGame forceContinueGame, int from);
|
|
||||||
|
|
||||||
void received(ClientStartGame clientStartGame, int from);
|
|
||||||
|
|
||||||
void received(NoPowerCard noPowerCard, int from);
|
|
||||||
|
|
||||||
void received(SelectedPieces selectedPieces, int from);
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user