aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-04-02 08:15:32 +0000
committerPacien TRAN-GIRARD2014-04-02 08:15:32 +0000
commit4137433c5b57720d00cb249715e0ec252a99a173 (patch)
tree29aab8cf8b3bd37fe9e91500c65f84dd46738878
parent74feecd48f6bd97c2c5d7d678d0dfdf97560f6bd (diff)
parent3c2224e20b5323d51589b7d09a11182a3e951d10 (diff)
downloadesieequest-4137433c5b57720d00cb249715e0ec252a99a173.tar.gz
Merge branch 'zuul-mcv' into 'master'
Zuul Mcv
-rw-r--r--src/esieequest/view/View.java54
-rw-r--r--src/esieequest/view/app/UserInterface.java61
-rw-r--r--src/esieequest/view/text/TextInterface.java36
-rw-r--r--src/esieequest/view/web/WebInterface.java48
4 files changed, 131 insertions, 68 deletions
diff --git a/src/esieequest/view/View.java b/src/esieequest/view/View.java
index 545879a..9ffd7ec 100644
--- a/src/esieequest/view/View.java
+++ b/src/esieequest/view/View.java
@@ -3,8 +3,13 @@
3 */ 3 */
4package esieequest.view; 4package esieequest.view;
5 5
6import java.util.HashMap;
7
6import esieequest.controller.GameEngine; 8import esieequest.controller.GameEngine;
7import esieequest.model.Game; 9import esieequest.model.Item;
10import esieequest.model.Quest;
11import esieequest.model.Room;
12import esieequest.model.Side;
8 13
9/** 14/**
10 * The view interface that describes an user interface. 15 * The view interface that describes an user interface.
@@ -14,14 +19,6 @@ import esieequest.model.Game;
14public interface View { 19public interface View {
15 20
16 /** 21 /**
17 * Sets the model to use.
18 *
19 * @param game
20 * the Game model
21 */
22 public void setModel(Game game);
23
24 /**
25 * Sets the controller to use. 22 * Sets the controller to use.
26 * 23 *
27 * @param gameEngine 24 * @param gameEngine
@@ -40,21 +37,48 @@ public interface View {
40 public void enable(); 37 public void enable();
41 38
42 /** 39 /**
40 * Displays a message.
41 *
42 * @param message
43 * the message
44 */
45 public void echo(String message);
46
47 /**
43 * Disables the user interface. 48 * Disables the user interface.
44 */ 49 */
45 public void disable(); 50 public void disable();
46 51
47 /** 52 /**
48 * Refreshes the user interface. 53 * Updates the view to match the current room.
54 *
55 * @param room
56 * the room to display
49 */ 57 */
50 public void refresh(); 58 public void updateRoom(Room room);
51 59
52 /** 60 /**
53 * Displays a message. 61 * Updates the view to match a side of a room.
54 * 62 *
55 * @param message 63 * @param side
56 * the message 64 * the side of a room
57 */ 65 */
58 public void echo(String message); 66 public void updateSide(Side side);
67
68 /**
69 * Updates the view to match the current quest.
70 *
71 * @param quest
72 * the current quest to display
73 */
74 public void updateQuest(Quest quest);
75
76 /**
77 * Updates the view to display the items contained in the inventory
78 *
79 * @param items
80 * the items
81 */
82 public void updateInventory(HashMap<String, Item> items);
59 83
60} 84}
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java
index 1fc57bd..28b2f37 100644
--- a/src/esieequest/view/app/UserInterface.java
+++ b/src/esieequest/view/app/UserInterface.java
@@ -18,7 +18,10 @@ import javax.swing.border.EmptyBorder;
18import com.wordpress.tipsforjava.swing.StretchIcon; 18import com.wordpress.tipsforjava.swing.StretchIcon;
19 19
20import esieequest.controller.GameEngine; 20import esieequest.controller.GameEngine;
21import esieequest.model.Game; 21import esieequest.model.Item;
22import esieequest.model.Quest;
23import esieequest.model.Room;
24import esieequest.model.Side;
22import esieequest.view.View; 25import esieequest.view.View;
23 26
24/** 27/**
@@ -28,7 +31,6 @@ import esieequest.view.View;
28 */ 31 */
29abstract class UserInterface implements View, ActionListener { 32abstract class UserInterface implements View, ActionListener {
30 33
31 protected Game game;
32 private GameEngine gameEngine; 34 private GameEngine gameEngine;
33 35
34 private JPanel layout; 36 private JPanel layout;
@@ -127,18 +129,20 @@ abstract class UserInterface implements View, ActionListener {
127 controlPanel.add(topControlPanel, BorderLayout.NORTH); 129 controlPanel.add(topControlPanel, BorderLayout.NORTH);
128 topControlPanel.setLayout(new BorderLayout(0, 0)); 130 topControlPanel.setLayout(new BorderLayout(0, 0));
129 131
132 final Font font = new Font("Dialog", Font.BOLD, 19);
133
130 final JButton forwardButton = new JButton("↥"); 134 final JButton forwardButton = new JButton("↥");
131 forwardButton.setFont(new Font("Dialog", Font.BOLD, 19)); 135 forwardButton.setFont(font);
132 forwardButton.setToolTipText("Go forward"); 136 forwardButton.setToolTipText("Go forward");
133 topControlPanel.add(forwardButton, BorderLayout.CENTER); 137 topControlPanel.add(forwardButton, BorderLayout.CENTER);
134 138
135 final JButton inventoryButton = new JButton("⇱"); 139 final JButton inventoryButton = new JButton("⇱");
136 inventoryButton.setFont(new Font("Dialog", Font.BOLD, 19)); 140 inventoryButton.setFont(font);
137 inventoryButton.setToolTipText("Use item"); 141 inventoryButton.setToolTipText("Use item");
138 topControlPanel.add(inventoryButton, BorderLayout.WEST); 142 topControlPanel.add(inventoryButton, BorderLayout.WEST);
139 143
140 final JButton actionButton = new JButton("⇲"); 144 final JButton actionButton = new JButton("⇲");
141 actionButton.setFont(new Font("Dialog", Font.BOLD, 19)); 145 actionButton.setFont(font);
142 actionButton.setToolTipText("Talk/Take item"); 146 actionButton.setToolTipText("Talk/Take item");
143 topControlPanel.add(actionButton, BorderLayout.EAST); 147 topControlPanel.add(actionButton, BorderLayout.EAST);
144 148
@@ -147,17 +151,17 @@ abstract class UserInterface implements View, ActionListener {
147 bottomControlPanel.setLayout(new BorderLayout(0, 0)); 151 bottomControlPanel.setLayout(new BorderLayout(0, 0));
148 152
149 final JButton backButton = new JButton("↧"); 153 final JButton backButton = new JButton("↧");
150 backButton.setFont(new Font("Dialog", Font.BOLD, 19)); 154 backButton.setFont(font);
151 backButton.setToolTipText("Go back"); 155 backButton.setToolTipText("Go back");
152 bottomControlPanel.add(backButton, BorderLayout.CENTER); 156 bottomControlPanel.add(backButton, BorderLayout.CENTER);
153 157
154 final JButton leftButton = new JButton("↰"); 158 final JButton leftButton = new JButton("↰");
155 leftButton.setFont(new Font("Dialog", Font.BOLD, 19)); 159 leftButton.setFont(font);
156 leftButton.setToolTipText("Turn left"); 160 leftButton.setToolTipText("Turn left");
157 bottomControlPanel.add(leftButton, BorderLayout.WEST); 161 bottomControlPanel.add(leftButton, BorderLayout.WEST);
158 162
159 final JButton rightButton = new JButton("↱"); 163 final JButton rightButton = new JButton("↱");
160 rightButton.setFont(new Font("Dialog", Font.BOLD, 19)); 164 rightButton.setFont(font);
161 rightButton.setToolTipText("Turn right"); 165 rightButton.setToolTipText("Turn right");
162 bottomControlPanel.add(rightButton, BorderLayout.EAST); 166 bottomControlPanel.add(rightButton, BorderLayout.EAST);
163 167
@@ -215,8 +219,7 @@ abstract class UserInterface implements View, ActionListener {
215 * @param actionListener 219 * @param actionListener
216 * the action listener 220 * the action listener
217 */ 221 */
218 private void setActionListener(final HashMap<String, JButton> hashMap, 222 private void setActionListener(final HashMap<String, JButton> hashMap, final ActionListener actionListener) {
219 final ActionListener actionListener) {
220 for (final JButton vButton : hashMap.values()) { 223 for (final JButton vButton : hashMap.values()) {
221 vButton.addActionListener(actionListener); 224 vButton.addActionListener(actionListener);
222 } 225 }
@@ -260,15 +263,15 @@ abstract class UserInterface implements View, ActionListener {
260 * @param quest 263 * @param quest
261 * the quest title 264 * the quest title
262 */ 265 */
263 private void setQuest(final String quest) { 266 private void setQuestLabel(final String questTitle) {
264 this.questTextPane.setText(quest); 267 this.questTextPane.setText(questTitle);
265 } 268 }
266 269
267 /** 270 /**
268 * Updates the room illustration. 271 * Updates the room illustration.
269 */ 272 */
270 private void updateIllustration() { 273 private void updateIllustration(final String locationImageName) {
271 String imageName = this.game.getLocationImageName(); 274 String imageName = locationImageName;
272 if (imageName == null) { 275 if (imageName == null) {
273 imageName = "res/img/placeholder.jpg"; 276 imageName = "res/img/placeholder.jpg";
274 }