mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
- Fixed snackbar not showing on race view
- Added close label on server creation dialog #story[1273]
This commit is contained in:
@@ -7,6 +7,7 @@ import com.jfoenix.controls.JFXTextField;
|
|||||||
import com.jfoenix.validation.RequiredFieldValidator;
|
import com.jfoenix.validation.RequiredFieldValidator;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@@ -27,6 +28,7 @@ import seng302.utilities.Sounds;
|
|||||||
import seng302.visualiser.ServerListener;
|
import seng302.visualiser.ServerListener;
|
||||||
import seng302.visualiser.ServerListenerDelegate;
|
import seng302.visualiser.ServerListenerDelegate;
|
||||||
import seng302.visualiser.controllers.cells.ServerCell;
|
import seng302.visualiser.controllers.cells.ServerCell;
|
||||||
|
import seng302.visualiser.controllers.dialogs.ServerCreationController;
|
||||||
import seng302.visualiser.validators.HostNameFieldValidator;
|
import seng302.visualiser.validators.HostNameFieldValidator;
|
||||||
import seng302.visualiser.validators.NumberRangeValidator;
|
import seng302.visualiser.validators.NumberRangeValidator;
|
||||||
import seng302.visualiser.validators.ValidationTools;
|
import seng302.visualiser.validators.ValidationTools;
|
||||||
@@ -55,6 +57,14 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
|||||||
|
|
||||||
private Label noServersFound;
|
private Label noServersFound;
|
||||||
private Logger logger = LoggerFactory.getLogger(ServerListController.class);
|
private Logger logger = LoggerFactory.getLogger(ServerListController.class);
|
||||||
|
private JFXDialog serverCreationDialog;
|
||||||
|
private List<ServerCreationDialogListener> serverCreationDialogListeners = new ArrayList<>();
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ServerCreationDialogListener {
|
||||||
|
|
||||||
|
void notifyClosure();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 12/09/17 ajm412: break this method down, its way too long.
|
// TODO: 12/09/17 ajm412: break this method down, its way too long.
|
||||||
@Override
|
@Override
|
||||||
@@ -115,6 +125,8 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
|||||||
serverListHostButton.setOnAction(action -> {
|
serverListHostButton.setOnAction(action -> {
|
||||||
showServerCreationDialog();
|
showServerCreationDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addServerCreationDialogListener(this::closeServerCreationDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,9 +137,11 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
|||||||
FXMLLoader dialogContent = new FXMLLoader(getClass().getResource(
|
FXMLLoader dialogContent = new FXMLLoader(getClass().getResource(
|
||||||
"/views/dialogs/ServerCreationDialog.fxml"));
|
"/views/dialogs/ServerCreationDialog.fxml"));
|
||||||
try {
|
try {
|
||||||
JFXDialog dialog = new JFXDialog(serverListMainStackPane, dialogContent.load(),
|
serverCreationDialog = new JFXDialog(serverListMainStackPane, dialogContent.load(),
|
||||||
DialogTransition.CENTER);
|
DialogTransition.CENTER);
|
||||||
dialog.show();
|
ServerCreationController serverCreationController = dialogContent.getController();
|
||||||
|
serverCreationController.setListener(serverCreationDialogListeners);
|
||||||
|
serverCreationDialog.show();
|
||||||
Sounds.playButtonClick();
|
Sounds.playButtonClick();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Could not create Server Creation Dialog.");
|
logger.warn("Could not create Server Creation Dialog.");
|
||||||
@@ -135,6 +149,10 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void closeServerCreationDialog() {
|
||||||
|
serverCreationDialog.close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the connection and attempts to connect to a given hostname and port number.
|
* Validates the connection and attempts to connect to a given hostname and port number.
|
||||||
*/
|
*/
|
||||||
@@ -203,4 +221,14 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
|||||||
public void serverDetected(ServerDescription serverDescription, List<ServerDescription> servers) {
|
public void serverDetected(ServerDescription serverDescription, List<ServerDescription> servers) {
|
||||||
Platform.runLater(() -> refreshServers(servers));
|
Platform.runLater(() -> refreshServers(servers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addServerCreationDialogListener(
|
||||||
|
ServerCreationDialogListener serverCreationDialogListener) {
|
||||||
|
serverCreationDialogListeners.add(serverCreationDialogListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeServerCreationDialogListener(
|
||||||
|
ServerCreationDialogListener serverCreationDialogListener) {
|
||||||
|
serverCreationDialogListeners.remove(serverCreationDialogListener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ public class ViewManager {
|
|||||||
gameClient.stopGame();
|
gameClient.stopGame();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
jfxSnackbar = new JFXSnackbar(decorator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,6 +186,7 @@ public class ViewManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jfxSnackbar = new JFXSnackbar(decorator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public class KeyBindingDialogController implements Initializable {
|
|||||||
resetBtn.setOnMouseClicked(event -> {
|
resetBtn.setOnMouseClicked(event -> {
|
||||||
gameKeyBind.setToDefault();
|
gameKeyBind.setToDefault();
|
||||||
loadKeyBind();
|
loadKeyBind();
|
||||||
|
showSnackBar("All keys reset!", false);
|
||||||
});
|
});
|
||||||
|
|
||||||
closeLabel.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog());
|
closeLabel.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog());
|
||||||
|
|||||||
@@ -5,14 +5,15 @@ import com.jfoenix.controls.JFXSlider;
|
|||||||
import com.jfoenix.controls.JFXTextField;
|
import com.jfoenix.controls.JFXTextField;
|
||||||
import com.jfoenix.validation.RequiredFieldValidator;
|
import com.jfoenix.validation.RequiredFieldValidator;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import seng302.gameServer.ServerDescription;
|
import seng302.gameServer.ServerDescription;
|
||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
|
import seng302.visualiser.controllers.ServerListController.ServerCreationDialogListener;
|
||||||
import seng302.visualiser.controllers.ViewManager;
|
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;
|
||||||
@@ -28,8 +29,12 @@ public class ServerCreationController implements Initializable {
|
|||||||
private Label maxPlayersLabel;
|
private Label maxPlayersLabel;
|
||||||
@FXML
|
@FXML
|
||||||
private JFXButton submitBtn;
|
private JFXButton submitBtn;
|
||||||
|
@FXML
|
||||||
|
private Label closeLabel;
|
||||||
//---------FXML END---------//
|
//---------FXML END---------//
|
||||||
|
|
||||||
|
private List<ServerCreationDialogListener> serverCreationDialogListeners;
|
||||||
|
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
updateMaxPlayerLabel();
|
updateMaxPlayerLabel();
|
||||||
maxPlayersSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
|
maxPlayersSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
@@ -49,6 +54,7 @@ public class ServerCreationController implements Initializable {
|
|||||||
validateServerSettings();
|
validateServerSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
closeLabel.setOnMouseClicked(event -> notifyListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,4 +93,14 @@ public class ServerCreationController implements Initializable {
|
|||||||
Sounds.playHoverSound();
|
Sounds.playHoverSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setListener(List<ServerCreationDialogListener> serverCreationDialogListeners) {
|
||||||
|
this.serverCreationDialogListeners = serverCreationDialogListeners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyListeners() {
|
||||||
|
for (ServerCreationDialogListener serverCreationDialogListener : serverCreationDialogListeners) {
|
||||||
|
serverCreationDialogListener.notifyClosure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,3 +45,13 @@
|
|||||||
.maxPlayers {
|
.maxPlayers {
|
||||||
-fx-font-size: 13px;
|
-fx-font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#closeLabel {
|
||||||
|
-fx-font-size: 30;
|
||||||
|
-fx-text-fill: -fx-pp-dark-text-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#closeLabel:hover {
|
||||||
|
-fx-text-fill: red;
|
||||||
|
-fx-font-size: 33px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,14 +4,18 @@
|
|||||||
<?import com.jfoenix.controls.JFXDialogLayout?>
|
<?import com.jfoenix.controls.JFXDialogLayout?>
|
||||||
<?import com.jfoenix.controls.JFXSlider?>
|
<?import com.jfoenix.controls.JFXSlider?>
|
||||||
<?import com.jfoenix.controls.JFXTextField?>
|
<?import com.jfoenix.controls.JFXTextField?>
|
||||||
<?import java.lang.String?>
|
<?import java.net.URL?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<JFXDialogLayout maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="550.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.dialogs.ServerCreationController">
|
|
||||||
|
<JFXDialogLayout maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
|
||||||
|
minWidth="-Infinity" prefWidth="550.0" xmlns="http://javafx.com/javafx/8.0.111"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="seng302.visualiser.controllers.dialogs.ServerCreationController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane>
|
<GridPane>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
@@ -59,11 +63,13 @@
|
|||||||
</VBox>
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
<Label fx:id="closeLabel" text="✖" GridPane.halignment="RIGHT"
|
||||||
|
GridPane.valignment="TOP"/>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
<String fx:value="/css/dialogs/ServerCreation.css" />
|
<URL value="@../../css/dialogs/ServerCreation.css"/>
|
||||||
<String fx:value="/css/Master.css"/>
|
<URL value="@../../css/Master.css"/>
|
||||||
</stylesheets>
|
</stylesheets>
|
||||||
</JFXDialogLayout>
|
</JFXDialogLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user