mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Everything works. Needs a bit of polish, and possibly look at boat shapes next.
tags: #story[1142]
This commit is contained in:
@@ -60,6 +60,8 @@ public class GameState implements Runnable {
|
|||||||
public static Double windDirection;
|
public static Double windDirection;
|
||||||
private static Double windSpeed;
|
private static Double windSpeed;
|
||||||
|
|
||||||
|
private static Boolean customizationFlag;
|
||||||
|
|
||||||
private static String hostIpAddress;
|
private static String hostIpAddress;
|
||||||
private static List<Player> players;
|
private static List<Player> players;
|
||||||
private static Map<Integer, ServerYacht> yachts;
|
private static Map<Integer, ServerYacht> yachts;
|
||||||
@@ -91,6 +93,7 @@ public class GameState implements Runnable {
|
|||||||
yachts = new HashMap<>();
|
yachts = new HashMap<>();
|
||||||
players = new ArrayList<>();
|
players = new ArrayList<>();
|
||||||
GameState.hostIpAddress = hostIpAddress;
|
GameState.hostIpAddress = hostIpAddress;
|
||||||
|
customizationFlag = false;
|
||||||
|
|
||||||
currentStage = GameStages.LOBBYING;
|
currentStage = GameStages.LOBBYING;
|
||||||
isRaceStarted = false;
|
isRaceStarted = false;
|
||||||
@@ -668,4 +671,16 @@ public class GameState implements Runnable {
|
|||||||
public static void addMarkPassListener(NewMessageListener listener) {
|
public static void addMarkPassListener(NewMessageListener listener) {
|
||||||
markListeners.add(listener);
|
markListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setCustomizationFlag() {
|
||||||
|
customizationFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getCustomizationFlag() {
|
||||||
|
return customizationFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetCustomizationFlag() {
|
||||||
|
customizationFlag = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,13 +76,13 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
serverLog("Interrupted exception in Main Server Thread thread sleep", 1);
|
serverLog("Interrupted exception in Main Server Thread thread sleep", 1);
|
||||||
}
|
}
|
||||||
|
if (GameState.getCurrentStage() == GameStages.LOBBYING && GameState
|
||||||
if (GameState.getCurrentStage() == GameStages.LOBBYING) {
|
.getCustomizationFlag()) {
|
||||||
// TODO: 16/08/17 ajm412: This can probably be done in a nicer way via those fancy functional interfaces.
|
// TODO: 16/08/17 ajm412: This can probably be done in a nicer way via those fancy functional interfaces.
|
||||||
for (ServerToClientThread thread : serverToClientThreads) {
|
for (ServerToClientThread thread : serverToClientThreads) {
|
||||||
thread.sendSetupMessages();
|
thread.sendSetupMessages();
|
||||||
}
|
}
|
||||||
|
GameState.resetCustomizationFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
|
if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public class ServerToClientThread implements Runnable, Observer {
|
|||||||
new StreamPacket(type, payloadLength, timeStamp, payload));
|
new StreamPacket(type, payloadLength, timeStamp, payload));
|
||||||
GameState.customizePlayer(sourceID, requestType,
|
GameState.customizePlayer(sourceID, requestType,
|
||||||
Arrays.copyOfRange(payload, 6, payload.length));
|
Arrays.copyOfRange(payload, 6, payload.length));
|
||||||
sendSetupMessages();
|
GameState.setCustomizationFlag();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ public class GameClient {
|
|||||||
);
|
);
|
||||||
clientLobbyList.clear();
|
clientLobbyList.clear();
|
||||||
allBoatsMap.forEach((id, boat) ->
|
allBoatsMap.forEach((id, boat) ->
|
||||||
clientLobbyList.add(id + " " + boat.getBoatName())
|
clientLobbyList.add(boat.getBoatName())
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public class CustomizationController {
|
|||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
|
boatColorPicker.setValue(new Color(0.0, 0.0, 0.0, 1.0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServerThread(ClientToServerThread ctsThread) {
|
public void setServerThread(ClientToServerThread ctsThread) {
|
||||||
@@ -56,6 +58,9 @@ public class CustomizationController {
|
|||||||
this.windowStage = stage;
|
this.windowStage = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPlayerName(String name) {
|
||||||
|
this.nameField.setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,9 +149,11 @@ public class LobbyController {
|
|||||||
try {
|
try {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(LobbyController.class.getResource("/views/customizeView.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(LobbyController.class.getResource("/views/customizeView.fxml"));
|
||||||
root = fxmlLoader.load();
|
root = fxmlLoader.load();
|
||||||
|
root.getStylesheets().add("/css/master.css");
|
||||||
Stage customizeStage = new Stage();
|
Stage customizeStage = new Stage();
|
||||||
CustomizationController cc = fxmlLoader.getController();
|
CustomizationController cc = fxmlLoader.getController();
|
||||||
cc.setServerThread(this.socketThread);
|
cc.setServerThread(this.socketThread);
|
||||||
|
cc.setPlayerName(this.players.get(playerID - 1));
|
||||||
customizeStage.setTitle("Customize Boat");
|
customizeStage.setTitle("Customize Boat");
|
||||||
customizeStage.setScene(new Scene(root, 700, 450));
|
customizeStage.setScene(new Scene(root, 700, 450));
|
||||||
cc.setStage(customizeStage); // pass the stage through so it can be closed later.
|
cc.setStage(customizeStage); // pass the stage through so it can be closed later.
|
||||||
|
|||||||
@@ -1,25 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.ColorPicker?>
|
||||||
<?import java.lang.*?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.CustomizationController">
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.text.Text?>
|
||||||
|
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
||||||
|
prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: #2C2c36;"
|
||||||
|
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="seng302.visualiser.controllers.CustomizationController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="SOMETIMES"
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
maxWidth="1.7976931348623157E308" minWidth="1.0" percentWidth="10.0" prefWidth="1.0"/>
|
||||||
|
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="SOMETIMES" maxWidth="299.0"
|
||||||
|
minWidth="10.0" percentWidth="30.0" prefWidth="299.0"/>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="299.0" minWidth="10.0" percentWidth="50.0"
|
||||||
|
prefWidth="154.0"/>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="123.0" minWidth="0.0" percentWidth="10.0"
|
||||||
|
prefWidth="122.0"/>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" percentHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" percentHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<TextField fx:id="nameField" GridPane.columnIndex="1" />
|
<TextField fx:id="nameField" maxWidth="200.0" minWidth="200.0" prefWidth="200.0"
|
||||||
<ColorPicker fx:id="boatColorPicker" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1"
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Player Name" />
|
GridPane.valignment="CENTER"/>
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Boat Color" GridPane.rowIndex="1" />
|
<ColorPicker fx:id="boatColorPicker" prefWidth="200.0" style="-fx-background-color: eeeeee;"
|
||||||
<Button fx:id="customizeSubmit" mnemonicParsing="false" onAction="#submitCustomization" text="Submit" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER" />
|
GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="2"
|
||||||
|
GridPane.valignment="CENTER"/>
|
||||||
|
<Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Player Name"
|
||||||
|
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||||
|
<Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Boat Color"
|
||||||
|
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||||
|
<Button fx:id="customizeSubmit" mnemonicParsing="false" onAction="#submitCustomization"
|
||||||
|
text="Submit" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3"
|
||||||
|
GridPane.valignment="CENTER"/>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user