Fix minor error in notification processing

This commit is contained in:
Felix Koppe
2024-12-03 15:00:00 +01:00
parent c4d11ff961
commit a0a088a0c4
3 changed files with 33 additions and 29 deletions

View File

@@ -26,37 +26,42 @@ public void addTestNotification(Notification n) {
public void update() {
Notification n = app.getGameLogic().getNotification();
if(n instanceof InfoNotification infoNotification) {
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
return;
}
if(n != null) {
switch (app.getState()) {
case MAIN:
handleMain(n);
break;
case LOBBY:
handleLobby(n);
break;
case GAME:
handleGame(n);
break;
case CEREMONY:
handleCeremony(n);
break;
case NONE:
throw new RuntimeException("no notification expected: " + n.toString());
while (n != null) {
if(n instanceof InfoNotification infoNotification) {
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
return;
}
if(n != null) {
switch (app.getState()) {
case MAIN:
handleMain(n);
break;
case LOBBY:
handleLobby(n);
break;
case GAME:
handleGame(n);
break;
case CEREMONY:
handleCeremony(n);
break;
case NONE:
throw new RuntimeException("no notification expected: " + n.getClass().getName());
}
}
n = app.getGameLogic().getNotification();
}
}
private void handleMain(Notification notification) {
if (notification instanceof LobbyDialogNotification) {
app.enter(MdgaState.LOBBY);
} else if (notification instanceof StartDialogNotification) {
//nothing
} else {
throw new RuntimeException("notification not expected: ");
throw new RuntimeException("notification not expected in main: "+ notification.getClass().getName());
}
}
@@ -75,7 +80,7 @@ private void handleLobby(Notification notification) {
app.enter(MdgaState.GAME);
((GameView) app.getView()).setOwnColor(n.getOwnColor());
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
throw new RuntimeException("notification not expected in lobby: " + notification.getClass().getName());
}
}
@@ -189,7 +194,7 @@ private void handleGame(Notification notification) {
} else if (notification instanceof FinishNotification n){
guiHandler.finish(n.getColorFinished());
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
throw new RuntimeException("notification not expected in game: " + notification.getClass().getName());
}
}
@@ -197,7 +202,7 @@ private void handleCeremony(Notification notification) {
if (notification instanceof StartDialogNotification) {
app.enter(MdgaState.MAIN);
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
throw new RuntimeException("notification not expected in ceremony: " + notification.getClass().getName());
}
}
}

View File

@@ -86,7 +86,7 @@ public void update(float tpf) {
videoSettingsDialog.update();
audioSettingsDialog.update();
if (null != infoLabel && infoTimer.getTimeInSeconds() > 7) {
if (null != infoLabel && infoTimer.getTimeInSeconds() > 5) {
infoLabel.hide();
infoLabel = null;
}