summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/control/ApplicationControl.java
blob: cf9a8ca0eb9e93c1ae66c13c69237288fd6431a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package jrummikub.control;

import jrummikub.model.GameSettings;
import jrummikub.util.IListener;
import jrummikub.util.IListener1;
import jrummikub.view.IView;
import jrummikub.view.IView.BottomPanelType;

/**
 * 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.showScorePanel(false);
		view.setBottomPanel(BottomPanelType.START_GAME_PANEL);
		SettingsControl settingsControl = new SettingsControl(view,
				new GameSettings());
		settingsControl.getStartGameEvent().add(new IListener1<GameSettings>() {

			@Override
			public void handle(GameSettings settings) {
				GameControl gameControl = new GameControl(settings, view);
				gameControl.getEndOfGameEvent().add(new IListener() {
					@Override
					public void handle() {
						startApplication();
					}
				});
				gameControl.startGame();

			}
		});
		settingsControl.startSettings();
	}

}