mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Finished implementing room codes.
- Fixed bug where room code wasn't parsed correctly - Added room code selection to server list screen. - Added room code to hosts lobby. - Implemented communication protocols on the game client. Tags: #story[1281]
This commit is contained in:
@@ -23,6 +23,8 @@ import javafx.scene.layout.VBox;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.gameServer.ServerDescription;
|
||||
import seng302.serverRepository.ServerListing;
|
||||
import seng302.serverRepository.ServerRepositoryClient;
|
||||
import seng302.utilities.Sounds;
|
||||
import seng302.visualiser.ServerListener;
|
||||
import seng302.visualiser.ServerListenerDelegate;
|
||||
@@ -51,6 +53,10 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
private JFXTextField serverHostName;
|
||||
@FXML
|
||||
private JFXTextField serverPortNumber;
|
||||
@FXML
|
||||
private JFXButton roomConnectButton;
|
||||
@FXML
|
||||
private JFXTextField roomNumber;
|
||||
//---------FXML END---------//
|
||||
|
||||
private Label noServersFound;
|
||||
@@ -64,6 +70,17 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
// Set Event Bindings
|
||||
connectButton.setOnMouseEntered(event -> Sounds.playHoverSound());
|
||||
serverListHostButton.setOnMouseEntered(event -> Sounds.playHoverSound());
|
||||
|
||||
roomConnectButton.setOnMouseReleased(event -> {
|
||||
connectToRoomCode(roomNumber.getText());
|
||||
Sounds.playButtonClick();
|
||||
});
|
||||
roomNumber.setOnKeyPressed(event -> {
|
||||
if (event.getCode().equals(KeyCode.ENTER)) {
|
||||
connectToRoomCode(roomNumber.getText());
|
||||
}
|
||||
});
|
||||
|
||||
connectButton.setOnMouseReleased(event -> {
|
||||
attemptToDirectConnect();
|
||||
Sounds.playButtonClick();
|
||||
@@ -150,6 +167,15 @@ public class ServerListController implements Initializable, ServerListenerDelega
|
||||
return hostNameValid && portNumberValid;
|
||||
}
|
||||
|
||||
private void connectToRoomCode(String roomCode){
|
||||
try {
|
||||
ServerListing serverListing = new ServerRepositoryClient().getServerForRoomCode(roomCode);
|
||||
ViewManager.getInstance().getGameClient().runAsClient(serverListing.getAddress(), serverListing.getPortNumber());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects the user to a lobby via the Direct Connect form.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user