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/Story62_Reading_Keystrokes' into Story62_Reading_Keystrokes
# Conflicts: # src/main/java/seng302/controllers/LobbyController.java # src/main/java/seng302/gameServer/MainServerThread.java
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
package seng302.controllers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.text.Text;
|
||||
import seng302.gameServer.GameServerThread;
|
||||
import seng302.gameServer.GameStages;
|
||||
import seng302.gameServer.GameState;
|
||||
|
||||
import java.io.IOException;
|
||||
import seng302.gameServerWithThreading.MainServerThread;
|
||||
import seng302.gameServerWithThreading.ServerToClientThread;
|
||||
|
||||
/**
|
||||
* A class describing the actions of the lobby screen
|
||||
@@ -17,11 +25,16 @@ import java.io.IOException;
|
||||
*/
|
||||
public class LobbyController {
|
||||
|
||||
@FXML
|
||||
private ListView competitorsListView;
|
||||
@FXML
|
||||
private GridPane lobbyScreen;
|
||||
@FXML
|
||||
private Text lobbyIpText;
|
||||
|
||||
private GameServerThread gameServerThread;
|
||||
private static ObservableList competitors;
|
||||
|
||||
private void setContentPane(String jfxUrl) {
|
||||
try {
|
||||
AnchorPane contentPane = (AnchorPane) lobbyScreen.getParent();
|
||||
@@ -37,6 +50,11 @@ public class LobbyController {
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
competitors = FXCollections.observableArrayList();
|
||||
competitorsListView.setItems(competitors);
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void leaveLobbyButtonPressed() {
|
||||
@@ -44,12 +62,21 @@ public class LobbyController {
|
||||
setContentPane("/views/StartScreenView.fxml");
|
||||
System.out.println("Leaving lobby!");
|
||||
GameState.setCurrentStage(GameStages.CANCELLED);
|
||||
gameServerThread.terminateGame();
|
||||
}
|
||||
|
||||
public static void refreshCompetitors(){
|
||||
Collection<String> competitorsIps = MainServerThread.getServerToClientThreads();
|
||||
competitors.clear();
|
||||
competitors.addAll(competitorsIps);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void readyButtonPressed() {
|
||||
GameState.setCurrentStage(GameStages.RACING);
|
||||
}
|
||||
|
||||
protected void setGameServerThread(GameServerThread gameServerThread) {
|
||||
this.gameServerThread = gameServerThread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,10 +78,14 @@ public class StartScreenController {
|
||||
public void connectButtonPressed() {
|
||||
// TODO: 10/07/17 wmu16 - Finish function
|
||||
String ipAddress = ipTextField.getText().trim().toLowerCase();
|
||||
ClientToServerThread clientToServerThread = new ClientToServerThread(ipAddress, 4950);
|
||||
controller.setClientToServerThread(clientToServerThread);
|
||||
clientToServerThread.start();
|
||||
|
||||
try {
|
||||
ClientToServerThread clientToServerThread = new ClientToServerThread(ipAddress, 4950);
|
||||
controller.setClientToServerThread(clientToServerThread);
|
||||
clientToServerThread.start();
|
||||
setContentPane("/views/LobbyView.fxml");
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setController(Controller controller) {
|
||||
|
||||
Reference in New Issue
Block a user