From 9d3cef233e8d5afbeacbc9ede93c8f62d07ada94 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 17 May 2014 23:09:26 +0200 Subject: Add iframe illustrations for web view --- src/esieequest/view/app/UserInterface.java | 6 +++--- src/esieequest/view/web/WebInterface.java | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java index c4e072d..fffe440 100644 --- a/src/esieequest/view/app/UserInterface.java +++ b/src/esieequest/view/app/UserInterface.java @@ -293,11 +293,11 @@ abstract class UserInterface implements Viewable, ActionListener { } /** - * Updates the room's illustration. + * Sets the Room's illustration. * * Placeholder generation from http://stackoverflow.com/a/17802477/1348634 */ - private void updateIllustration(final String imageName) { + private void setIllustration(final String imageName) { final URL imageURL = this.getClass().getClassLoader().getResource(imageName + ".jpg"); final StretchIcon imageIcon; if (imageURL == null) { @@ -351,7 +351,7 @@ abstract class UserInterface implements Viewable, ActionListener { @Override public void updateLocation(final Room room, final Direction direction, final Side side) { this.echo(room.getInformations()); - this.updateIllustration(room.name() + "_" + direction.name()); + this.setIllustration(room.name() + "_" + direction.name()); } @Override diff --git a/src/esieequest/view/web/WebInterface.java b/src/esieequest/view/web/WebInterface.java index 4099063..7174180 100644 --- a/src/esieequest/view/web/WebInterface.java +++ b/src/esieequest/view/web/WebInterface.java @@ -40,6 +40,9 @@ import esieequest.view.Viewable; */ class WebInterface extends Composite implements Viewable { + private static final String ILLUSTRATION_DIR = "illustrations/"; + private static final String ILLUSTRATION_EXT = ".html"; + private GameEngine gameEngine; private static WebInterfaceUiBinder uiBinder = GWT.create(WebInterfaceUiBinder.class); @@ -235,7 +238,7 @@ class WebInterface extends Composite implements Viewable { * the illustration page URL */ private void setIllustration(final String illustration) { - this.illustrationFrame.setUrl(illustration); + this.illustrationFrame.setUrl(WebInterface.ILLUSTRATION_DIR + illustration + WebInterface.ILLUSTRATION_EXT); } /** @@ -294,7 +297,7 @@ class WebInterface extends Composite implements Viewable { @Override public void updateLocation(final Room room, final Direction direction, final Side side) { - // TODO: update illustration + this.setIllustration(room.name() + "_" + direction.name()); this.echo(room.getInformations()); } -- cgit v1.2.3