From 92fe29000b3a8da2adc498154521e7969b6f9c5f Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Sun, 19 Jun 2011 16:11:20 +0200 Subject: Load error, save default file, save disable git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@483 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/ApplicationControl.java | 8 ++++++++ src/jrummikub/control/SaveControl.java | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/jrummikub/control') diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java index bcf497f..d07a0f6 100644 --- a/src/jrummikub/control/ApplicationControl.java +++ b/src/jrummikub/control/ApplicationControl.java @@ -65,6 +65,12 @@ public class ApplicationControl { } }); + saveControl.getLoadErrorEvent().add(new IListener() { + @Override + public void handle() { + view.showError(); + } + }); } private void addLoginControlListeners() { @@ -123,10 +129,12 @@ public class ApplicationControl { saveControl.setGameState(null); settingsControl = new SettingsControl(view, new GameSettings()); + view.enableSave(false); settingsControl.getStartGameEvent().add(new IListener1() { @Override public void handle(GameSettings settings) { + view.enableSave(true); settingsControl = null; saveControl.setGameSettings(settings); diff --git a/src/jrummikub/control/SaveControl.java b/src/jrummikub/control/SaveControl.java index bebe6c5..3e12a9d 100644 --- a/src/jrummikub/control/SaveControl.java +++ b/src/jrummikub/control/SaveControl.java @@ -9,6 +9,7 @@ import java.io.ObjectOutputStream; import jrummikub.model.GameSettings; import jrummikub.model.GameState; import jrummikub.model.IRoundState; +import jrummikub.util.Event; import jrummikub.util.Event3; import jrummikub.util.IEvent3; import jrummikub.util.IListener1; @@ -22,6 +23,7 @@ public class SaveControl { private GameState gameState; private IRoundState roundState; private Event3 loadEvent = new Event3(); + private Event loadErrorEvent = new Event(); /** * Creates a new SaveControl @@ -96,17 +98,20 @@ public class SaveControl { stream.close(); if (gameState == null || gameSettings == null) { - // TODO Fehlermeldung - System.err.println("laden ging nicht"); + loadErrorEvent.emit(); return; } loadEvent.emit(gameSettings, gameState, roundState); } catch (Exception e) { - e.printStackTrace(); + loadErrorEvent.emit(); } } + + public Event getLoadErrorEvent(){ + return loadErrorEvent; + } private void save(File file) { if (gameState == null || gameSettings == null) { -- cgit v1.2.3