aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-20 21:00:08 +0200
committerPacien TRAN-GIRARD2014-05-20 21:00:08 +0200
commit8394c66e0ba2fbbfcdc5738b7485e934d05773b9 (patch)
treec7df6f7107b72566df066c7b3a606ecb73ccf768 /src
parent614965104e47724f55c17dd88cb97eb109e477f4 (diff)
downloadesieequest-8394c66e0ba2fbbfcdc5738b7485e934d05773b9.tar.gz
Stop music on quit
Diffstat (limited to 'src')
-rw-r--r--src/esieequest/controller/commands/GoCommand.java2
-rw-r--r--src/esieequest/controller/commands/NewCommand.java2
-rw-r--r--src/esieequest/controller/commands/QuitCommand.java3
-rw-r--r--src/esieequest/model/items/Disk.java2
-rw-r--r--src/esieequest/view/Viewable.java9
-rw-r--r--src/esieequest/view/app/UserInterface.java9
-rw-r--r--src/esieequest/view/text/TextInterface.java9
-rw-r--r--src/esieequest/view/web/WebInterface.java20
8 files changed, 43 insertions, 13 deletions
diff --git a/src/esieequest/controller/commands/GoCommand.java b/src/esieequest/controller/commands/GoCommand.java
index 1078d49..a68f5ad 100644
--- a/src/esieequest/controller/commands/GoCommand.java
+++ b/src/esieequest/controller/commands/GoCommand.java
@@ -45,7 +45,7 @@ public class GoCommand implements Executable {
45 // handle challenge mode 45 // handle challenge mode
46 if (game.getPlayer().walk()) { 46 if (game.getPlayer().walk()) {
47 view.echo(Text.CHALLENGE_FAILED.toString()); 47 view.echo(Text.CHALLENGE_FAILED.toString());
48 view.disable(); 48 view.disableInput();
49 } 49 }
50 50
51 } 51 }
diff --git a/src/esieequest/controller/commands/NewCommand.java b/src/esieequest/controller/commands/NewCommand.java
index 7283989..571b4a9 100644
--- a/src/esieequest/controller/commands/NewCommand.java
+++ b/src/esieequest/controller/commands/NewCommand.java
@@ -35,7 +35,7 @@ public class NewCommand implements Executable {
35 .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer() 35 .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer()
36 .canGoBack()); 36 .canGoBack());
37 37
38 view.enable(); 38 view.enableInput();
39 } 39 }
40 }); 40 });
41 41
diff --git a/src/esieequest/controller/commands/QuitCommand.java b/src/esieequest/controller/commands/QuitCommand.java
index 4453597..024b35f 100644
--- a/src/esieequest/controller/commands/QuitCommand.java
+++ b/src/esieequest/controller/commands/QuitCommand.java
@@ -15,7 +15,8 @@ public class QuitCommand implements Executable {
15 public void execute(final String argument, final Game game, final Viewable view) { 15 public void execute(final String argument, final Game game, final Viewable view) {
16 16
17 view.echo(Text.QUIT.toString()); 17 view.echo(Text.QUIT.toString());
18 view.disable(); 18 view.disableInput();
19 view.stopMusic();
19 20
20 } 21 }
21 22
diff --git a/src/esieequest/model/items/Disk.java b/src/esieequest/model/items/Disk.java
index e83ac8c..b534ad8 100644
--- a/src/esieequest/model/items/Disk.java
+++ b/src/esieequest/model/items/Disk.java
@@ -31,7 +31,7 @@ public class Disk extends SimpleItem {
31 game.getPlayer().getInventory().removeItem(Item.DISK); 31 game.getPlayer().getInventory().removeItem(Item.DISK);
32 game.getPlayer().getCurrentSide().getInventory().putItem(Item.DISK); 32 game.getPlayer().getCurrentSide().getInventory().putItem(Item.DISK);
33 33
34 view.disable(); 34 view.disableInput();
35 35
36 Scene.RUN_CONSOLE.setCallback(new Callback() { 36 Scene.RUN_CONSOLE.setCallback(new Callback() {
37 @Override 37 @Override
diff --git a/src/esieequest/view/Viewable.java b/src/esieequest/view/Viewable.java
index 845b4ea..fa53e1a 100644
--- a/src/esieequest/view/Viewable.java
+++ b/src/esieequest/view/Viewable.java
@@ -31,12 +31,12 @@ public interface Viewable {
31 /** 31 /**
32 * Enables the user interface. 32 * Enables the user interface.
33 */ 33 */
34 public void enable(); 34 public void enableInput();
35 35
36 /** 36 /**
37 * Disables the user interface. 37 * Disables the user interface.
38 */ 38 */
39 public void disable(); 39 public void disableInput();
40 40
41 /** 41 /**
42 * Displays a message. 42 * Displays a message.
@@ -83,4 +83,9 @@ public interface Viewable {
83 */ 83 */
84 public void playScene(final Scene scene); 84 public void playScene(final Scene scene);
85 85
86 /**
87 * Stops the music currently playing.
88 */
89 public void stopMusic();
90
86} 91}
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java
index d7d8b44..b3d5a77 100644
--- a/src/esieequest/view/app/UserInterface.java
+++ b/src/esieequest/view/app/UserInterface.java
@@ -482,12 +482,12 @@ abstract class UserInterface implements Viewable, ActionListener {
482 } 482 }
483 483
484 @Override 484 @Override
485 public void enable() { 485 public void enableInput() {
486 this.setControlsState(true); 486 this.setControlsState(true);
487 } 487 }
488 488
489 @Override 489 @Override
490 public void disable() { 490 public void disableInput() {
491 this.setControlsState(false); 491 this.setControlsState(false);
492 this.setQuestLabel(Text.DEFAULT_QUEST_TITLE.toString()); 492 this.setQuestLabel(Text.DEFAULT_QUEST_TITLE.toString());
493 } 493 }
@@ -544,4 +544,9 @@ abstract class UserInterface implements Viewable, ActionListener {
544 this.playAudio(scene.name()); 544 this.playAudio(scene.name());
545 } 545 }
546 546
547 @Override
548 public void stopMusic() {
549 return;
550 }
551
547} 552}
diff --git a/src/esieequest/view/text/TextInterface.java b/src/esieequest/view/text/TextInterface.java
index c735640..308a4e0 100644
--- a/src/esieequest/view/text/TextInterface.java
+++ b/src/esieequest/view/text/TextInterface.java
@@ -64,7 +64,7 @@ abstract class TextInterface implements Viewable {
64 } 64 }
65 65
66 @Override 66 @Override
67 public void enable() { 67 public void enableInput() {
68 if (!this.running) { 68 if (!this.running) {
69 this.running = true; 69 this.running = true;
70 this.run(); 70 this.run();
@@ -72,7 +72,7 @@ abstract class TextInterface implements Viewable {
72 } 72 }
73 73
74 @Override 74 @Override
75 public void disable() { 75 public void disableInput() {
76 this.running = false; 76 this.running = false;
77 } 77 }
78 78
@@ -102,4 +102,9 @@ abstract class TextInterface implements Viewable {
102 scene.getCallback().call(); 102 scene.getCallback().call();
103 } 103 }
104 104
105 @Override
106 public void stopMusic() {
107 return;
108 }
109
105} 110}
diff --git a/src/esieequest/view/web/WebInterface.java b/src/esieequest/view/web/WebInterface.java
index d417d24..6a4ac35 100644
--- a/src/esieequest/view/web/WebInterface.java
+++ b/src/esieequest/view/web/WebInterface.java
@@ -297,6 +297,9 @@ class WebInterface extends Composite implements Viewable {
297 * the URL of the audio file 297 * the URL of the audio file
298 */ 298 */
299 private void playAudio(final String fileName) { 299 private void playAudio(final String fileName) {
300 if (this.audio == null) {
301 return;
302 }
300 this.audio.setSrc(WebInterface.SOUND_DIR + fileName + WebInterface.SOUND_EXT); 303 this.audio.setSrc(WebInterface.SOUND_DIR + fileName + WebInterface.SOUND_EXT);
301 this.audio.play(); 304 this.audio.play();
302 } 305 }
@@ -305,6 +308,9 @@ class WebInterface extends Composite implements Viewable {
305 * Toggles the sound (music). 308 * Toggles the sound (music).
306 */ 309 */
307 private void toggleAudio() { 310 private void toggleAudio() {
311 if (this.audio == null) {
312 return;
313 }
308 this.audio.setMuted(!this.audio.isMuted()); 314 this.audio.setMuted(!this.audio.isMuted());
309 } 315 }
310 316
@@ -367,12 +373,12 @@ class WebInterface extends Composite implements Viewable {
367 } 373 }
368 374
369 @Override 375 @Override
370 public void enable() { 376 public void enableInput() {
371 this.setControlsEnabled(true); 377 this.setControlsEnabled(true);
372 } 378 }
373 379
374 @Override 380 @Override
375 public void disable() { 381 public void disableInput() {
376 this.setControlsEnabled(false); 382 this.setControlsEnabled(false);
377 this.setQuestLabel(Text.DEFAULT_QUEST_TITLE.toString()); 383 this.setQuestLabel(Text.DEFAULT_QUEST_TITLE.toString());
378 } 384 }
@@ -422,7 +428,7 @@ class WebInterface extends Composite implements Viewable {
422 428
423 @Override 429 @Override
424 public void playScene(final Scene scene) { 430 public void playScene(final Scene scene) {
425 this.disable(); 431 this.disableInput();
426 432
427 this.setQuestLabel(scene.getTitle()); 433 this.setQuestLabel(scene.getTitle());
428