merge dev into test #28

Merged
j23f0712 merged 29 commits from development into dev/test 2024-12-01 23:11:24 +01:00
22 changed files with 125 additions and 406 deletions
Showing only changes of commit 9cb7a156bb - Show all commits

View File

@@ -6,7 +6,7 @@
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" /> <option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage"> <extension name="coverage">
<pattern> <pattern>
<option name="PATTERN" value="pp.mdga.client.board.Outline.*" /> <option name="PATTERN" value="pp.mdga.client.board.outline.*" />
<option name="ENABLED" value="true" /> <option name="ENABLED" value="true" />
</pattern> </pattern>
</extension> </extension>

View File

@@ -44,13 +44,13 @@ public enum Asset {
private final String modelPath; private final String modelPath;
private final String diffPath; private final String diffPath;
private final float size; private final float size;
private static final String root = "Models/"; private static final String ROOT = "Models/";
/** /**
* Default constructor. Initializes modelPath and diffPath based on the enum name and sets default size to 1.0. * Default constructor. Initializes modelPath and diffPath based on the enum name and sets default size to 1.0.
*/ */
Asset() { Asset() {
String folderFileName = "./" + root + name() + "/" + name(); String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = folderFileName + ".j3o"; this.modelPath = folderFileName + ".j3o";
this.diffPath = folderFileName + "_diff.png"; this.diffPath = folderFileName + "_diff.png";
this.size = 1f; this.size = 1f;
@@ -74,7 +74,7 @@ public enum Asset {
* @param modelPath Path to the 3D model file. * @param modelPath Path to the 3D model file.
*/ */
Asset(String modelPath) { Asset(String modelPath) {
String folderFileName = "./" + root + name() + "/" + name(); String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = modelPath; this.modelPath = modelPath;
this.diffPath = folderFileName + "_diff.png";; this.diffPath = folderFileName + "_diff.png";;
this.size = 1f; this.size = 1f;
@@ -86,7 +86,7 @@ public enum Asset {
* @param size Scaling factor for the asset. * @param size Scaling factor for the asset.
*/ */
Asset(float size) { Asset(float size) {
String folderFileName = "./" + root + name() + "/" + name(); String folderFileName = "./" + ROOT + name() + "/" + name();
this.modelPath = folderFileName + ".j3o"; this.modelPath = folderFileName + ".j3o";
this.diffPath = folderFileName + "_diff.png"; this.diffPath = folderFileName + "_diff.png";
this.size = size; this.size = size;

View File

@@ -130,9 +130,7 @@ public void setJoin(String ip, int port) {
} }
public void leave() { public void leave() {
LOGGER.log(Level.INFO, "leave"); app.getGameLogic().selectLeave();
app.getAcousticHandler().playSound(MdgaSound.LEAVE);
enter(MdgaState.MAIN);
} }
public void enter(MdgaState state) { public void enter(MdgaState state) {

View File

@@ -20,7 +20,7 @@ enum MusicAsset {
private final String path; private final String path;
private final boolean loop; private final boolean loop;
private final float subVolume; private final float subVolume;
private static final String root = "Music/"; private static final String ROOT = "Music/";
/** /**
* Constructs a new MusicAsset object with the specified name and sub-volume. * Constructs a new MusicAsset object with the specified name and sub-volume.
@@ -30,7 +30,7 @@ enum MusicAsset {
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage). * @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
*/ */
MusicAsset(String name, float subVolume) { MusicAsset(String name, float subVolume) {
this.path = root + name; this.path = ROOT + name;
this.loop = false; this.loop = false;
this.subVolume = subVolume; this.subVolume = subVolume;
} }
@@ -43,7 +43,7 @@ enum MusicAsset {
* @param subVolume A relative volume that modifies the base volume of the track (typically a percentage). * @param subVolume A relative volume that modifies the base volume of the track (typically a percentage).
*/ */
MusicAsset(String name, boolean loop, float subVolume) { MusicAsset(String name, boolean loop, float subVolume) {
this.path = root + name; this.path = ROOT + name;
this.loop = loop; this.loop = loop;
this.subVolume = subVolume; this.subVolume = subVolume;
} }

View File

@@ -1,79 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.MaterialDef;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.FrameBuffer;
public class OutlineFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/Outline.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
// System.out.println("OutlineFilter.preFrame()");
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
// material.setTexture("OutlineDepthTexture", outlinePreFilter.getDefaultPassDepthTexture());
// System.out.println("OutlineFilter.postFrame()");
}
@Override
protected Material getMaterial() {
return material;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public float getOutlineWidth() {
return outlineWidth;
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
}

View File

@@ -1,67 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
public class OutlinePreFilter extends Filter {
private Pass normalPass;
private RenderManager renderManager;
/**
* Creates a OutlinePreFilter
*/
public OutlinePreFilter() {
super("OutlinePreFilter");
}
@Override
protected boolean isRequiresDepthTexture() {
return true;
}
@Override
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, false);
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
}
@Override
protected Material getMaterial() {
return material;
}
public Texture getOutlineTexture() {
return normalPass.getRenderedTexture();
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "MatDefs/SelectObjectOutliner/OutlinePre.j3md");
}
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
}

View File

@@ -1,79 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.material.MaterialDef;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.FrameBuffer;
public class OutlineProFilter extends Filter {
private OutlinePreFilter outlinePreFilter;
private ColorRGBA outlineColor = new ColorRGBA(0, 1, 0, 1);
private float outlineWidth = 1;
public OutlineProFilter(OutlinePreFilter outlinePreFilter) {
super("OutlineFilter");
this.outlinePreFilter = outlinePreFilter;
}
@Override
protected void initFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) {
MaterialDef matDef = (MaterialDef) assetManager.loadAsset("MatDefs/SelectObjectOutliner/OutlinePro.j3md");
material = new Material(matDef);
material.setVector2("Resolution", new Vector2f(w, h));
material.setColor("OutlineColor", outlineColor);
material.setFloat("OutlineWidth", outlineWidth);
}
@Override
protected void preFrame(float tpf) {
super.preFrame(tpf);
material.setTexture("OutlineDepthTexture", outlinePreFilter.getOutlineTexture());
// System.out.println("OutlineFilter.preFrame()");
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
// material.setTexture("OutlineDepthTexture", outlinePreFilter.getDefaultPassDepthTexture());
// System.out.println("OutlineFilter.postFrame()");
}
@Override
protected Material getMaterial() {
return material;
}
public ColorRGBA getOutlineColor() {
return outlineColor;
}
public void setOutlineColor(ColorRGBA outlineColor) {
this.outlineColor = outlineColor;
if (material != null) {
material.setColor("OutlineColor", outlineColor);
}
}
public float getOutlineWidth() {
return outlineWidth;
}
public void setOutlineWidth(float outlineWidth) {
this.outlineWidth = outlineWidth;
if (material != null) {
material.setFloat("OutlineWidth", outlineWidth);
}
}
public OutlinePreFilter getOutlinePreFilter() {
return outlinePreFilter;
}
}

View File

@@ -1,88 +0,0 @@
package pp.mdga.client.board.Outline;
import com.jme3.asset.AssetManager;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial;
import pp.mdga.client.MdgaApp;
public class SelectObjectOutliner {
private final FilterPostProcessor fpp;
private final RenderManager renderManager;
private final AssetManager assetManager;
private final Camera cam;
private final int width;
private boolean selected;
private ViewPort outlineViewport = null;
// private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null;
private final MdgaApp app;
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam, MdgaApp app) {
this.selected = false;
this.fpp = fpp;
this.renderManager = renderManager;
this.assetManager = assetManager;
this.cam = cam;
this.width = width;
this.app = app;
}
public void deselect(Spatial model) {
if(selected){
selected = false;
hideOutlineFilterEffect(model);
}
}
public void select(Spatial model, ColorRGBA color) {
if(!selected){
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
public void select(Spatial model, ColorRGBA color, int width) {
if(!selected){
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
private void hideOutlineFilterEffect(Spatial model) {
// app.enqueue(() -> {
outlineFilter.setEnabled(false);
outlineFilter.getOutlinePreFilter().setEnabled(false);
fpp.removeFilter(outlineFilter);
outlineViewport.detachScene(model);
outlineViewport.clearProcessors();
renderManager.removePreView(outlineViewport);
outlineViewport = null;
// return null;
// });
}
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
// app.enqueue(() -> {
outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
outlineFpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp);
outlineFilter = new OutlineProFilter(outlinePreFilter);
outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineWidth(width);
fpp.addFilter(outlineFilter);
// return null;
// });
}
}

View File

@@ -8,7 +8,7 @@
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.MdgaApp; import pp.mdga.client.MdgaApp;
import pp.mdga.client.board.Outline.SelectObjectOutliner; import pp.mdga.client.board.outline.SelectObjectOutliner;
public class OutlineControl extends AbstractControl { public class OutlineControl extends AbstractControl {
private static final int THICKNESS_DEFAULT = 6; private static final int THICKNESS_DEFAULT = 6;

View File

@@ -197,14 +197,14 @@ protected void setImageRelative(Picture picture) {
return; return;
} }
final float LARGER = 10; final float larger = 10;
picture.setWidth(instance.getPreferredSize().x + LARGER); picture.setWidth(instance.getPreferredSize().x + larger);
picture.setHeight(instance.getPreferredSize().y + LARGER); picture.setHeight(instance.getPreferredSize().y + larger);
picture.setLocalTranslation( picture.setLocalTranslation(
instance.getLocalTranslation().x - LARGER / 2, instance.getLocalTranslation().x - larger / 2,
(instance.getLocalTranslation().y - picture.getHeight()) + LARGER / 2, (instance.getLocalTranslation().y - picture.getHeight()) + larger / 2,
instance.getLocalTranslation().z + 0.01f instance.getLocalTranslation().z + 0.01f
); );
} }

View File

@@ -28,5 +28,6 @@ public void hide() {
} }
protected abstract void onShow(); protected abstract void onShow();
protected abstract void onHide(); protected abstract void onHide();
} }

View File

@@ -65,6 +65,7 @@ public void update(float delta) {
try { try {
this.connectionFuture.get(); this.connectionFuture.get();
} catch (ExecutionException ignored) { } catch (ExecutionException ignored) {
// todo: implement
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }

View File

@@ -4,7 +4,6 @@
import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager; import com.jme3.app.state.AppStateManager;
import com.jme3.light.DirectionalLight; import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
@@ -15,16 +14,16 @@
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.shadow.DirectionalLightShadowFilter; import com.jme3.shadow.DirectionalLightShadowFilter;
import com.jme3.shadow.DirectionalLightShadowRenderer;
import com.jme3.shadow.EdgeFilteringMode; import com.jme3.shadow.EdgeFilteringMode;
import com.jme3.texture.Image; import com.jme3.texture.Image;
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
import pp.mdga.client.Asset;
import java.util.*; import java.util.*;
public class CardLayer extends AbstractAppState { public class CardLayer extends AbstractAppState {
public static final int SHADOWMAP_SIZE = 1024 * 8;
private Node root; private Node root;
private Application app; private Application app;
private boolean init; private boolean init;
@@ -60,8 +59,6 @@ public void initialize(AppStateManager stateManager, Application app ) {
sun.setDirection(new Vector3f(.5f, -.5f, -1)); sun.setDirection(new Vector3f(.5f, -.5f, -1));
root.addLight(sun); root.addLight(sun);
final int SHADOWMAP_SIZE=1024*8;
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3); DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(app.getAssetManager(), SHADOWMAP_SIZE, 3);
dlsf.setLight(sun); dlsf.setLight(sun);
dlsf.setEnabled(true); dlsf.setEnabled(true);
@@ -80,7 +77,6 @@ public void shutdown(){
} }
@Override @Override
public void render(RenderManager rm) { public void render(RenderManager rm) {
root.updateGeometricState(); root.updateGeometricState();

View File

@@ -16,8 +16,7 @@ public class SymbolControl extends AbstractControl {
private BonusCard state; private BonusCard state;
private float rotationSpeed = 0.8f; private float rotationSpeed = 0.8f;
private Quaternion initialRotation = null; private Quaternion initialRotation = null;
private float Y = 5; private float y = 5;
@Override @Override
@@ -80,11 +79,12 @@ private void swapUpdate(float tpf){
spatial.removeFromParent(); spatial.removeFromParent();
} }
} }
private void turboUpdate(float tpf) { private void turboUpdate(float tpf) {
if (zoomingIn) { if (zoomingIn) {
progress += tpf * zoomSpeed; progress += tpf * zoomSpeed;
if (progress > 1) progress = 1; if (progress > 1) progress = 1;
float y = lerp(-Y,0, easeOut(progress)); float y = lerp(-this.y, 0, easeOut(progress));
spatial.setLocalTranslation(0, y, 0); spatial.setLocalTranslation(0, y, 0);
if (progress >= 1) { if (progress >= 1) {
zoomingIn = false; zoomingIn = false;
@@ -93,7 +93,7 @@ private void turboUpdate(float tpf){
} }
} else if (zoomingOut) { } else if (zoomingOut) {
progress += tpf * zoomSpeed; progress += tpf * zoomSpeed;
float y = lerp(0,Y, easeIn(progress)); float y = lerp(0, this.y, easeIn(progress));
spatial.setLocalTranslation(0, y, 0); spatial.setLocalTranslation(0, y, 0);
if (progress > 1) { if (progress > 1) {
zoomingIn = false; zoomingIn = false;

View File

@@ -12,7 +12,8 @@ public class ZoomControl extends AbstractControl {
private float zoomSpeed = 1f; private float zoomSpeed = 1f;
private float zoomFactor = 1f; private float zoomFactor = 1f;
public ZoomControl(){} public ZoomControl() {
}
public ZoomControl(float speed) { public ZoomControl(float speed) {
zoomSpeed = speed; zoomSpeed = speed;
@@ -72,6 +73,7 @@ private float easeOut(float x) {
return x == 1 ? 1 : (float) (1 - Math.pow(2, -10 * x)); return x == 1 ? 1 : (float) (1 - Math.pow(2, -10 * x));
} }
// private float easeIn(float t) { // private float easeIn(float t) {
// return t * t * t * t; // return t * t * t * t;
// } // }

View File

@@ -14,6 +14,7 @@
import java.io.IOException; import java.io.IOException;
import java.lang.System.Logger; import java.lang.System.Logger;
import java.lang.System.Logger.Level; import java.lang.System.Logger.Level;
import java.net.InetAddress;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
@@ -52,6 +53,7 @@ public MdgaServer(int port) {
LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
logic = new ServerGameLogic(this, new Game()); logic = new ServerGameLogic(this, new Game());
} }
/** /**
* *
*/ */
@@ -67,13 +69,13 @@ public void run() {
private void startServer() { private void startServer() {
try { try {
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
myServer = Network.createServer(port); myServer = Network.createServer(port);
initializeSerializables(); initializeSerializables();
myServer.start(); myServer.start();
registerListeners(); registerListeners();
LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS
} } catch (IOException e) {
catch (IOException e) {
LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS
exit(1); exit(1);
} }
@@ -190,6 +192,7 @@ private void messageReceived(HostedConnection source, ClientMessage message) {
@Override @Override
public void connectionAdded(Server server, HostedConnection hostedConnection) { public void connectionAdded(Server server, HostedConnection hostedConnection) {
System.out.println("new connection " + hostedConnection); //NON-NLS
LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS
} }

View File

@@ -102,25 +102,23 @@ private void tryHost() {
if(port >= 1 && port <= 65535) { if(port >= 1 && port <= 65535) {
app.getModelSynchronize().setName(startDialog.getName()); app.getModelSynchronize().setName(startDialog.getName());
hostDialog.setHostname(Inet4Address.getLocalHost().getHostAddress());
hostDialog.hostServer(); hostDialog.hostServer();
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
// todo: implement
} }
hostDialog.connectServerAsClient(); hostDialog.connectServerAsClient();
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
// todo: implement
} }
app.getModelSynchronize().setHost(port); app.getModelSynchronize().setHost(port);
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); //app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return; return;
} }
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
//nothing
} catch (UnknownHostException e) {
throw new RuntimeException(e);
} }
hostDialog.resetPort(); hostDialog.resetPort();
@@ -130,7 +128,7 @@ private void tryHost() {
private void tryJoin() { private void tryJoin() {
int port = 0; int port = 0;
String ip = joinDialog.getIpt(); String ip = joinDialog.getIpt();
String portText = hostDialog.getPort(); String portText = joinDialog.getPort();
try { try {
// Validate the port // Validate the port
@@ -138,19 +136,24 @@ private void tryJoin() {
if (port < 1 || port > 65535) { if (port < 1 || port > 65535) {
throw new IllegalArgumentException("Invalid port"); throw new IllegalArgumentException("Invalid port");
} }
joinDialog.setPortNumber(port);
// Validate the IP address // Validate the IP address
if (isValidIpAddress(ip)) { if (isValidIpAddress(ip)) {
app.getModelSynchronize().setName(startDialog.getName()); app.getModelSynchronize().setName(startDialog.getName());
app.getModelSynchronize().setJoin(ip, port); joinDialog.setHostname(ip);
joinDialog.connectToServer(); joinDialog.connectToServer();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
app.getModelSynchronize().setJoin(ip, port);
return; return;
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// Invalid input, fall through to reset // Invalid input, fall through to reset
} }
hostDialog.resetPort(); joinDialog.resetPort();
joinDialog.resetIp(); joinDialog.resetIp();
app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
} }

View File

@@ -84,10 +84,14 @@ public void update(float tpf) {
} }
protected abstract void onEnter(); protected abstract void onEnter();
protected abstract void onLeave(); protected abstract void onLeave();
protected void onUpdate(float tpf) {}
protected void onUpdate(float tpf) {
}
protected abstract void onEnterOverlay(Overlay overlay); protected abstract void onEnterOverlay(Overlay overlay);
protected abstract void onLeaveOverlay(Overlay overlay); protected abstract void onLeaveOverlay(Overlay overlay);
protected Geometry createBackground(String texturePath) { protected Geometry createBackground(String texturePath) {

View File

@@ -174,9 +174,9 @@ public LobbyState getLobbyState() {
} }
/** /**
* This method will be used to return gameState attribute of ServerGameLogic class. * This method will be used to return gamestate attribute of ServerGameLogic class.
* *
* @return gameState as a GameState object. * @return gamestate as a GameState object.
*/ */
public GameState getGameState() { public GameState getGameState() {
return this.gameState; return this.gameState;
@@ -192,9 +192,9 @@ public InterruptState getInterruptState() {
} }
/** /**
* This method will be used to return ceremonyState attribute of ServerGameLogic class. * This method will be used to return ceremonystate attribute of ServerGameLogic class.
* *
* @return ceremonyState as a CeremonyState object. * @return ceremonystate as a CeremonyState object.
*/ */
public CeremonyState getCeremonyState() { public CeremonyState getCeremonyState() {
return this.ceremonyState; return this.ceremonyState;

View File

@@ -45,7 +45,7 @@ public void exit() {
/** /**
* This method will be called whenever the server received a JoinedLobbyMessage message. * This method will be called whenever the server received a JoinedLobbyMessage message.
* It will also get the client id of the player who send this messag * It will also get the client id of the player who send this message
* *
* @param msg as the message which was sent by the player as a JoinedLobbyMessage object. * @param msg as the message which was sent by the player as a JoinedLobbyMessage object.
* @param from as the client id of the player as an Integer. * @param from as the client id of the player as an Integer.

View File

@@ -0,0 +1,31 @@
package pp.mdga.server.automaton.game.turn.rolldice;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.RollDiceState;
public class FirstRollState extends RollDiceAutomatonState {
/**
* Create FirstRollState constants.
*/
private static final System.Logger LOGGER = System.getLogger(FirstRollState.class.getName());
/**
* Constructs a server state of the specified game logic.
*
* @param rollDiceAutomaton as the automaton of the roll dice state as a RollDiceState object.
* @param logic the game logic
*/
public FirstRollState(RollDiceState rollDiceAutomaton, ServerGameLogic logic) {
super(rollDiceAutomaton, logic);
}
@Override
public void enter() {
LOGGER.log(System.Logger.Level.DEBUG, "Entered FirstRollState state.");
}
@Override
public void exit() {
LOGGER.log(System.Logger.Level.DEBUG, "Exited FirstRollStatte state.");
}
}

View File

@@ -1,7 +0,0 @@
package pp.mdga.server.automaton.game.turn.rolldice;
import pp.mdga.server.ServerGameLogic;
import pp.mdga.server.automaton.game.turn.RollDiceState;
public class FirstRollStateState {
}