diff --git a/Projekte/.run/MdgaApp.run.xml b/Projekte/.run/MdgaApp.run.xml
index 123a07af..4c60627e 100644
--- a/Projekte/.run/MdgaApp.run.xml
+++ b/Projekte/.run/MdgaApp.run.xml
@@ -1,6 +1,5 @@
-
@@ -16,4 +15,4 @@
-
\ No newline at end of file
+
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/Asset.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/Asset.java
index 1f3da542..a24d9d1c 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/Asset.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/Asset.java
@@ -30,14 +30,14 @@ public enum Asset {
tank,
world(1.2f),
shieldRing("Models/shieldRing/shieldRing.j3o", null),
- treeSmall,
- treeBig,
+ treeSmall(1.2f),
+ treeBig(1.2f),
turboCard,
- turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.j3o"),
+ turboSymbol("Models/turboCard/turboSymbol.j3o", "Models/turboCard/turboCard_diff.png"),
swapCard,
- swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.j3o"),
+ swapSymbol("Models/swapCard/swapSymbol.j3o", "Models/swapCard/swapCard_diff.png"),
shieldCard,
- shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.j3o"),
+ shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
dice
;
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java
index b251134f..e0f657da 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/InputSynchronizer.java
@@ -17,6 +17,7 @@
import pp.mdga.client.board.OutlineControl;
import pp.mdga.client.board.PieceControl;
import pp.mdga.client.gui.CardControl;
+import pp.mdga.client.gui.DiceControl;
import pp.mdga.client.view.GameView;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
@@ -26,6 +27,7 @@
import pp.mdga.notification.SelectableCardsNotification;
import java.util.List;
+import java.util.UUID;
public class InputSynchronizer {
@@ -93,10 +95,14 @@ public void onAction(String name, boolean isPressed, float tpf) {
}
if(name.equals("Click") && isPressed) {
if (app.getView() instanceof GameView gameView) {
+ DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
- if(cardLayerSelect != null) {
+ if(diceSelect != null) {
+ app.getModelSynchronize().rolledDice();
+ }
+ else if(cardLayerSelect != null) {
//cardSelect
if(cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect);
}
@@ -118,8 +124,21 @@ else if(boardSelect != null) {
}
if(name.equals("Test") &&isPressed){
if(app.getView() instanceof GameView gameView){
-// app.getNotificationSynchronizer().addTestNotification(new FinishNotification(Color.NAVY));
-// app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification());
+// gameView.getGuiHandler().rollRankingResult(Color.AIRFORCE, 1);
+// gameView.getGuiHandler().rollRankingResult(Color.ARMY, 2);
+// gameView.getGuiHandler().rollRankingResult(Color.NAVY, 3);
+// gameView.getGuiHandler().rollRankingResult(Color.CYBER, 4);
+// gameView.getGuiHandler().showDice();
+// UUID p1 = UUID.randomUUID();
+
+// gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p1,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
+// gameView.getBoardHandler().movePieceStartAnim(p1,0);
+ gameView.getGuiHandler().drawCard(Color.ARMY);
+ gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
+ gameView.getGuiHandler().playCardOwn(BonusCard.SHIELD);
+
+
+
}
}
}
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java
index cb0371c0..69f35012 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/MdgaApp.java
@@ -2,12 +2,18 @@
import com.jme3.app.SimpleApplication;
import com.simsilica.lemur.GuiGlobals;
+import com.sun.tools.javac.Main;
import pp.mdga.client.acoustic.AcousticHandler;
import com.jme3.system.AppSettings;
import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.view.*;
+import javax.imageio.ImageIO;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.io.File;
import java.io.IOException;
+import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.prefs.Preferences;
@@ -39,7 +45,7 @@ public class MdgaApp extends SimpleApplication {
private MdgaState state = null;
/** Scale for rendering images. */
- private float imageScale = prefs.getInt("scale", 1);
+ private final float imageScale = prefs.getInt("scale", 1);
/** The main menu view. */
private MdgaView mainView;
@@ -60,7 +66,7 @@ public class MdgaApp extends SimpleApplication {
private ServerConnection networkConnection;
- private MdgaApp() {
+ public MdgaApp() {
networkConnection = new NetworkSupport(this);
this.clientGameLogic = new ClientGameLogic(networkConnection);
}
@@ -76,12 +82,15 @@ public static void main(String[] args) {
settings.setSamples(128);
settings.setWidth(prefs.getInt("width", 1280));
settings.setHeight(prefs.getInt("height", 720));
+ settings.setFullscreen(prefs.getBoolean("fullscreen", false));
settings.setCenterWindow(true);
settings.setVSync(false);
-
+ settings.setTitle("MDGA");
MdgaApp app = new MdgaApp();
app.setSettings(settings);
app.setShowSettings(false);
+ app.setPauseOnLostFocus(false);
+
app.start();
}
@@ -106,7 +115,7 @@ public void simpleInitApp() {
gameView = new GameView(this);
ceremonyView = new CeremonyView(this);
- enter(MdgaState.MAIN);
+ enter(MdgaState.GAME);
}
/**
@@ -244,30 +253,50 @@ public ServerConnection getNetworkSupport(){
return networkConnection;
}
- public void updateResolution(int width, int height, float imageFactor) {
- prefs.putInt("width", width);
- prefs.putInt("height", height);
- prefs.putFloat("scale", imageFactor);
+ public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
+ if(isFullscreen) {
+ int baseWidth = 1280;
+ int baseHeight = 720;
+ float baseAspectRatio = (float) baseWidth / baseHeight;
+ float newAspectRatio = (float) width / height;
- try {
- restartApp();
- } catch (Exception e) {
- //nothing
+ float scaleFactor = Math.max((float) width / baseWidth, (float) height / baseHeight);
+
+ settings.setFullscreen(true);
+
+ prefs.putFloat("scale", scaleFactor);
+ prefs.putBoolean("fullscreen", true);
+ } else {
+ prefs.putInt("width", width);
+ prefs.putInt("height", height);
+ prefs.putFloat("scale", imageFactor);
+ prefs.putBoolean("fullscreen", false);
}
}
- public static void restartApp() throws IOException {
- String javaBin = System.getProperty("java.home") + "/bin/java";
- String classPath = System.getProperty("java.class.path");
- String className = System.getProperty("sun.java.command");
+ public static void restartApp() {
+ try {
+ String javaBin = System.getProperty("java.home") + "/bin/java";
+ String classPath = System.getProperty("java.class.path");
+ String className = System.getProperty("sun.java.command");
- ProcessBuilder builder = new ProcessBuilder(
- javaBin, "-cp", classPath, className
- );
+ ProcessBuilder builder = new ProcessBuilder(
+ javaBin, "-cp", classPath, className
+ );
- builder.start();
+ builder.start();
- System.exit(0);
+ System.exit(0);
+ } catch (Exception e) {
+ throw new RuntimeException("restart failed");
+ }
+ }
+
+ public void afterGameCleanup() {
+ MainView main = (MainView) mainView;
+
+ main.getJoinDialog().disconnect();
+ main.getHostDialog().shutdownServer();
}
}
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java
index 4e3f64b0..cc7dd0ee 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/NotificationSynchronizer.java
@@ -26,32 +26,42 @@ public void addTestNotification(Notification n) {
public void update() {
Notification n = app.getGameLogic().getNotification();
-
- if(n != null) {
- switch (app.getState()) {
- case MAIN:
- handleMain(n);
- break;
- case LOBBY:
- handleLobby(n);
- break;
- case GAME:
- handleGame(n);
- break;
- case CEREMONY:
- handleCeremony(n);
- break;
- case NONE:
- throw new RuntimeException("no notification expected: " + n.toString());
+ while (n != null) {
+ if(n instanceof InfoNotification infoNotification) {
+ app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
+ return;
}
+
+ if(n != null) {
+ switch (app.getState()) {
+ case MAIN:
+ handleMain(n);
+ break;
+ case LOBBY:
+ handleLobby(n);
+ break;
+ case GAME:
+ handleGame(n);
+ break;
+ case CEREMONY:
+ handleCeremony(n);
+ break;
+ case NONE:
+ throw new RuntimeException("no notification expected: " + n.getClass().getName());
+ }
+ }
+
+ n = app.getGameLogic().getNotification();
}
}
private void handleMain(Notification notification) {
if (notification instanceof LobbyDialogNotification) {
app.enter(MdgaState.LOBBY);
+ } else if (notification instanceof StartDialogNotification) {
+ //nothing
} else {
- throw new RuntimeException("notification not expected: ");
+ throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName());
}
}
@@ -61,6 +71,7 @@ private void handleLobby(Notification notification) {
if (notification instanceof TskSelectNotification n) {
lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
} else if (notification instanceof StartDialogNotification) {
+ app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else if (notification instanceof TskUnselectNotification n) {
lobbyView.setTaken(n.getColor(), false, false, null);
@@ -70,7 +81,7 @@ private void handleLobby(Notification notification) {
app.enter(MdgaState.GAME);
((GameView) app.getView()).setOwnColor(n.getOwnColor());
} else {
- throw new RuntimeException("notification not expected: " + notification.toString());
+ throw new RuntimeException("notification not expected in lobby: " + notification.getClass().getName());
}
}
@@ -81,7 +92,7 @@ private void handleGame(Notification notification) {
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
if (notification instanceof AcquireCardNotification n) {
- guiHandler.addCard(n.getBonusCard());
+ guiHandler.addCardOwn(n.getBonusCard());
} else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor());
boardHandler.showDice(n.getColor());
@@ -136,18 +147,15 @@ private void handleGame(Notification notification) {
} else if (notification instanceof NoShieldNotification n) {
boardHandler.unshieldPiece(n.getPieceId());
} else if (notification instanceof PlayCardNotification n) {
- switch(n.getCard()){
- case SWAP -> guiHandler.swap();
- case TURBO -> guiHandler.turbo();
- case SHIELD -> guiHandler.shield();
- default -> throw new RuntimeException("invalid card");
- }
+ if(n.getColor() == gameView.getOwnColor()) guiHandler.playCardOwn(n.getCard());
+ else guiHandler.playCardEnemy(n.getColor(), n.getCard());
} else if (notification instanceof PlayerInGameNotification n) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) {
//ignore
} else if (notification instanceof RollDiceNotification n) {
+ gameView.getGuiHandler().hideText();
if(n.getColor() == gameView.getOwnColor()){
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
}
@@ -163,6 +171,7 @@ private void handleGame(Notification notification) {
} else if (notification instanceof ShieldSuppressedNotification n) {
boardHandler.suppressShield(n.getPieceId());
} else if (notification instanceof StartDialogNotification) {
+ app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else if (notification instanceof SwapPieceNotification n) {
// boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
@@ -183,15 +192,16 @@ private void handleGame(Notification notification) {
} else if (notification instanceof FinishNotification n){
guiHandler.finish(n.getColorFinished());
} else {
- throw new RuntimeException("notification not expected: " + notification.toString());
+ throw new RuntimeException("notification not expected in game: " + notification.getClass().getName());
}
}
private void handleCeremony(Notification notification) {
if (notification instanceof StartDialogNotification) {
+ app.afterGameCleanup();
app.enter(MdgaState.MAIN);
} else {
- throw new RuntimeException("notification not expected: " + notification.toString());
+ throw new RuntimeException("notification not expected in ceremony: " + notification.getClass().getName());
}
}
}
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java
index 57da8393..82e333d5 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/CameraHandler.java
@@ -7,6 +7,8 @@
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
+import com.jme3.post.filters.FXAAFilter;
+import com.jme3.post.ssao.SSAOFilter;
import com.jme3.scene.Spatial;
import com.jme3.shadow.DirectionalLightShadowFilter;
import com.jme3.shadow.EdgeFilteringMode;
@@ -37,6 +39,8 @@ public class CameraHandler {
private Color ownColor;
private boolean init;
private boolean initRot;
+ private SSAOFilter ssaoFilter;
+ private FXAAFilter fxaaFilter;
/**
* Constructor for the CameraHandler. Initializes the camera settings and lighting.
@@ -65,6 +69,9 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
dlsf.setEnabled(true);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
dlsf.setShadowIntensity(0.7f);
+ ssaoFilter = new SSAOFilter(6, 10f, 0.33f, 0.61f);
+// ssaoFilter = new SSAOFilter();
+ fxaaFilter = new FXAAFilter();
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);
@@ -82,6 +89,8 @@ public void init(Color ownColor) {
app.getRootNode().addLight(ambient);
app.getRootNode().attachChild(sky);
fpp.addFilter(dlsf);
+ fpp.addFilter(ssaoFilter);
+ fpp.addFilter(fxaaFilter);
init = true;
initRot = true;
this.ownColor = ownColor;
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/MapLoader.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/MapLoader.java
index 9d283f8f..76b286da 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/board/MapLoader.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/board/MapLoader.java
@@ -107,8 +107,8 @@ private static Asset getLoadedAsset(String assetName) {
case "radar" -> Asset.radar;
case "ship" -> Asset.ship;
case "tank" -> Asset.tank;
- case "tree_small" -> Asset.treeSmall;
- case "tree_big" -> Asset.treeBig;
+ case "treeSmall" -> Asset.treeSmall;
+ case "treeBig" -> Asset.treeBig;
default -> throw new IllegalStateException("Unexpected value: " + assetName);
};
}
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java
index 067ba3c7..eedd8cb8 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/JoinDialog.java
@@ -92,4 +92,16 @@ public void resetPort() {
public void connectToServer() {
connectServer();
}
+
+ public void disconnect() {
+ NetworkSupport network = getNetwork();
+ if (network != null) {
+ try {
+ network.disconnect();
+ } catch (Exception e) {
+ System.err.println("Error while disconnecting: " + e.getMessage());
+ }
+ }
+ }
}
+
diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/NetworkDialog.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/NetworkDialog.java
index 15c680e9..d44de294 100644
--- a/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/NetworkDialog.java
+++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/dialog/NetworkDialog.java
@@ -14,6 +14,8 @@ public abstract class NetworkDialog extends Dialog {
private String hostname;
private int portNumber;
private Future