diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/esieequest/controller/commands/BackCommand.java | 3 | ||||
-rw-r--r-- | src/esieequest/controller/commands/GoCommand.java | 4 | ||||
-rw-r--r-- | src/esieequest/controller/commands/NewCommand.java | 1 | ||||
-rw-r--r-- | src/esieequest/controller/commands/TurnCommand.java | 4 | ||||
-rw-r--r-- | src/esieequest/view/Viewable.java | 15 | ||||
-rw-r--r-- | src/esieequest/view/app/UserInterface.java | 33 | ||||
-rw-r--r-- | src/esieequest/view/text/TextInterface.java | 8 | ||||
-rw-r--r-- | src/esieequest/view/web/WebInterface.java | 9 |
8 files changed, 37 insertions, 40 deletions
diff --git a/src/esieequest/controller/commands/BackCommand.java b/src/esieequest/controller/commands/BackCommand.java index 627df59..299bda9 100644 --- a/src/esieequest/controller/commands/BackCommand.java +++ b/src/esieequest/controller/commands/BackCommand.java | |||
@@ -14,7 +14,8 @@ public class BackCommand implements Executable { | |||
14 | public void execute(final String argument, final Game game, final Viewable view) { | 14 | public void execute(final String argument, final Game game, final Viewable view) { |
15 | 15 | ||
16 | game.getPlayer().goToPreviousRoom(); | 16 | game.getPlayer().goToPreviousRoom(); |
17 | view.updateRoom(game.getPlayer().getCurrentRoom()); | 17 | |
18 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide()); | ||
18 | 19 | ||
19 | } | 20 | } |
20 | 21 | ||
diff --git a/src/esieequest/controller/commands/GoCommand.java b/src/esieequest/controller/commands/GoCommand.java index ccb974b..9ebdf49 100644 --- a/src/esieequest/controller/commands/GoCommand.java +++ b/src/esieequest/controller/commands/GoCommand.java | |||
@@ -39,8 +39,8 @@ public class GoCommand implements Executable { | |||
39 | return; | 39 | return; |
40 | } | 40 | } |
41 | 41 | ||
42 | view.updateRoom(game.getPlayer().getCurrentRoom()); | 42 | view.updateLocation(game.getPlayer().getCurrentRoom(), direction, game.getPlayer().getCurrentSide()); |
43 | 43 | ||
44 | // handle challenge mode | 44 | // handle challenge mode |
45 | if (game.getPlayer().walk()) { | 45 | if (game.getPlayer().walk()) { |
46 | view.echo(Text.CHALLENGE_FAILED.getText()); | 46 | view.echo(Text.CHALLENGE_FAILED.getText()); |
diff --git a/src/esieequest/controller/commands/NewCommand.java b/src/esieequest/controller/commands/NewCommand.java index 3c23882..dcb4f8f 100644 --- a/src/esieequest/controller/commands/NewCommand.java +++ b/src/esieequest/controller/commands/NewCommand.java | |||
@@ -21,6 +21,7 @@ public class NewCommand implements Executable { | |||
21 | game.getPlayer().setCurrentRoom(Room.AMPHITHEATER_SEAT); | 21 | game.getPlayer().setCurrentRoom(Room.AMPHITHEATER_SEAT); |
22 | 22 | ||
23 | view.enable(); | 23 | view.enable(); |
24 | view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer().getCurrentDirection(), game.getPlayer().getCurrentSide()); | ||
24 | view.echo(Text.WELCOME.getText()); | 25 | view.echo(Text.WELCOME.getText()); |
25 | 26 | ||
26 | } | 27 | } |
diff --git a/src/esieequest/controller/commands/TurnCommand.java b/src/esieequest/controller/commands/TurnCommand.java index a03fbab..4f6eb4c 100644 --- a/src/esieequest/controller/commands/TurnCommand.java +++ b/src/esieequest/controller/commands/TurnCommand.java | |||
@@ -30,8 +30,8 @@ public class TurnCommand implements Executable { | |||
30 | final Direction newDirection = currentDirection.rotate(orientation); | 30 | final Direction newDirection = currentDirection.rotate(orientation); |
31 | game.getPlayer().setCurrentDirection(newDirection); | 31 | game.getPlayer().setCurrentDirection(newDirection); |
32 | 32 | ||
33 | view.updateSide(game.getPlayer().getCurrentSide()); | 33 | view.updateLocation(game.getPlayer().getCurrentRoom(), newDirection, game.getPlayer().getCurrentSide()); |
34 | 34 | ||
35 | } | 35 | } |
36 | 36 | ||
37 | } | 37 | } |
diff --git a/src/esieequest/view/Viewable.java b/src/esieequest/view/Viewable.java index 6fc8592..5d2675f 100644 --- a/src/esieequest/view/Viewable.java +++ b/src/esieequest/view/Viewable.java | |||
@@ -5,6 +5,7 @@ import java.util.HashMap; | |||
5 | import esieequest.controller.GameEngine; | 5 | import esieequest.controller.GameEngine; |
6 | import esieequest.model.events.Quest; | 6 | import esieequest.model.events.Quest; |
7 | import esieequest.model.items.SimpleItem; | 7 | import esieequest.model.items.SimpleItem; |
8 | import esieequest.model.map.Direction; | ||
8 | import esieequest.model.map.Room; | 9 | import esieequest.model.map.Room; |
9 | import esieequest.model.map.Side; | 10 | import esieequest.model.map.Side; |
10 | 11 | ||
@@ -47,20 +48,16 @@ public interface Viewable { | |||
47 | public void disable(); | 48 | public void disable(); |
48 | 49 | ||
49 | /** | 50 | /** |
50 | * Updates the view to match the current room. | 51 | * Updates the view to match the current location. |
51 | * | 52 | * |
52 | * @param room | 53 | * @param room |
53 | * the room to display | 54 | * the room |
54 | */ | 55 | * @param direction |
55 | public void updateRoom(Room room); | 56 | * the current direction |
56 | |||
57 | /** | ||
58 | * Updates the view to match a side of a room. | ||
59 | * | ||
60 | * @param side | 57 | * @param side |
61 | * the side of a room | 58 | * the side of a room |
62 | */ | 59 | */ |
63 | public void updateSide(Side side); | 60 | public void updateLocation(Room room, Direction direction, Side side); |
64 | 61 | ||
65 | /** | 62 | /** |
66 | * Updates the view to match the current quest. | 63 | * Updates the view to match the current quest. |
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java index ba6d786..66a0af1 100644 --- a/src/esieequest/view/app/UserInterface.java +++ b/src/esieequest/view/app/UserInterface.java | |||
@@ -3,8 +3,10 @@ package esieequest.view.app; | |||
3 | import java.awt.BorderLayout; | 3 | import java.awt.BorderLayout; |
4 | import java.awt.Dimension; | 4 | import java.awt.Dimension; |
5 | import java.awt.Font; | 5 | import java.awt.Font; |
6 | import java.awt.Graphics; | ||
6 | import java.awt.event.ActionEvent; | 7 | import java.awt.event.ActionEvent; |
7 | import java.awt.event.ActionListener; | 8 | import java.awt.event.ActionListener; |
9 | import java.awt.image.BufferedImage; | ||
8 | import java.net.URL; | 10 | import java.net.URL; |
9 | import java.util.HashMap; | 11 | import java.util.HashMap; |
10 | 12 | ||
@@ -21,6 +23,7 @@ import esieequest.controller.GameEngine; | |||
21 | import esieequest.controller.commands.Command; | 23 | import esieequest.controller.commands.Command; |
22 | import esieequest.model.events.Quest; | 24 | import esieequest.model.events.Quest; |
23 | import esieequest.model.items.SimpleItem; | 25 | import esieequest.model.items.SimpleItem; |
26 | import esieequest.model.map.Direction; | ||
24 | import esieequest.model.map.Orientation; | 27 | import esieequest.model.map.Orientation; |
25 | import esieequest.model.map.Room; | 28 | import esieequest.model.map.Room; |
26 | import esieequest.model.map.Side; | 29 | import esieequest.model.map.Side; |
@@ -52,6 +55,7 @@ abstract class UserInterface implements Viewable, ActionListener { | |||
52 | public UserInterface() { | 55 | public UserInterface() { |
53 | this.buildUI(); | 56 | this.buildUI(); |
54 | this.inputField.addActionListener(this); | 57 | this.inputField.addActionListener(this); |
58 | this.setActionListener(this); | ||
55 | this.setControlsState(false); | 59 | this.setControlsState(false); |
56 | this.inputField.setEnabled(true); | 60 | this.inputField.setEnabled(true); |
57 | } | 61 | } |
@@ -270,15 +274,21 @@ abstract class UserInterface implements Viewable, ActionListener { | |||
270 | } | 274 | } |
271 | 275 | ||
272 | /** | 276 | /** |
273 | * Updates the room illustration. | 277 | * Updates the room's illustration. |
278 | * | ||
279 | * Placeholder generation from http://stackoverflow.com/a/17802477/1348634 | ||
274 | */ | 280 | */ |
275 | private void updateIllustration(final String locationImageName) { | 281 | private void updateIllustration(final String imageName) { |
276 | String imageName = locationImageName; | 282 | final URL imageURL = this.getClass().getClassLoader().getResource(imageName + ".jpg"); |
277 | if (imageName == null) { | 283 | final StretchIcon imageIcon; |
278 | imageName = "res/img/placeholder.jpg"; | 284 | if (imageURL == null) { |
285 | final BufferedImage bufferedImage = new BufferedImage(240, 135, BufferedImage.TYPE_BYTE_BINARY); | ||
286 | final Graphics graphics = bufferedImage.getGraphics(); | ||
287 | graphics.drawString(imageName, 5, 10 + 5); | ||
288 | imageIcon = new StretchIcon(bufferedImage, true); | ||
289 | } else { | ||
290 | imageIcon = new StretchIcon(imageURL, true); | ||
279 | } | 291 | } |
280 | final URL imageURL = this.getClass().getClassLoader().getResource(imageName); | ||
281 | final StretchIcon imageIcon = new StretchIcon(imageURL, true); | ||
282 | this.imageLabel.setIcon(imageIcon); | 292 | this.imageLabel.setIcon(imageIcon); |
283 | } | 293 | } |
284 | 294 | ||
@@ -314,14 +324,9 @@ abstract class UserInterface implements Viewable, ActionListener { | |||
314 | } | 324 | } |
315 | 325 | ||
316 | @Override | 326 | @Override |
317 | public void updateRoom(final Room room) { | 327 | public void updateLocation(final Room room, final Direction direction, final Side side) { |
318 | // this.updateIllustration(room.getImageName()); | ||
319 | this.echo(room.getInformations()); | 328 | this.echo(room.getInformations()); |
320 | } | 329 | this.updateIllustration(room.name() + "_" + direction.name()); |
321 | |||
322 | @Override | ||
323 | public void updateSide(final Side side) { | ||
324 | // this.updateIllustration(side.getImageName()); | ||
325 | } | 330 | } |
326 | 331 | ||
327 | @Override | 332 | @Override |
diff --git a/src/esieequest/view/text/TextInterface.java b/src/esieequest/view/text/TextInterface.java index c94eb1a..8f37c53 100644 --- a/src/esieequest/view/text/TextInterface.java +++ b/src/esieequest/view/text/TextInterface.java | |||
@@ -6,6 +6,7 @@ import esieequest.controller.GameEngine; | |||
6 | import esieequest.controller.commands.Command; | 6 | import esieequest.controller.commands.Command; |
7 | import esieequest.model.events.Quest; | 7 | import esieequest.model.events.Quest; |
8 | import esieequest.model.items.SimpleItem; | 8 | import esieequest.model.items.SimpleItem; |
9 | import esieequest.model.map.Direction; | ||
9 | import esieequest.model.map.Room; | 10 | import esieequest.model.map.Room; |
10 | import esieequest.model.map.Side; | 11 | import esieequest.model.map.Side; |
11 | import esieequest.view.Viewable; | 12 | import esieequest.view.Viewable; |
@@ -82,16 +83,11 @@ abstract class TextInterface implements Viewable { | |||
82 | } | 83 | } |
83 | 84 | ||
84 | @Override | 85 | @Override |
85 | public void updateRoom(final Room room) { | 86 | public void updateLoc |