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

View File

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

View File

@ -4,11 +4,11 @@
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?> <?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> <content>
<AnchorPane fx:id="scollingAnchorPane"> <AnchorPane fx:id="scollingAnchorPane" minHeight="400.0" minWidth="450.0">
<children> <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> </children></AnchorPane>
</content> </content>
</ScrollPane> </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> <center>
<TilePane alignment="CENTER" orientation="VERTICAL" BorderPane.alignment="CENTER"> <TilePane alignment="CENTER" orientation="VERTICAL" BorderPane.alignment="CENTER">
<children> <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> <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> <items>
<Button fx:id="newGameButton" mnemonicParsing="false" pickOnBounds="false" text="New Lobby" /> <Button fx:id="newGameButton" mnemonicParsing="false" pickOnBounds="false" text="New Lobby" />
</items> </items>
@ -53,7 +53,11 @@
</TextFlow> </TextFlow>
</bottom> </bottom>
<center> <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> </center>
</BorderPane> </BorderPane>
</children> </children>

View File

@ -1,16 +1,5 @@
*{ *{
-fx-background-color: midnightblue; -fx-background-color: transparent;
}
.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;
} }
.tree-cell .tree-disclosure-node .arrow { .tree-cell .tree-disclosure-node .arrow {

View File

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