aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-19 23:25:31 +0200
committerPacien TRAN-GIRARD2014-05-19 23:25:31 +0200
commit611fd21d13fe2ee223fcf7ca647be20131887c96 (patch)
tree8cbd5abd471049f37a183bf9f6db8b6b79456605
parentb77e4a7c77d9608be715e943f282af1f6ef45596 (diff)
downloadesieequest-611fd21d13fe2ee223fcf7ca647be20131887c96.tar.gz
Implement audio (WebInterface)
-rw-r--r--src/esieequest/controller/commands/Command.java1
-rw-r--r--src/esieequest/controller/commands/SoundCommand.java19
-rw-r--r--src/esieequest/model/Text.java2
-rw-r--r--src/esieequest/model/events/Quest.java2
-rw-r--r--src/esieequest/model/events/Scene.java5
-rw-r--r--src/esieequest/view/app/UserInterface.java28
-rw-r--r--src/esieequest/view/web/WebInterface.java35
7 files changed, 56 insertions, 36 deletions
diff --git a/src/esieequest/controller/commands/Command.java b/src/esieequest/controller/commands/Command.java
index 0879bef..a29b79b 100644
--- a/src/esieequest/controller/commands/Command.java
+++ b/src/esieequest/controller/commands/Command.java
@@ -22,7 +22,6 @@ public enum Command {
22 LOAD(new LoadCommand()), 22 LOAD(new LoadCommand()),
23 SAVE(new SaveCommand()), 23 SAVE(new SaveCommand()),
24 QUIT(new QuitCommand()), 24 QUIT(new QuitCommand()),
25 SOUND(new SoundCommand()),
26 HELP(new HelpCommand()), 25 HELP(new HelpCommand()),
27 ALEA(new AleaCommand()), 26 ALEA(new AleaCommand()),
28 27
diff --git a/src/esieequest/controller/commands/SoundCommand.java b/src/esieequest/controller/commands/SoundCommand.java
deleted file mode 100644
index fbd11d7..0000000
--- a/src/esieequest/controller/commands/SoundCommand.java
+++ /dev/null
@@ -1,19 +0,0 @@
1package esieequest.controller.commands;
2
3import esieequest.model.Game;
4import esieequest.view.Viewable;
5
6/**
7 * Allows the user to enable or disable the game's sounds.
8 *
9 * @author Pacien TRAN-GIRARD
10 */
11public class SoundCommand implements Executable {
12
13 @Override
14 public void execute(final String argument, final Game game, final Viewable view) {
15 // TODO Auto-generated method stub
16
17 }
18
19}
diff --git a/src/esieequest/model/Text.java b/src/esieequest/model/Text.java
index d70b86f..8e916fc 100644
--- a/src/esieequest/model/Text.java
+++ b/src/esieequest/model/Text.java
@@ -14,7 +14,7 @@ public enum Text {
14 DEFAULT_QUEST_TITLE("ESIEEquest"), 14 DEFAULT_QUEST_TITLE("ESIEEquest"),
15 CURRENT_QUEST_PREFIX("Current quest: "), 15 CURRENT_QUEST_PREFIX("Current quest: "),
16 16
17 NOT_IMPLEMENTED("Not implementer... Yet."), 17 NOT_IMPLEMENTED("Not implemented... Yet."),
18 18
19 NEW_GAME_BUTTON("New"), 19 NEW_GAME_BUTTON("New"),
20 NEW_GAME_TOOLTIP("New game"), 20 NEW_GAME_TOOLTIP("New game"),
diff --git a/src/esieequest/model/events/Quest.java b/src/esieequest/model/events/Quest.java
index ac523e2..84bc80b 100644
--- a/src/esieequest/model/events/Quest.java
+++ b/src/esieequest/model/events/Quest.java
@@ -12,7 +12,7 @@ public enum Quest {
12 // @formatter:off 12 // @formatter:off
13 13
14 WHAT_HAPPENED("What happened?!?!"), 14 WHAT_HAPPENED("What happened?!?!"),
15 FIND_ATHANASE("Find Athanase"), 15 //FIND_ATHANASE("Find Athanase"),
16 FEED_ATHANASE("Feed Athanase"), 16 FEED_ATHANASE("Feed Athanase"),
17 FIND_DISK("Find the Disk"), 17 FIND_DISK("Find the Disk"),
18 FIND_TRANSPONDER("Find the Transponder"), 18 FIND_TRANSPONDER("Find the Transponder"),
diff --git a/src/esieequest/model/events/Scene.java b/src/esieequest/model/events/Scene.java
index eebd9f6..91ae7c2 100644
--- a/src/esieequest/model/events/Scene.java
+++ b/src/esieequest/model/events/Scene.java
@@ -13,8 +13,9 @@ public enum Scene {
13 13
14 // @formatter:off 14 // @formatter:off
15 15
16 INTRO("Testing is the future...", "...", 2500), 16 INTRO("THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY!", "...", 90000),
17 END("...and the future starts with you!", "...", 2500), 17 TRANSPONDER_ACTIVATED("Stalemate Resolved.", "...", 2500),
18 END("Good work getting this far, future-starter!", "...", 2500),
18 19
19 ; 20 ;
20 21
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java
index cb8d6aa..d7d8b44 100644
--- a/src/esieequest/view/app/UserInterface.java
+++ b/src/esieequest/view/app/UserInterface.java
@@ -51,8 +51,12 @@ import esieequest.view.Viewable;
51 */ 51 */
52abstract class UserInterface implements Viewable, ActionListener { 52abstract class UserInterface implements Viewable, ActionListener {
53 53
54 private static final String ILLUSTRATION_DIR = "res/frame/";
54 private static final String ILLUSTRATION_EXT = ".html"; 55 private static final String ILLUSTRATION_EXT = ".html";
55 56
57 private static final String SOUND_DIR = "res/audio/";
58 private static final String SOUND_EXT = ".ogg";
59
56 private GameEngine gameEngine; 60 private GameEngine gameEngine;
57 61
58 @Getter 62 @Getter
@@ -137,7 +141,6 @@ abstract class UserInterface implements Viewable, ActionListener {
137 141
138 this.soundButton = new JButton(Text.TOGGLE_SOUND_BUTTON.toString()); 142 this.soundButton = new JButton(Text.TOGGLE_SOUND_BUTTON.toString());
139 this.soundButton.setToolTipText(Text.TOGGLE_SOUND_TOOLTIP.toString()); 143 this.soundButton.setToolTipText(Text.TOGGLE_SOUND_TOOLTIP.toString());
140 this.soundButton.setActionCommand(Command.SOUND.name());
141 this.gamePanel.add(this.soundButton); 144 this.gamePanel.add(this.soundButton);
142 145
143 this.filePanel = new JPanel(); 146 this.filePanel = new JPanel();
@@ -439,6 +442,25 @@ abstract class UserInterface implements Viewable, ActionListener {
439 } 442 }
440 443
441 /** 444 /**
445 * Sets the current music playing.
446 *
447 * @param fileName
448 * the URL of the audio file
449 */
450 private void playAudio(final String fileName) {
451 // TODO Auto-generated method stub
452 this.echo(Text.NOT_IMPLEMENTED.toString());
453 }
454
455 /**
456 * Toggles the sound (music).
457 */
458 private void toggleAudio() {
459 // TODO Auto-generated method stub
460 this.echo(Text.NOT_IMPLEMENTED.toString());
461 }
462
463 /**
442 * Translates the received ActionEvent into the corresponding game command 464 * Translates the received ActionEvent into the corresponding game command
443 * and forwards it to the game engine. 465 * and forwards it to the game engine.
444 */ 466 */
@@ -446,6 +468,8 @@ abstract class UserInterface implements Viewable, ActionListener {
446 public void actionPerformed(final ActionEvent actionEvent) { 468 public void actionPerformed(final ActionEvent actionEvent) {
447 if (actionEvent.getActionCommand() == Text.INVENTORY_BUTTON.toString()) { 469 if (actionEvent.getActionCommand() == Text.INVENTORY_BUTTON.toString()) {
448 this.toggleInventory(); 470 this.toggleInventory();
471 } else if (actionEvent.getActionCommand() == Text.TOGGLE_SOUND_BUTTON.toString()) {
472 this.toggleAudio();
449 } else { 473 } else {
450 this.gameEngine.interpret(actionEvent.getActionCommand()); 474 this.gameEngine.interpret(actionEvent.getActionCommand());
451 this.clearInputField(); 475 this.clearInputField();
@@ -478,6 +502,7 @@ abstract class UserInterface implements Viewable, ActionListener {
478 @Override 502 @Override
479 public void updateQuest(final Quest quest) { 503 public void updateQuest(final Quest quest) {
480 this.setQuestLabel(quest.getTitle()); 504 this.setQuestLabel(quest.getTitle());
505 this.playAudio(quest.name());
481 } 506 }
482 507
483 @Override 508 @Override
@@ -516,6 +541,7 @@ abstract class UserInterface implements Viewable, ActionListener {
516 @Override 541 @Override
517 public void playScene(final Scene scene) { 542 public void playScene(final Scene scene) {
518 scene.getCallback().call(); 543 scene.getCallback().call();
544 this.playAudio(scene.name());
519 } 545 }
520 546
521} 547}
diff --git a/src/esieequest/view/web/WebInterface.java b/src/esieequest/view/web/WebInterface.java
index 0bd5776..a85fc78 100644
--- a/src/esieequest/view/web/WebInterface.java
+++ b/src/esieequest/view/web/WebInterface.java
@@ -6,6 +6,7 @@ import com.google.gwt.event.dom.client.ClickHandler;
6import com.google.gwt.event.dom.client.KeyCodes; 6import com.google.gwt.event.dom.client.KeyCodes;
7import com.google.gwt.event.dom.client.KeyDownEvent; 7import com.google.gwt.event.dom.client.KeyDownEvent;
8import com.google.gwt.event.dom.client.KeyDownHandler; 8import com.google.gwt.event.dom.client.KeyDownHandler;
9import com.google.gwt.media.client.Audio;
9import com.google.gwt.uibinder.client.UiBinder; 10import com.google.gwt.uibinder.client.UiBinder;
10import com.google.gwt.uibinder.client.UiField; 11import com.google.gwt.uibinder.client.UiField;
11import com.google.gwt.user.client.Event; 12import com.google.gwt.user.client.Event;
@@ -42,9 +43,12 @@ import esieequest.view.Viewable;
42 */ 43 */
43class WebInterface extends Composite implements Viewable { 44class WebInterface extends Composite implements Viewable {
44 45
45 private static final String ILLUSTRATION_DIR = "illustrations/"; 46 private static final String ILLUSTRATION_DIR = "res/frame/";
46 private static final String ILLUSTRATION_EXT = ".html"; 47 private static final String ILLUSTRATION_EXT = ".html";
47 48
49 private static final String SOUND_DIR = "res/audio/";
50 private static final String SOUND_EXT = ".ogg";
51
48 private GameEngine gameEngine; 52 private GameEngine gameEngine;
49 53
50 private static WebInterfaceUiBinder uiBinder = GWT.create(WebInterfaceUiBinder.class); 54 private static WebInterfaceUiBinder uiBinder = GWT.create(WebInterfaceUiBinder.class);
@@ -82,6 +86,8 @@ class WebInterface extends Composite implements Viewable {
82 @UiField 86 @UiField
83 Button leftButton; 87 Button leftButton;
84 88
89 private Audio audio;
90
85 /** 91 /**
86 * The web user interface binder interface. 92 * The web user interface binder interface.
87 */ 93 */
@@ -104,6 +110,12 @@ class WebInterface extends Composite implements Viewable {
104 this.bindInputField(); 110 this.bindInputField();
105 this.bindKeys();