diff options
author | Pacien TRAN-GIRARD | 2014-05-19 23:25:31 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2014-05-19 23:25:31 +0200 |
commit | 611fd21d13fe2ee223fcf7ca647be20131887c96 (patch) | |
tree | 8cbd5abd471049f37a183bf9f6db8b6b79456605 /src/esieequest/view/app/UserInterface.java | |
parent | b77e4a7c77d9608be715e943f282af1f6ef45596 (diff) | |
download | esieequest-611fd21d13fe2ee223fcf7ca647be20131887c96.tar.gz |
Implement audio (WebInterface)
Diffstat (limited to 'src/esieequest/view/app/UserInterface.java')
-rw-r--r-- | src/esieequest/view/app/UserInterface.java | 28 |
1 files changed, 27 insertions, 1 deletions
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 | */ |
52 | abstract class UserInterface implements Viewable, ActionListener { | 52 | abstract 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 | } |