From 9e42ce69208d1b496b96c1a2473993e215c06352 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 11 Mar 2014 08:58:40 +0100 Subject: Fix close on start --- src/esieequest/Main.java | 1 - src/esieequest/controller/GameEngine.java | 2 ++ src/esieequest/view/View.java | 5 +++++ src/esieequest/view/app/Applet.java | 3 +-- src/esieequest/view/app/UserInterface.java | 4 ++++ src/esieequest/view/app/Window.java | 4 +++- src/esieequest/view/console/Console.java | 7 +++++++ src/esieequest/view/web/WebInterface.java | 6 +++++- 8 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/esieequest/Main.java b/src/esieequest/Main.java index 86e6c5e..2ad11b1 100755 --- a/src/esieequest/Main.java +++ b/src/esieequest/Main.java @@ -49,7 +49,6 @@ public class Main extends JApplet { if (Arrays.asList(args).contains("--nogui")) { view = new Console(); - } else { view = new Window(); } diff --git a/src/esieequest/controller/GameEngine.java b/src/esieequest/controller/GameEngine.java index c072e77..6c25fb3 100644 --- a/src/esieequest/controller/GameEngine.java +++ b/src/esieequest/controller/GameEngine.java @@ -32,6 +32,8 @@ public class GameEngine { this.view.setController(this); this.interpreter = new Interpreter(this.game, this.view); + + this.view.show(); } /** diff --git a/src/esieequest/view/View.java b/src/esieequest/view/View.java index b41a214..545879a 100644 --- a/src/esieequest/view/View.java +++ b/src/esieequest/view/View.java @@ -29,6 +29,11 @@ public interface View { */ public void setController(GameEngine gameEngine); + /** + * Displays the user interface. + */ + public void show(); + /** * Enables the user interface. */ diff --git a/src/esieequest/view/app/Applet.java b/src/esieequest/view/app/Applet.java index 3d5bc75..8ad1564 100644 --- a/src/esieequest/view/app/Applet.java +++ b/src/esieequest/view/app/Applet.java @@ -22,8 +22,7 @@ public class Applet extends UserInterface { } @Override - public void enable() { + public void show() { this.applet.add(this.getLayout()); } - } diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java index b6035c5..23384c7 100644 --- a/src/esieequest/view/app/UserInterface.java +++ b/src/esieequest/view/app/UserInterface.java @@ -301,6 +301,10 @@ abstract class UserInterface implements View, ActionListener { this.infoTextPane.setText(message); this.clearInputField(); } + + @Override + public void enable() { + } @Override public void disable() { diff --git a/src/esieequest/view/app/Window.java b/src/esieequest/view/app/Window.java index e400fde..82e3a2e 100644 --- a/src/esieequest/view/app/Window.java +++ b/src/esieequest/view/app/Window.java @@ -2,6 +2,8 @@ package esieequest.view.app; import javax.swing.JFrame; +import com.google.gwt.user.client.ui.RootLayoutPanel; + /** * The window view. * @@ -25,7 +27,7 @@ public class Window extends UserInterface { } @Override - public void enable() { + public void show() { this.window.setVisible(true); } diff --git a/src/esieequest/view/console/Console.java b/src/esieequest/view/console/Console.java index a8acbe0..0f3247a 100644 --- a/src/esieequest/view/console/Console.java +++ b/src/esieequest/view/console/Console.java @@ -2,6 +2,8 @@ package esieequest.view.console; import java.util.Scanner; +import com.google.gwt.user.client.ui.RootLayoutPanel; + import esieequest.controller.GameEngine; import esieequest.model.Game; import esieequest.view.View; @@ -47,6 +49,11 @@ public class Console implements View { this.gameEngine = gameEngine; } + @Override + public void show() { + this.enable(); + } + @Override public void enable() { if (!this.running) { diff --git a/src/esieequest/view/web/WebInterface.java b/src/esieequest/view/web/WebInterface.java index ca1598c..221eea9 100644 --- a/src/esieequest/view/web/WebInterface.java +++ b/src/esieequest/view/web/WebInterface.java @@ -78,7 +78,6 @@ class WebInterface extends Composite implements View { this.initWidget(WebInterface.uiBinder.createAndBindUi(this)); this.bindInputField(); this.bindButtons(); - RootLayoutPanel.get().add(this); } /** @@ -253,6 +252,11 @@ class WebInterface extends Composite implements View { this.gameEngine = gameEngine; } + @Override + public void show() { + RootLayoutPanel.get().add(this); + } + @Override public void enable() { this.setControlsEnabled(true); -- cgit v1.2.3