mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
- Added documentation to controllers
- Moved Customization Dialog logic into LobbyController tags : #story[1245]
This commit is contained in:
@@ -31,6 +31,7 @@ import seng302.model.stream.xml.parser.RaceXMLData;
|
|||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
import seng302.visualiser.GameView;
|
import seng302.visualiser.GameView;
|
||||||
import seng302.visualiser.controllers.cells.PlayerCell;
|
import seng302.visualiser.controllers.cells.PlayerCell;
|
||||||
|
import seng302.visualiser.controllers.dialogs.BoatCustomizeController;
|
||||||
|
|
||||||
public class LobbyController implements Initializable {
|
public class LobbyController implements Initializable {
|
||||||
|
|
||||||
@@ -93,8 +94,8 @@ public class LobbyController implements Initializable {
|
|||||||
Integer playerId = ViewManager.getInstance().getGameClient().getServerThread().getClientId();
|
Integer playerId = ViewManager.getInstance().getGameClient().getServerThread().getClientId();
|
||||||
String name = ViewManager.getInstance().getGameClient().getPlayerNames().get(playerId - 1);
|
String name = ViewManager.getInstance().getGameClient().getPlayerNames().get(playerId - 1);
|
||||||
|
|
||||||
Color playerColor = Colors.getColor( playerId - 1);
|
playersColor = Colors.getColor(playerId - 1);
|
||||||
customizationDialog = ViewManager.getInstance().loadCustomizationDialog(serverListMainStackPane, this, playerColor, name);
|
customizationDialog = createCustomizeDialog();
|
||||||
|
|
||||||
customizeButton.setOnMouseReleased(event -> {
|
customizeButton.setOnMouseReleased(event -> {
|
||||||
Sounds.playButtonClick();
|
Sounds.playButtonClick();
|
||||||
@@ -109,6 +110,28 @@ public class LobbyController implements Initializable {
|
|||||||
initMapPreview();
|
initMapPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JFXDialog createCustomizeDialog() {
|
||||||
|
// TODO: 12/09/17 ajm412: Why is this here? is there no better way we can do this? Ideally inside the LobbyController.
|
||||||
|
FXMLLoader dialog = new FXMLLoader(
|
||||||
|
getClass().getResource("/views/dialogs/BoatCustomizeDialog.fxml"));
|
||||||
|
|
||||||
|
JFXDialog customizationDialog = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
customizationDialog = new JFXDialog(serverListMainStackPane, dialog.load(),
|
||||||
|
JFXDialog.DialogTransition.CENTER);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
BoatCustomizeController controller = dialog.getController();
|
||||||
|
|
||||||
|
controller.setParentController(this);
|
||||||
|
|
||||||
|
return customizationDialog;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package seng302.visualiser.controllers;
|
|||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXDecorator;
|
import com.jfoenix.controls.JFXDecorator;
|
||||||
import com.jfoenix.controls.JFXDialog;
|
|
||||||
import com.jfoenix.svg.SVGGlyph;
|
import com.jfoenix.svg.SVGGlyph;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -16,7 +15,6 @@ import javafx.scene.Scene;
|
|||||||
import javafx.scene.SceneAntialiasing;
|
import javafx.scene.SceneAntialiasing;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -25,7 +23,6 @@ import seng302.gameServer.ServerAdvertiser;
|
|||||||
import seng302.utilities.BonjourInstallChecker;
|
import seng302.utilities.BonjourInstallChecker;
|
||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
import seng302.visualiser.GameClient;
|
import seng302.visualiser.GameClient;
|
||||||
import seng302.visualiser.controllers.dialogs.BoatCustomizeController;
|
|
||||||
|
|
||||||
public class ViewManager {
|
public class ViewManager {
|
||||||
|
|
||||||
@@ -296,30 +293,4 @@ public class ViewManager {
|
|||||||
|
|
||||||
return loader.getController();
|
return loader.getController();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 12/09/17 ajm412: Why is this here? is there no better way we can do this? Ideally inside the LobbyController.
|
|
||||||
public JFXDialog loadCustomizationDialog(StackPane parent, LobbyController lobbyController,
|
|
||||||
Color playerColor, String name) {
|
|
||||||
FXMLLoader dialog = loadFxml("/views/dialogs/BoatCustomizeDialog.fxml");
|
|
||||||
|
|
||||||
JFXDialog customizationDialog = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
customizationDialog = new JFXDialog(parent, dialog.load(),
|
|
||||||
JFXDialog.DialogTransition.CENTER);
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
BoatCustomizeController controller = dialog.getController();
|
|
||||||
|
|
||||||
controller.setParentController(lobbyController);
|
|
||||||
controller.setPlayerColor(playerColor);
|
|
||||||
controller.setPlayerName(name);
|
|
||||||
controller.setServerThread(gameClient.getServerThread());
|
|
||||||
controller.setPlayerColor(lobbyController.playersColor);
|
|
||||||
|
|
||||||
return customizationDialog;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import seng302.gameServer.messages.CustomizeRequestType;
|
|||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
import seng302.visualiser.ClientToServerThread;
|
import seng302.visualiser.ClientToServerThread;
|
||||||
import seng302.visualiser.controllers.LobbyController;
|
import seng302.visualiser.controllers.LobbyController;
|
||||||
|
import seng302.visualiser.controllers.ViewManager;
|
||||||
import seng302.visualiser.validators.FieldLengthValidator;
|
import seng302.visualiser.validators.FieldLengthValidator;
|
||||||
import seng302.visualiser.validators.ValidationTools;
|
import seng302.visualiser.validators.ValidationTools;
|
||||||
|
|
||||||
@@ -42,6 +43,10 @@ public class BoatCustomizeController implements Initializable{
|
|||||||
submitCustomization();
|
submitCustomization();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setPlayerColor(lobbyController.playersColor);
|
||||||
|
|
||||||
|
socketThread = ViewManager.getInstance().getGameClient().getServerThread();
|
||||||
|
|
||||||
RequiredFieldValidator playerNameReqValidator = new RequiredFieldValidator();
|
RequiredFieldValidator playerNameReqValidator = new RequiredFieldValidator();
|
||||||
playerNameReqValidator.setMessage("Player name required.");
|
playerNameReqValidator.setMessage("Player name required.");
|
||||||
|
|
||||||
@@ -86,10 +91,6 @@ public class BoatCustomizeController implements Initializable{
|
|||||||
this.colorPicker.setValue(playerColor);
|
this.colorPicker.setValue(playerColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServerThread(ClientToServerThread ctsThread) {
|
|
||||||
this.socketThread = ctsThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentController(LobbyController lobbyController){
|
public void setParentController(LobbyController lobbyController){
|
||||||
this.lobbyController = lobbyController;
|
this.lobbyController = lobbyController;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user