Adde a s**t tone of try-catch blocks in case gui hasnt been initialized yet
This commit is contained in:
parent
3aca60d8ee
commit
97194d0157
@ -19,7 +19,7 @@ public class BudaLogConfig {
|
|||||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
Configuration config = ctx.getConfiguration();
|
Configuration config = ctx.getConfiguration();
|
||||||
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||||
loggerConfig.setLevel(Level.ERROR); // change level here
|
loggerConfig.setLevel(Level.INFO); // change level here
|
||||||
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -370,13 +370,13 @@ public class Client {
|
|||||||
*/
|
*/
|
||||||
public void notificationTextDisplay(String data) {
|
public void notificationTextDisplay(String data) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
gameController.addMessageToNotificationText(data);
|
|
||||||
try {
|
try {
|
||||||
|
gameController.addMessageToNotificationText(data);
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
gameController.clearNotificationText();
|
gameController.clearNotificationText();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
LOGGER.warn(e.getMessage());
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.multiplayer.client.Client;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
@ -34,8 +35,12 @@ import javafx.scene.layout.VBox;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.scene.text.TextFlow;
|
import javafx.scene.text.TextFlow;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class GameController {
|
public class GameController {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger(GameController.class);
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
private static ClientModel client;
|
private static ClientModel client;
|
||||||
|
|
||||||
@ -160,10 +165,14 @@ public class GameController {
|
|||||||
* Takes a given message and displays it in the notificationText Flow in the game Scene
|
* Takes a given message and displays it in the notificationText Flow in the game Scene
|
||||||
* @param msg the message to be displayed
|
* @param msg the message to be displayed
|
||||||
*/
|
*/
|
||||||
public void addMessageToNotificationText(String msg) {
|
public void addMessageToNotificationText(String msg){
|
||||||
Text notification = new Text(msg);
|
Text notification = new Text(msg);
|
||||||
|
try {
|
||||||
notificationText.getChildren().clear();
|
notificationText.getChildren().clear();
|
||||||
notificationText.getChildren().add(notification);
|
notificationText.getChildren().add(notification);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
//TODO: Wait for a certain time, then clear all again
|
//TODO: Wait for a certain time, then clear all again
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +180,11 @@ public class GameController {
|
|||||||
* Clears all children from notificationText TextFlow
|
* Clears all children from notificationText TextFlow
|
||||||
*/
|
*/
|
||||||
public void clearNotificationText() {
|
public void clearNotificationText() {
|
||||||
|
try {
|
||||||
notificationText.getChildren().clear();
|
notificationText.getChildren().clear();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,6 +206,7 @@ public class GameController {
|
|||||||
Text role4 = new Text(roles[4]);
|
Text role4 = new Text(roles[4]);
|
||||||
Text role5 = new Text(roles[5]);
|
Text role5 = new Text(roles[5]);
|
||||||
|
|
||||||
|
try {
|
||||||
lableRoom0.getChildren().clear();
|
lableRoom0.getChildren().clear();
|
||||||
lableRoom0.getChildren().add(name0);
|
lableRoom0.getChildren().add(name0);
|
||||||
lableRoom0.getChildren().add(role0);
|
lableRoom0.getChildren().add(role0);
|
||||||
@ -211,6 +225,9 @@ public class GameController {
|
|||||||
lableRoom5.getChildren().clear();
|
lableRoom5.getChildren().clear();
|
||||||
lableRoom5.getChildren().add(name5);
|
lableRoom5.getChildren().add(name5);
|
||||||
lableRoom5.getChildren().add(role5);
|
lableRoom5.getChildren().add(role5);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,7 +235,11 @@ public class GameController {
|
|||||||
*/
|
*/
|
||||||
public void noiseDisplay0(){
|
public void noiseDisplay0(){
|
||||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||||
|
try {
|
||||||
noiseImage0.setImage(bell);
|
noiseImage0.setImage(bell);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +247,11 @@ public class GameController {
|
|||||||
*/
|
*/
|
||||||
public void noiseDisplay1(){
|
public void noiseDisplay1(){
|
||||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||||
|
try {
|
||||||
noiseImage0.setImage(bell);
|
noiseImage0.setImage(bell);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,7 +259,11 @@ public class GameController {
|
|||||||
*/
|
*/
|
||||||
public void noiseDisplay2(){
|
public void noiseDisplay2(){
|
||||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||||
|
try {
|
||||||
noiseImage0.setImage(bell);
|
noiseImage0.setImage(bell);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,7 +271,11 @@ public class GameController {
|
|||||||
*/
|
*/
|
||||||
public void noiseDisplay3(){
|
public void noiseDisplay3(){
|
||||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||||
|
try {
|
||||||
noiseImage0.setImage(bell);
|
noiseImage0.setImage(bell);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -250,7 +283,11 @@ public class GameController {
|
|||||||
*/
|
*/
|
||||||
public void noiseDisplay4(){
|
public void noiseDisplay4(){
|
||||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||||
|
try {
|
||||||
noiseImage0.setImage(bell);
|
noiseImage0.setImage(bell);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -258,7 +295,11 @@ public class GameController {
|
|||||||
*/
|
*/
|
||||||
public void noiseDisplay5(){
|
public void noiseDisplay5(){
|
||||||
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
Image bell = new Image("ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.DayOpen.bell.png");
|
||||||
|
try {
|
||||||
noiseImage0.setImage(bell);
|
noiseImage0.setImage(bell);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.trace("Not yet initialized");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user