summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/control/AbstractSettingsControl.java71
-rw-r--r--src/jrummikub/util/Pair.java2
-rw-r--r--src/jrummikub/view/IGameListPanel.java8
-rw-r--r--src/jrummikub/view/ISettingsPanel.java21
-rw-r--r--src/jrummikub/view/IView.java48
-rw-r--r--src/jrummikub/view/impl/GameListPanel.java16
6 files changed, 120 insertions, 46 deletions
diff --git a/src/jrummikub/control/AbstractSettingsControl.java b/src/jrummikub/control/AbstractSettingsControl.java
index ff43ce2..79f8274 100644
--- a/src/jrummikub/control/AbstractSettingsControl.java
+++ b/src/jrummikub/control/AbstractSettingsControl.java
@@ -17,6 +17,10 @@ import jrummikub.util.IListener2;
import jrummikub.view.ISettingsPanel;
import jrummikub.view.IView;
+/**
+ * Abstract control class managing joined methods and attributes of all
+ * different (network, default...) settings controls
+ */
public abstract class AbstractSettingsControl {
protected IView view;
protected List<Connection> connections = new ArrayList<Connection>();
@@ -45,15 +49,15 @@ public abstract class AbstractSettingsControl {
}
private void addPlayerSettingsListeners() {
- connections.add(view.getSettingsPanel().getAddPlayerEvent()
- .add(new IListener() {
+ connections.add(view.getSettingsPanel().getAddPlayerEvent().add(
+ new IListener() {
@Override
public void handle() {
addPlayer();
}
}));
- connections.add(view.getSettingsPanel().getRemovePlayerEvent()
- .add(new IListener1<Integer>() {
+ connections.add(view.getSettingsPanel().getRemovePlayerEvent().add(
+ new IListener1<Integer>() {
@Override
public void handle(Integer i) {
removePlayer(i);
@@ -66,32 +70,32 @@ public abstract class AbstractSettingsControl {
setPlayerColor(i, color);
}
}));
- connections.add(view.getSettingsPanel().getChangePlayerNameEvent()
- .add(new IListener2<Integer, String>() {
+ connections.add(view.getSettingsPanel().getChangePlayerNameEvent().add(
+ new IListener2<Integer, String>() {
@Override
public void handle(Integer i, String name) {
setPlayerName(i, name);
}
}));
- connections.add(view.getSettingsPanel().getChangePlayerTypeEvent()
- .add(new IListener2<Integer, Type>() {
+ connections.add(view.getSettingsPanel().getChangePlayerTypeEvent().add(
+ new IListener2<Integer, Type>() {
@Override
public void handle(Integer i, Type type) {
setPlayerType(i, type);
}
}));
}
-
+
private void addOptionListeners1() {
connections.add(view.getSettingsPanel()
- .getChangeInitialMeldThresholdEvent()
- .add(new IListener1<Integer>() {
- @Override
- public void handle(Integer value) {
- settings.setInitialMeldThreshold(value);
- update();
- }
- }));
+ .getChangeInitialMeldThresholdEvent().add(
+ new IListener1<Integer>() {
+ @Override
+ public void handle(Integer value) {
+ settings.setInitialMeldThreshold(value);
+ update();
+ }
+ }));
connections.add(view.getSettingsPanel().getChangeJokerNumberEvent()
.add(new IListener1<Integer>() {
@@ -111,14 +115,14 @@ public abstract class AbstractSettingsControl {
}
}));
connections.add(view.getSettingsPanel()
- .getChangeNumberOfStonesDealtEvent()
- .add(new IListener1<Integer>() {
- @Override
- public void handle(Integer value) {
- settings.setNumberOfStonesDealt(value);
- update();
- }
- }));
+ .getChangeNumberOfStonesDealtEvent().add(
+ new IListener1<Integer>() {
+ @Override
+ public void handle(Integer value) {
+ settings.setNumberOfStonesDealt(value);
+ update();
+ }
+ }));
}
private void addOptionListeners2() {
@@ -130,8 +134,8 @@ public abstract class AbstractSettingsControl {
update();
}
}));
- connections.add(view.getSettingsPanel().getChangeTimeEvent()
- .add(new IListener1<Integer>() {
+ connections.add(view.getSettingsPanel().getChangeTimeEvent().add(
+ new IListener1<Integer>() {
@Override
public void handle(Integer value) {
settings.setTotalTime(value);
@@ -147,8 +151,8 @@ public abstract class AbstractSettingsControl {
}
}));
- connections.add(view.getSettingsPanel().getChangeNoLimitsEvent()
- .add(new IListener1<Boolean>() {
+ connections.add(view.getSettingsPanel().getChangeNoLimitsEvent().add(
+ new IListener1<Boolean>() {
@Override
public void handle(Boolean value) {
settings.setNoLimits(value);
@@ -182,7 +186,7 @@ public abstract class AbstractSettingsControl {
}
}));
}
-
+
/**
* Start the operation of the settings control
*/
@@ -231,7 +235,7 @@ public abstract class AbstractSettingsControl {
settings.getPlayerList().remove(i);
update();
}
-
+
protected boolean checkSettings() {
if (!checkName()) {
return false;
@@ -269,7 +273,8 @@ 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()
+ view
+ .getSettingsPanel()
.setError(
ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR);
view.getSettingsPanel().enableStartGameButton(false);
@@ -325,7 +330,7 @@ public abstract class AbstractSettingsControl {
return;
}
}
-
+
/**
* Abort settings control once settings are set
*/
diff --git a/src/jrummikub/util/Pair.java b/src/jrummikub/util/Pair.java
index 80b9ea0..5ebc7f2 100644
--- a/src/jrummikub/util/Pair.java
+++ b/src/jrummikub/util/Pair.java
@@ -61,6 +61,7 @@ public class Pair<T1, T2> implements Serializable {
return result;
}
+ @SuppressWarnings("unchecked")
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -69,7 +70,6 @@ public class Pair<T1, T2> implements Serializable {
return false;
if (getClass() != obj.getClass())
return false;
- @SuppressWarnings("rawtypes")
Pair other = (Pair) obj;
if (first == null) {
if (other.first != null)
diff --git a/src/jrummikub/view/IGameListPanel.java b/src/jrummikub/view/IGameListPanel.java
index 8a05546..47de90e 100644
--- a/src/jrummikub/view/IGameListPanel.java
+++ b/src/jrummikub/view/IGameListPanel.java
@@ -35,9 +35,15 @@ public interface IGameListPanel {
* Sets the channel name
*
* @param name
- * channel name
+ * channel name
*/
public void setChannelName(String name);
+ /**
+ * Set the games (host and player count) into the game list
+ *
+ * @param games
+ * list of game data
+ */
public void setGameList(List<GameData> games);
}
diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java
index d01129e..c52d72c 100644
--- a/src/jrummikub/view/ISettingsPanel.java
+++ b/src/jrummikub/view/ISettingsPanel.java
@@ -37,10 +37,10 @@ public interface ISettingsPanel {
};
/**
- * enables the start of a network game at a given point in game
+ * Sets the settings mode according to the point of the game
*
- * @param enable
- * starting a network game
+ * @param mode
+ * settings mode to be set (join, offer, network, default)
*/
public void setSettingsMode(SettingsMode mode);
@@ -237,6 +237,12 @@ public interface ISettingsPanel {
*/
public IEvent getOfferGameEvent();
+ /**
+ * Sets the player colors which can be chosen
+ *
+ * @param colors
+ * a Set of colors which are not taken yet
+ */
public void setPlayerColors(Set<Color> colors);
/**
@@ -260,13 +266,14 @@ public interface ISettingsPanel {
/** Only computer players added */
COMPUTER_PLAYERS_ONLY_WARNING
}
-
+
/**
- * SettingsPanel can be used with different functions in different situations
+ * SettingsPanel can be used with different functions in different
+ * situations
*/
public enum SettingsMode {
- /**Local game settings */
- DEFAULT,
+ /** Local game settings */
+ DEFAULT,
/** */
NETWORK_SETUP,
/** */
diff --git a/src/jrummikub/view/IView.java b/src/jrummikub/view/IView.java
index 1121b44..33f6284 100644
--- a/src/jrummikub/view/IView.java
+++ b/src/jrummikub/view/IView.java
@@ -162,22 +162,70 @@ public interface IView {
*/
public IEvent1<File> getSaveEvent();
+ /**
+ * The pause event is emitted when the user wants to pause the current turn
+ *
+ * @return the event
+ */
public IEvent getPauseEvent();
+ /**
+ * The end pause event is emitted when the user wants to sresume the game
+ * after a pause
+ *
+ * @return the event
+ */
public IEvent getEndPauseEvent();
+ /**
+ * Hides all view elements and panels except for the cleared table and an
+ * empty hand panel
+ */
public void clearView();
+ /**
+ * The network game event is emitted when the user chooses a network game
+ *
+ * @return the event
+ */
public IEvent getNetworkGameEvent();
+ /**
+ * Getter for login panel
+ *
+ * @return login panel
+ */
public ILoginPanel getLoginPanel();
+ /**
+ * Getter for game list panel
+ *
+ * @return game list panel
+ */
public IGameListPanel getGameListPanel();
+ /**
+ * Show/hide login panel
+ *
+ * @param show
+ * true = login panel is shown
+ */
public void showLoginPanel(boolean show);
+ /**
+ * Enable/disable pause mode
+ *
+ * @param enable
+ * true = enable
+ */
public void enablePauseMode(boolean enable);
+ /**
+ * Show/hide game list panel
+ *
+ * @param show
+ * true = show
+ */
public void showGameListPanel(boolean show);
/**
diff --git a/src/jrummikub/view/impl/GameListPanel.java b/src/jrummikub/view/impl/GameListPanel.java
index b7b170b..e1e1c9d 100644
--- a/src/jrummikub/view/impl/GameListPanel.java
+++ b/src/jrummikub/view/impl/GameListPanel.java
@@ -31,6 +31,8 @@ import jrummikub.util.IEvent1;
import jrummikub.view.IGameListPanel;
class GameListPanel extends JPanel implements IGameListPanel {
+ private static final long serialVersionUID = 1L;
+
private JLabel title;
private JList gameList;
private JButton joinButton;
@@ -67,6 +69,13 @@ class GameListPanel extends JPanel implements IGameListPanel {
c.weighty = 0;
add(Box.createVerticalStrut(3), c);
+ addButtons(c);
+
+ setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
+ new EmptyBorder(10, 10, 10, 10)));
+ }
+
+ private void addButtons(GridBagConstraints c) {
joinButton = new JButton("Beitreten");
c.gridwidth = 1;
add(joinButton, c);
@@ -109,9 +118,6 @@ class GameListPanel extends JPanel implements IGameListPanel {
cancelEvent.emit();
}
});
-
- setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
- 10, 10, 10, 10)));
}
void reset() {
@@ -157,6 +163,7 @@ class GameListPanel extends JPanel implements IGameListPanel {
private static class GameDataCellRenderer extends JPanel implements
ListCellRenderer {
+ private static final long serialVersionUID = -892701906163443927L;
JLabel hostLabel, playerCountLabel;
GameDataCellRenderer() {
@@ -193,7 +200,8 @@ class GameListPanel extends JPanel implements IGameListPanel {
int total = gameData.getGameSettings().getPlayerList().size();
int occupied = total;
- for (PlayerSettings player : gameData.getGameSettings().getPlayerList()) {
+ for (PlayerSettings player : gameData.getGameSettings()
+ .getPlayerList()) {
if (player.getType() == Type.VACANT) {
occupied--;
}