aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-19 20:40:34 +0200
committerPacien TRAN-GIRARD2014-05-19 20:40:34 +0200
commitb77e4a7c77d9608be715e943f282af1f6ef45596 (patch)
treed2ac6d313efdb7ce6cf4f32868ed5b9d50f0aede
parent3ff1fbbc8c79ebd86b74e53b8a4d08a51adcc1b6 (diff)
downloadesieequest-b77e4a7c77d9608be715e943f282af1f6ef45596.tar.gz
Implement Scene
-rw-r--r--src/esieequest/controller/Callback.java15
-rw-r--r--src/esieequest/controller/commands/NewCommand.java23
-rw-r--r--src/esieequest/model/events/Quest.java2
-rw-r--r--src/esieequest/model/events/Scene.java48
-rw-r--r--src/esieequest/view/Viewable.java9
-rw-r--r--src/esieequest/view/app/UserInterface.java91
-rw-r--r--src/esieequest/view/text/TextInterface.java9
-rw-r--r--src/esieequest/view/web/WebInterface.java27
8 files changed, 164 insertions, 60 deletions
diff --git a/src/esieequest/controller/Callback.java b/src/esieequest/controller/Callback.java
new file mode 100644
index 0000000..ef03b72
--- /dev/null
+++ b/src/esieequest/controller/Callback.java
@@ -0,0 +1,15 @@
1package esieequest.controller;
2
3/**
4 * The Callback interface.
5 *
6 * @author Pacien TRAN-GIRARD
7 */
8public interface Callback {
9
10 /**
11 * Will be run after the execution of the function.
12 */
13 public void call();
14
15}
diff --git a/src/esieequest/controller/commands/NewCommand.java b/src/esieequest/controller/commands/NewCommand.java
index 3f0b4b9..7283989 100644
--- a/src/esieequest/controller/commands/NewCommand.java
+++ b/src/esieequest/controller/commands/NewCommand.java
@@ -1,7 +1,9 @@
1package esieequest.controller.commands; 1package esieequest.controller.commands;
2 2
3import esieequest.controller.Callback;
3import esieequest.model.Game; 4import esieequest.model.Game;
4import esieequest.model.Text; 5import esieequest.model.Text;
6import esieequest.model.events.Scene;
5import esieequest.view.Viewable; 7import esieequest.view.Viewable;
6 8
7/** 9/**
@@ -22,13 +24,22 @@ public class NewCommand implements Executable {
22 24
23 game.newGame(true, challengeMode); 25 game.newGame(true, challengeMode);
24 26
25 view.enable();
26
27 view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer()
28 .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer()
29 .canGoBack());
30 view.echo(Text.WELCOME.toString()); 27 view.echo(Text.WELCOME.toString());
31 28
32 } 29 Scene.INTRO.setCallback(new Callback() {
30 @Override
31 public void call() {
32 view.updateQuest(game.getPlayer().getCurrentQuest());
33
34 view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer()
35 .getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer()
36 .canGoBack());
33 37
38 view.enable();
39 }
40 });
41
42 view.playScene(Scene.INTRO);
43
44 }
34} 45}
diff --git a/src/esieequest/model/events/Quest.java b/src/esieequest/model/events/Quest.java
index 54cbb4a..ac523e2 100644
--- a/src/esieequest/model/events/Quest.java
+++ b/src/esieequest/model/events/Quest.java
@@ -13,7 +13,7 @@ public enum Quest {
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"),
19 ACTIVATE_TRANSPONDER("Activate the Transponder"), 19 ACTIVATE_TRANSPONDER("Activate the Transponder"),
diff --git a/src/esieequest/model/events/Scene.java b/src/esieequest/model/events/Scene.java
new file mode 100644
index 0000000..eebd9f6
--- /dev/null
+++ b/src/esieequest/model/events/Scene.java
@@ -0,0 +1,48 @@
1package esieequest.model.events;
2
3import lombok.Getter;
4import lombok.Setter;
5import esieequest.controller.Callback;
6
7/**
8 * Represents an animated Scene that can be played.
9 *
10 * @author Pacien TRAN-GIRARD
11 */
12public enum Scene {
13
14 // @formatter:off
15
16 INTRO("Testing is the future...", "...", 2500),
17 END("...and the future starts with you!", "...", 2500),
18
19 ;
20
21 // @formatter:on
22
23 @Getter
24 private final String title;
25
26 @Getter
27 private final String text;
28
29 @Getter
30 private final int duration;
31
32 @Getter
33 @Setter
34 private Callback callback;
35
36 Scene(final String title, final String text, final int duration) {
37 this.title = title;
38 this.text = text;
39 this.duration = duration;
40 this.callback = new Callback() {
41 @Override
42 public void call() {
43 return;
44 }
45 };
46 }
47
48}
diff --git a/src/esieequest/view/Viewable.java b/src/esieequest/view/Viewable.java
index dc12973..845b4ea 100644
--- a/src/esieequest/view/Viewable.java
+++ b/src/esieequest/view/Viewable.java
@@ -2,6 +2,7 @@ package esieequest.view;
2 2
3import esieequest.controller.GameEngine; 3import esieequest.controller.GameEngine;
4import esieequest.model.events.Quest; 4import esieequest.model.events.Quest;
5import esieequest.model.events.Scene;
5import esieequest.model.items.Inventory; 6import esieequest.model.items.Inventory;
6import esieequest.model.map.Direction; 7import esieequest.model.map.Direction;
7import esieequest.model.map.Room; 8import esieequest.model.map.Room;
@@ -74,4 +75,12 @@ public interface Viewable {
74 */ 75 */
75 public void updateInventory(final Inventory inventory); 76 public void updateInventory(final Inventory inventory);
76 77
78 /**
79 * Plays the given Scene.
80 *
81 * @param scene
82 * the Scene to play
83 */
84 public void playScene(final Scene scene);
85
77} 86}
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java
index 0b0a44b..cb8d6aa 100644
--- a/src/esieequest/view/app/UserInterface.java
+++ b/src/esieequest/view/app/UserInterface.java
@@ -14,9 +14,7 @@ import java.awt.event.KeyEvent;
14import java.awt.image.BufferedImage; 14import java.awt.image.BufferedImage;
15import java.net.URL; 15import java.net.URL;
16import java.util.HashMap; 16import java.util.HashMap;
17import java.util.HashSet;
18import java.util.Map.Entry; 17import java.util.Map.Entry;
19import java.util.Set;
20 18
21import javax.swing.AbstractAction; 19import javax.swing.AbstractAction;
22import javax.swing.JButton; 20import javax.swing.JButton;
@@ -36,6 +34,7 @@ import esieequest.controller.GameEngine;
36import esieequest.controller.commands.Command; 34import esieequest.controller.commands.Command;
37import esieequest.model.Text; 35import esieequest.model.Text;
38import esieequest.model.events.Quest; 36import esieequest.model.events.Quest;
37import esieequest.model.events.Scene;
39import esieequest.model.items.Inventory; 38import esieequest.model.items.Inventory;
40import esieequest.model.items.Item; 39import esieequest.model.items.Item;
41import esieequest.model.map.Direction; 40import esieequest.model.map.Direction;
@@ -67,11 +66,10 @@ abstract class UserInterface implements Viewable, ActionListener {
67 private JPanel questPanel; 66 private JPanel questPanel;
68 private JPanel gamePanel; 67 private JPanel gamePanel;
69 68
70 private final Set<JButton> gameButtons;
71
72 private JButton newButton; 69 private JButton newButton;
73 private JButton soundButton; 70 private JButton soundButton;
74 private JPanel filePanel; 71 private JPanel filePanel;
72 private JButton loadButton;
75 private JButton saveButton; 73 private JButton saveButton;
76 74
77 private JPanel imagePanel; 75 private JPanel imagePanel;
@@ -89,8 +87,6 @@ abstract class UserInterface implements Viewable, ActionListener {
89 private JTextPane infoTextPane; 87 private JTextPane infoTextPane;
90 private JTextField inputField; 88 private JTextField inputField;
91 89
92 private final Set<JButton> controlButtons;
93
94 private JButton forwardButton; 90 private JButton forwardButton;
95 private JButton inventoryButton; 91 private JButton inventoryButton;
96 private JButton actionButton; 92 private JButton actionButton;
@@ -102,9 +98,6 @@ abstract class UserInterface implements Viewable, ActionListener {
102 * The default constructor. 98 * The default constructor.
103 */ 99 */
104 public UserInterface() { 100 public UserInterface() {
105 this.gameButtons = new HashSet<>();
106 this.controlButtons = new HashSet<>();
107
108 this.buildUI();