summaryrefslogtreecommitdiffstats
path: root/src/subconscious/graphics/GameWindow.java
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-11-24 19:53:58 +0100
committerNao Pross <naopross@thearcway.org>2018-11-24 19:53:58 +0100
commitaab49eed1dc38f3f349ef180d5c5fd3b6ccb9023 (patch)
tree4923737221151b8af95457bc784eb45eca4f616a /src/subconscious/graphics/GameWindow.java
parentAdd simple PerfView widget to show the deltaTime (diff)
downloadSubconscious-java-aab49eed1dc38f3f349ef180d5c5fd3b6ccb9023.tar.gz
Subconscious-java-aab49eed1dc38f3f349ef180d5c5fd3b6ccb9023.zip
Rename MenuScene to MainMenuScene and minor code cleanup
Diffstat (limited to 'src/subconscious/graphics/GameWindow.java')
-rw-r--r--src/subconscious/graphics/GameWindow.java19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/subconscious/graphics/GameWindow.java b/src/subconscious/graphics/GameWindow.java
index eb360f5..b26d6a4 100644
--- a/src/subconscious/graphics/GameWindow.java
+++ b/src/subconscious/graphics/GameWindow.java
@@ -32,14 +32,12 @@ public class GameWindow extends Frame implements WindowListener {
private volatile Game game;
- // TODO: remove map editor, start directly on Battle mode
public GameWindow(Game g) {
super("Subconscious");
-
+
this.game = g;
// set up JFrame
- // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(WINDOW_SIZE);
this.setPreferredSize(WINDOW_SIZE);
this.setLocationRelativeTo(null);
@@ -61,7 +59,7 @@ public class GameWindow extends Frame implements WindowListener {
// ovserver of this.game
private void loop() {
// load the first scene
- this.loadScene(new MenuScene(this.game));
+ this.loadScene(new MainMenuScene(this.game));
while (this.game.isRunning()) {
// check if the scene has requested a new scene
@@ -80,9 +78,7 @@ public class GameWindow extends Frame implements WindowListener {
Game.State newState = this.game.getState();
Game.State lastState = this.game.getLastState();
- if (lastState == newState) {
- throw new IllegalStateException();
- }
+ assert newState != lastState;
// MAIN_MENU is always the first scene
if (newState == Game.State.MAIN_MENU) {
@@ -130,12 +126,6 @@ public class GameWindow extends Frame implements WindowListener {
this.unloadScene();
}
- // private void unloadScenes(int count) {
- // for (int i = 0; i < count; i++) {
- // this.unloadScene();
- // }
- // }
-
private void unloadScene() {
// close old scene
this.scene.stop();
@@ -167,6 +157,9 @@ public class GameWindow extends Frame implements WindowListener {
this.setVisible(false);
this.dispose();
+ // check that all scene threads have been killed
+ assert this.loadedScenes.empty();
+
System.exit(0);
}