Boat Names Change. Colors Change too. Updates clients during lobby when a change is made.

tags: #story[1142]
This commit is contained in:
Alistair McIntyre
2017-08-16 19:31:27 +12:00
parent 6d045e9976
commit 02a7b804c1
9 changed files with 67 additions and 15 deletions
@@ -4,6 +4,8 @@ import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.TextField;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import seng302.gameServer.server.messages.CustomizeRequestType;
import seng302.visualiser.ClientToServerThread;
@@ -19,6 +21,7 @@ public class CustomizationController {
private Button customizeSubmit;
private ClientToServerThread socketThread;
private Stage windowStage;
public void initialize() {
@@ -33,8 +36,24 @@ public class CustomizationController {
System.out.println("Attempting to send");
socketThread.sendCustomizationRequest(CustomizeRequestType.NAME, nameField.getText().getBytes());
// TODO: 16/08/17 ajm412: Turn colors into byte array.
socketThread.sendCustomizationRequest(CustomizeRequestType.COLOR,
boatColorPicker.getValue().toString().getBytes());
Color color = boatColorPicker.getValue();
short red = (short) (color.getRed() * 255);
short green = (short) (color.getGreen() * 255);
short blue = (short) (color.getBlue() * 255);
byte[] colorArray = new byte[3];
colorArray[0] = (byte) red;
colorArray[1] = (byte) green;
colorArray[2] = (byte) blue;
socketThread.sendCustomizationRequest(CustomizeRequestType.COLOR, colorArray);
windowStage.close();
}
public void setStage(Stage stage) {
this.windowStage = stage;
}
@@ -1,7 +1,10 @@
package seng302.visualiser.controllers;
import java.util.*;
import com.sun.media.jfxmedia.logging.Logger;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javafx.application.Platform;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
@@ -18,9 +21,7 @@ import javafx.stage.Stage;
import seng302.gameServer.GameStages;
import seng302.gameServer.GameState;
import seng302.model.RaceState;
import seng302.visualiser.GameClient;
import seng302.visualiser.ClientToServerThread;
import seng302.visualiser.GameView;
/**
* A class describing the actions of the lobby screen
@@ -153,6 +154,7 @@ public class LobbyController {
cc.setServerThread(this.socketThread);
customizeStage.setTitle("Customize Boat");
customizeStage.setScene(new Scene(root, 700, 450));
cc.setStage(customizeStage); // pass the stage through so it can be closed later.
customizeStage.show();
} catch (IOException e) {
Logger.logMsg(4, "Failed to load Customization View from resources.");