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); }, 0, 1200);
try { try {
parseArgs(args); parseArgs(args);
} catch (ParseException e) { } catch (ParseException e) {
@@ -48,7 +48,7 @@ public class DiscoveryServer {
" .:;...'cxxxxxxxxxxxxoc;,::,..cdl;;l' \n" + " .:;...'cxxxxxxxxxxxxoc;,::,..cdl;;l' \n" +
" .cl;':,'';oxxxxxxdxxxxxx:....,cooc,cO; \n" + " .cl;':,'';oxxxxxxdxxxxxx:....,cooc,cO; \n" +
" .,,,::;,lxoc:,,:lxxxxxxxxxxxo:,,;lxxl;'oNc \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" + " .loc'.'lxxxxxxxxocc;''''';ccoxxxxxxxxx:..oc \n" +
"olc,..',:cccccccccccc:;;;;;;;;:ccccccccc,.'c, \n" + "olc,..',:cccccccccccc:;;;;;;;;:ccccccccc,.'c, \n" +
"Ol;......................................;l' "); "Ol;......................................;l' ");
@@ -19,7 +19,7 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
public class DiscoveryServerClient { public class DiscoveryServerClient {
private final Integer UPDATE_INTERVAL_MS = 5000; private final Integer UPDATE_INTERVAL_MS = 1000;
private static String roomCode = null; private static String roomCode = null;
private Timer serverListingUpdateTimer; private Timer serverListingUpdateTimer;
@@ -1,7 +1,7 @@
package seng302.discoveryServer.util; package seng302.discoveryServer.util;
public class ServerListing { public class ServerListing {
public final static int SERVER_TTL_DEFAULT = 10; public final static int SERVER_TTL_DEFAULT = 3;
private String serverName = ""; private String serverName = "";
private String mapName = ""; 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.ReadOnlyIntegerWrapper;
import javafx.beans.property.ReadOnlyLongProperty; import javafx.beans.property.ReadOnlyLongProperty;
import javafx.beans.property.ReadOnlyLongWrapper; import javafx.beans.property.ReadOnlyLongWrapper;
import javafx.beans.value.ObservableObjectValue;
import javafx.collections.FXCollections;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import jdk.nashorn.internal.objects.annotations.Function;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import seng302.model.token.TokenType; import seng302.model.token.TokenType;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType; import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
import seng302.model.token.TokenType;
import seng302.visualiser.fxObjects.assets_3D.BoatObject; import seng302.visualiser.fxObjects.assets_3D.BoatObject;
/** /**
@@ -286,6 +282,7 @@ public class ClientYacht extends Observable {
public void setHeading(Double heading) { public void setHeading(Double heading) {
this.heading = heading; this.heading = heading;
System.out.println(heading);
setHeadingProperty(); setHeadingProperty();
} }
@@ -72,7 +72,6 @@ public class CompoundMark {
getSubMark(1).setRoundingSide(RoundingSide.STARBOARD); getSubMark(1).setRoundingSide(RoundingSide.STARBOARD);
break; break;
} }
} }
@@ -180,10 +180,12 @@ public class ClientToServerThread implements Runnable {
notifyDisconnectListeners("Connection to server was terminated"); notifyDisconnectListeners("Connection to server was terminated");
closeSocket(); closeSocket();
Platform.runLater(() -> { //thread.interrupt();
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
// Platform.runLater(() -> {
// ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
// ViewManager.getInstance().goToStartView(); // ViewManager.getInstance().goToStartView();
}); // });
} }
public void sendCustomizationRequest(CustomizeRequestType reqType, byte[] payload) { public void sendCustomizationRequest(CustomizeRequestType reqType, byte[] payload) {
@@ -83,7 +83,7 @@ public class GameClient {
* @param ipAddress IP to connect to. * @param ipAddress IP to connect to.
* @param portNumber Port to connect to. * @param portNumber Port to connect to.
*/ */
public void runAsClient(String ipAddress, Integer portNumber) { public boolean runAsClient(String ipAddress, Integer portNumber) {
try { try {
startClientToServerThread(ipAddress, portNumber); startClientToServerThread(ipAddress, portNumber);
socketThread.addDisconnectionListener((cause) -> { socketThread.addDisconnectionListener((cause) -> {
@@ -94,12 +94,19 @@ public class GameClient {
ViewManager.getInstance().setPlayerList(clientLobbyList); ViewManager.getInstance().setPlayerList(clientLobbyList);
while (regattaData == null){ int triesLeft = 10;
while (regattaData == null && triesLeft >= 0){
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) { } catch (InterruptedException ignored) {
e.printStackTrace(); ;
} }
triesLeft--;
}
if (triesLeft < 1){
return false;
} }
ViewManager.getInstance().setProperty("serverName", regattaData.getRegattaName()); ViewManager.getInstance().setProperty("serverName", regattaData.getRegattaName());
@@ -112,6 +119,8 @@ public class GameClient {
} catch (IOException ioe) { } catch (IOException ioe) {
ViewManager.getInstance().showErrorSnackBar("There are no servers currently available."); ViewManager.getInstance().showErrorSnackBar("There are no servers currently available.");
} }
return true;
} }
/** /**
@@ -1,6 +1,5 @@
package seng302.visualiser; package seng302.visualiser;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
@@ -35,7 +34,8 @@ public class MapMaker {
private int index = 0; private int index = 0;
private XMLGenerator xmlGenerator = new XMLGenerator(); 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() { public static MapMaker getInstance() {
if (instance == null) { if (instance == null) {
@@ -140,7 +140,9 @@ public class ServerListController implements Initializable, ServerListenerDelega
return; 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", 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), -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), 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); 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; final String hullFile, mastFile, sailFile, jibFile;
@@ -100,19 +100,19 @@ public class ModelFactory {
mast.setMaterial(new PhongMaterial(primaryColour)); mast.setMaterial(new PhongMaterial(primaryColour));
boatAssets.getChildren().add(mast); boatAssets.getChildren().add(mast);
} else { } else {
boatAssets.getChildren().add(new Group()); boatAssets.getChildren().add(new MeshView());
} }
MeshView sail = importBoatSTL(boatType.sailFile); MeshView sail = importBoatSTL(boatType.sailFile);
sail.setMaterial( sail.setMaterial(
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE) new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
); );
boatAssets.getChildren().add(sail); boatAssets.getChildren().add(sail);
if (boatType.jibFile != null) { if (boatType.jibFile != null) {
MeshView jib = importBoatSTL(boatType.jibFile); MeshView jib = importBoatSTL(boatType.jibFile);
jib.setMaterial( jib.setMaterial(
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE) new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
); );
boatAssets.getChildren().add(jib); 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>
@@ -0,0 +1,9 @@
package seng302.utilities;
/**
* Created by cir27 on 28/09/17.
*/
public class MapMakerTest {
// @Test
}
+16 -16
View File
@@ -16,26 +16,26 @@ public class CustomMapsSteps {
@Given("^that the game has multiple race xml files$") @Given("^that the game has multiple race xml files$")
public void that_the_game_has_multiple_race_xml_files() throws Throwable { public void that_the_game_has_multiple_race_xml_files() throws Throwable {
// mapMaker = MapMaker.getInstance(); mapMaker = MapMaker.getInstance();
// String firstMap = mapMaker.getCurrentRacePath(); String firstMap = mapMaker.getCurrentRacePath();
// int numMaps = 0; int numMaps = 0;
// do { do {
// mapMaker.next(); mapMaker.next();
// numMaps++; numMaps++;
// } while (!mapMaker.getCurrentRacePath().equals(firstMap)); } while (!mapMaker.getCurrentRacePath().equals(firstMap));
// Assert.assertTrue(numMaps >= 2); Assert.assertTrue(numMaps >= 2);
} }
@Then("^all of them can be seen$") @Then("^all of them can be seen$")
public void all_of_them_can_be_seen() throws Throwable { public void all_of_them_can_be_seen() throws Throwable {
// File[] files = new File(this.getClass().getResource("/maps/").getPath()).listFiles(); File[] files = new File(this.getClass().getResource("/maps/").getPath()).listFiles();
// for (File file : files) { for (File file : files) {
// if (file.isFile()) { if (file.isFile()) {
// Assert.assertTrue(file.getAbsolutePath().equals(mapMaker.getCurrentRacePath())); Assert.assertTrue(file.getAbsolutePath().equals(mapMaker.getCurrentRacePath()));
// mapMaker.next(); mapMaker.next();
// System.out.println(file.getAbsolutePath()); System.out.println(file.getAbsolutePath());
// } }
// } }
} }
@Given("^that I choose a race$") @Given("^that I choose a race$")