Review fixes for merge request.

PlayerCell now takes in the yacht for construction rather than taking in a whole lot of values extracted from the yacht

Reduced boiler plate in BoatCustomizeController

#story[1274]
This commit is contained in:
William Muir
2017-09-22 20:44:06 +12:00
parent c4a6113f6c
commit da8c91f5c1
4 changed files with 24 additions and 30 deletions
@@ -205,7 +205,7 @@ public class LobbyController implements Initializable {
FXMLLoader loader = new FXMLLoader(
getClass().getResource("/views/cells/PlayerCell.fxml"));
loader.setController(new PlayerCell(playerId, yacht.getBoatName(), yacht.getColour(), yacht.getBoatType()));
loader.setController(new PlayerCell(playerId, yacht));
try {
pane = loader.load();
@@ -6,6 +6,7 @@ import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import seng302.model.ClientYacht;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
import seng302.visualiser.fxObjects.assets_3D.BoatModel;
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
@@ -24,13 +25,13 @@ public class PlayerCell {
private String name;
private Color boatColor;
private Integer playerId;
private BoatMeshType boatype;
private BoatMeshType boatType;
public PlayerCell(Integer playerId, String playerName, Color color, String boatType) {
public PlayerCell(Integer playerId, ClientYacht yacht) {
this.playerId = playerId;
this.name = playerName;
this.boatColor = color;
this.boatype = BoatMeshType.getBoatMeshType(boatType);
this.name = yacht.getBoatName();
this.boatColor = yacht.getColour();
this.boatType = BoatMeshType.getBoatMeshType(yacht.getBoatType());
}
public void initialize() {
@@ -39,7 +40,7 @@ public class PlayerCell {
// Add Rotating Boat to Player Cell with players color on it.
Group group = new Group();
boatPane.getChildren().add(group);
BoatModel bo = ModelFactory.boatIconView(this.boatype, this.boatColor);
BoatModel bo = ModelFactory.boatIconView(boatType, boatColor);
group.getChildren().add(bo.getAssets());
}
@@ -6,7 +6,6 @@ import com.jfoenix.controls.JFXTextField;
import com.jfoenix.validation.RequiredFieldValidator;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
@@ -40,9 +39,8 @@ public class BoatCustomizeController implements Initializable{
@FXML
private Pane boatPane;
@FXML
void colorChanged(ActionEvent event) {
Color color = colorPicker.getValue();
RefreshBoat();
void colorChanged() {
refreshBoat();
}
//---------FXML END---------//
@@ -62,6 +60,8 @@ public class BoatCustomizeController implements Initializable{
playerNameLengthValidator.setMessage("Player name too long.");
boatName.setValidators(playerNameLengthValidator, playerNameReqValidator);
boatPane.setBackground(
new Background(new BackgroundFill(Color.SKYBLUE, CornerRadii.EMPTY, Insets.EMPTY)));
submitBtn.setOnMouseReleased(event -> {
Sounds.playButtonClick();
@@ -69,7 +69,6 @@ public class BoatCustomizeController implements Initializable{
});
submitBtn.setOnMouseEntered(e -> Sounds.playHoverSound());
}
/**
@@ -113,36 +112,30 @@ public class BoatCustomizeController implements Initializable{
}
public void setCurrentBoat(String boatType) {
Group group = new Group();
this.currentBoat = BoatMeshType.getBoatMeshType(boatType);
boatPane.setBackground(new Background(new BackgroundFill(Color.SKYBLUE, CornerRadii.EMPTY, Insets.EMPTY)));
boatPane.getChildren().add(group);
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
group.getChildren().add(bo.getAssets());
group.getChildren().add(new PointLight());
currentBoat = BoatMeshType.getBoatMeshType(boatType);
displayCurrentBoat();
}
public void nextBoat(ActionEvent actionEvent) {
boatPane.getChildren().clear();
Group group = new Group();
boatPane.getChildren().add(group);
public void nextBoat() {
currentBoat = BoatMeshType.getNextBoatType(currentBoat);
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
group.getChildren().add(bo.getAssets());
group.getChildren().add(new PointLight());
displayCurrentBoat();
}
public void prevBoat(ActionEvent actionEvent) {
public void prevBoat() {
currentBoat = BoatMeshType.getPrevBoatType(currentBoat);
displayCurrentBoat();
}
private void displayCurrentBoat() {
boatPane.getChildren().clear();
Group group = new Group();
boatPane.getChildren().add(group);
currentBoat = BoatMeshType.getPrevBoatType(currentBoat);
BoatModel bo = ModelFactory.boatCustomiseView(currentBoat, colorPicker.getValue());
group.getChildren().add(bo.getAssets());
group.getChildren().add(new PointLight());
}
private void RefreshBoat() {
private void refreshBoat() {
boatPane.getChildren().clear();
Group group = new Group();
boatPane.getChildren().add(group);