Had to change some things around, now notificationText and the bell pop up works, as well as voting and noise notification
This commit is contained in:
parent
77d1976332
commit
f4ccb6894a
@ -1 +1,2 @@
|
||||
B
|
||||
serai
|
||||
|
||||
@ -19,7 +19,7 @@ public class BudaLogConfig {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration config = ctx.getConfiguration();
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||
loggerConfig.setLevel(Level.INFO); // change level here
|
||||
loggerConfig.setLevel(Level.DEBUG); // change level here
|
||||
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ public class GameState {
|
||||
} else if (array[i].getIsGhost()) {
|
||||
print[i] = array[i].getName() + ":g:" + array[i].getKickedOff();
|
||||
} else {
|
||||
print[i] = "| " + array[i].getName() + ":h:" + array[i].getKickedOff();
|
||||
print[i] = array[i].getName() + ":h:" + array[i].getKickedOff();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import ch.unibas.dmi.dbis.cs108.gamelogic.ClientGameInfoHandler;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GUI;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp;
|
||||
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.helpers.ClientPinger;
|
||||
@ -41,7 +41,6 @@ public class Client {
|
||||
private GUI chatGui;
|
||||
private ClientModel clientModel;
|
||||
private GameStateModel gameStateModel;
|
||||
private GameController gameController;
|
||||
|
||||
/**
|
||||
* Saves the position of the client, gets refreshed everytime the client gets a vote request.
|
||||
@ -70,11 +69,11 @@ public class Client {
|
||||
systemName = username;
|
||||
}
|
||||
sendMsgToServer(Protocol.clientLogin + "$" + systemName);
|
||||
this.chatApp = new ChatApp(new ClientModel(systemName, this));
|
||||
this.chatGui = new GUI(this.chatApp);
|
||||
clientPinger = new ClientPinger(this, this.socket);
|
||||
this.gameStateModel = new GameStateModel();
|
||||
this.gameController = new GameController(ChatApp.getClientModel(), gameStateModel);
|
||||
this.chatApp = new ChatApp(new ClientModel(systemName, this));
|
||||
ChatApp.setGameController(new GameController(ChatApp.getClientModel(), gameStateModel));
|
||||
this.chatGui = new GUI(this.chatApp);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -146,6 +145,9 @@ public class Client {
|
||||
|
||||
}
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a thread which listens for incoming chat messages / other messages that the user has to
|
||||
@ -327,6 +329,7 @@ public class Client {
|
||||
*/
|
||||
public void sendToGUI(String parameter, String data) {
|
||||
try {
|
||||
LOGGER.debug("GUI: PARAMETER:" + parameter + ", DATA: " + data);
|
||||
switch (parameter) {
|
||||
case ClientGameInfoHandler.itsNightTime: //ClientGameInfoHandler
|
||||
gameStateModel.setDayClone(false);
|
||||
@ -336,14 +339,14 @@ public class Client {
|
||||
break;
|
||||
case GuiParameters.updateGameState:
|
||||
gameStateModel.setGSFromString(data);
|
||||
gameController.updateRoomLabels();
|
||||
chatApp.getGameController().updateRoomLabels();
|
||||
break;
|
||||
case GuiParameters.noiseHeardAtPosition:
|
||||
try {
|
||||
int position = Integer.parseInt(data);
|
||||
determineNoiseDisplay(position);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Not a position given for noise");
|
||||
LOGGER.warn("Not a position given for noise " +e.getMessage());
|
||||
}
|
||||
break;
|
||||
case GuiParameters.listOfLobbies:
|
||||
@ -380,7 +383,7 @@ public class Client {
|
||||
int n = arr.length;
|
||||
for (int i = 0; i < n; i = i + 2) {
|
||||
list.add(new SimpleStringProperty(arr[i]));
|
||||
ChatController.getClient().addLobbyToList(new SimpleStringProperty(arr[i]));
|
||||
//ChatController.getClient().addLobbyToList(new SimpleStringProperty(arr[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,9 +406,9 @@ public class Client {
|
||||
public void notificationTextDisplay(String data) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
gameController.addMessageToNotificationText(data);
|
||||
chatApp.getGameController().addMessageToNotificationText(data);
|
||||
Thread.sleep(3000);
|
||||
gameController.clearNotificationText();
|
||||
chatApp.getGameController().clearNotificationText();
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.warn(e.getMessage());
|
||||
}
|
||||
@ -416,17 +419,17 @@ public class Client {
|
||||
public void determineNoiseDisplay(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
gameController.noiseDisplay0();
|
||||
chatApp.getGameController().noiseDisplay0();
|
||||
case 1:
|
||||
gameController.noiseDisplay1();
|
||||
chatApp.getGameController().noiseDisplay1();
|
||||
case 2:
|
||||
gameController.noiseDisplay2();
|
||||
chatApp.getGameController().noiseDisplay2();
|
||||
case 3:
|
||||
gameController.noiseDisplay3();
|
||||
chatApp.getGameController().noiseDisplay3();
|
||||
case 4:
|
||||
gameController.noiseDisplay4();
|
||||
chatApp.getGameController().noiseDisplay4();
|
||||
case 5:
|
||||
gameController.noiseDisplay5();
|
||||
chatApp.getGameController().noiseDisplay5();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.client;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.gamelogic.ClientGameInfoHandler;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.GameController;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
import java.io.OutputStreamWriter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -61,17 +62,20 @@ public class JClientProtocolParser {
|
||||
break;
|
||||
case Protocol.printToGUI:
|
||||
String substring = msg.substring(6);
|
||||
int index = msg.indexOf("$");
|
||||
int index = substring.indexOf("$");
|
||||
String parameter = "";
|
||||
String data = substring;
|
||||
try {
|
||||
parameter = msg.substring(0,index);
|
||||
data = msg.substring(index+1);
|
||||
parameter = substring.substring(0,index);
|
||||
data = substring.substring(index+1);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("No parameter in PTGUI");
|
||||
}
|
||||
c.sendToGUI(parameter,data);
|
||||
break;
|
||||
case Protocol.positionOfClient:
|
||||
int position = Integer.parseInt(msg.substring(6));
|
||||
GameController.getClient().getClient().setPosition(position);
|
||||
default:
|
||||
System.out.println("Received unknown command");
|
||||
}
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat;
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.GameController;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
@ -19,7 +22,9 @@ public class ChatApp extends Application {
|
||||
|
||||
private static ClientModel clientModel;
|
||||
private static ChatController chatController;
|
||||
private static GameController gameController;
|
||||
private ClientModel cModel;
|
||||
private GameController gameC;
|
||||
|
||||
public ChatApp() {
|
||||
super();
|
||||
@ -50,10 +55,27 @@ public class ChatApp extends Application {
|
||||
this.cModel = cModel;
|
||||
}
|
||||
|
||||
public void setGameC(GameController gameC) {
|
||||
this.gameC = gameC;
|
||||
}
|
||||
|
||||
public ClientModel getcModel() {
|
||||
return cModel;
|
||||
}
|
||||
|
||||
public static void setGameController(
|
||||
GameController gameController) {
|
||||
ChatApp.gameController = gameController;
|
||||
}
|
||||
|
||||
public GameController getGameController() {
|
||||
return gameController;
|
||||
}
|
||||
|
||||
public GameController getGameC() {
|
||||
return gameC;
|
||||
}
|
||||
|
||||
public static void setClientModel(ClientModel clientM) {
|
||||
clientModel = clientM;
|
||||
}
|
||||
@ -83,16 +105,16 @@ public class ChatApp extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
this.setcModel(clientModel);
|
||||
URL resource = ChatApp.class.getResource(
|
||||
"ChatView.fxml");
|
||||
if (resource == null) {
|
||||
System.out.println("File wasnt found");
|
||||
}
|
||||
//ChatApp chatApp = new ChatApp(new ClientModel());
|
||||
this.setGameC(gameController);
|
||||
gameC.setClient(cModel);
|
||||
gameC.setGameStateModel(GameController.getGameStateModel());
|
||||
URL chatResource = ChatApp.class.getResource(
|
||||
"chat/ChatView.fxml");
|
||||
URL gameResource = ChatApp.class.getResource(
|
||||
"game/GameDayAll.fxml");
|
||||
try {
|
||||
Parent root = FXMLLoader.load(
|
||||
Objects.requireNonNull(ChatApp.class.getResource(
|
||||
"ChatView.fxml")));
|
||||
Objects.requireNonNull(gameResource));
|
||||
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
|
||||
Scene scene = new Scene(root);
|
||||
scene.setRoot(root);
|
||||
@ -100,11 +122,15 @@ public class ChatApp extends Application {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
primaryStage.setResizable(false);
|
||||
Node chat = FXMLLoader.load(
|
||||
Objects.requireNonNull(chatResource));
|
||||
primaryStage.setTitle("Night Train To Budapest");
|
||||
primaryStage.setResizable(true);
|
||||
primaryStage.setTitle("Chat");
|
||||
primaryStage.show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -1,7 +1,6 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatApp;
|
||||
import javafx.application.Application;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -2,6 +2,7 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat;
|
||||
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.utils.ChatLabelConfigurator;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.Protocol;
|
||||
|
||||
@ -1,44 +1,33 @@
|
||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.Client;
|
||||
import static javafx.scene.AccessibleRole.PARENT;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters;
|
||||
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.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
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;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class GameController {
|
||||
public class GameController implements Initializable{
|
||||
public static final Logger LOGGER = LogManager.getLogger(GameController.class);
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
@ -47,13 +36,27 @@ public class GameController {
|
||||
private static GameStateModel gameStateModel;
|
||||
|
||||
|
||||
|
||||
public GameController() {
|
||||
super();
|
||||
}
|
||||
//TODO(Seraina, Sebi): Same issue as ChatController? do with setters?
|
||||
public GameController(ClientModel c, GameStateModel g) {
|
||||
client = c;
|
||||
gameStateModel = g;
|
||||
}
|
||||
|
||||
public void setClient(ClientModel c) {
|
||||
client = c;
|
||||
}
|
||||
|
||||
public static ClientModel getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public static GameStateModel getGameStateModel() {
|
||||
return gameStateModel;
|
||||
}
|
||||
|
||||
@FXML
|
||||
private AnchorPane gameBG;
|
||||
@FXML
|
||||
@ -102,14 +105,25 @@ public class GameController {
|
||||
@FXML
|
||||
private Button noiseButton;
|
||||
@FXML
|
||||
private TextFlow notificationText;
|
||||
public TextFlow notificationText;
|
||||
@FXML
|
||||
private AnchorPane chatAreaGame;
|
||||
|
||||
|
||||
public void addToChatArea(Node n) {
|
||||
chatAreaGame.getChildren().add(n);
|
||||
}
|
||||
|
||||
public AnchorPane getChatAreaGame() {
|
||||
return chatAreaGame;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + "$" + 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +131,7 @@ public class GameController {
|
||||
*/
|
||||
public void sendVote1() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 1);
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + "$" + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +139,7 @@ public class GameController {
|
||||
*/
|
||||
public void sendVote2() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 2);
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + "$" + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +147,7 @@ public class GameController {
|
||||
*/
|
||||
public void sendVote3() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 3);
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + "$" + 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +155,7 @@ public class GameController {
|
||||
*/
|
||||
public void sendVote4() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 4);
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + "$" + 4);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,15 +163,21 @@ public class GameController {
|
||||
*/
|
||||
public void sendVote5() {
|
||||
client.getClient()
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + 5);
|
||||
.sendMsgToServer(Protocol.votedFor + "$" + client.getClient().getPosition() + "$" + 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a noise message, to the server, should be a gui message?
|
||||
*/
|
||||
public void noise() {
|
||||
LOGGER.info("Do you even get here");
|
||||
LOGGER.info(client.getClient());
|
||||
LOGGER.info(client.getClient().getPosition());
|
||||
if(client.getClient() == null) {
|
||||
LOGGER.info("But why???");
|
||||
}
|
||||
client.getClient().sendMsgToServer(
|
||||
Protocol.sendMessageToAllClients + "$" + Protocol.printToGUI + GuiParameters.noiseHeardAtPosition + "$"
|
||||
Protocol.sendMessageToAllClients + "$" + Protocol.printToGUI + "$" +GuiParameters.noiseHeardAtPosition + "$"
|
||||
+ client.getClient().getPosition()); //TODO: Test!!
|
||||
}
|
||||
|
||||
@ -166,13 +186,22 @@ public class GameController {
|
||||
* @param msg the message to be displayed
|
||||
*/
|
||||
public void addMessageToNotificationText(String msg){
|
||||
LOGGER.trace("addMessage " + msg);
|
||||
Text notification = new Text(msg);
|
||||
notification.setFill(Color.BLACK);
|
||||
notification.setStyle("-fx-font: 50 arial;");
|
||||
Platform.runLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
notificationText.getChildren().clear();
|
||||
notificationText.getChildren().add(notification);
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//TODO: Wait for a certain time, then clear all again
|
||||
}
|
||||
|
||||
@ -180,17 +209,25 @@ public class GameController {
|
||||
* Clears all children from notificationText TextFlow
|
||||
*/
|
||||
public void clearNotificationText() {
|
||||
LOGGER.trace("clear notify");
|
||||
Platform.runLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
notificationText.getChildren().clear();
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug("Not yet initialized");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the labels of the rooms accordingly to the datastructures in GameStateModel
|
||||
*/
|
||||
public void updateRoomLabels() {
|
||||
LOGGER.debug("roomlables update");
|
||||
String[] names = gameStateModel.getPassengerTrainClone()[0];
|
||||
String[] roles = gameStateModel.getPassengerTrainClone()[1];
|
||||
Text name0 = new Text(names[0]);
|
||||
@ -206,6 +243,9 @@ public class GameController {
|
||||
Text role4 = new Text(roles[4]);
|
||||
Text role5 = new Text(roles[5]);
|
||||
|
||||
Platform.runLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
lableRoom0.getChildren().clear();
|
||||
lableRoom0.getChildren().add(name0);
|
||||
@ -229,83 +269,126 @@ public class GameController {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Image loadBellImage(){
|
||||
Image bell = new Image("ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/DayOpen/bell.png");
|
||||
return bell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an image of a bell on top of button0
|
||||
*/
|
||||
public void noiseDisplay0(){
|
||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||
LOGGER.debug("noise0 called");
|
||||
Platform.runLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
noiseImage0.setImage(bell);
|
||||
noiseImage0.setImage(loadBellImage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an image of a bell on top of button1
|
||||
*/
|
||||
public void noiseDisplay1(){
|
||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||
LOGGER.debug("noise1 called");
|
||||
Platform.runLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
noiseImage0.setImage(bell);
|
||||
noiseImage1.setImage(loadBellImage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an image of a bell on top of button2
|
||||
*/
|
||||
public void noiseDisplay2(){
|
||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||
LOGGER.debug("noise2 called");
|
||||
Platform.runLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
noiseImage0.setImage(bell);
|
||||
noiseImage2.setImage(loadBellImage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug(e.getMessage());;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an image of a bell on top of button3
|
||||
*/
|
||||
public void noiseDisplay3(){
|
||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||
public void noiseDisplay3() {
|
||||
LOGGER.debug("noise3 called");
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
noiseImage0.setImage(bell);
|
||||
LOGGER.debug("hello");
|
||||
noiseImage3.setImage(loadBellImage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an image of a bell on top of button4
|
||||
*/
|
||||
public void noiseDisplay4(){
|
||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||
public void noiseDisplay4() {
|
||||
LOGGER.debug("noise4 called");
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
noiseImage0.setImage(bell);
|
||||
LOGGER.debug("hello");
|
||||
noiseImage4.setImage(loadBellImage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an image of a bell on top of button5
|
||||
*/
|
||||
public void noiseDisplay5(){
|
||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||
LOGGER.debug("noise5 called");
|
||||
Platform.runLater(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
noiseImage0.setImage(bell);
|
||||
noiseImage5.setImage(loadBellImage());
|
||||
} catch (Exception e) {
|
||||
LOGGER.trace("Not yet initialized");
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void setGameStateModel(
|
||||
GameStateModel gameStateModel) {
|
||||
GameController.gameStateModel = gameStateModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
ChatApp.setGameController(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,5 +207,11 @@ public class Protocol {
|
||||
*/
|
||||
public static final String printToGUI = "PTGUI";
|
||||
|
||||
/**
|
||||
* Sends an information to client at which position in the train from the game (0 to 5) they sit, as soon as the game starts
|
||||
* {@code POSOF$position}
|
||||
*/
|
||||
public static final String positionOfClient = "POSOF";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -376,9 +376,13 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
LOGGER.debug("Vote is:" + vote);
|
||||
if (vote != Integer.MAX_VALUE) { //gets MAX_VALUE when the vote wasn't valid
|
||||
try {
|
||||
getLobby().getGame().getGameState().getClientVoteData().setVote(position, vote);
|
||||
LOGGER.debug("Player vote: " + vote);
|
||||
getLobby().getGame().getGameState().getClientVoteData().setHasVoted(position, true);
|
||||
} catch (NullPointerException e) {
|
||||
LOGGER.info("Client not in Lobby");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
|
||||
<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">
|
||||
<AnchorPane id="BG" fx:id="gameBG" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.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">
|
||||
<children>
|
||||
<Group fx:id="roomButtonGroupDay" layoutX="230.5" layoutY="220.0">
|
||||
<children>
|
||||
@ -107,10 +107,11 @@
|
||||
</HBox>
|
||||
</children>
|
||||
</Group>
|
||||
<Button fx:id="noiseButton" alignment="CENTER" layoutX="267.0" layoutY="636.0" mnemonicParsing="false" onAction="#noise" prefHeight="114.0" prefWidth="217.0" text="I heard some noise">
|
||||
<Button fx:id="noiseButton" alignment="CENTER" layoutX="267.0" layoutY="610.0" mnemonicParsing="false" onAction="#noise" 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" />
|
||||
<TextFlow fx:id="notificationText" accessibleRole="PARENT" layoutX="210.0" layoutY="20.0" prefHeight="200.0" prefWidth="800.0" textAlignment="CENTER" />
|
||||
<AnchorPane fx:id="chatAreaGame" layoutY="738.0" prefHeight="342.0" prefWidth="1920.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
Reference in New Issue
Block a user