Made loungeView a sensible size and added a button and made it at the moment the main scene
This commit is contained in:
parent
3f88831466
commit
505577817e
@ -80,16 +80,14 @@ public class Client {
|
||||
}
|
||||
sendMsgToServer(Protocol.clientLogin + "$" + systemName);
|
||||
this.chatApp = new ChatApp(new ClientModel(systemName, this));
|
||||
//this.chatGui = new GUI(this.chatApp);
|
||||
this.gui = new GUI(this.chatApp);
|
||||
clientPinger = new ClientPinger(this, this.socket);
|
||||
this.gameStateModel = new GameStateModel();
|
||||
this.chatApp = new ChatApp(new ClientModel(systemName, this));
|
||||
ChatApp.setGameController(new GameController(ChatApp.getClientModel(), gameStateModel));
|
||||
this.chatGui = new GUI(this.chatApp);
|
||||
this.gui = new GUI(this.chatApp);
|
||||
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) {
|
||||
@ -273,7 +271,7 @@ public class Client {
|
||||
cP.start();
|
||||
client.userInputListener(); //this one blocks.
|
||||
//Start the GUI
|
||||
GUI gui = new GUI(client.chatApp,client.loungeApp);
|
||||
GUI gui = new GUI(client.chatApp);
|
||||
Thread guiThread = new Thread(gui);
|
||||
guiThread.start();
|
||||
LOGGER.info("7");
|
||||
@ -372,7 +370,7 @@ public class Client {
|
||||
}
|
||||
break;
|
||||
case GuiParameters.listOfLobbies:
|
||||
//updateListOfLobbies(data); (commented out due to compiling error)
|
||||
updateListOfLobbies(data);
|
||||
//TODO
|
||||
break;
|
||||
case GuiParameters.VoteIsOver:
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat;
|
||||
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.ClientModel;
|
||||
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.LoungeSceneViewController;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import javafx.application.Application;
|
||||
@ -23,8 +26,8 @@ public class ChatApp extends Application {
|
||||
private static GameController gameController;
|
||||
private ClientModel cModel;
|
||||
private GameController gameC;
|
||||
|
||||
private static LoungeSceneViewController loungeSceneViewController;
|
||||
private LoungeSceneViewController lSVController;
|
||||
|
||||
public ChatApp() {
|
||||
super();
|
||||
@ -59,6 +62,11 @@ public class ChatApp extends Application {
|
||||
this.gameC = gameC;
|
||||
}
|
||||
|
||||
public void setlSVController(
|
||||
LoungeSceneViewController lSVController) {
|
||||
this.lSVController = lSVController;
|
||||
}
|
||||
|
||||
public ClientModel getcModel() {
|
||||
return cModel;
|
||||
}
|
||||
@ -88,6 +96,10 @@ public class ChatApp extends Application {
|
||||
return chatController;
|
||||
}
|
||||
|
||||
public LoungeSceneViewController getlSVController() {
|
||||
return lSVController;
|
||||
}
|
||||
|
||||
public static void setLoungeSceneViewController(LoungeSceneViewController controller) {
|
||||
loungeSceneViewController = controller;
|
||||
}
|
||||
@ -110,33 +122,33 @@ public class ChatApp extends Application {
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
this.setcModel(clientModel);
|
||||
this.setGameC(gameController);
|
||||
this.setlSVController(loungeSceneViewController);
|
||||
gameC.setClient(cModel);
|
||||
gameC.setGameStateModel(GameController.getGameStateModel());
|
||||
URL chatResource = ChatApp.class.getResource(
|
||||
"chat/ChatView.fxml");
|
||||
URL gameResource = ChatApp.class.getResource(
|
||||
"game/GameDayAll.fxml");
|
||||
URL loungeResource = ChatApp.class.getResource(
|
||||
"lounge/LoungeSceneView.fxml");
|
||||
try {
|
||||
Parent root = FXMLLoader.load(
|
||||
Objects.requireNonNull(gameResource));
|
||||
Parent lounge = FXMLLoader.load(
|
||||
Objects.requireNonNull(loungeResource));
|
||||
Node chat = FXMLLoader.load(Objects.requireNonNull(chatResource));
|
||||
Node game = FXMLLoader.load(Objects.requireNonNull(gameResource));
|
||||
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
|
||||
Scene scene = new Scene(root);
|
||||
scene.setRoot(root);
|
||||
Scene scene = new Scene(lounge);
|
||||
scene.setRoot(lounge);
|
||||
primaryStage.setScene(scene);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
primaryStage.setResizable(false);
|
||||
Node chat = FXMLLoader.load(
|
||||
Objects.requireNonNull(chatResource));
|
||||
|
||||
primaryStage.setTitle("Night Train To Budapest");
|
||||
primaryStage.setResizable(true);
|
||||
primaryStage.setTitle("Chat");
|
||||
primaryStage.show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
|
||||
@ -1,7 +1,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.ChatApp;
|
||||
import javafx.application.Application;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -12,21 +12,21 @@ public class GUI implements Runnable {
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
private ChatApp chatApp;
|
||||
private LoungeApp loungeApp;
|
||||
//private LoungeApp loungeApp;
|
||||
|
||||
public GUI(ChatApp chatApp) {
|
||||
this.chatApp = chatApp;
|
||||
}
|
||||
|
||||
public GUI(LoungeApp loungeApp) {
|
||||
/*public GUI(LoungeApp loungeApp) {
|
||||
this.loungeApp = loungeApp;
|
||||
}
|
||||
}*/
|
||||
|
||||
public GUI(ChatApp chatApp,
|
||||
/*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
|
||||
@ -42,6 +42,6 @@ public class GUI implements Runnable {
|
||||
public void run() {
|
||||
LOGGER.info("here");
|
||||
//Application.launch(this.chatApp.getClass());
|
||||
Application.launch(this.loungeApp.getClass());
|
||||
Application.launch(this.chatApp.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
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.ChatApp;
|
||||
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;
|
||||
|
||||
@ -1,7 +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.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;
|
||||
@ -38,8 +38,10 @@ import javafx.scene.text.Text;
|
||||
|
||||
public class LoungeSceneViewController implements Initializable {
|
||||
|
||||
Protocol protocol;
|
||||
|
||||
@FXML
|
||||
public Button leaveLobbyButton;
|
||||
@FXML
|
||||
public Button newGameButton;
|
||||
@FXML
|
||||
private ListView<HBox> LobbyListView;
|
||||
@ -80,9 +82,8 @@ 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());
|
||||
LeaveServerButton.setOnAction(event -> leaveServer());
|
||||
newGameButton.setOnAction(event -> newGame());
|
||||
LobbyListView.setVisible(true);
|
||||
ClientListView.setVisible(true);
|
||||
@ -169,8 +170,9 @@ public class LoungeSceneViewController implements Initializable {
|
||||
client.getClient().sendMsgToServer(Protocol.startANewGame);
|
||||
}
|
||||
|
||||
;
|
||||
public void leaveLobby() {client.getClient().sendMsgToServer(Protocol.leaveLobby);}
|
||||
|
||||
public void leaveServer() {client.getClient().sendMsgToServer(Protocol.clientQuitRequest);}
|
||||
/**
|
||||
* Used to add a new player to the list of players.
|
||||
* "NPLOS" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
||||
|
||||
@ -7,36 +7,37 @@
|
||||
<?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">
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" 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">
|
||||
<BorderPane fx:id="LoungeSceneBorderPane" layoutX="860.0" layoutY="440.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<top>
|
||||
<ToolBar fx:id="NTtBToolBar" prefHeight="77.0" prefWidth="1913.0" BorderPane.alignment="CENTER">
|
||||
<ToolBar fx:id="NTtBToolBar" prefHeight="77.0" BorderPane.alignment="CENTER">
|
||||
<items>
|
||||
<Button fx:id="ChangeNameButton" mnemonicParsing="false" text="Change Name" />
|
||||
<Button fx:id="LeaveServerButton" mnemonicParsing="false" text="Leave server" />
|
||||
<Button fx:id="leaveLobbyButton" mnemonicParsing="false" onAction="#leaveLobby" text="Leave Lobby" />
|
||||
</items>
|
||||
</ToolBar>
|
||||
</top>
|
||||
<center>
|
||||
<AnchorPane prefHeight="661.0" prefWidth="600.0" BorderPane.alignment="CENTER">
|
||||
<AnchorPane BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Button fx:id="newGameButton" layoutX="272.0" layoutY="103.0" mnemonicParsing="false" text="New Game" />
|
||||
<Button fx:id="newGameButton" layoutX="136.0" layoutY="105.0" mnemonicParsing="false" text="New Game" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</center>
|
||||
<bottom>
|
||||
<AnchorPane fx:id="ChatArea" prefHeight="342.0" prefWidth="1920.0" BorderPane.alignment="CENTER">
|
||||
<AnchorPane fx:id="ChatArea" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<HBox fx:id="ChatAreaHBox" layoutX="394.0" layoutY="-9.0" prefHeight="322.0" prefWidth="1920.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
<HBox fx:id="ChatAreaHBox" layoutX="394.0" layoutY="-33.0" prefWidth="842.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-33.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</bottom>
|
||||
<left>
|
||||
<ListView fx:id="ClientListView" prefHeight="681.0" prefWidth="661.0" BorderPane.alignment="CENTER" />
|
||||
<ListView fx:id="ClientListView" BorderPane.alignment="CENTER" />
|
||||
</left>
|
||||
<right>
|
||||
<ListView fx:id="LobbyListView" prefHeight="681.0" prefWidth="641.0" BorderPane.alignment="CENTER" />
|
||||
<ListView fx:id="LobbyListView" BorderPane.alignment="CENTER" />
|
||||
</right>
|
||||
</BorderPane>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user