55 lines
1.2 KiB
Java
55 lines
1.2 KiB
Java
![]() |
package jrummikub.control;
|
||
|
|
||
|
import jrummikub.model.GameSettings;
|
||
|
import jrummikub.util.Event1;
|
||
|
import jrummikub.util.IEvent1;
|
||
|
import jrummikub.util.IListener1;
|
||
|
import jrummikub.view.IView;
|
||
|
|
||
|
public class SettingsControl {
|
||
|
private IView view;
|
||
|
private Event1<GameSettings> startGameEvent = new Event1<GameSettings>();
|
||
|
|
||
|
public SettingsControl(IView view) {
|
||
|
this.view = view;
|
||
|
}
|
||
|
|
||
|
public IEvent1<GameSettings> getStartGameEvent() {
|
||
|
return startGameEvent;
|
||
|
}
|
||
|
|
||
|
public void startSettings() {
|
||
|
/*
|
||
|
* 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);
|
||
|
|
||
|
startGameEvent.emit(settings);
|
||
|
}
|
||
|
}
|