Started fleshing out the game GUI, with its controller and fxml
This commit is contained in:
parent
26dffdbbdc
commit
79f5cb407f
@ -1,17 +1,44 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.SplitPane;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.text.TextFlow;
|
||||
|
||||
public class GameController {
|
||||
|
||||
private static ClientModel client;
|
||||
|
||||
@FXML
|
||||
private AnchorPane gameBG;
|
||||
@FXML
|
||||
private Group roomButtonGroupDay;
|
||||
|
||||
@FXML
|
||||
private Button buttonRoom0;
|
||||
@FXML
|
||||
@ -28,22 +55,97 @@ public class GameController {
|
||||
@FXML
|
||||
private HBox roomLables;
|
||||
@FXML
|
||||
private TextField lableRoom0;
|
||||
private TextFlow lableRoom0;
|
||||
@FXML
|
||||
private TextField lableRoom1;
|
||||
private TextFlow lableRoom1;
|
||||
@FXML
|
||||
private TextField lableRoom2;
|
||||
private TextFlow lableRoom2;
|
||||
@FXML
|
||||
private TextField lableRoom3;
|
||||
private TextFlow lableRoom3;
|
||||
@FXML
|
||||
private TextField lableRoom4;
|
||||
private TextFlow lableRoom4;
|
||||
@FXML
|
||||
private TextField lableRoom5;
|
||||
private TextFlow lableRoom5;
|
||||
@FXML
|
||||
private Button noiseButton;
|
||||
@FXML
|
||||
private TextFlow notificationText;
|
||||
|
||||
/**
|
||||
* If button 0 is clicked, send the vote message 0 to the server
|
||||
*/
|
||||
public void sendVote0() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* If button 1 is clicked, send the vote message 0 to the server
|
||||
*/
|
||||
public void sendVote1() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* If button 2 is clicked, send the vote message 0 to the server
|
||||
*/
|
||||
public void sendVote2() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* If button 3 is clicked, send the vote message 0 to the server
|
||||
*/
|
||||
public void sendVote3() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* If button 4 is clicked, send the vote message 0 to the server
|
||||
*/
|
||||
public void sendVote4() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* If button 5 is clicked, send the vote message 0 to the server
|
||||
*/
|
||||
public void sendVote5() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a noise message, to the server, should be a gui message?
|
||||
*/
|
||||
public void noise() {
|
||||
client.getClient().sendMsgToServer("noise"); //TODO: Add message
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a given message and displays it in the notificationText Flow in the game Scene
|
||||
* @param msg the message to be displayed
|
||||
*/
|
||||
public void addMessageToNotificationText(String msg) {
|
||||
Text notification = new Text(msg);
|
||||
notificationText.getChildren().clear();
|
||||
notificationText.getChildren().add(notification);
|
||||
//TODO: Wait for a certain time, then clear all again
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a msg to the room Lable at the specified position
|
||||
* @param names a String array containing all the names
|
||||
*/
|
||||
public void addRoomLabels(String[] names) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
*{
|
||||
|
||||
}
|
||||
|
||||
.button{
|
||||
}
|
||||
|
||||
|
||||
.roomButtonGroup{
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
<?import javafx.scene.Group?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
@ -10,119 +9,98 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
|
||||
<AnchorPane id="BG" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="812.0" prefWidth="1200.0" styleClass="theme" stylesheets="@GameDay.css" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.GameController">
|
||||
<AnchorPane id="BG" fx:id="gameBG" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1080.0" prefWidth="1920.0" styleClass="theme" stylesheets="@GameDay.css" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.GameController">
|
||||
<children>
|
||||
<Group fx:id="roomButtonGroupDay" layoutX="230.5" layoutY="220.0">
|
||||
<children>
|
||||
<Button id="room1" fx:id="buttonRoom0" accessibleRole="RADIO_BUTTON" alignment="TOP_CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="21.5" minWidth="-Infinity" mnemonicParsing="false" prefHeight="110.0" prefWidth="90.0" text="room0">
|
||||
<Button id="room1" fx:id="buttonRoom0" accessibleRole="RADIO_BUTTON" alignment="TOP_CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="21.5" minWidth="-Infinity" mnemonicParsing="false" onAction="#sendVote0" prefHeight="110.0" prefWidth="90.0" text="room0">
|
||||
<font>
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="109.2" fitWidth="136.0" pickOnBounds="true" preserveRatio="true">
|
||||
<ImageView fitHeight="145.24" fitWidth="217.6" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@DayOpen/room1button.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button id="room1" fx:id="buttonRoom1" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="114.5" layoutY="19.800003051757812" minWidth="-Infinity" mnemonicParsing="false" prefHeight="101.0" prefWidth="90.0" text="room1">
|
||||
<Button id="room1" fx:id="buttonRoom1" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="145.0" layoutY="26.0" minWidth="-Infinity" mnemonicParsing="false" onAction="#sendVote1" prefHeight="101.0" prefWidth="90.0" text="room1">
|
||||
<font>
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="109.2" fitWidth="136.0" pickOnBounds="true" preserveRatio="true">
|
||||
<ImageView fitHeight="145.236" fitWidth="217.6" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@DayOpen/room2button.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button id="room1" fx:id="buttonRoom2" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="207.5" layoutY="39.59999084472656" minWidth="-Infinity" mnemonicParsing="false" prefHeight="110.0" prefWidth="90.0" text="room2">
|
||||
<Button id="room1" fx:id="buttonRoom2" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="268.5" layoutY="52.0" minWidth="-Infinity" mnemonicParsing="false" onAction="#sendVote2" prefHeight="110.0" prefWidth="90.0" text="room2">
|
||||
<font>
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="109.2" fitWidth="136.0" pickOnBounds="true" preserveRatio="true">
|
||||
<ImageView fitHeight="145.24" fitWidth="217.6" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@DayOpen/room3button.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button id="room1" fx:id="buttonRoom3" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="300.5" layoutY="59.40000915527344" minWidth="-Infinity" mnemonicParsing="false" prefHeight="110.0" prefWidth="90.0" text="room3">
|
||||
<Button id="room1" fx:id="buttonRoom3" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="392.0" layoutY="78.0" minWidth="-Infinity" mnemonicParsing="false" onAction="#sendVote3" prefHeight="110.0" prefWidth="90.0" text="room3">
|
||||
<font>
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="109.2" fitWidth="136.0" pickOnBounds="true" preserveRatio="true">
|
||||
<ImageView fitHeight="145.24" fitWidth="217.6" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@DayOpen/room4button.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button id="room1" fx:id="buttonRoom4" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="393.5999755859375" layoutY="79.40000915527344" minWidth="-Infinity" mnemonicParsing="false" prefHeight="110.0" prefWidth="90.0" text="room4">
|
||||
<Button id="room1" fx:id="buttonRoom4" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="515.3" layoutY="104.0" minWidth="-Infinity" mnemonicParsing="false" onAction="#sendVote4" prefHeight="110.0" prefWidth="90.0" text="room4">
|
||||
<font>
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="109.2" fitWidth="136.0" pickOnBounds="true" preserveRatio="true">
|
||||
<ImageView fitHeight="145.24" fitWidth="217.6" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@DayOpen/room5button.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button id="room1" fx:id="buttonRoom5" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="486.8499755859375" layoutY="99.99998474121094" minWidth="-Infinity" mnemonicParsing="false" prefHeight="110.0" prefWidth="90.0" text="room5">
|
||||
<Button id="room1" fx:id="buttonRoom5" accessibleRole="RADIO_BUTTON" alignment="CENTER" contentDisplay="GRAPHIC_ONLY" layoutX="639.0" layoutY="130.0" minWidth="-Infinity" mnemonicParsing="false" onAction="#sendVote5" prefHeight="110.0" prefWidth="90.0" text="room5">
|
||||
<font>
|
||||
<Font size="25.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="109.2" fitWidth="136.0" pickOnBounds="true" preserveRatio="true">
|
||||
<ImageView fitHeight="145.24" fitWidth="217.6" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@DayOpen/room6button.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<HBox fx:id="roomLables" alignment="CENTER" layoutX="10.0" layoutY="50.0" prefHeight="62.0" prefWidth="571.0" rotate="12.4">
|
||||
<HBox fx:id="roomLables" alignment="CENTER" layoutY="80.0" prefHeight="62.0" prefWidth="747.0" rotate="12.4">
|
||||
<children>
|
||||
<TextField fx:id="lableRoom0" alignment="CENTER" editable="false" prefHeight="40.0" text="Seraina Ghost">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<TextField fx:id="lableRoom1" accessibleRole="TEXT" alignment="CENTER" editable="false" prefHeight="40.0">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<TextField fx:id="lableRoom2" accessibleRole="TEXT" alignment="CENTER" editable="false" prefHeight="40.0">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<TextField fx:id="lableRoom3" accessibleRole="TEXT" alignment="CENTER" editable="false" prefHeight="40.0">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<TextField fx:id="lableRoom4" accessibleRole="TEXT" alignment="CENTER" editable="false" prefHeight="40.0">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<TextField fx:id="lableRoom5" accessibleRole="TEXT" alignment="CENTER" editable="false" prefHeight="40.0">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<TextFlow fx:id="lableRoom0" prefHeight="200.0" prefWidth="200.0" />
|
||||
<TextFlow fx:id="lableRoom1" prefHeight="200.0" prefWidth="200.0" />
|
||||
<TextFlow fx:id="lableRoom2" prefHeight="200.0" prefWidth="200.0" />
|
||||
<TextFlow fx:id="lableRoom3" prefHeight="200.0" prefWidth="200.0" />
|
||||
<TextFlow fx:id="lableRoom4" prefHeight="200.0" prefWidth="200.0" />
|
||||
<TextFlow fx:id="lableRoom5" prefHeight="200.0" prefWidth="200.0" />
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</Group>
|
||||
<Button fx:id="noiseButton" alignment="CENTER" layoutX="236.0" layoutY="606.0" mnemonicParsing="false" prefHeight="59.0" prefWidth="128.0" text="I heard some noise" />
|
||||
<TextFlow fx:id="notificationText" layoutX="359.0" layoutY="14.0" prefHeight="200.0" prefWidth="500.0" textAlignment="CENTER" />
|
||||
<Button fx:id="noiseButton" alignment="CENTER" layoutX="267.0" layoutY="636.0" mnemonicParsing="false" prefHeight="114.0" prefWidth="217.0" text="I heard some noise">
|
||||
<font>
|
||||
<Font name="System Bold" size="21.0" />
|
||||
</font></Button>
|
||||
<TextFlow fx:id="notificationText" layoutX="581.0" layoutY="386.0" prefHeight="200.0" prefWidth="800.0" textAlignment="CENTER" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
Reference in New Issue
Block a user