diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/esieequest/controller/Callback.java | 15 | ||||
-rw-r--r-- | src/esieequest/controller/commands/NewCommand.java | 23 | ||||
-rw-r--r-- | src/esieequest/model/events/Quest.java | 2 | ||||
-rw-r--r-- | src/esieequest/model/events/Scene.java | 48 | ||||
-rw-r--r-- | src/esieequest/view/Viewable.java | 9 | ||||
-rw-r--r-- | src/esieequest/view/app/UserInterface.java | 91 | ||||
-rw-r--r-- | src/esieequest/view/text/TextInterface.java | 9 | ||||
-rw-r--r-- | src/esieequest/view/web/WebInterface.java | 27 |
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 @@ | |||
1 | package esieequest.controller; | ||
2 | |||
3 | /** | ||
4 | * The Callback interface. | ||
5 | * | ||
6 | * @author Pacien TRAN-GIRARD | ||
7 | */ | ||
8 | public 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 @@ | |||
1 | package esieequest.controller.commands; | 1 | package esieequest.controller.commands; |
2 | 2 | ||
3 | import esieequest.controller.Callback; | ||
3 | import esieequest.model.Game; | 4 | import esieequest.model.Game; |
4 | import esieequest.model.Text; | 5 | import esieequest.model.Text; |
6 | import esieequest.model.events.Scene; | ||
5 | import esieequest.view.Viewable; | 7 | import 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 @@ | |||
1 | package esieequest.model.events; | ||
2 | |||
3 | import lombok.Getter; | ||
4 | import lombok.Setter; | ||
5 | import esieequest.controller.Callback; | ||
6 | |||
7 | /** | ||
8 | * Represents an animated Scene that can be played. | ||
9 | * | ||
10 | * @author Pacien TRAN-GIRARD | ||
11 | */ | ||
12 | public 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 | ||
3 | import esieequest.controller.GameEngine; | 3 | import esieequest.controller.GameEngine; |
4 | import esieequest.model.events.Quest; | 4 | import esieequest.model.events.Quest; |
5 | import esieequest.model.events.Scene; | ||
5 | import esieequest.model.items.Inventory; | 6 | import esieequest.model.items.Inventory; |
6 | import esieequest.model.map.Direction; | 7 | import esieequest.model.map.Direction; |
7 | import esieequest.model.map.Room; | 8 | import 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; | |||
14 | import java.awt.image.BufferedImage; | 14 | import java.awt.image.BufferedImage; |
15 | import java.net.URL; | 15 | import java.net.URL; |
16 | import java.util.HashMap; | 16 | import java.util.HashMap; |
17 | import java.util.HashSet; | ||
18 | import java.util.Map.Entry; | 17 | import java.util.Map.Entry; |
19 | import java.util.Set; | ||
20 | 18 | ||
21 | import javax.swing.AbstractAction; | 19 | import javax.swing.AbstractAction; |
22 | import javax.swing.JButton; | 20 | import javax.swing.JButton; |
@@ -36,6 +34,7 @@ import esieequest.controller.GameEngine; | |||
36 | import esieequest.controller.commands.Command; | 34 | import esieequest.controller.commands.Command; |
37 | import esieequest.model.Text; | 35 | import esieequest.model.Text; |
38 | import esieequest.model.events.Quest; | 36 | import esieequest.model.events.Quest; |
37 | import esieequest.model.events.Scene; | ||
39 | import esieequest.model.items.Inventory; | 38 | import esieequest.model.items.Inventory; |
40 | import esieequest.model.items.Item; | 39 | import esieequest.model.items.Item; |
41 | import esieequest.model.map.Direction; | 40 | import 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(); | 101 | this.buildUI(); |
109 | this.setActionListener(this); | 102 | this.setActionListener(this); |
110 | this.bindKeys(); | 103 | this.bindKeys(); |