Changed some layouts, wasted a lot of time and made sure the LobbyDisplayHandler-Updater can only have one thread at a time that is writing to the same data

This commit is contained in:
Seraina 2022-05-17 16:49:35 +02:00
parent 43aab6c282
commit 3b5b2da60e
7 changed files with 71 additions and 36 deletions

View File

@ -10,6 +10,7 @@ import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.Sprites;
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.ListOfLobbiesController;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LobbyDisplayHandler;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeApp;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeSceneViewController;
@ -382,12 +383,13 @@ public class Client {
chatApp.getLoungeSceneViewController().addGameView();
gameStateModel.setGameOver(false);
dayNightChangeListener = new DayNightChangeListener(gameStateModel, chatApp, Integer.MAX_VALUE);
ListOfLobbiesController.setGameOngoing(true);
new Thread(dayNightChangeListener).start();
break;
case GuiParameters.viewChangeToLobby:
chatApp.getLoungeSceneViewController().removeGameView();
gameStateModel.setGameOver(true);
//TODO
ListOfLobbiesController.setGameOngoing(false);
break;
case GuiParameters.updateHighScore:
chatApp.getLoungeSceneViewController().addHighScore(data);
@ -398,10 +400,14 @@ public class Client {
case GuiParameters.updateLobbyString:
if(!data.isEmpty()) {
lobbyDisplayHandler.updateLobbies(data);
if(!ListOfLobbiesController.isGameOngoing()) {
ChatApp.getListController().updateList();
}
} else {
if(!ListOfLobbiesController.isGameOngoing()) {
ChatApp.getListController().clearVBox();
}
}
break;
default:
notificationTextDisplay(data);

View File

@ -44,11 +44,19 @@ public class ListOfLobbiesController implements Initializable {
private ChatApp chatApp; //TODO: VeryImportant to set this one right!
private HashSet<TreeView> treeViews = new HashSet<TreeView>();
private static boolean gameOngoing = false;
public void setChatApp(ChatApp chatApp) {
this.chatApp = chatApp;
}
public static void setGameOngoing(boolean gameOngoing) {
ListOfLobbiesController.gameOngoing = gameOngoing;
}
public static boolean isGameOngoing() {
return gameOngoing;
}
public void updateList() {
new Thread(new Runnable() {

View File

@ -4,11 +4,11 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<ScrollPane fx:id="backDropScrolePane" hbarPolicy="NEVER" prefHeight="300.0" prefWidth="200.0" stylesheets="@listStyle.css" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.ListOfLobbiesController">
<ScrollPane fx:id="backDropScrolePane" hbarPolicy="NEVER" minHeight="400.0" minWidth="450.0" stylesheets="@listStyle.css" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.ListOfLobbiesController">
<content>
<AnchorPane fx:id="scollingAnchorPane">
<AnchorPane fx:id="scollingAnchorPane" minHeight="400.0" minWidth="450.0">
<children>
<VBox fx:id="LobbyListVBox" fillWidth="false" prefWidth="200.0" />
<VBox fx:id="LobbyListVBox" fillWidth="false" maxWidth="450.0" minHeight="400.0" minWidth="450.0" />
</children></AnchorPane>
</content>
</ScrollPane>

View File

@ -0,0 +1,41 @@
*{
-fx-background-color: transparent;
-fx-text-fill: white;
-fx-font-family: serif;
}
.border-pane{
-fx-background-color: rgb(15,26,59,0.8);
-fx-border-color: rgb(204,186,138);
-fx-border-width: 10;
}
.tool-bar{
-fx-background-color: rgb(15,26,59,0.8);
}
#highScore{
-fx-background-color: rgb(15,26,59,0.8);
-fx-text-fill: white;
-fx-font-family: serif;
}
#listTilePane{
-fx-background-color: rgb(15,26,59,0.8)
}
.button{
-fx-background-color: rgb(204,186,138);
-fx-effect: innershadow(gaussian, rgb(142,121,89), 10, 0.5 , 2, 2);
-fx-text-fill: black;
}
.button:pressed{
-fx-background-color: rgb(90,69,51);
-fx-text-fill: rgb(197,177,131);
}
.button:hover{
-fx-effect: innershadow(gaussian, rgb(90,69,51), 10, 0.5 , 2, 2);
}

View File

@ -37,9 +37,9 @@
<center>
<TilePane alignment="CENTER" orientation="VERTICAL" BorderPane.alignment="CENTER">
<children>
<BorderPane fx:id="allLobbyElementsBorderPane" prefHeight="600.0" prefWidth="500.0">
<BorderPane fx:id="allLobbyElementsBorderPane" prefHeight="600.0" prefWidth="500.0" stylesheets="@LobbiesBorderPane.css">
<top>
<ToolBar fx:id="LobbyControlsToolBar" prefHeight="37.0" prefWidth="500.0" BorderPane.alignment="CENTER">
<ToolBar fx:id="LobbyControlsToolBar" prefHeight="35.0" prefWidth="500.0" BorderPane.alignment="CENTER">
<items>
<Button fx:id="newGameButton" mnemonicParsing="false" pickOnBounds="false" text="New Lobby" />
</items>
@ -53,7 +53,11 @@
</TextFlow>
</bottom>
<center>
<AnchorPane fx:id="listLobbyAnchorPane" prefWidth="0.0" BorderPane.alignment="CENTER" />
<TilePane fx:id="listTilePane" alignment="TOP_CENTER" orientation="VERTICAL" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<AnchorPane fx:id="listLobbyAnchorPane" minHeight="450.0" minWidth="450.0" prefWidth="0.0" />
</children>
</TilePane>
</center>
</BorderPane>
</children>

View File

@ -1,16 +1,5 @@
*{
-fx-background-color: midnightblue;
}
.button{
-fx-text-fill: black;
-fx-background-color: lightGrey;
}
.button:hover{
-fx-effect: innershadow(gaussian, grey, 10, 0.2 , 2, 2);
}
.button:pressed{
-fx-background-color: grey;
-fx-background-color: transparent;
}
.tree-cell .tree-disclosure-node .arrow {

View File

@ -1,20 +1,7 @@
#highScore{
-fx-background-color: midnightblue;
*{
-fx-font-family: serif;
}
#LobbyListView{
-fx-background-color: transparent;
}
#lobbyPrint{
-fx-background-color: midnightblue;
}
#buttonPane{
-fx-background-color: midnightblue;
-fx-alignment: center;
}
.anchorPane{
-fx-alignment: center;