Load error, save default file, save disable

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@483 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Ida Massow 2011-06-19 16:11:20 +02:00
parent 0506b7f154
commit 92fe29000b
5 changed files with 55 additions and 12 deletions

View file

@ -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<GameSettings>() {
@Override
public void handle(GameSettings settings) {
view.enableSave(true);
settingsControl = null;
saveControl.setGameSettings(settings);

View file

@ -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<GameSettings, GameState, IRoundState> loadEvent = new Event3<GameSettings, GameState, IRoundState>();
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) {