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.collections.ObservableList;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.stage.Stage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -33,18 +36,18 @@ public class ViewManager {
|
||||
private Logger logger = LoggerFactory.getLogger(ViewManager.class);
|
||||
private Stage stage;
|
||||
|
||||
private ViewManager(){
|
||||
private ViewManager() {
|
||||
properties = new HashMap<>();
|
||||
}
|
||||
|
||||
private FXMLLoader loadFxml(String fxmlLocation) {
|
||||
return new FXMLLoader(
|
||||
getClass().getResource(fxmlLocation)
|
||||
getClass().getResource(fxmlLocation)
|
||||
);
|
||||
}
|
||||
|
||||
public static ViewManager getInstance(){
|
||||
if (instance == null){
|
||||
public static ViewManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ViewManager();
|
||||
}
|
||||
|
||||
@@ -86,7 +89,7 @@ public class ViewManager {
|
||||
}
|
||||
|
||||
private void checkCompatibility() {
|
||||
if(BonjourInstallChecker.isBonjourSupported()){
|
||||
if (BonjourInstallChecker.isBonjourSupported()) {
|
||||
BonjourInstallChecker.openInstallUrl();
|
||||
}
|
||||
}
|
||||
@@ -105,7 +108,7 @@ public class ViewManager {
|
||||
return decorator;
|
||||
}
|
||||
|
||||
public void setScene(Node scene){
|
||||
public void setScene(Node scene) {
|
||||
Platform.runLater(() -> decorator.setContent(scene));
|
||||
}
|
||||
|
||||
@@ -122,15 +125,15 @@ public class ViewManager {
|
||||
}
|
||||
}
|
||||
|
||||
public GameClient getGameClient(){
|
||||
public GameClient getGameClient() {
|
||||
return gameClient;
|
||||
}
|
||||
|
||||
public String getProperty(String key){
|
||||
public String getProperty(String key) {
|
||||
return properties.get(key);
|
||||
}
|
||||
|
||||
public void setProperty(String key, String val){
|
||||
public void setProperty(String key, String val) {
|
||||
properties.put(key, val);
|
||||
}
|
||||
|
||||
@@ -138,11 +141,11 @@ public class ViewManager {
|
||||
this.playerList = playerList;
|
||||
}
|
||||
|
||||
public ObservableList<String> getPlayerList(){
|
||||
public ObservableList<String> getPlayerList() {
|
||||
return playerList;
|
||||
}
|
||||
|
||||
public LobbyController goToLobby(Boolean disableReadyButton){
|
||||
public LobbyController goToLobby(Boolean disableReadyButton) {
|
||||
FXMLLoader loader = loadFxml("/views/LobbyView.fxml");
|
||||
|
||||
try {
|
||||
@@ -151,7 +154,7 @@ public class ViewManager {
|
||||
logger.error("Could not load lobby view");
|
||||
}
|
||||
|
||||
if (disableReadyButton){
|
||||
if (disableReadyButton) {
|
||||
LobbyController lobbyController = loader.getController();
|
||||
lobbyController.disableReadyButton();
|
||||
}
|
||||
@@ -162,34 +165,52 @@ public class ViewManager {
|
||||
public RaceViewController loadRaceView() {
|
||||
FXMLLoader loader = loadFxml("/views/RaceView.fxml");
|
||||
|
||||
try {
|
||||
setScene(loader.load());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// have to create a new stage and set the race view maximized as JFoenix decorator has
|
||||
// bug causes stage cannot be fully maximised.
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
stage.close();
|
||||
|
||||
decorator.getScene().setOnKeyPressed(gameClient::keyPressed);
|
||||
decorator.getScene().setOnKeyReleased(gameClient::keyReleased);
|
||||
Scene scene = new Scene(loader.load());
|
||||
// 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.playRaceMusic();
|
||||
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");
|
||||
|
||||
JFXDialog customizationDialog = null;
|
||||
|
||||
try {
|
||||
customizationDialog = new JFXDialog(parent, dialog.load(),
|
||||
JFXDialog.DialogTransition.CENTER);
|
||||
JFXDialog.DialogTransition.CENTER);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
BoatCustomizeController controller = dialog.getController();
|
||||
|
||||
controller.setParentController(lobbyController);
|
||||
@@ -198,7 +219,6 @@ public class ViewManager {
|
||||
controller.setServerThread(gameClient.getServerThread());
|
||||
controller.setPlayerColor(lobbyController.playersColor);
|
||||
|
||||
|
||||
return customizationDialog;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,18 @@
|
||||
-fx-background: transparent;
|
||||
}
|
||||
|
||||
|
||||
#customizeButton, #leaveLobbyButton, #beginRaceButton {
|
||||
-fx-background-color: -fx-pp-light-text-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 {
|
||||
@@ -52,12 +59,6 @@
|
||||
-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 {
|
||||
-fx-background-image: url("/images/bg.jpg");
|
||||
-fx-background-repeat: no-repeat;
|
||||
|
||||
@@ -32,12 +32,21 @@
|
||||
-fx-text-fill: -fx-pp-light-text-color;
|
||||
}
|
||||
|
||||
#hostButton:hover {
|
||||
-fx-background-color: -fx-pp-light-theme-color;
|
||||
-fx-font-size: 23px;
|
||||
}
|
||||
|
||||
#connectButton {
|
||||
-fx-background-color: -fx-pp-light-text-color; /* inverted */
|
||||
-fx-text-fill: -fx-pp-theme-color; /* inverted */
|
||||
-fx-font-size: 20px;
|
||||
}
|
||||
|
||||
#connectButton:hover {
|
||||
-fx-font-size: 23px;
|
||||
}
|
||||
|
||||
#connectLabel, #serverPortNumber, #serverHostName {
|
||||
-fx-text-fill: -fx-pp-light-text-color;
|
||||
-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 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>
|
||||
<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>
|
||||
<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" />
|
||||
<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>
|
||||
<Insets left="30.0" right="30.0" />
|
||||
</GridPane.margin></JFXTextField>
|
||||
@@ -40,14 +42,15 @@
|
||||
<RowConstraints maxHeight="69.0" minHeight="10.0" percentHeight="60.0" prefHeight="19.6" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<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>
|
||||
<Insets top="-10.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<JFXColorPicker fx:id="colorPicker" onAction="#colorChanged" GridPane.columnIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets top="-10.0" />
|
||||
<Insets left="30.0" top="-10.0"/>
|
||||
</GridPane.margin>
|
||||
</JFXColorPicker>
|
||||
</children>
|
||||
@@ -59,7 +62,7 @@
|
||||
</GridPane>
|
||||
</children>
|
||||
<stylesheets>
|
||||
<String fx:value="/css/dialogs/ServerCreation.css"/>
|
||||
<String fx:value="/css/dialogs/BoatCustomize.css"/>
|
||||
<String fx:value="/css/master.css" />
|
||||
</stylesheets>
|
||||
</JFXDialogLayout>
|
||||
|
||||
Reference in New Issue
Block a user