summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jrummikub/JRummikub.java17
-rw-r--r--src/jrummikub/control/ApplicationControl.java63
-rw-r--r--src/jrummikub/view/impl/SettingsPanel.java2
3 files changed, 67 insertions, 15 deletions
diff --git a/src/jrummikub/JRummikub.java b/src/jrummikub/JRummikub.java
index 9c22dc6..61da8d0 100644
--- a/src/jrummikub/JRummikub.java
+++ b/src/jrummikub/JRummikub.java
@@ -1,12 +1,8 @@
package jrummikub;
-import java.awt.Color;
-
import javax.swing.UIManager;
-import jrummikub.control.GameControl;
-import jrummikub.model.GameSettings;
-import jrummikub.model.PlayerSettings;
+import jrummikub.control.ApplicationControl;
import jrummikub.view.impl.View;
/**
@@ -28,17 +24,10 @@ public class JRummikub {
} catch (Exception e) {
}
- GameSettings gameSettings = new GameSettings();
- gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED));
- gameSettings.getPlayerList().add(
- new PlayerSettings("Matthias", Color.YELLOW));
- gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
- gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
-
View view = new View();
- GameControl gameControl = new GameControl(gameSettings, view);
- gameControl.startGame();
+ ApplicationControl appControl = new ApplicationControl(view);
+ appControl.startApplication();
}
diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java
new file mode 100644
index 0000000..b3d432c
--- /dev/null
+++ b/src/jrummikub/control/ApplicationControl.java
@@ -0,0 +1,63 @@
+package jrummikub.control;
+
+import jrummikub.model.GameSettings;
+import jrummikub.util.IListener1;
+import jrummikub.view.IView;
+
+/**
+ * The application control controls the settings for a new games and create the
+ * game control
+ */
+public class ApplicationControl {
+ private IView view;
+
+ /**
+ * Creates a new application control
+ *
+ * @param view
+ * the view to use
+ */
+ public ApplicationControl(IView view) {
+ this.view = view;
+ }
+
+ /**
+ * Starts the application by showing the game settings dialog panel
+ */
+ public void startApplication() {
+ view.getSettingsPanel().getSettingsChangeEvent()
+ .add(new IListener1<GameSettings>() {
+ @Override
+ public void handle(GameSettings settings) {
+ checkSettings(settings);
+ }
+ });
+ view.getSettingsPanel().getStartGameEvent()
+ .add(new IListener1<GameSettings>() {
+ @Override
+ public void handle(GameSettings settings) {
+ startGame(settings);
+ }
+ });
+
+ view.showSettingsPanel(true);
+ }
+
+ private boolean checkSettings(GameSettings settings) {
+ // TODO Check
+ // TODO Show error
+
+ return true;
+ }
+
+ private void startGame(GameSettings settings) {
+ if (!checkSettings(settings)) {
+ return;
+ }
+
+ view.showSettingsPanel(false);
+
+ GameControl gameControl = new GameControl(settings, view);
+ gameControl.startGame();
+ }
+}
diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java
index 9164942..7a9347c 100644
--- a/src/jrummikub/view/impl/SettingsPanel.java
+++ b/src/jrummikub/view/impl/SettingsPanel.java
@@ -166,7 +166,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
c.weighty = 1;
add(tabbedPane, c);
- JLabel errorMessageLabel = new JLabel("Fehler: Implementierung fehlt!");
+ JLabel errorMessageLabel = new JLabel(" ");
errorMessageLabel.setForeground(Color.RED);
c.weighty = 0;
add(errorMessageLabel, c);