Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	src/main/java/seng302/visualiser/ClientToServerThread.java
This commit is contained in:
Kusal Ekanayake
2017-09-28 15:08:53 +13:00
15 changed files with 121 additions and 39 deletions
-1
View File
@@ -105,7 +105,6 @@ public class App extends Application {
}
}, 0, 1200);
try {
parseArgs(args);
} catch (ParseException e) {
@@ -48,7 +48,7 @@ public class DiscoveryServer {
" .:;...'cxxxxxxxxxxxxoc;,::,..cdl;;l' \n" +
" .cl;':,'';oxxxxxxdxxxxxx:....,cooc,cO; \n" +
" .,,,::;,lxoc:,,:lxxxxxxxxxxxo:,,;lxxl;'oNc \n" +
" .cdxo;':lxxxxxxc'';cccccoxxxxxxxxxxxxo,.;lc. " + ANSI_YELLOW + "Party-Parrots-At-Sea Discovery Server v0.1 " + selectedColor +"\n" +
" .cdxo;':lxxxxxxc'';cccccoxxxxxxxxxxxxo,.;lc. " + ANSI_YELLOW + "Party-Parrots-At-Sea Discovery Server v1.0.0 (Release) " + selectedColor +"\n" +
" .loc'.'lxxxxxxxxocc;''''';ccoxxxxxxxxx:..oc \n" +
"olc,..',:cccccccccccc:;;;;;;;;:ccccccccc,.'c, \n" +
"Ol;......................................;l' ");
@@ -19,7 +19,7 @@ import java.util.Timer;
import java.util.TimerTask;
public class DiscoveryServerClient {
private final Integer UPDATE_INTERVAL_MS = 5000;
private final Integer UPDATE_INTERVAL_MS = 1000;
private static String roomCode = null;
private Timer serverListingUpdateTimer;
@@ -1,7 +1,7 @@
package seng302.discoveryServer.util;
public class ServerListing {
public final static int SERVER_TTL_DEFAULT = 10;
public final static int SERVER_TTL_DEFAULT = 3;
private String serverName = "";
private String mapName = "";
+1 -4
View File
@@ -13,15 +13,11 @@ import javafx.beans.property.ReadOnlyIntegerProperty;
import javafx.beans.property.ReadOnlyIntegerWrapper;
import javafx.beans.property.ReadOnlyLongProperty;
import javafx.beans.property.ReadOnlyLongWrapper;
import javafx.beans.value.ObservableObjectValue;
import javafx.collections.FXCollections;
import javafx.scene.paint.Color;
import jdk.nashorn.internal.objects.annotations.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import seng302.model.token.TokenType;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
import seng302.model.token.TokenType;
import seng302.visualiser.fxObjects.assets_3D.BoatObject;
/**
@@ -286,6 +282,7 @@ public class ClientYacht extends Observable {
public void setHeading(Double heading) {
this.heading = heading;
System.out.println(heading);
setHeadingProperty();
}
@@ -72,7 +72,6 @@ public class CompoundMark {
getSubMark(1).setRoundingSide(RoundingSide.STARBOARD);
break;
}
}
@@ -180,10 +180,12 @@ public class ClientToServerThread implements Runnable {
notifyDisconnectListeners("Connection to server was terminated");
closeSocket();
Platform.runLater(() -> {
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
//thread.interrupt();
// Platform.runLater(() -> {
// ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
// ViewManager.getInstance().goToStartView();
});
// });
}
public void sendCustomizationRequest(CustomizeRequestType reqType, byte[] payload) {
@@ -83,7 +83,7 @@ public class GameClient {
* @param ipAddress IP to connect to.
* @param portNumber Port to connect to.
*/
public void runAsClient(String ipAddress, Integer portNumber) {
public boolean runAsClient(String ipAddress, Integer portNumber) {
try {
startClientToServerThread(ipAddress, portNumber);
socketThread.addDisconnectionListener((cause) -> {
@@ -94,12 +94,19 @@ public class GameClient {
ViewManager.getInstance().setPlayerList(clientLobbyList);
while (regattaData == null){
int triesLeft = 10;
while (regattaData == null && triesLeft >= 0){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ignored) {
;
}
triesLeft--;
}
if (triesLeft < 1){
return false;
}
ViewManager.getInstance().setProperty("serverName", regattaData.getRegattaName());
@@ -112,6 +119,8 @@ public class GameClient {
} catch (IOException ioe) {
ViewManager.getInstance().showErrorSnackBar("There are no servers currently available.");
}
return true;
}
/**
@@ -1,6 +1,5 @@
package seng302.visualiser;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
@@ -35,7 +34,8 @@ public class MapMaker {
private int index = 0;
private XMLGenerator xmlGenerator = new XMLGenerator();
private List<String> maps = new ArrayList<>(Arrays.asList("default.xml", "horseshoe.xml", "loop.xml"));
private List<String> maps = new ArrayList<>(
Arrays.asList("default.xml", "horseshoe.xml", "madagascar.xml", "loop.xml"));
public static MapMaker getInstance() {
if (instance == null) {
@@ -140,7 +140,9 @@ public class ServerListController implements Initializable, ServerListenerDelega
return;
}
ViewManager.getInstance().getGameClient().runAsClient(listing.getAddress(), listing.getPortNumber());
if (!ViewManager.getInstance().getGameClient().runAsClient(listing.getAddress(), listing.getPortNumber())){
ViewManager.getInstance().showErrorSnackBar("Could not connect to server");
}
});
/*
@@ -13,7 +13,7 @@ public enum BoatMeshType {
PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl",
-0.5415, "pirateship_frontsail.stl", true, 1.2, 1.6, 1.2),
DUCKY("ducky_hull.stl", "ducky_mast.stl", -2.18539, "ducky_sail.stl", -2.18539, "ducky_eyes.stl", false, 1.2, 1.1, 1.4),
PARROT("parrot_hull.stl", null, 0, "parrot_sail.stl", 0, "parrot_features.stl", true, 1, 1, 1),
PARROT("parrot_hull.stl", null, 0, "parrot_features.stl", 0, "parrot_sail.stl", true, 1, 1, 1),
WAKA("waka_hull.stl", "waka_mast.stl", 0, "waka_sail.stl", 0, null, true, 1.7, 0.5, 1.5);
final String hullFile, mastFile, sailFile, jibFile;
@@ -100,19 +100,19 @@ public class ModelFactory {
mast.setMaterial(new PhongMaterial(primaryColour));
boatAssets.getChildren().add(mast);
} else {
boatAssets.getChildren().add(new Group());
boatAssets.getChildren().add(new MeshView());
}
MeshView sail = importBoatSTL(boatType.sailFile);
sail.setMaterial(
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
);
boatAssets.getChildren().add(sail);
if (boatType.jibFile != null) {
MeshView jib = importBoatSTL(boatType.jibFile);
jib.setMaterial(
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
);
boatAssets.getChildren().add(jib);
}
+65
View File
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<RaceDefinition>
<CourseName>Madagascar</CourseName>
<CentralLat>-15.67707</CentralLat>
<CentralLng>49.79338</CentralLng>
<MaxPlayers>10</MaxPlayers>
<Marks>
<CompoundMark CompoundMarkID="1">
<Mark Lat="-15.67466" Lng="49.79104"/>
<Mark Lat="-15.67408" Lng="49.79224"/>
</CompoundMark>
<CompoundMark CompoundMarkID="2">
<Mark Lat="-15.67548" Lng="49.79271"/>
</CompoundMark>
<CompoundMark CompoundMarkID="3">
<Mark Lat="-15.67744" Lng="49.79235"/>
</CompoundMark>
<CompoundMark CompoundMarkID="4">
<Mark Lat="-15.67691" Lng="49.79501"/>
</CompoundMark>
<CompoundMark CompoundMarkID="5">
<Mark Lat="-15.67775" Lng="49.79619"/>
<Mark Lat="-15.67827" Lng="49.79713"/>
</CompoundMark>
<CompoundMark CompoundMarkID="6">
<Mark Lat="-15.67922" Lng="49.79318"/>
<Mark Lat="-15.67972" Lng="49.79393"/>
</CompoundMark>
</Marks>
<Course>
<OpeningSegment>
<Corner CompoundMarkID="1" Rounding="PS"/>
</OpeningSegment>
<RepeatingSegment>
<Corner CompoundMarkID="2" Rounding="P"/>
<Corner CompoundMarkID="3" Rounding="S"/>
<Corner CompoundMarkID="4" Rounding="S"/>
<Corner CompoundMarkID="3" Rounding="P"/>
</RepeatingSegment>
<ClosingSegment>
<Corner CompoundMarkID="5" Rounding="PS"/>
<Corner CompoundMarkID="6" Rounding="PS"/>
</ClosingSegment>
</Course>
<CourseLimit>
<Limit Lat="-15.67571" Lng="49.78984"/>
<Limit Lat="-15.6787" Lng="49.79024"/>
<Limit Lat="-15.68046" Lng="49.79247"/>
<Limit Lat="-15.68073" Lng="49.79599"/>
<Limit Lat="-15.67939" Lng="49.79855"/>
<Limit Lat="-15.67662" Lng="49.79855"/>
<Limit Lat="-15.67474" Lng="49.79694"/>
<Limit Lat="-15.67271" Lng="49.79355"/>
<Limit Lat="-15.67333" Lng="49.79071"/>
</CourseLimit>
</RaceDefinition>