mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Race view is default to be full screen now and minor bug fixes.
- race view is force to be full screen and run in a new stage - fixed button animations in lobby view - polished UI element is boat customization dialog #story[1245]
This commit is contained in:
@@ -5,12 +5,15 @@ import com.jfoenix.controls.JFXDialog;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.geometry.Rectangle2D;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.stage.Screen;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -33,18 +36,18 @@ public class ViewManager {
|
|||||||
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
|
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
|
|
||||||
private ViewManager(){
|
private ViewManager() {
|
||||||
properties = new HashMap<>();
|
properties = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FXMLLoader loadFxml(String fxmlLocation) {
|
private FXMLLoader loadFxml(String fxmlLocation) {
|
||||||
return new FXMLLoader(
|
return new FXMLLoader(
|
||||||
getClass().getResource(fxmlLocation)
|
getClass().getResource(fxmlLocation)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ViewManager getInstance(){
|
public static ViewManager getInstance() {
|
||||||
if (instance == null){
|
if (instance == null) {
|
||||||
instance = new ViewManager();
|
instance = new ViewManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@ public class ViewManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkCompatibility() {
|
private void checkCompatibility() {
|
||||||
if(BonjourInstallChecker.isBonjourSupported()){
|
if (BonjourInstallChecker.isBonjourSupported()) {
|
||||||
BonjourInstallChecker.openInstallUrl();
|
BonjourInstallChecker.openInstallUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,7 +108,7 @@ public class ViewManager {
|
|||||||
return decorator;
|
return decorator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScene(Node scene){
|
public void setScene(Node scene) {
|
||||||
Platform.runLater(() -> decorator.setContent(scene));
|
Platform.runLater(() -> decorator.setContent(scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,15 +125,15 @@ public class ViewManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameClient getGameClient(){
|
public GameClient getGameClient() {
|
||||||
return gameClient;
|
return gameClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProperty(String key){
|
public String getProperty(String key) {
|
||||||
return properties.get(key);
|
return properties.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperty(String key, String val){
|
public void setProperty(String key, String val) {
|
||||||
properties.put(key, val);
|
properties.put(key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,11 +141,11 @@ public class ViewManager {
|
|||||||
this.playerList = playerList;
|
this.playerList = playerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<String> getPlayerList(){
|
public ObservableList<String> getPlayerList() {
|
||||||
return playerList;
|
return playerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LobbyController goToLobby(Boolean disableReadyButton){
|
public LobbyController goToLobby(Boolean disableReadyButton) {
|
||||||
FXMLLoader loader = loadFxml("/views/LobbyView.fxml");
|
FXMLLoader loader = loadFxml("/views/LobbyView.fxml");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -151,7 +154,7 @@ public class ViewManager {
|
|||||||
logger.error("Could not load lobby view");
|
logger.error("Could not load lobby view");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disableReadyButton){
|
if (disableReadyButton) {
|
||||||
LobbyController lobbyController = loader.getController();
|
LobbyController lobbyController = loader.getController();
|
||||||
lobbyController.disableReadyButton();
|
lobbyController.disableReadyButton();
|
||||||
}
|
}
|
||||||
@@ -162,34 +165,52 @@ public class ViewManager {
|
|||||||
public RaceViewController loadRaceView() {
|
public RaceViewController loadRaceView() {
|
||||||
FXMLLoader loader = loadFxml("/views/RaceView.fxml");
|
FXMLLoader loader = loadFxml("/views/RaceView.fxml");
|
||||||
|
|
||||||
try {
|
// have to create a new stage and set the race view maximized as JFoenix decorator has
|
||||||
setScene(loader.load());
|
// bug causes stage cannot be fully maximised.
|
||||||
} catch (IOException e) {
|
Platform.runLater(() -> {
|
||||||
e.printStackTrace();
|
try {
|
||||||
}
|
stage.close();
|
||||||
|
|
||||||
decorator.getScene().setOnKeyPressed(gameClient::keyPressed);
|
Scene scene = new Scene(loader.load());
|
||||||
decorator.getScene().setOnKeyReleased(gameClient::keyReleased);
|
// set key press event to catch key stoke
|
||||||
|
scene.setOnKeyPressed(gameClient::keyPressed);
|
||||||
|
scene.setOnKeyReleased(gameClient::keyReleased);
|
||||||
|
|
||||||
|
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
|
||||||
|
stage = new Stage();
|
||||||
|
stage.setOnCloseRequest(e -> closeAll());
|
||||||
|
stage.setX(visualBounds.getMinX());
|
||||||
|
stage.setY(visualBounds.getMinY());
|
||||||
|
stage.setWidth(visualBounds.getWidth());
|
||||||
|
stage.setHeight(visualBounds.getHeight());
|
||||||
|
stage.setMaximized(true);
|
||||||
|
stage.setFullScreen(true);
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Sounds.stopMusic();
|
Sounds.stopMusic();
|
||||||
Sounds.playRaceMusic();
|
Sounds.playRaceMusic();
|
||||||
return loader.getController();
|
return loader.getController();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JFXDialog loadCustomizationDialog(StackPane parent, LobbyController lobbyController, Color playerColor, String name) {
|
public JFXDialog loadCustomizationDialog(StackPane parent, LobbyController lobbyController,
|
||||||
|
Color playerColor, String name) {
|
||||||
FXMLLoader dialog = loadFxml("/views/dialogs/BoatCustomizeDialog.fxml");
|
FXMLLoader dialog = loadFxml("/views/dialogs/BoatCustomizeDialog.fxml");
|
||||||
|
|
||||||
JFXDialog customizationDialog = null;
|
JFXDialog customizationDialog = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
customizationDialog = new JFXDialog(parent, dialog.load(),
|
customizationDialog = new JFXDialog(parent, dialog.load(),
|
||||||
JFXDialog.DialogTransition.CENTER);
|
JFXDialog.DialogTransition.CENTER);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BoatCustomizeController controller = dialog.getController();
|
BoatCustomizeController controller = dialog.getController();
|
||||||
|
|
||||||
controller.setParentController(lobbyController);
|
controller.setParentController(lobbyController);
|
||||||
@@ -198,7 +219,6 @@ public class ViewManager {
|
|||||||
controller.setServerThread(gameClient.getServerThread());
|
controller.setServerThread(gameClient.getServerThread());
|
||||||
controller.setPlayerColor(lobbyController.playersColor);
|
controller.setPlayerColor(lobbyController.playersColor);
|
||||||
|
|
||||||
|
|
||||||
return customizationDialog;
|
return customizationDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,18 @@
|
|||||||
-fx-background: transparent;
|
-fx-background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#customizeButton, #leaveLobbyButton, #beginRaceButton {
|
#customizeButton, #leaveLobbyButton, #beginRaceButton {
|
||||||
-fx-background-color: -fx-pp-light-text-color; /* inverted */
|
-fx-background-color: -fx-pp-light-text-color; /* inverted */
|
||||||
-fx-text-fill: -fx-pp-theme-color; /* inverted */
|
-fx-text-fill: -fx-pp-theme-color; /* inverted */
|
||||||
-fx-font-size: 16px;
|
-fx-font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#customizeButton:hover, #leaveLobbyButton:hover, #beginRaceButton:hover {
|
||||||
|
-fx-font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invertedButton .jfx-rippler {
|
||||||
|
-jfx-rippler-fill: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
#connectLabel, #serverPortNumber, #serverHostName {
|
#connectLabel, #serverPortNumber, #serverHostName {
|
||||||
@@ -52,12 +59,6 @@
|
|||||||
-fx-background-color: transparent;
|
-fx-background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.invertedButton {
|
|
||||||
-fx-background-color: -fx-pp-light-text-color; /* inverted */
|
|
||||||
-fx-text-fill: -fx-pp-theme-color; /* inverted */
|
|
||||||
-fx-font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#serverMap {
|
#serverMap {
|
||||||
-fx-background-image: url("/images/bg.jpg");
|
-fx-background-image: url("/images/bg.jpg");
|
||||||
-fx-background-repeat: no-repeat;
|
-fx-background-repeat: no-repeat;
|
||||||
|
|||||||
@@ -32,12 +32,21 @@
|
|||||||
-fx-text-fill: -fx-pp-light-text-color;
|
-fx-text-fill: -fx-pp-light-text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#hostButton:hover {
|
||||||
|
-fx-background-color: -fx-pp-light-theme-color;
|
||||||
|
-fx-font-size: 23px;
|
||||||
|
}
|
||||||
|
|
||||||
#connectButton {
|
#connectButton {
|
||||||
-fx-background-color: -fx-pp-light-text-color; /* inverted */
|
-fx-background-color: -fx-pp-light-text-color; /* inverted */
|
||||||
-fx-text-fill: -fx-pp-theme-color; /* inverted */
|
-fx-text-fill: -fx-pp-theme-color; /* inverted */
|
||||||
-fx-font-size: 20px;
|
-fx-font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#connectButton:hover {
|
||||||
|
-fx-font-size: 23px;
|
||||||
|
}
|
||||||
|
|
||||||
#connectLabel, #serverPortNumber, #serverHostName {
|
#connectLabel, #serverPortNumber, #serverHostName {
|
||||||
-fx-text-fill: -fx-pp-light-text-color;
|
-fx-text-fill: -fx-pp-light-text-color;
|
||||||
-fx-font-size: 18px;
|
-fx-font-size: 18px;
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
* {
|
||||||
|
-fx-text-fill: -fx-pp-dark-text-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#submitBtn {
|
||||||
|
-fx-background-color: -fx-pp-theme-color;
|
||||||
|
-fx-text-fill: -fx-pp-light-text-color;
|
||||||
|
-fx-font-size: 20px !important;
|
||||||
|
-fx-effect: -fx-pp-dropshadow-dark;
|
||||||
|
-fx-min-width: 130px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#submitBtn:hover {
|
||||||
|
-fx-font-size: 23px !important;
|
||||||
|
-fx-background-color: -fx-pp-light-theme-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hostDialogHeader {
|
||||||
|
-fx-font-size: 23px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#boatColorLabel, #colorPicker {
|
||||||
|
-fx-font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#boatName {
|
||||||
|
-fx-font-size: 18px;
|
||||||
|
-fx-prompt-text-fill: -fx-pp-dark-text-color;
|
||||||
|
}
|
||||||
@@ -4,7 +4,11 @@
|
|||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<AnchorPane fx:id="rvAnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController">
|
<AnchorPane fx:id="rvAnchorPane" maxHeight="1.7976931348623157E308"
|
||||||
|
maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0"
|
||||||
|
prefWidth="800.0" style="-fx-background-color: skyblue;" xmlns="http://javafx.com/javafx/8"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="seng302.visualiser.controllers.RaceViewController">
|
||||||
<children>
|
<children>
|
||||||
<StackPane fx:id="contentAnchorPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<StackPane fx:id="contentAnchorPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,11 @@
|
|||||||
<RowConstraints maxHeight="164.0" minHeight="100.0" prefHeight="164.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="164.0" minHeight="100.0" prefHeight="164.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label fx:id="hostDialogHeader" text="Customize Boat..." GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
|
<Label fx:id="hostDialogHeader" text="Customize Boat" GridPane.halignment="CENTER"
|
||||||
|
GridPane.valignment="CENTER"/>
|
||||||
<JFXButton fx:id="submitBtn" prefHeight="45.0" prefWidth="220.0" text="Customize Boat" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER" />
|
<JFXButton fx:id="submitBtn" prefHeight="45.0" prefWidth="220.0" text="Customize Boat" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER" />
|
||||||
<JFXTextField fx:id="boatName" promptText="Boat Name" GridPane.rowIndex="1">
|
<JFXTextField fx:id="boatName" focusColor="#6c6c6c" promptText="Boat Name"
|
||||||
|
unFocusColor="#6b6b6b" GridPane.rowIndex="1">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets left="30.0" right="30.0" />
|
<Insets left="30.0" right="30.0" />
|
||||||
</GridPane.margin></JFXTextField>
|
</GridPane.margin></JFXTextField>
|
||||||
@@ -40,14 +42,15 @@
|
|||||||
<RowConstraints maxHeight="69.0" minHeight="10.0" percentHeight="60.0" prefHeight="19.6" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="69.0" minHeight="10.0" percentHeight="60.0" prefHeight="19.6" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label fx:id="hostDialogHeader1" prefHeight="25.0" prefWidth="96.0" text="Boat Color">
|
<Label fx:id="boatColorLabel" prefHeight="25.0" prefWidth="96.0"
|
||||||
|
text="Boat Color">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets top="-10.0" />
|
<Insets top="-10.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<JFXColorPicker fx:id="colorPicker" onAction="#colorChanged" GridPane.columnIndex="1">
|
<JFXColorPicker fx:id="colorPicker" onAction="#colorChanged" GridPane.columnIndex="1">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets top="-10.0" />
|
<Insets left="30.0" top="-10.0"/>
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</JFXColorPicker>
|
</JFXColorPicker>
|
||||||
</children>
|
</children>
|
||||||
@@ -59,7 +62,7 @@
|
|||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
<String fx:value="/css/dialogs/ServerCreation.css"/>
|
<String fx:value="/css/dialogs/BoatCustomize.css"/>
|
||||||
<String fx:value="/css/master.css" />
|
<String fx:value="/css/master.css" />
|
||||||
</stylesheets>
|
</stylesheets>
|
||||||
</JFXDialogLayout>
|
</JFXDialogLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user