Added a way to list HighScore and added very simple textFlow view for LobbyDisplay, in case ListView wont work till tomorrow
This commit is contained in:
parent
68d84b9493
commit
a655df2e41
@ -406,6 +406,10 @@ public class Client {
|
|||||||
case GuiParameters.updateHighScore:
|
case GuiParameters.updateHighScore:
|
||||||
chatApp.getLoungeSceneViewController().addHighScore(data);
|
chatApp.getLoungeSceneViewController().addHighScore(data);
|
||||||
break;
|
break;
|
||||||
|
case GuiParameters.updatePrintLobby:
|
||||||
|
chatApp.getLoungeSceneViewController().clearLobbyPrint();
|
||||||
|
chatApp.getLoungeSceneViewController().addLobbyPrint(data);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
notificationTextDisplay(data);
|
notificationTextDisplay(data);
|
||||||
//TODO(Sebi,Seraina): should the gameController be in the Application just like the ChatController?
|
//TODO(Sebi,Seraina): should the gameController be in the Application just like the ChatController?
|
||||||
|
|||||||
@ -49,9 +49,13 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
public static final Logger LOGGER = LogManager.getLogger(LoungeSceneViewController.class);
|
public static final Logger LOGGER = LogManager.getLogger(LoungeSceneViewController.class);
|
||||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TextFlow highScore;
|
private TextFlow highScore;
|
||||||
@FXML
|
@FXML
|
||||||
|
public TextFlow lobbyPrint;
|
||||||
|
@FXML
|
||||||
private SplitPane chatSplitPane;
|
private SplitPane chatSplitPane;
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane chatAnchorPane;
|
private AnchorPane chatAnchorPane;
|
||||||
@ -62,6 +66,8 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button leaveLobbyButton;
|
private Button leaveLobbyButton;
|
||||||
@FXML
|
@FXML
|
||||||
|
private Button lobbyPrintButton;
|
||||||
|
@FXML
|
||||||
private Button startGame;
|
private Button startGame;
|
||||||
@FXML
|
@FXML
|
||||||
private Button newGameButton;
|
private Button newGameButton;
|
||||||
@ -495,6 +501,14 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
client.getClient().sendMsgToServer(Protocol.highScoreList);
|
client.getClient().sendMsgToServer(Protocol.highScoreList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendLilstle() {
|
||||||
|
client.getClient().sendMsgToServer(Protocol.listLobbies);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a String to the highScore Text Flow
|
||||||
|
* @param data the String to be added
|
||||||
|
*/
|
||||||
public void addHighScore(String data) {
|
public void addHighScore(String data) {
|
||||||
String[] arguments = data.split("/n");
|
String[] arguments = data.split("/n");
|
||||||
LOGGER.debug(arguments.length);
|
LOGGER.debug(arguments.length);
|
||||||
@ -511,5 +525,37 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a String to the lobbyPrint TextFlow
|
||||||
|
* @param data the String to be added
|
||||||
|
* */
|
||||||
|
public void addLobbyPrint(String data) {
|
||||||
|
String[] arguments = data.split("/n");
|
||||||
|
LOGGER.debug(arguments.length);
|
||||||
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for(String argument : arguments) {
|
||||||
|
LOGGER.debug("HighScore " + argument);
|
||||||
|
Text text = new Text(argument + System.lineSeparator());
|
||||||
|
text.setFill(Color.BLACK);
|
||||||
|
lobbyPrint.getChildren().add(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the lobbyPrint TextFlow
|
||||||
|
*/
|
||||||
|
public void clearLobbyPrint() {
|
||||||
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
lobbyPrint.getChildren().clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,5 +86,14 @@ public class GuiParameters {
|
|||||||
*/
|
*/
|
||||||
public static final String removePlayerFromList = "RMVLST";
|
public static final String removePlayerFromList = "RMVLST";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells Gui to update its HighScore TextFlow according to the following data
|
||||||
|
*/
|
||||||
public static final String updateHighScore = "HISCR";
|
public static final String updateHighScore = "HISCR";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells Gui to add a String to printLobby TextFlow - a provisory solution in case ListeView won't
|
||||||
|
* pan out
|
||||||
|
*/
|
||||||
|
public static final String updatePrintLobby = "PRLOBB";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -563,6 +563,46 @@ public class ClientHandler implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all lobbies and their members, along with players outside lobbies to this clientHandler's
|
||||||
|
* client a GUI message in a form, the gui can decode.
|
||||||
|
*/
|
||||||
|
public void listLobbiesGuiFormat() {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
if (Lobby.lobbies.isEmpty()) {
|
||||||
|
stringBuilder.append("No Lobbies.").append("/n");
|
||||||
|
} else {
|
||||||
|
for (Lobby l : Lobby.lobbies) {
|
||||||
|
String lobbyStatus = "closed";
|
||||||
|
if (l.getLobbyIsOpen()) {
|
||||||
|
lobbyStatus = "open";
|
||||||
|
}
|
||||||
|
stringBuilder.append("Lobby nr. " + l.getLobbyID() + ": (" + lobbyStatus + ")").append("/n");
|
||||||
|
for (ClientHandler c : l.getLobbyClients()) {
|
||||||
|
if (c.equals(l.getAdmin())) {
|
||||||
|
stringBuilder.append(" -" + c.getClientUserName() + " (admin)").append("/n");
|
||||||
|
} else {
|
||||||
|
stringBuilder.append(" -" + c.getClientUserName()).append("/n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean helper = false; //used to print "Clients not in lobbies" only once, if needed.
|
||||||
|
for (ClientHandler c : connectedClients) {
|
||||||
|
if (Lobby.clientIsInLobby(c) == -1) {
|
||||||
|
if (!helper) {
|
||||||
|
helper = true;
|
||||||
|
stringBuilder.append("Clients not in lobbies:").append("/n");
|
||||||
|
}
|
||||||
|
stringBuilder.append(" -").append(c.getClientUserName()).append("/n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!helper) {
|
||||||
|
stringBuilder.append("No clients outside of lobbies").append("/n");
|
||||||
|
}
|
||||||
|
sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.updatePrintLobby + "$" + stringBuilder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all players in the client's lobby. If the client is not in a Lobby, it will say "You are
|
* Lists all players in the client's lobby. If the client is not in a Lobby, it will say "You are
|
||||||
* not in a lobby."
|
* not in a lobby."
|
||||||
|
|||||||
@ -99,6 +99,7 @@ public class JServerProtocolParser {
|
|||||||
break;
|
break;
|
||||||
case Protocol.listLobbies:
|
case Protocol.listLobbies:
|
||||||
h.listLobbies();
|
h.listLobbies();
|
||||||
|
h.listLobbiesGuiFormat();
|
||||||
break;
|
break;
|
||||||
case Protocol.listPlayersInLobby:
|
case Protocol.listPlayersInLobby:
|
||||||
h.listPlayersInLobby();
|
h.listPlayersInLobby();
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
<?import javafx.scene.control.ToolBar?>
|
<?import javafx.scene.control.ToolBar?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.shape.Line?>
|
||||||
<?import javafx.scene.text.TextFlow?>
|
<?import javafx.scene.text.TextFlow?>
|
||||||
|
|
||||||
<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">
|
<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">
|
||||||
@ -16,16 +17,17 @@
|
|||||||
<ToolBar fx:id="NTtBToolBar" prefHeight="77.0" BorderPane.alignment="CENTER">
|
<ToolBar fx:id="NTtBToolBar" prefHeight="77.0" BorderPane.alignment="CENTER">
|
||||||
<items>
|
<items>
|
||||||
<Button fx:id="highScoreButton" mnemonicParsing="false" onAction="#sendHIghScore" text="High Score" />
|
<Button fx:id="highScoreButton" mnemonicParsing="false" onAction="#sendHIghScore" text="High Score" />
|
||||||
<Button fx:id="ChangeNameButton" mnemonicParsing="false" text="Change Name" />
|
<Button fx:id="lobbyPrintButton" mnemonicParsing="false" onAction="#sendLilstle" text="Lobby List" />
|
||||||
<Button fx:id="LeaveServerButton" mnemonicParsing="false" text="Leave server" />
|
<Button fx:id="LeaveServerButton" mnemonicParsing="false" text="Leave server" />
|
||||||
<Button fx:id="leaveLobbyButton" mnemonicParsing="false" onAction="#leaveLobby" text="Leave Lobby" />
|
<Button fx:id="leaveLobbyButton" mnemonicParsing="false" onAction="#leaveLobby" text="Leave Lobby" />
|
||||||
|
<Button fx:id="ChangeNameButton" mnemonicParsing="false" text="Change Name" />
|
||||||
</items>
|
</items>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</top>
|
</top>
|
||||||
<center>
|
<center>
|
||||||
<AnchorPane BorderPane.alignment="CENTER">
|
<AnchorPane BorderPane.alignment="CENTER">
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="newGameButton" layoutX="68.0" layoutY="101.0" mnemonicParsing="false" text="New Lobby" />
|
<Button fx:id="newGameButton" layoutX="34.0" layoutY="101.0" mnemonicParsing="false" text="New Lobby" />
|
||||||
<AnchorPane fx:id="gameAnchorPane" />
|
<AnchorPane fx:id="gameAnchorPane" />
|
||||||
<Button fx:id="startGame" layoutX="68.0" layoutY="156.0" mnemonicParsing="false" onAction="#startGame" opacity="0.0" text="Start Game" />
|
<Button fx:id="startGame" layoutX="68.0" layoutY="156.0" mnemonicParsing="false" onAction="#startGame" opacity="0.0" text="Start Game" />
|
||||||
</children>
|
</children>
|
||||||
@ -34,13 +36,16 @@
|
|||||||
<bottom>
|
<bottom>
|
||||||
<AnchorPane fx:id="ChatArea" BorderPane.alignment="CENTER">
|
<AnchorPane fx:id="ChatArea" BorderPane.alignment="CENTER">
|
||||||
<children>
|
<children>
|
||||||
<SplitPane fx:id="chatSplitPane" dividerPositions="0.8555729984301413" minHeight="50.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<SplitPane fx:id="chatSplitPane" dividerPositions="0.46467817896389324" minHeight="50.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<items>
|
<items>
|
||||||
<AnchorPane fx:id="chatAnchorPane" minHeight="0.0" minWidth="0.0" />
|
<AnchorPane fx:id="chatAnchorPane" minHeight="0.0" minWidth="0.0" />
|
||||||
<AnchorPane fx:id="otherNotificationAnchorPane" minHeight="0.0" minWidth="0.0">
|
<AnchorPane fx:id="otherNotificationAnchorPane" minHeight="0.0" minWidth="0.0">
|
||||||
<children>
|
<children>
|
||||||
<Label text="High Score:" />
|
<Label text="High Score:" />
|
||||||
<TextFlow fx:id="highScore" layoutY="18.0" prefHeight="30.0" prefWidth="315.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="18.0" />
|
<TextFlow fx:id="highScore" layoutY="18.0" prefHeight="30.0" prefWidth="99.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="239.0" AnchorPane.topAnchor="18.0" />
|
||||||
|
<Label layoutX="120.0" text="Lobbies:" />
|
||||||
|
<TextFlow fx:id="lobbyPrint" layoutX="120.0" layoutY="18.0" />
|
||||||
|
<Line endX="-6.5" endY="-24.0" layoutX="120.0" layoutY="24.0" startX="-6.5" startY="48.5" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</items>
|
</items>
|
||||||
|
|||||||
Reference in New Issue
Block a user