mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Lobby view will switch to race view when received race status packet with race start type.
Ready button can only be pressed by host. Once pressed, it will send out race status packet with race start to all clients. #story[1055]
This commit is contained in:
@@ -18,6 +18,7 @@ import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
@@ -29,19 +30,20 @@ import seng302.client.ClientState;
|
||||
import seng302.client.ClientStateQueryingRunnable;
|
||||
import seng302.gameServer.GameStages;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.gameServer.MainServerThread;
|
||||
|
||||
/**
|
||||
* A class describing the actions of the lobby screen
|
||||
* Created by wmu16 on 10/07/17.
|
||||
*/
|
||||
public class LobbyController implements Initializable, Observer{
|
||||
|
||||
|
||||
@FXML
|
||||
private GridPane lobbyScreen;
|
||||
@FXML
|
||||
private Text lobbyIpText;
|
||||
@FXML
|
||||
private Button readyButton;
|
||||
@FXML
|
||||
private ListView firstListView;
|
||||
@FXML
|
||||
private ListView secondListView;
|
||||
@@ -85,6 +87,9 @@ public class LobbyController implements Initializable, Observer{
|
||||
private static ObservableList<String> eighthCompetitor = FXCollections.observableArrayList();
|
||||
private ClientStateQueryingRunnable clientStateQueryingRunnable;
|
||||
|
||||
private Boolean switchedPane = false;
|
||||
private MainServerThread mainServerThread;
|
||||
|
||||
private void setContentPane(String jfxUrl) {
|
||||
try {
|
||||
AnchorPane contentPane = (AnchorPane) lobbyScreen.getParent();
|
||||
@@ -102,10 +107,14 @@ public class LobbyController implements Initializable, Observer{
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
if (ClientState.isHost())
|
||||
if (ClientState.isHost()) {
|
||||
lobbyIpText.setText("Lobby Host IP: " + ClientState.getHostIp());
|
||||
else
|
||||
readyButton.setDisable(false);
|
||||
}
|
||||
else {
|
||||
lobbyIpText.setText("Connected to IP: ");
|
||||
readyButton.setDisable(true);
|
||||
}
|
||||
initialiseListView();
|
||||
// initialiseLobbyControllerThread();
|
||||
// initialiseImageView(); // parrot gif init
|
||||
@@ -124,9 +133,12 @@ public class LobbyController implements Initializable, Observer{
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// switchToRaceView();
|
||||
initialiseListView();
|
||||
// clientStateQueryingRunnable.terminate();
|
||||
if (arg.equals("game started") && !switchedPane) {
|
||||
switchToRaceView();
|
||||
}
|
||||
if (arg.equals(("update players"))) {
|
||||
initialiseListView();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -163,8 +175,6 @@ public class LobbyController implements Initializable, Observer{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
firstListView.setItems(firstCompetitor);
|
||||
secondListView.setItems(secondCompetitor);
|
||||
thirdListView.setItems(thirdCompetitor);
|
||||
@@ -220,11 +230,19 @@ public class LobbyController implements Initializable, Observer{
|
||||
|
||||
@FXML
|
||||
public void readyButtonPressed() {
|
||||
setContentPane("/views/RaceView.fxml");
|
||||
// setContentPane("/views/RaceView.fxml");
|
||||
GameState.setCurrentStage(GameStages.RACING);
|
||||
mainServerThread.startGame();
|
||||
}
|
||||
|
||||
private void switchToRaceView() {
|
||||
setContentPane("/views/RaceView.fxml");
|
||||
if (!switchedPane) {
|
||||
switchedPane = true;
|
||||
setContentPane("/views/RaceView.fxml");
|
||||
}
|
||||
}
|
||||
|
||||
public void setMainServerThread(MainServerThread mainServerThread) {
|
||||
this.mainServerThread = mainServerThread;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user