mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge remote-tracking branch 'origin/develop' into 1273_Skybox
# Conflicts: # src/main/java/seng302/gameServer/GameState.java # src/main/java/seng302/gameServer/MainServerThread.java # src/main/java/seng302/gameServer/MessageFactory.java # src/main/java/seng302/gameServer/ServerToClientThread.java # src/main/java/seng302/model/ClientYacht.java # src/main/java/seng302/model/mark/MarkOrder.java # src/main/java/seng302/visualiser/GameClient.java # src/main/java/seng302/visualiser/GameView3D.java # src/main/java/seng302/visualiser/controllers/ServerListController.java # src/main/java/seng302/visualiser/controllers/dialogs/ServerCreationController.java # src/main/resources/icons/bumperIcon.png # src/main/resources/icons/handlingIcon.png # src/main/resources/icons/velocity.png # src/main/resources/icons/windWalkerIcon.png # src/main/resources/views/RaceView.fxml # src/main/resources/views/dialogs/ServerCreationDialog.fxml
This commit is contained in:
@@ -5,6 +5,12 @@ import com.jfoenix.controls.JFXDialog;
|
||||
import com.jfoenix.controls.JFXDialog.DialogTransition;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.validation.RequiredFieldValidator;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
@@ -32,6 +38,10 @@ import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import seng302.visualiser.controllers.dialogs.ServerCreationController;
|
||||
import seng302.visualiser.validators.HostNameFieldValidator;
|
||||
import seng302.visualiser.validators.NumberRangeValidator;
|
||||
import seng302.visualiser.validators.ValidationTools;
|
||||
|
||||
public class ServerListController implements Initializable, ServerListenerDelegate {
|
||||
|
||||
@@ -63,6 +73,14 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
private Logger logger = LoggerFactory.getLogger(ServerListController.class);
|
||||
private JFXDialog directConnectDialog;
|
||||
|
||||
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.
|
||||
@Override
|
||||
@@ -166,6 +184,8 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
serverListHostButton.setOnAction(action -> {
|
||||
showServerCreationDialog();
|
||||
});
|
||||
|
||||
addServerCreationDialogListener(this::closeServerCreationDialog);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,9 +196,11 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
FXMLLoader dialogContent = new FXMLLoader(getClass().getResource(
|
||||
"/views/dialogs/ServerCreationDialog.fxml"));
|
||||
try {
|
||||
JFXDialog dialog = new JFXDialog(serverListMainStackPane, dialogContent.load(),
|
||||
serverCreationDialog = new JFXDialog(serverListMainStackPane, dialogContent.load(),
|
||||
DialogTransition.CENTER);
|
||||
dialog.show();
|
||||
ServerCreationController serverCreationController = dialogContent.getController();
|
||||
serverCreationController.setListener(serverCreationDialogListeners);
|
||||
serverCreationDialog.show();
|
||||
Sounds.playButtonClick();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -205,6 +227,10 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
return dcDialog;
|
||||
}
|
||||
|
||||
private void closeServerCreationDialog() {
|
||||
serverCreationDialog.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the connection and attempts to connect to a given hostname and port number.
|
||||
*/
|
||||
@@ -303,4 +329,14 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
public void serverDetected(ServerDescription serverDescription, List<ServerDescription> servers) {
|
||||
Platform.runLater(() -> refreshServers(servers));
|
||||
}
|
||||
|
||||
private void addServerCreationDialogListener(
|
||||
ServerCreationDialogListener serverCreationDialogListener) {
|
||||
serverCreationDialogListeners.add(serverCreationDialogListener);
|
||||
}
|
||||
|
||||
private void removeServerCreationDialogListener(
|
||||
ServerCreationDialogListener serverCreationDialogListener) {
|
||||
serverCreationDialogListeners.remove(serverCreationDialogListener);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user