Fix minor error in notification processing
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
|
<configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
|
||||||
<option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
|
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||||
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
|
<option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
|
||||||
<module name="Projekte.mdga.client.main" />
|
<module name="Projekte.mdga.client.main" />
|
||||||
|
|||||||
@@ -26,37 +26,42 @@ public void addTestNotification(Notification n) {
|
|||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
Notification n = app.getGameLogic().getNotification();
|
Notification n = app.getGameLogic().getNotification();
|
||||||
|
while (n != null) {
|
||||||
if(n instanceof InfoNotification infoNotification) {
|
if(n instanceof InfoNotification infoNotification) {
|
||||||
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
|
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
|
||||||
return;
|
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
private void handleMain(Notification notification) {
|
||||||
if (notification instanceof LobbyDialogNotification) {
|
if (notification instanceof LobbyDialogNotification) {
|
||||||
app.enter(MdgaState.LOBBY);
|
app.enter(MdgaState.LOBBY);
|
||||||
|
} else if (notification instanceof StartDialogNotification) {
|
||||||
|
//nothing
|
||||||
} else {
|
} 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);
|
app.enter(MdgaState.GAME);
|
||||||
((GameView) app.getView()).setOwnColor(n.getOwnColor());
|
((GameView) app.getView()).setOwnColor(n.getOwnColor());
|
||||||
} else {
|
} 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){
|
} else if (notification instanceof FinishNotification n){
|
||||||
guiHandler.finish(n.getColorFinished());
|
guiHandler.finish(n.getColorFinished());
|
||||||
} else {
|
} 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) {
|
if (notification instanceof StartDialogNotification) {
|
||||||
app.enter(MdgaState.MAIN);
|
app.enter(MdgaState.MAIN);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("notification not expected: " + notification.toString());
|
throw new RuntimeException("notification not expected in ceremony: " + notification.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public void update(float tpf) {
|
|||||||
videoSettingsDialog.update();
|
videoSettingsDialog.update();
|
||||||
audioSettingsDialog.update();
|
audioSettingsDialog.update();
|
||||||
|
|
||||||
if (null != infoLabel && infoTimer.getTimeInSeconds() > 7) {
|
if (null != infoLabel && infoTimer.getTimeInSeconds() > 5) {
|
||||||
infoLabel.hide();
|
infoLabel.hide();
|
||||||
infoLabel = null;
|
infoLabel = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user