Fever dream
This commit is contained in:
parent
9007870d19
commit
2e9a47cbd4
@ -8,6 +8,7 @@ import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.GameController;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeSceneViewController;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.ClientPinger;
|
||||
|
||||
@ -39,10 +40,15 @@ public class Client {
|
||||
public ClientPinger clientPinger;
|
||||
|
||||
private ChatApp chatApp;
|
||||
private GUI chatGui;
|
||||
//private GUI chatGui;
|
||||
private ClientModel clientModel;
|
||||
private GameStateModel gameStateModel;
|
||||
private GameController gameController;
|
||||
|
||||
private GUI gui;
|
||||
|
||||
private LoungeApp loungeApp;
|
||||
//private GUI loungeGui;
|
||||
private LoungeSceneViewController loungeSceneViewController;
|
||||
|
||||
/**
|
||||
@ -73,10 +79,13 @@ public class Client {
|
||||
}
|
||||
sendMsgToServer(Protocol.clientLogin + "$" + systemName);
|
||||
this.chatApp = new ChatApp(new ClientModel(systemName, this));
|
||||
this.chatGui = new GUI(this.chatApp);
|
||||
//this.chatGui = new GUI(this.chatApp);
|
||||
clientPinger = new ClientPinger(this, this.socket);
|
||||
this.gameStateModel = new GameStateModel();
|
||||
this.gameController = new GameController(ChatApp.getClientModel(), gameStateModel);
|
||||
this.loungeApp = new LoungeApp(ChatApp.getClientModel());
|
||||
//this.loungeGui = new GUI(this.loungeApp);
|
||||
this.gui = new GUI(this.chatApp,this.loungeApp);
|
||||
this.loungeSceneViewController = new LoungeSceneViewController();
|
||||
LoungeSceneViewController.setClient(ChatApp.getClientModel());
|
||||
} catch (IOException e) {
|
||||
@ -257,7 +266,7 @@ public class Client {
|
||||
cP.start();
|
||||
client.userInputListener(); //this one blocks.
|
||||
//Start the GUI
|
||||
GUI gui = new GUI(client.chatApp);
|
||||
GUI gui = new GUI(client.chatApp,client.loungeApp);
|
||||
Thread guiThread = new Thread(gui);
|
||||
guiThread.start();
|
||||
LOGGER.info("7");
|
||||
@ -287,7 +296,7 @@ public class Client {
|
||||
cP.start();
|
||||
client.userInputListener(); //this one blocks.
|
||||
LOGGER.info("7.1");
|
||||
Thread guiThread = new Thread(client.chatGui);
|
||||
Thread guiThread = new Thread(client.gui);
|
||||
LOGGER.info("8");
|
||||
guiThread.start();
|
||||
LOGGER.info("9");
|
||||
|
||||
@ -61,12 +61,12 @@ public class JClientProtocolParser {
|
||||
break;
|
||||
case Protocol.printToGUI:
|
||||
String substring = msg.substring(6);
|
||||
int index = msg.indexOf("$");
|
||||
int index = substring.indexOf("$");
|
||||
String parameter = "";
|
||||
String data = substring;
|
||||
try {
|
||||
parameter = msg.substring(0,index);
|
||||
data = msg.substring(index+1);
|
||||
parameter = substring.substring(0,index);
|
||||
data = substring.substring(index+1);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("No parameter in PTGUI");
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeApp;
|
||||
import javafx.application.Application;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -12,12 +13,21 @@ public class GUI implements Runnable {
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
private ChatApp chatApp;
|
||||
|
||||
private LoungeApp loungeApp;
|
||||
|
||||
public GUI(ChatApp chatApp) {
|
||||
this.chatApp = chatApp;
|
||||
}
|
||||
|
||||
public GUI(LoungeApp loungeApp) {
|
||||
this.loungeApp = loungeApp;
|
||||
}
|
||||
|
||||
public GUI(ChatApp chatApp,
|
||||
LoungeApp loungeApp) {
|
||||
this.chatApp = chatApp;
|
||||
this.loungeApp = loungeApp;
|
||||
}
|
||||
|
||||
/**
|
||||
* When an object implementing interface {@code Runnable} is used to create a thread, starting the
|
||||
@ -32,6 +42,7 @@ public class GUI implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
LOGGER.info("here");
|
||||
Application.launch(this.chatApp.getClass());
|
||||
//Application.launch(this.chatApp.getClass());
|
||||
Application.launch(this.loungeApp.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeSceneViewController;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import javafx.application.Application;
|
||||
@ -21,6 +22,8 @@ public class ChatApp extends Application {
|
||||
private static ChatController chatController;
|
||||
private ClientModel cModel;
|
||||
|
||||
private static LoungeSceneViewController loungeSceneViewController;
|
||||
|
||||
public ChatApp() {
|
||||
super();
|
||||
LOGGER.info("Empty ChatApp constructor got called: ");
|
||||
@ -66,6 +69,10 @@ public class ChatApp extends Application {
|
||||
return chatController;
|
||||
}
|
||||
|
||||
public static void setLoungeSceneViewController(LoungeSceneViewController controller) {
|
||||
loungeSceneViewController = controller;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The main entry point for all JavaFX applications. The start method is called after the init
|
||||
@ -94,6 +101,7 @@ public class ChatApp extends Application {
|
||||
Objects.requireNonNull(ChatApp.class.getResource(
|
||||
"ChatView.fxml")));
|
||||
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
|
||||
|
||||
Scene scene = new Scene(root);
|
||||
scene.setRoot(root);
|
||||
primaryStage.setScene(scene);
|
||||
@ -101,7 +109,7 @@ public class ChatApp extends Application {
|
||||
e.printStackTrace();
|
||||
}
|
||||
primaryStage.setResizable(true);
|
||||
primaryStage.setTitle("Chat");
|
||||
primaryStage.setTitle("Lounge");
|
||||
primaryStage.show();
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,128 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Class for debugging the lounge gui scene
|
||||
*/
|
||||
public class LoungeApp extends Application {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(ChatApp.class);
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
private static ClientModel clientModel;
|
||||
private static ChatController chatController;
|
||||
private ClientModel cModel;
|
||||
|
||||
private static LoungeSceneViewController loungeSceneViewController;
|
||||
|
||||
public LoungeApp() {
|
||||
super();
|
||||
LOGGER.info("Empty ChatApp constructor got called: ");
|
||||
}
|
||||
|
||||
public LoungeApp(ClientModel clientM) {
|
||||
clientModel = clientM;
|
||||
chatController = new ChatController(clientM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ChatController for the Application, needs to be static, but only one application can
|
||||
* be launched per programm
|
||||
*
|
||||
* @param chatC the ChatController to be linked to this chatApp
|
||||
*/
|
||||
public static void setChatController(ChatController chatC) {
|
||||
chatController = chatC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the non-static ClientModel field of this class
|
||||
*
|
||||
* @param cModel the non static ClientModel to be added
|
||||
*/
|
||||
public void setcModel(ClientModel cModel) {
|
||||
this.cModel = cModel;
|
||||
}
|
||||
|
||||
public ClientModel getcModel() {
|
||||
return cModel;
|
||||
}
|
||||
|
||||
public static void setClientModel(ClientModel clientM) {
|
||||
clientModel = clientM;
|
||||
}
|
||||
|
||||
public static ClientModel getClientModel() {
|
||||
return clientModel;
|
||||
}
|
||||
|
||||
public ChatController getChatController() {
|
||||
return chatController;
|
||||
}
|
||||
|
||||
public static void setLoungeSceneViewController(LoungeSceneViewController controller) {
|
||||
loungeSceneViewController = controller;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The main entry point for all JavaFX applications. The start method is called after the init
|
||||
* method has returned, and after the system is ready for the application to begin running.
|
||||
*
|
||||
* <p>
|
||||
* NOTE: This method is called on the JavaFX Application Thread.
|
||||
* </p>
|
||||
*
|
||||
* @param primaryStage the primary stage for this application, onto which the application scene
|
||||
* can be set. Applications may create other stages, if needed, but they will
|
||||
* not be primary stages.
|
||||
* @throws Exception if something goes wrong
|
||||
*/
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
this.setcModel(clientModel);
|
||||
URL resource = ChatApp.class.getResource(
|
||||
"LoungeSceneView.fxml");
|
||||
if (resource == null) {
|
||||
LOGGER.info("File wasnt found. Name: LoungeSceneView.fxml");
|
||||
}
|
||||
//ChatApp chatApp = new ChatApp(new ClientModel());
|
||||
try {
|
||||
Parent root = FXMLLoader.load(
|
||||
Objects.requireNonNull(LoungeApp.class.getResource(
|
||||
"LoungeSceneView.fxml")));
|
||||
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
|
||||
// loungeSceneViewController.getChatAreaHBox().getChildren()
|
||||
// .add(FXMLLoader.load(Objects.requireNonNull(ChatApp.class.getResource("ChatView.fxml"))));
|
||||
Scene scene = new Scene(root);
|
||||
scene.setRoot(root);
|
||||
primaryStage.setScene(scene);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
primaryStage.setResizable(true);
|
||||
primaryStage.setTitle("Lounge");
|
||||
primaryStage.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.events.ChangeNameButtonPressedEventHandler;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.events.LeaveServerButtonPressedEventHandler;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
@ -9,6 +10,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.SimpleListProperty;
|
||||
import javafx.beans.property.SimpleMapProperty;
|
||||
@ -57,6 +59,7 @@ public class LoungeSceneViewController implements Initializable {
|
||||
private ToolBar NTtBToolBar;
|
||||
|
||||
public static ClientModel client;
|
||||
public static ChatApp chatApp;
|
||||
|
||||
private ObservableMap<String, ObservableList<String>> lobbyToMemberssMap;
|
||||
private HashMap<String, String> clientToLobbyMap;
|
||||
@ -76,11 +79,13 @@ public class LoungeSceneViewController implements Initializable {
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
ChatApp.setLoungeSceneViewController(this);
|
||||
this.protocol = new Protocol();
|
||||
ChangeNameButton.setOnAction(event -> changeName());
|
||||
LeaveServerButton.setOnAction(new LeaveServerButtonPressedEventHandler());
|
||||
newGameButton.setOnAction(event -> newGame());
|
||||
|
||||
LobbyListView.setVisible(true);
|
||||
ClientListView.setVisible(true);
|
||||
ClientListView.setItems(client.getAllClients());
|
||||
LobbyListView.setPlaceholder(new Text("No open lobbies!"));
|
||||
client.getAllClients().addListener(new ListChangeListener<SimpleStringProperty>() {
|
||||
@ -136,8 +141,9 @@ public class LoungeSceneViewController implements Initializable {
|
||||
HBox lobby = new HBox();
|
||||
Label idLabel = new Label();
|
||||
Label adminLabel = new Label();
|
||||
idLabel.textProperty().bind(id);
|
||||
adminLabel.textProperty().bind(admin);
|
||||
idLabel.setText(lobbyID);
|
||||
adminLabel.setText(adminName);
|
||||
startOrJoin.setVisible(true);
|
||||
lobby.getChildren().add(idLabel);
|
||||
lobby.getChildren().add(adminLabel);
|
||||
lobby.getChildren().add(startOrJoin);
|
||||
@ -151,6 +157,7 @@ public class LoungeSceneViewController implements Initializable {
|
||||
}
|
||||
lobby.setId(lobbyID);
|
||||
lobbyToMemberssMap.put(lobbyID, members.getItems());
|
||||
lobby.setVisible(true);
|
||||
LobbyListView.getItems().add(lobby);
|
||||
}
|
||||
|
||||
@ -164,6 +171,11 @@ public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Used to add a new player to the list of players.
|
||||
* "NPLOS" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
||||
* @param s
|
||||
*/
|
||||
public void addClientToList(String s) {
|
||||
ClientListView.getItems().add(new SimpleStringProperty(s));
|
||||
}
|
||||
@ -174,13 +186,14 @@ public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
|
||||
public void changeName() {
|
||||
TextField name = new TextField("Enter new name!");
|
||||
TextField name = new TextField();
|
||||
name.setPromptText("Enter new Nickname!");
|
||||
this.NTtBToolBar.getItems().add(name);
|
||||
name.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
client.getClient().sendMsgToServer(Protocol.nameChange + "$" + name.getText());
|
||||
NTtBToolBar.getItems().remove(NTtBToolBar.getItems().size());
|
||||
NTtBToolBar.getItems().remove(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -204,4 +217,12 @@ public class LoungeSceneViewController implements Initializable {
|
||||
public static void setClient(ClientModel client) {
|
||||
LoungeSceneViewController.client = client;
|
||||
}
|
||||
|
||||
public HBox getChatAreaHBox() {
|
||||
return ChatAreaHBox;
|
||||
}
|
||||
|
||||
public void setChatAreaHBox(HBox chatAreaHBox) {
|
||||
ChatAreaHBox = chatAreaHBox;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,8 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.helpers;
|
||||
public class GuiParameters {
|
||||
|
||||
/**
|
||||
* Tells GUI to update the gameStateModel, in the form {@code UPDATE$name:role:kickedOff$name:role:kickedOff} ... usw.
|
||||
* Tells GUI to update the gameStateModel, in the form {@code UPDATE$name:role:kickedOff$name:role:kickedOff}
|
||||
* ... usw.
|
||||
*/
|
||||
public static final String updateGameState = "UPDATE";
|
||||
/**
|
||||
@ -20,8 +21,8 @@ public class GuiParameters {
|
||||
public static final String listOfPLayers = "PLAYERS";
|
||||
|
||||
/**
|
||||
* Tells Gui, that the passenger at position {@code position} has heard some noise
|
||||
* Form: {@code NOISE$position$}
|
||||
* Tells Gui, that the passenger at position {@code position} has heard some noise Form: {@code
|
||||
* NOISE$position$}
|
||||
*/
|
||||
public static final String noiseHeardAtPosition = "NOISE";
|
||||
|
||||
@ -41,22 +42,29 @@ public class GuiParameters {
|
||||
public static final String viewChangeToGame = "VCGAME";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tells Gui, who the members of a specified Lobby are.
|
||||
* Form: {@code LMEMBS$<lobbyID>:<ADMIN NAME>:<member names>:<..>}
|
||||
* Tells Gui, who the members of a specified Lobby are. Form: {@code LMEMBS$<lobbyID>:<ADMIN
|
||||
* NAME>:<member names>:<..>}
|
||||
*/
|
||||
public static final String getMembersInLobby = "LMEMBS";
|
||||
|
||||
/**
|
||||
* Tells Gui, that a new Lobby has been created.
|
||||
* Form: {@code NLOBBY$<lobbyID>:<Admin Name>}
|
||||
* Tells Gui, that a new Lobby has been created. Form: {@code NLOBBY$<lobbyID>:<Admin Name>}
|
||||
*/
|
||||
public static final String newLobbyCreated = "NLOBBY";
|
||||
|
||||
/**
|
||||
* Tells Gui, to add a player to a lobby.
|
||||
* Form: {@code NMEMB$<LobbyIS>:<PlayerNamse>}
|
||||
* Tells Gui, to add a player to a lobby. Form: {@code NMEMB$<LobbyIS>:<PlayerNamse>}
|
||||
*/
|
||||
public static final String addNewMemberToLobby = "NMEMB";
|
||||
|
||||
/**
|
||||
* Indicates a player changed their username. Form: {@code NCHANG$<oldName>:<newName>}
|
||||
*/
|
||||
public static final String nameChanged = "NCHANG";
|
||||
|
||||
/**
|
||||
* Indicates a player has joined the server. Form: {@code NPLOS$<playerName>}
|
||||
*/
|
||||
public static final String newPlayerOnServer = "NPLOS";
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import ch.unibas.dmi.dbis.cs108.gamelogic.Game;
|
||||
import ch.unibas.dmi.dbis.cs108.gamelogic.TrainOverflow;
|
||||
import ch.unibas.dmi.dbis.cs108.gamelogic.VoteHandler;
|
||||
import ch.unibas.dmi.dbis.cs108.highscore.OgGhostHighScore;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.ServerPinger;
|
||||
|
||||
@ -126,8 +127,12 @@ public class ClientHandler implements Runnable {
|
||||
*/
|
||||
public void changeUsername(String newName) {
|
||||
String helper = this.getClientUserName();
|
||||
String oldName = getClientUserName();
|
||||
this.clientUserName = nameDuplicateChecker.checkName(newName);
|
||||
guiUpdateAll(Protocol.printToGUI + "$" + GuiParameters.nameChanged + "$" + oldName + ":"
|
||||
+ getClientUserName());
|
||||
sendMsgToClient(Protocol.changedUserName + "$" + newName);
|
||||
|
||||
broadcastAnnouncementToAll(helper + " has changed their nickname to " + clientUserName);
|
||||
try {
|
||||
getLobby().getGame().getGameState().changeUsername(helper, newName);
|
||||
@ -245,6 +250,13 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public static void guiUpdateAll(String msg) {
|
||||
System.out.println(msg);
|
||||
for (ClientHandler client : connectedClients) {
|
||||
client.sendMsgToClient(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts a non-chat Message to all clients in the same lobby. This can be used for server
|
||||
* messages / announcements rather than chat messages. The message will be printed to the user
|
||||
@ -306,7 +318,8 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a given message to all connected client. The message has to already be protocol-formatted.
|
||||
* Sends a given message to all connected client. The message has to already be
|
||||
* protocol-formatted.
|
||||
*
|
||||
* @param msg the given message. Should already be protocol-formatted.
|
||||
*/
|
||||
@ -317,7 +330,9 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a Message to all clients in the same lobby. The message has to already be protocol-formatted.
|
||||
* Sends a Message to all clients in the same lobby. The message has to already be
|
||||
* protocol-formatted.
|
||||
*
|
||||
* @param msg the given message. Should already be protocol-formatted.
|
||||
*/
|
||||
public void sendMsgToClientsInLobby(String msg) {
|
||||
@ -456,6 +471,8 @@ public class ClientHandler implements Runnable {
|
||||
public void createNewLobby() {
|
||||
if (Lobby.clientIsInLobby(this) == -1) {
|
||||
Lobby newGame = new Lobby(this);
|
||||
guiUpdateAll(Protocol.printToGUI + "$" + GuiParameters.newLobbyCreated + "$" + getLobby()
|
||||
.getLobbyID() + ":" + getClientUserName());
|
||||
} else {
|
||||
sendAnnouncementToClient("You are already in lobby nr. " + Lobby.clientIsInLobby(this));
|
||||
}
|
||||
@ -472,6 +489,8 @@ public class ClientHandler implements Runnable {
|
||||
if (l != null) {
|
||||
if (l.getLobbyIsOpen()) {
|
||||
l.addPlayer(this);
|
||||
guiUpdateAll(Protocol.printToGUI + "$" + GuiParameters.addNewMemberToLobby + "$" + i + ":"
|
||||
+ getClientUserName());
|
||||
} else {
|
||||
sendAnnouncementToClient("The game in Lobby " + l.getLobbyID()
|
||||
+ " has already started, or the lobby is already full.");
|
||||
@ -567,11 +586,11 @@ public class ClientHandler implements Runnable {
|
||||
sendAnnouncementToClient("No Games");
|
||||
} else {
|
||||
sendAnnouncementToClient("Open Games (i.e. open Lobbies):");
|
||||
for (Lobby l : Lobby.lobbies) {
|
||||
if (l.getLobbyIsOpen()) {
|
||||
sendAnnouncementToClient(" - Lobby Nr. " + l.getLobbyID());
|
||||
}
|
||||
for (Lobby l : Lobby.lobbies) {
|
||||
if (l.getLobbyIsOpen()) {
|
||||
sendAnnouncementToClient(" - Lobby Nr. " + l.getLobbyID());
|
||||
}
|
||||
}
|
||||
sendAnnouncementToClient("Running Games:");
|
||||
try {
|
||||
for (Game runningGame : Lobby.runningGames) {
|
||||
@ -627,7 +646,7 @@ public class ClientHandler implements Runnable {
|
||||
public void sendHighScoreList() {
|
||||
String list = OgGhostHighScore.formatGhostHighscoreList();
|
||||
String[] listarray = list.split("\\R");
|
||||
for (String s: listarray) {
|
||||
for (String s : listarray) {
|
||||
sendAnnouncementToClient(s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,6 @@ public class JServerProtocolParser {
|
||||
try {
|
||||
int i = Integer.parseInt(msg.substring(6, 7));
|
||||
h.joinLobby(i);
|
||||
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||
} catch (Exception e) {
|
||||
h.sendMsgToClient(Protocol.printToClientConsole
|
||||
+ "$Invalid input. Please use JOINL$1 to join Lobby 1, for example.");
|
||||
@ -90,7 +89,12 @@ public class JServerProtocolParser {
|
||||
break;
|
||||
case Protocol.createNewLobby:
|
||||
h.createNewLobby();
|
||||
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby+ "$");
|
||||
h.sendMsgToClient(
|
||||
Protocol.printToGUI + "$" + GuiParameters.newLobbyCreated + "$" + h.getLobby()
|
||||
.getLobbyID() + ":" + h.getClientUserName());
|
||||
h.guiUpdateAll(Protocol.printToGUI + "$" + GuiParameters.newLobbyCreated + "$" + h.getLobby()
|
||||
.getLobbyID() + ":" + h.getClientUserName());
|
||||
LOGGER.info("Here");
|
||||
break;
|
||||
case Protocol.listLobbies:
|
||||
h.listLobbies();
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.ToolBar?>
|
||||
<?import javafx.scene.control.TreeView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1080.0" prefWidth="1920.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeSceneViewController">
|
||||
<children>
|
||||
<BorderPane fx:id="LoungeSceneBorderPane" layoutX="860.0" layoutY="440.0" prefHeight="1080.0" prefWidth="1920.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
@ -23,7 +21,7 @@
|
||||
<center>
|
||||
<AnchorPane prefHeight="661.0" prefWidth="600.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Button fx:id="newGameButton" mnemonicParsing="false" text="New Game" />
|
||||
<Button fx:id="newGameButton" layoutX="272.0" layoutY="103.0" mnemonicParsing="false" text="New Game" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</center>
|
||||
|
||||
Reference in New Issue
Block a user