Continued side panel
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@499 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
fcf33eb280
commit
ace7175f1a
7 changed files with 120 additions and 39 deletions
|
@ -33,9 +33,9 @@ public abstract class AbstractSettingsControl {
|
|||
* Create a new settings control
|
||||
*
|
||||
* @param view
|
||||
* the view to use
|
||||
* the view to use
|
||||
* @param settings
|
||||
* initial game settings
|
||||
* initial game settings
|
||||
*/
|
||||
protected AbstractSettingsControl(IView view, GameSettings settings) {
|
||||
this.view = view;
|
||||
|
@ -43,8 +43,10 @@ public abstract class AbstractSettingsControl {
|
|||
|
||||
view.getSettingsPanel().setPlayerNamesEditable(
|
||||
Collections.<Boolean> emptyList());
|
||||
view.getSettingsPanel().setPlayerColors(
|
||||
new HashSet<Color>(Arrays.asList(ISettingsPanel.PLAYER_COLORS)));
|
||||
view.getSettingsPanel()
|
||||
.setPlayerColors(
|
||||
new HashSet<Color>(Arrays
|
||||
.asList(ISettingsPanel.PLAYER_COLORS)));
|
||||
}
|
||||
|
||||
protected void addListeners() {
|
||||
|
@ -95,7 +97,8 @@ public abstract class AbstractSettingsControl {
|
|||
|
||||
private void addOptionListeners1() {
|
||||
connections.add(view.getSettingsPanel()
|
||||
.getChangeInitialMeldThresholdEvent().add(new IListener1<Integer>() {
|
||||
.getChangeInitialMeldThresholdEvent()
|
||||
.add(new IListener1<Integer>() {
|
||||
@Override
|
||||
public void handle(Integer value) {
|
||||
settings.setInitialMeldThreshold(value);
|
||||
|
@ -120,7 +123,8 @@ public abstract class AbstractSettingsControl {
|
|||
update();
|
||||
}
|
||||
}));
|
||||
connections.add(view.getSettingsPanel().getChangeNumberOfStonesDealtEvent()
|
||||
connections.add(view.getSettingsPanel()
|
||||
.getChangeNumberOfStonesDealtEvent()
|
||||
.add(new IListener1<Integer>() {
|
||||
@Override
|
||||
public void handle(Integer value) {
|
||||
|
@ -278,8 +282,9 @@ public abstract class AbstractSettingsControl {
|
|||
for (int j = i + 1; j < settings.getPlayerList().size(); ++j) {
|
||||
PlayerSettings player2 = settings.getPlayerList().get(j);
|
||||
if (player2.getName().equals(name) && player2.getType() == type) {
|
||||
view.getSettingsPanel().setError(
|
||||
ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR);
|
||||
view.getSettingsPanel()
|
||||
.setError(
|
||||
ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR);
|
||||
view.getSettingsPanel().enableStartGameButton(false);
|
||||
return false;
|
||||
}
|
||||
|
@ -291,8 +296,7 @@ public abstract class AbstractSettingsControl {
|
|||
private boolean checkErrors() {
|
||||
int totalStonesDealt = settings.getNumberOfStonesDealt()
|
||||
* settings.getPlayerList().size();
|
||||
int totalStones = settings.getHighestValue() * settings.getStoneSetNumber()
|
||||
* settings.getStoneColors().size() + settings.getJokerNumber();
|
||||
int totalStones = settings.getTotalStones();
|
||||
|
||||
if (totalStones <= totalStonesDealt) {
|
||||
view.getSettingsPanel().setError(
|
||||
|
|
|
@ -97,7 +97,6 @@ public class GameControl {
|
|||
* Game gets started by initializing the first Round
|
||||
*/
|
||||
public void startGame() {
|
||||
view.getSidePanel().setGameSettings(gameSettings);
|
||||
view.showSidePanel(true);
|
||||
startRound();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import jrummikub.model.IHand;
|
|||
import jrummikub.model.IPlayer;
|
||||
import jrummikub.model.IRoundState;
|
||||
import jrummikub.model.ITable;
|
||||
import jrummikub.model.Player;
|
||||
import jrummikub.model.PlayerSettings;
|
||||
import jrummikub.model.Position;
|
||||
import jrummikub.model.Score;
|
||||
|
@ -92,6 +93,7 @@ public class RoundControl {
|
|||
* Continue a saved round after loading
|
||||
*/
|
||||
public void continueRound() {
|
||||
|
||||
connections.add(view.getStartTurnEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
|
@ -141,6 +143,8 @@ public class RoundControl {
|
|||
}
|
||||
|
||||
protected void doPrepareTurn() {
|
||||
updateSidePanel();
|
||||
|
||||
boolean isHuman = roundState.getActivePlayer().getPlayerSettings()
|
||||
.getType() == HUMAN;
|
||||
boolean oneHuman = roundState.getGameSettings().oneHuman();
|
||||
|
@ -207,6 +211,18 @@ public class RoundControl {
|
|||
|
||||
turnControl.startTurn();
|
||||
}
|
||||
|
||||
private void updateSidePanel() {
|
||||
view.showSidePanel(true);
|
||||
view.getSidePanel().setGameSettings(roundState.getGameSettings());
|
||||
List<IPlayer> players = new ArrayList<IPlayer>();
|
||||
for (int i = 1; i < roundState.getPlayerCount(); i ++) {
|
||||
players.add(roundState.getNthNextPlayer(-i));
|
||||
}
|
||||
view.getSidePanel().setPlayers(players);
|
||||
view.getSidePanel().setHeapCapacity(roundState.getGameSettings().getTotalStones());
|
||||
view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
|
||||
}
|
||||
|
||||
/** Override this */
|
||||
protected void addTurnControlListeners(ITurnControl turnControl) {
|
||||
|
@ -217,14 +233,12 @@ public class RoundControl {
|
|||
}
|
||||
|
||||
void deal() {
|
||||
view.getSidePanel().setHeapCapacity(roundState.getGameHeap().getSize());
|
||||
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
||||
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
||||
for (int j = 0; j < roundState.getGameSettings().getNumberOfStonesDealt(); j++) {
|
||||
hand.drop(roundState.getGameHeap().drawStone(), new Position(0, 0));
|
||||
}
|
||||
}
|
||||
view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
|
||||
|
||||
}
|
||||
|
||||
|
@ -410,7 +424,6 @@ public class RoundControl {
|
|||
Hand.WIDTH - 1, rowCount - 1));
|
||||
}
|
||||
|
||||
view.getSidePanel().setHeapSize(roundState.getGameHeap().getSize());
|
||||
}
|
||||
|
||||
private void dealStone() {
|
||||
|
|
Reference in a new issue