Added some general UI improvements such as autofilling the color field of the form, and looked at how best to deal with response packets, as it should be part of the spec.

tags: #story[1142]
This commit is contained in:
alistairjmcintyre
2017-08-17 01:20:16 +12:00
parent 67f0c213c2
commit 6e02d3e533
7 changed files with 32 additions and 13 deletions
@@ -20,13 +20,12 @@ public class CustomizationController {
@FXML
private Button customizeSubmit;
private LobbyController lc;
private ClientToServerThread socketThread;
private Stage windowStage;
public void initialize() {
boatColorPicker.setValue(new Color(0.0, 0.0, 0.0, 1.0));
}
public void setServerThread(ClientToServerThread ctsThread) {
@@ -51,9 +50,14 @@ public class CustomizationController {
colorArray[2] = (byte) blue;
socketThread.sendCustomizationRequest(CustomizeRequestType.COLOR, colorArray);
lc.setPlayersColor(color);
windowStage.close();
}
public void setLobbyController(LobbyController lc) {
this.lc = lc;
}
public void setStage(Stage stage) {
this.windowStage = stage;
}
@@ -62,5 +66,9 @@ public class CustomizationController {
this.nameField.setText(name);
}
public void setPlayerColor(Color playerColor) {
this.boatColorPicker.setValue(playerColor);
}
}
@@ -16,10 +16,12 @@ import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import seng302.gameServer.GameStages;
import seng302.gameServer.GameState;
import seng302.model.Colors;
import seng302.model.RaceState;
import seng302.visualiser.ClientToServerThread;
@@ -86,6 +88,8 @@ public class LobbyController {
private ClientToServerThread socketThread;
private Color playersColor;
private int MAX_NUM_PLAYERS = 8;
private Integer playerID;
@@ -154,9 +158,16 @@ public class LobbyController {
CustomizationController cc = fxmlLoader.getController();
cc.setServerThread(this.socketThread);
cc.setPlayerName(this.players.get(playerID - 1));
if (this.playersColor == null) {
this.playersColor = Colors.getColor(playerID - 1);
}
cc.setPlayerColor(this.playersColor);
customizeStage.setTitle("Customize Boat");
customizeStage.setScene(new Scene(root, 700, 450));
cc.setStage(customizeStage); // pass the stage through so it can be closed later.
cc.setLobbyController(this);
customizeStage.show();
} catch (IOException e) {
Logger.logMsg(4, "Failed to load Customization View from resources.");
@@ -218,4 +229,9 @@ public class LobbyController {
readyButton.setDisable(true);
readyButton.setVisible(false);
}
public void setPlayersColor(Color playerColor) {
this.playersColor = playerColor;
}
}