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