Did some more styling, changed fonts ect. also moved the server notification in its one spot next to the chat, and now only the game over message is displayed

This commit is contained in:
Seraina 2022-05-17 18:33:57 +02:00
parent b3e520a2c3
commit 667585fa5e
12 changed files with 110 additions and 36 deletions

View File

@ -430,7 +430,10 @@ public class Client {
public void notificationTextDisplay(String data) {
new Thread(() -> {
try {
if (data.contains("Game over")) {
chatApp.getGameController().addMessageToNotificationText(data);
}
chatApp.getChatController().addChatMsgToServerView(data);
Thread.sleep(5000);
chatApp.getGameController().clearNotificationText();
} catch (InterruptedException e) {

View File

@ -42,6 +42,7 @@ public class JClientProtocolParser {
System.out.println(msg.substring(6));
if (!msg.substring(6).equals("Your vote was invalid")) {
c.notificationTextDisplay(msg.substring(6));
}
break;
case Protocol.printToClientChat:

View File

@ -22,12 +22,15 @@ import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -35,6 +38,15 @@ public class ChatController implements Initializable {
public static final Logger LOGGER = LogManager.getLogger(ChatController.class);
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
@FXML
private AnchorPane whisperAnchor;
@FXML
private AnchorPane chatinputAnchor;
@FXML
private ScrollPane serverScrollPane;
@FXML
private VBox vBoxServer;
@FXML
private Group vboxGroup;
@ -110,6 +122,20 @@ public class ChatController implements Initializable {
ChatScrollPane.setVvalue((Double) newValue);
}
});
vBoxServer.heightProperty().addListener(new ChangeListener<>() {
/**
* TODO: implement
* Adjust the height when new messages come in.
*/
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue,
Number newValue) {
vBoxServer.setMaxHeight(newValue.doubleValue());
serverScrollPane.setMaxHeight(newValue.doubleValue() * 2);
serverScrollPane.setVvalue((Double) newValue);
}
});
/**
* Initialize what happens when the send button is pressed
*/
@ -187,11 +213,12 @@ public class ChatController implements Initializable {
l.setMaxHeight(Double.MAX_VALUE);
if (msg.contains("whispers")) {
l.setBackground(Background.fill(Color.TRANSPARENT));
l.setPrefWidth(1135);
l.setTextFill(Color.rgb(15,26,150));
l.setPrefWidth(680);
l.setScaleShape(false);
} else {
l.setBackground(Background.fill(Color.TRANSPARENT));
l.setPrefWidth(1135);
l.setPrefWidth(680);
l.setScaleShape(false);
}
l.setTextFill(Color.BLACK);
@ -203,4 +230,27 @@ public class ChatController implements Initializable {
});
}
public void addChatMsgToServerView(String msg) {
TextFlow textFlow = new TextFlow();
textFlow.setPrefWidth(420);
textFlow.setPrefHeight(Region.USE_COMPUTED_SIZE);
Text text = new Text(msg);
textFlow.getChildren().add(text);
try {
Platform.runLater(new Runnable() {
@Override
public void run() {
try {
vBoxServer.getChildren().add(textFlow);
} catch (Exception e) {
LOGGER.warn(e.getMessage());
}
}
});
} catch(Exception e) {
LOGGER.warn(e.getMessage());
}
}
}

View File

@ -381,8 +381,8 @@ public class GameController implements Initializable {
public void addMessageToNotificationText(String msg) {
LOGGER.trace("addMessage " + msg);
Text notification = new Text(System.lineSeparator() + msg);
notification.setFill(Color.BLACK);
notification.setStyle("-fx-font: 50 arial;");
notification.setFill(Color.WHITE);
notification.setStyle("-fx-font: 50 serif;");
try {
Platform.runLater(new Runnable() {
@Override

View File

@ -89,10 +89,10 @@ public class ListOfLobbiesController implements Initializable {
HBox rootHBox = new HBox();
rootHBox.setPrefWidth(195);
rootHBox.setMaxHeight(20);
Label adminLabel = new Label(lobbyId + " " + admin);
Label adminLabel = new Label(" Lobby " + lobbyId + ": " + admin);
adminLabel.setTextFill(Color.WHITE);
rootHBox.getChildren().add(adminLabel);
rootHBox.getChildren().add(button);
rootHBox.getChildren().add(adminLabel);
TreeItem<HBox> root = new TreeItem<HBox>(rootHBox);
root.setExpanded(true);
for (String member : members) {

View File

@ -35,8 +35,10 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.TilePane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.util.Duration;
@ -48,6 +50,10 @@ public class LoungeSceneViewController implements Initializable {
public static final Logger LOGGER = LogManager.getLogger(LoungeSceneViewController.class);
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
@FXML
private AnchorPane highScorePane;
@FXML
private TilePane listTilePane;
@FXML
private AnchorPane gameDisplayAnchorPane;
@FXML
private AnchorPane listLobbyAnchorPane;
@ -309,7 +315,8 @@ public class LoungeSceneViewController implements Initializable {
for (String argument : arguments) {
LOGGER.debug("HighScore " + argument);
Text text = new Text(argument + System.lineSeparator());
text.setFill(Color.BLACK);
text.setFill(Color.WHITE);
text.setFont(new Font("serif",15));
highScore.getChildren().add(text);
}
}

View File

@ -28,7 +28,7 @@ public class ChatLabelConfigurator {
l.setAlignment(Pos.CENTER_RIGHT);
l.setWrapText(true);
l.setMaxHeight(Double.MAX_VALUE);
l.setPrefWidth(1135);
l.setPrefWidth(680);
l.setScaleShape(false);
} else {
//t = new Text(client.getUsername() + " (you): " + msg);
@ -37,7 +37,7 @@ public class ChatLabelConfigurator {
l.setAlignment(Pos.CENTER_RIGHT);
l.setWrapText(true);
l.setMaxHeight(Double.MAX_VALUE);
l.setPrefWidth(1135);
l.setPrefWidth(680);
l.setScaleShape(false);
}
return l;

View File

@ -3,6 +3,10 @@
-fx-background-color: transparent;
}
.text-flow{
-fx-text-alignment: center;
}
#vBoxChatMessages{
-fx-background-color: transparent;
}

View File

@ -4,6 +4,7 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollBar?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
@ -14,16 +15,17 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="chatPaneRoot" maxWidth="1300.0" pickOnBounds="false" prefWidth="1300.0" stylesheets="@Chat.css" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController">
<AnchorPane fx:id="chatPaneRoot" maxWidth="1300.0" pickOnBounds="false" prefHeight="386.0" prefWidth="1300.0" stylesheets="@Chat.css" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController">
<children>
<ImageView fitHeight="700.0" fitWidth="1300.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@images/chatwindow.png" />
</image>
</ImageView>
<AnchorPane layoutX="115.0" layoutY="95.0" prefHeight="220.0" prefWidth="1128.0">
<Separator layoutX="810.0" layoutY="95.0" orientation="VERTICAL" prefHeight="220.0" prefWidth="12.0" />
<AnchorPane layoutX="115.0" layoutY="95.0" prefHeight="220.0" prefWidth="700.0">
<children>
<GridPane alignment="CENTER" maxWidth="-Infinity" pickOnBounds="false" prefWidth="1300.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<GridPane alignment="CENTER" maxWidth="-Infinity" pickOnBounds="false" prefWidth="700.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="100.0" />
</columnConstraints>
@ -32,18 +34,18 @@
<RowConstraints maxHeight="-Infinity" minHeight="10.0" percentHeight="30.0" valignment="CENTER" vgrow="ALWAYS" />
</rowConstraints>
<children>
<ScrollPane fx:id="ChatScrollPane" fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" maxHeight="1.7976931348623157E308" maxWidth="-Infinity">
<ScrollPane fx:id="ChatScrollPane" fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" maxHeight="1.7976931348623157E308" maxWidth="-Infinity" prefWidth="700.0">
<content>
<VBox fx:id="vBoxChatMessages" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="1128.0" spacing="2.0" />
<VBox fx:id="vBoxChatMessages" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="695.0" spacing="2.0" />
</content>
</ScrollPane>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="-Infinity" pickOnBounds="false" prefWidth="1300.0" GridPane.rowIndex="1">
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="-Infinity" pickOnBounds="false" prefWidth="700.0" GridPane.rowIndex="1">
<children>
<GridPane alignment="CENTER" layoutX="10.0" layoutY="20.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="82.0" prefWidth="2072.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<GridPane alignment="CENTER" layoutX="10.0" layoutY="20.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="82.0" prefWidth="700.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" percentWidth="5.0" />
<ColumnConstraints hgrow="SOMETIMES" percentWidth="11.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="20.0" percentWidth="84.0" />
<ColumnConstraints hgrow="SOMETIMES" percentWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" percentWidth="15.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="20.0" percentWidth="75.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" percentHeight="90.0" vgrow="SOMETIMES" />
@ -61,7 +63,7 @@
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</GridPane.margin>
</AnchorPane>
<AnchorPane fx:id="whisperAnchor" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="92.0" prefWidth="85.0" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
<AnchorPane fx:id="whisperAnchor" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="42.0" prefWidth="164.0" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
<children>
<TextField fx:id="whisperTargetSelectField" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="56.0" prefWidth="488.0" promptText="whisper..." AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
@ -108,5 +110,10 @@
<VBox fx:id="vBoxServerMessage" alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mouseTransparent="true" pickOnBounds="false" prefHeight="184.0" spacing="2.0" GridPane.columnIndex="1" />
</children>
</GridPane>
<ScrollPane fx:id="serverScrollPane" fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" layoutX="818.0" layoutY="95.0" maxHeight="154.0" maxWidth="434.0" prefHeight="154.0" prefWidth="434.0">
<content>
<VBox fx:id="vBoxServer" maxWidth="430.0" minWidth="-Infinity" prefHeight="154.0" prefWidth="430.0" spacing="2.0" />
</content>
</ScrollPane>
</children>
</AnchorPane>

View File

@ -15,7 +15,7 @@
-fx-background-color: rgb(15,26,59,0.8);
}
#highScore{
#highScorePane{
-fx-background-color: rgb(15,26,59,0.8);
-fx-text-fill: white;
-fx-font-family: serif;

View File

@ -22,22 +22,22 @@
</ToolBar>
</top>
<left>
<AnchorPane prefHeight="316.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
<AnchorPane prefWidth="200.0" BorderPane.alignment="CENTER" />
</left>
<bottom>
<TilePane alignment="CENTER" orientation="VERTICAL" prefColumns="1" prefRows="1" BorderPane.alignment="CENTER">
<TilePane alignment="TOP_CENTER" orientation="VERTICAL" prefColumns="1" prefRows="1" BorderPane.alignment="CENTER">
<children>
<AnchorPane fx:id="ChatArea" pickOnBounds="false" prefHeight="83.0" prefWidth="578.0" />
<AnchorPane fx:id="ChatArea" pickOnBounds="false" prefWidth="578.0" />
</children>
</TilePane>
</bottom>
<right>
<AnchorPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
<AnchorPane prefWidth="200.0" BorderPane.alignment="CENTER" />
</right>
<center>
<TilePane alignment="CENTER" orientation="VERTICAL" BorderPane.alignment="CENTER">
<children>
<BorderPane fx:id="allLobbyElementsBorderPane" prefHeight="600.0" prefWidth="500.0" stylesheets="@LobbiesBorderPane.css">
<BorderPane fx:id="allLobbyElementsBorderPane" maxWidth="-Infinity" prefHeight="285.0" prefWidth="500.0" stylesheets="@LobbiesBorderPane.css">
<top>
<ToolBar fx:id="LobbyControlsToolBar" prefHeight="35.0" prefWidth="500.0" BorderPane.alignment="CENTER">
<items>
@ -45,20 +45,21 @@
</items>
</ToolBar>
</top>
<bottom>
<TextFlow fx:id="highScore" pickOnBounds="false" prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Label pickOnBounds="false" text="High Score:" />
</children>
</TextFlow>
</bottom>
<center>
<TilePane fx:id="listTilePane" alignment="TOP_CENTER" orientation="VERTICAL" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<TilePane fx:id="listTilePane" alignment="TOP_CENTER" maxHeight="-Infinity" orientation="VERTICAL" prefHeight="250.0" prefWidth="500.0" BorderPane.alignment="CENTER">
<children>
<AnchorPane fx:id="listLobbyAnchorPane" minHeight="450.0" minWidth="450.0" prefWidth="0.0" />
<AnchorPane fx:id="listLobbyAnchorPane" minHeight="300.0" minWidth="450.0" prefWidth="0.0" />
</children>
</TilePane>
</center>
<bottom>
<AnchorPane fx:id="highScorePane" prefWidth="416.0" BorderPane.alignment="CENTER">
<children>
<TextFlow fx:id="highScore" layoutX="88.0" layoutY="6.0" pickOnBounds="false" prefHeight="94.0" prefWidth="245.0" />
<Label layoutX="14.0" layoutY="35.0" pickOnBounds="false" text="High Score:" AnchorPane.leftAnchor="10.0" />
</children>
</AnchorPane>
</bottom>
</BorderPane>
</children>
</TilePane>

View File

@ -1,5 +1,6 @@
*{
-fx-font-family: serif;
-fx-font-size: 15;
}