mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge remote-tracking branch 'origin/develop' into 1293_PowerUps
# Conflicts: # src/main/resources/views/RaceView.fxml
This commit is contained in:
@@ -7,6 +7,7 @@ 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;
|
||||
@@ -27,6 +28,7 @@ import seng302.utilities.Sounds;
|
||||
import seng302.visualiser.ServerListener;
|
||||
import seng302.visualiser.ServerListenerDelegate;
|
||||
import seng302.visualiser.controllers.cells.ServerCell;
|
||||
import seng302.visualiser.controllers.dialogs.ServerCreationController;
|
||||
import seng302.visualiser.validators.HostNameFieldValidator;
|
||||
import seng302.visualiser.validators.NumberRangeValidator;
|
||||
import seng302.visualiser.validators.ValidationTools;
|
||||
@@ -55,6 +57,14 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
|
||||
private Label noServersFound;
|
||||
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.
|
||||
@Override
|
||||
@@ -115,6 +125,8 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
serverListHostButton.setOnAction(action -> {
|
||||
showServerCreationDialog();
|
||||
});
|
||||
|
||||
addServerCreationDialogListener(this::closeServerCreationDialog);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,9 +137,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) {
|
||||
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.
|
||||
*/
|
||||
@@ -203,4 +221,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +102,6 @@ public class ViewManager {
|
||||
gameClient.stopGame();
|
||||
System.exit(0);
|
||||
});
|
||||
|
||||
jfxSnackbar = new JFXSnackbar(decorator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,6 +186,7 @@ public class ViewManager {
|
||||
}
|
||||
});
|
||||
|
||||
jfxSnackbar = new JFXSnackbar(decorator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,6 +220,7 @@ public class ViewManager {
|
||||
.getController();
|
||||
keyBindingDialogController.setGameClient(this.gameClient);
|
||||
keyBindingDialog.show();
|
||||
decorator.requestFocus();
|
||||
Sounds.playButtonClick();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -71,8 +71,7 @@ public class KeyBindingDialogController implements Initializable {
|
||||
buttons = new ArrayList<>();
|
||||
Collections.addAll(buttons,
|
||||
zoomInbtn, zoomOutBtn, vmgBtn, sailInOutBtn, tackGybeBtn, upwindBtn, downwindBtn,
|
||||
viewButton,
|
||||
rightButton, leftButton, forwardButton, backwardButton);
|
||||
viewButton, rightButton, leftButton, forwardButton, backwardButton);
|
||||
bindButtonWithAction();
|
||||
loadKeyBind();
|
||||
|
||||
@@ -88,12 +87,10 @@ public class KeyBindingDialogController implements Initializable {
|
||||
resetBtn.setOnMouseClicked(event -> {
|
||||
gameKeyBind.setToDefault();
|
||||
loadKeyBind();
|
||||
showSnackBar("All keys reset!", false);
|
||||
});
|
||||
|
||||
closeLabel.setOnMouseClicked(event -> ViewManager.getInstance().closeKeyBindingDialog());
|
||||
|
||||
keyBindingDialogHeader.setFocusTraversable(true);
|
||||
keyBindingDialogHeader.requestFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,6 +158,7 @@ public class KeyBindingDialogController implements Initializable {
|
||||
+ "-fx-background-color: -fx-pp-front-color; "
|
||||
+ "-fx-text-fill: -fx-pp-theme-color; "
|
||||
+ "-fx-font-size: 13;");
|
||||
keyBindingDialogHeader.requestFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,14 +5,15 @@ import com.jfoenix.controls.JFXSlider;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.validation.RequiredFieldValidator;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import seng302.gameServer.ServerDescription;
|
||||
import seng302.utilities.Sounds;
|
||||
import seng302.visualiser.controllers.ServerListController.ServerCreationDialogListener;
|
||||
import seng302.visualiser.controllers.ViewManager;
|
||||
import seng302.visualiser.validators.FieldLengthValidator;
|
||||
import seng302.visualiser.validators.ValidationTools;
|
||||
@@ -28,8 +29,12 @@ public class ServerCreationController implements Initializable {
|
||||
private Label maxPlayersLabel;
|
||||
@FXML
|
||||
private JFXButton submitBtn;
|
||||
@FXML
|
||||
private Label closeLabel;
|
||||
//---------FXML END---------//
|
||||
|
||||
private List<ServerCreationDialogListener> serverCreationDialogListeners;
|
||||
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
updateMaxPlayerLabel();
|
||||
maxPlayersSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||
@@ -49,6 +54,7 @@ public class ServerCreationController implements Initializable {
|
||||
validateServerSettings();
|
||||
});
|
||||
|
||||
closeLabel.setOnMouseClicked(event -> notifyListeners());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,4 +93,14 @@ public class ServerCreationController implements Initializable {
|
||||
Sounds.playHoverSound();
|
||||
}
|
||||
|
||||
public void setListener(List<ServerCreationDialogListener> serverCreationDialogListeners) {
|
||||
this.serverCreationDialogListeners = serverCreationDialogListeners;
|
||||
}
|
||||
|
||||
public void notifyListeners() {
|
||||
for (ServerCreationDialogListener serverCreationDialogListener : serverCreationDialogListeners) {
|
||||
serverCreationDialogListener.notifyClosure();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user