This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
JRummikub/src/jrummikub/control/ApplicationControl.java

64 lines
1.3 KiB
Java
Raw Normal View History

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();
}
}