From aab49eed1dc38f3f349ef180d5c5fd3b6ccb9023 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 24 Nov 2018 19:53:58 +0100 Subject: Rename MenuScene to MainMenuScene and minor code cleanup --- src/subconscious/graphics/GameWindow.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/subconscious/graphics/GameWindow.java') 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); } -- cgit v1.2.1