Added an option do delete message in notificationText in GameController again
This commit is contained in:
parent
421074a59b
commit
227cfdbedd
@ -86,9 +86,7 @@ public class Game implements Runnable {
|
||||
* Initializes new thread that constantly sends a gameState update to all clients in this game
|
||||
*/
|
||||
public void gameStateModelUpdater(){
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new Thread(() -> {
|
||||
while (getGame().isOngoing) {
|
||||
for (Passenger passenger : getGameState().getPassengerTrain()) {
|
||||
passenger.send(GuiParameters.updateGameState, getGame());
|
||||
@ -99,7 +97,6 @@ public class Game implements Runnable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
@ -342,8 +342,8 @@ public class Client {
|
||||
case GuiParameters.listOfPLayers:
|
||||
break;
|
||||
default:
|
||||
gameController.addMessageToNotificationText(
|
||||
data); //TODO(Sebi,Seraina): should the gameController be in the Application just like the ChatController?
|
||||
notificationTextDisplay(data);
|
||||
//TODO(Sebi,Seraina): should the gameController be in the Application just like the ChatController?
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Communication with GUI currently not possible: " + e.getMessage());
|
||||
@ -352,6 +352,24 @@ public class Client {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new thread, thad adds a message to notificationText in the gameController,
|
||||
* waits 3 seconds and deletes it again.
|
||||
* @param data the message to be added
|
||||
*/
|
||||
public void notificationTextDisplay(String data) {
|
||||
new Thread(() -> {
|
||||
gameController.addMessageToNotificationText(data);
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
gameController.clearNotificationText();
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
public void determineNoiseDisplay(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
|
||||
@ -167,6 +167,13 @@ public class GameController {
|
||||
//TODO: Wait for a certain time, then clear all again
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all children from notificationText TextFlow
|
||||
*/
|
||||
public void clearNotificationText() {
|
||||
notificationText.getChildren().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the labels of the rooms accordingly to the datastructures in GameStateModel
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user