Test für SettingsControl, 3 neue Klassen, Mocks für SettingPanel, lauter fixes
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@285 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
df79c78dec
commit
531fe57b17
7 changed files with 432 additions and 58 deletions
|
@ -15,7 +15,7 @@ public class ApplicationControl {
|
|||
* Creates a new application control
|
||||
*
|
||||
* @param view
|
||||
* the view to use
|
||||
* the view to use
|
||||
*/
|
||||
public ApplicationControl(IView view) {
|
||||
this.view = view;
|
||||
|
@ -25,39 +25,17 @@ public class ApplicationControl {
|
|||
* 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);
|
||||
}
|
||||
});
|
||||
SettingsControl settingsControl = new SettingsControl(view);
|
||||
settingsControl.getStartGameEvent().add(new IListener1<GameSettings>() {
|
||||
|
||||
view.showSettingsPanel(true);
|
||||
@Override
|
||||
public void handle(GameSettings settings) {
|
||||
GameControl gameControl = new GameControl(settings, view);
|
||||
gameControl.startGame();
|
||||
|
||||
}
|
||||
});
|
||||
settingsControl.startSettings();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
54
src/jrummikub/control/SettingsControl.java
Normal file
54
src/jrummikub/control/SettingsControl.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
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);
|
||||
}
|
||||
}
|
Reference in a new issue