Kommentare, Kommentare
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@509 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
477e8e9b82
commit
74d8205f30
18 changed files with 315 additions and 154 deletions
|
@ -3,7 +3,9 @@ package jrummikub.view;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.MockEvent;
|
import jrummikub.util.MockEvent;
|
||||||
|
|
||||||
public class MockConnectPanel implements IConnectPanel{
|
/** */
|
||||||
|
public class MockConnectPanel implements IConnectPanel {
|
||||||
|
/** */
|
||||||
public MockEvent cancelEvent = new MockEvent();
|
public MockEvent cancelEvent = new MockEvent();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,6 +41,8 @@ public class MockView implements IView {
|
||||||
public boolean isLoginPanelVisible = false;
|
public boolean isLoginPanelVisible = false;
|
||||||
/** */
|
/** */
|
||||||
public boolean isGameListPanelVisible = false;
|
public boolean isGameListPanelVisible = false;
|
||||||
|
/** */
|
||||||
|
public boolean isQuitWarningPanelVisible = false;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public Collection<Stone> selectedStones;
|
public Collection<Stone> selectedStones;
|
||||||
|
@ -128,8 +130,8 @@ public class MockView implements IView {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showSettingsPanel(boolean show) {
|
public IGameListPanel getGameListPanel() {
|
||||||
isSettingsPanelVisible = show;
|
return gameListPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -137,11 +139,62 @@ public class MockView implements IView {
|
||||||
return scorePanel;
|
return scorePanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ILoginPanel getLoginPanel() {
|
||||||
|
return loginPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IConnectPanel getConnectPanel() {
|
||||||
|
return connectPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ISidePanel getSidePanel() {
|
||||||
|
return new MockSidePanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockQuitWarningPanel getQuitWarningPanel() {
|
||||||
|
return quitWarningPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showSettingsPanel(boolean show) {
|
||||||
|
isSettingsPanelVisible = show;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showScorePanel(boolean show) {
|
public void showScorePanel(boolean show) {
|
||||||
isScorePanelVisible = show;
|
isScorePanelVisible = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showSidePanel(boolean show) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showQuitWarningPanel(boolean show) {
|
||||||
|
isQuitWarningPanelVisible =show;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showLoginPanel(boolean show) {
|
||||||
|
isLoginPanelVisible = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showGameListPanel(boolean show) {
|
||||||
|
isGameListPanelVisible = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showConnectPanel(boolean show) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentPlayerColor(Color color) {
|
public void setCurrentPlayerColor(Color color) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -206,31 +259,6 @@ public class MockView implements IView {
|
||||||
return networkGameEvent;
|
return networkGameEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ILoginPanel getLoginPanel() {
|
|
||||||
return loginPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showLoginPanel(boolean show) {
|
|
||||||
isLoginPanelVisible = show;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showGameListPanel(boolean show) {
|
|
||||||
isGameListPanelVisible = show;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IGameListPanel getGameListPanel() {
|
|
||||||
return gameListPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IConnectPanel getConnectPanel() {
|
|
||||||
return connectPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInitialMeldError(int points) {
|
public void setInitialMeldError(int points) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -267,32 +295,11 @@ public class MockView implements IView {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ISidePanel getSidePanel() {
|
|
||||||
return new MockSidePanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showSidePanel(boolean show) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showQuitWarningPanel(boolean show) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getQuitEvent() {
|
public IEvent getQuitEvent() {
|
||||||
return quitEvent;
|
return quitEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IQuitWarningPanel getQuitWarningPanel() {
|
|
||||||
return quitWarningPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent1<File> getLoadFileEvent() {
|
public IEvent1<File> getLoadFileEvent() {
|
||||||
return loadFileEvent;
|
return loadFileEvent;
|
||||||
|
@ -302,10 +309,4 @@ public class MockView implements IView {
|
||||||
public void load() {
|
public void load() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showConnectPanel(boolean show) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package jrummikub.control;
|
package jrummikub.control;
|
||||||
|
|
||||||
import static jrummikub.model.PlayerSettings.Type.*;
|
import static jrummikub.model.PlayerSettings.Type.HUMAN;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -64,6 +64,11 @@ public class RoundControl {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is emitted in network when a new turn starts
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent1<IRoundState> getRoundStateUpdateEvent() {
|
public IEvent1<IRoundState> getRoundStateUpdateEvent() {
|
||||||
return roundStateUpdateEvent;
|
return roundStateUpdateEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,27 @@ public class GameOfferControl extends AbstractGameBeginControl {
|
||||||
super(connectionControl, view, new GameData(UUID.randomUUID(), settings),
|
super(connectionControl, view, new GameData(UUID.randomUUID(), settings),
|
||||||
SettingsMode.NETWORK_OFFER);
|
SettingsMode.NETWORK_OFFER);
|
||||||
|
|
||||||
|
addConnectionControlListeners(connectionControl, settings);
|
||||||
|
|
||||||
|
connections.add(view.getSettingsPanel().getStartGameEvent()
|
||||||
|
.add(new IListener() {
|
||||||
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
List<PlayerSettings> players = gameData.getGameSettings()
|
||||||
|
.getPlayerList();
|
||||||
|
for (PlayerSettings s : players) {
|
||||||
|
if (s.getType() == Type.NETWORK) {
|
||||||
|
startGame();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addConnectionControlListeners(
|
||||||
|
final IConnectionControl connectionControl,
|
||||||
|
final GameSettings settings) {
|
||||||
connections.add(connectionControl.getGameJoinEvent().add(
|
connections.add(connectionControl.getGameJoinEvent().add(
|
||||||
new IListener1<String>() {
|
new IListener1<String>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,21 +92,6 @@ public class GameOfferControl extends AbstractGameBeginControl {
|
||||||
connectionControl.offerGame(gameData);
|
connectionControl.offerGame(gameData);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
connections.add(view.getSettingsPanel().getStartGameEvent()
|
|
||||||
.add(new IListener() {
|
|
||||||
@Override
|
|
||||||
public void handle() {
|
|
||||||
List<PlayerSettings> players = gameData.getGameSettings()
|
|
||||||
.getPlayerList();
|
|
||||||
for (PlayerSettings s : players) {
|
|
||||||
if (s.getType() == Type.NETWORK) {
|
|
||||||
startGame();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -260,6 +260,12 @@ public class NetworkControl {
|
||||||
return stopNetworkEvent;
|
return stopNetworkEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The back to login event is emitted when the player aborted the connecting
|
||||||
|
* process or when a connection error has occured and been acknowledged
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent getBackToLoginEvent() {
|
public IEvent getBackToLoginEvent() {
|
||||||
return backToLoginEvent;
|
return backToLoginEvent;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +299,8 @@ public class NetworkControl {
|
||||||
if (gameOfferControl != null) {
|
if (gameOfferControl != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gameOfferControl = new GameOfferControl(connectionControl, settings, view);
|
gameOfferControl = new GameOfferControl(connectionControl, settings,
|
||||||
|
view);
|
||||||
gameOfferControl.getBackEvent().add(new IListener() {
|
gameOfferControl.getBackEvent().add(new IListener() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
|
|
@ -21,6 +21,9 @@ import jrummikub.util.Pair;
|
||||||
*/
|
*/
|
||||||
public class AIControl extends AbstractTurnControl {
|
public class AIControl extends AbstractTurnControl {
|
||||||
private TurnLogic logic;
|
private TurnLogic logic;
|
||||||
|
/**
|
||||||
|
* Does the AI control currently use an internal timer
|
||||||
|
*/
|
||||||
public static boolean useBackgroundThread = true;
|
public static boolean useBackgroundThread = true;
|
||||||
long startTime;
|
long startTime;
|
||||||
|
|
||||||
|
@ -160,8 +163,8 @@ public class AIControl extends AbstractTurnControl {
|
||||||
for (StoneSet set : result) {
|
for (StoneSet set : result) {
|
||||||
turnInfo.getTable().drop(
|
turnInfo.getTable().drop(
|
||||||
set,
|
set,
|
||||||
new Position(10 * (Math.random() * 2 - 1),
|
new Position(10 * (Math.random() * 2 - 1), 5 * (Math
|
||||||
5 * (Math.random() * 2 - 1)));
|
.random() * 2 - 1)));
|
||||||
for (Stone stone : set) {
|
for (Stone stone : set) {
|
||||||
turnInfo.getHand().pickUp(stone);
|
turnInfo.getHand().pickUp(stone);
|
||||||
}
|
}
|
||||||
|
@ -173,10 +176,11 @@ public class AIControl extends AbstractTurnControl {
|
||||||
|
|
||||||
private void doNotMoveExistingSets(List<StoneSet> result) {
|
private void doNotMoveExistingSets(List<StoneSet> result) {
|
||||||
|
|
||||||
outerLoop: for (Iterator<Pair<StoneSet, Position>> it = turnInfo.getTable()
|
outerLoop: for (Iterator<Pair<StoneSet, Position>> it = turnInfo
|
||||||
.iterator(); it.hasNext();) {
|
.getTable().iterator(); it.hasNext();) {
|
||||||
Pair<StoneSet, Position> pair = it.next();
|
Pair<StoneSet, Position> pair = it.next();
|
||||||
setSearch: for (Iterator<StoneSet> it2 = result.iterator(); it2.hasNext();) {
|
setSearch: for (Iterator<StoneSet> it2 = result.iterator(); it2
|
||||||
|
.hasNext();) {
|
||||||
StoneSet set = it2.next();
|
StoneSet set = it2.next();
|
||||||
if (set.getSize() != pair.getFirst().getSize()) {
|
if (set.getSize() != pair.getFirst().getSize()) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -49,10 +49,16 @@ public interface ITurnControl {
|
||||||
*/
|
*/
|
||||||
public void abortTurn();
|
public void abortTurn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted in network when the table changes during player turn
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent1<ITable> getTableUpdateEvent();
|
public IEvent1<ITable> getTableUpdateEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TurnInfo class encapsulates all information concerning the current turn
|
* The TurnInfo class encapsulates all information concerning the current
|
||||||
|
* turn
|
||||||
*/
|
*/
|
||||||
public class TurnInfo {
|
public class TurnInfo {
|
||||||
private ITable table;
|
private ITable table;
|
||||||
|
|
|
@ -248,6 +248,11 @@ public class GameSettings implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the total number of stones in game
|
||||||
|
*
|
||||||
|
* @return total number of stones
|
||||||
|
*/
|
||||||
public int getTotalStones() {
|
public int getTotalStones() {
|
||||||
return getHighestValue() * getStoneSetNumber()
|
return getHighestValue() * getStoneSetNumber()
|
||||||
* getStoneColors().size() + getJokerNumber();
|
* getStoneColors().size() + getJokerNumber();
|
||||||
|
|
|
@ -45,11 +45,33 @@ public interface IPlayer extends Serializable {
|
||||||
*/
|
*/
|
||||||
public void setLaidOut(boolean laidOut);
|
public void setLaidOut(boolean laidOut);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for last turn invalid
|
||||||
|
*
|
||||||
|
* @return last turn invalid
|
||||||
|
*/
|
||||||
public boolean wasLastTurnInvalid();
|
public boolean wasLastTurnInvalid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets last turn invalid
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* last turn invalid
|
||||||
|
*/
|
||||||
public void setLastTurnInvalid(boolean value);
|
public void setLastTurnInvalid(boolean value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of stones put on table in player's last turn
|
||||||
|
*
|
||||||
|
* @return number of stones
|
||||||
|
*/
|
||||||
public int getLastTurnStoneCount();
|
public int getLastTurnStoneCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the number of stones out on the table in player's last turn
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* number of stones
|
||||||
|
*/
|
||||||
public void setLastTurnStoneCount(int value);
|
public void setLastTurnStoneCount(int value);
|
||||||
}
|
}
|
|
@ -55,6 +55,13 @@ public interface IStoneTray<E extends Sizeable> extends
|
||||||
*/
|
*/
|
||||||
public int getSize();
|
public int getSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for an object within the stone tray
|
||||||
|
*
|
||||||
|
* @param object
|
||||||
|
* object to search for
|
||||||
|
* @return object found in stone tray
|
||||||
|
*/
|
||||||
public boolean contains(E object);
|
public boolean contains(E object);
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,10 +2,25 @@ package jrummikub.view;
|
||||||
|
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Panel shown during connection process and showing errors
|
||||||
|
*/
|
||||||
public interface IConnectPanel {
|
public interface IConnectPanel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show connection process while error = null, error else
|
||||||
|
*
|
||||||
|
* @param error
|
||||||
|
* the error to allow specific error messages
|
||||||
|
*/
|
||||||
public void setMode(LoginError error);
|
public void setMode(LoginError error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is emitted when the user wants to abort connecting or has acknowledged
|
||||||
|
* the error
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent getCancelEvent();
|
public IEvent getCancelEvent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,14 @@ package jrummikub.view;
|
||||||
|
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warning panel shown to if the emitted event would cancel the current game
|
||||||
|
*/
|
||||||
public interface IQuitWarningPanel {
|
public interface IQuitWarningPanel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum summarizing the different events invoking the quit warning panel
|
||||||
|
*/
|
||||||
public enum QuitMode {
|
public enum QuitMode {
|
||||||
/** */
|
/** */
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
|
@ -13,12 +19,33 @@ public interface IQuitWarningPanel {
|
||||||
QUIT_GAME
|
QUIT_GAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is emitted if the user is positive about quitting
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent getQuitEvent();
|
public IEvent getQuitEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is emitted if the user selected quit by mistake
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent getCancelEvent();
|
public IEvent getCancelEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the panel according to the event which invoked it
|
||||||
|
*
|
||||||
|
* @param mode
|
||||||
|
* the invoking event type
|
||||||
|
*/
|
||||||
public void setMode(QuitMode mode);
|
public void setMode(QuitMode mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for quit mode
|
||||||
|
*
|
||||||
|
* @return the quit mode
|
||||||
|
*/
|
||||||
public QuitMode getQuitMode();
|
public QuitMode getQuitMode();
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,10 +6,8 @@ import java.util.Collection;
|
||||||
|
|
||||||
import jrummikub.model.Stone;
|
import jrummikub.model.Stone;
|
||||||
import jrummikub.model.StoneSet;
|
import jrummikub.model.StoneSet;
|
||||||
import jrummikub.util.Event;
|
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IEvent1;
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.view.IQuitWarningPanel.QuitMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The top-level view interface
|
* The top-level view interface
|
||||||
|
@ -126,8 +124,8 @@ public interface IView {
|
||||||
public void setCurrentPlayerColor(Color color);
|
public void setCurrentPlayerColor(Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is used for the PlayerPanel to display if a player has laid out along with
|
* Is used for the PlayerPanel to display if a player has laid out along
|
||||||
* the name
|
* with the name
|
||||||
*
|
*
|
||||||
* @param hasLaidOut
|
* @param hasLaidOut
|
||||||
* specifies if the current player has laid out or not
|
* specifies if the current player has laid out or not
|
||||||
|
@ -150,8 +148,8 @@ public interface IView {
|
||||||
public void setBottomPanel(BottomPanelType type);
|
public void setBottomPanel(BottomPanelType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The menu new game event is emitted when the user selects the new game menu
|
* The menu new game event is emitted when the user selects the new game
|
||||||
* entry
|
* menu entry
|
||||||
*
|
*
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
|
@ -292,13 +290,60 @@ public interface IView {
|
||||||
* Enables/disables saving in menu bar
|
* Enables/disables saving in menu bar
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
|
* saving possible
|
||||||
*/
|
*/
|
||||||
public void enableSave(boolean enable);
|
public void enableSave(boolean enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the quit warning panel visible
|
||||||
|
*
|
||||||
|
* @param show
|
||||||
|
* is visible
|
||||||
|
*/
|
||||||
public void showQuitWarningPanel(boolean show);
|
public void showQuitWarningPanel(boolean show);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The quit event is emitted when the user wants to leave the application
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent getQuitEvent();
|
public IEvent getQuitEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for quit warning panel
|
||||||
|
*
|
||||||
|
* @return the panel
|
||||||
|
*/
|
||||||
|
public IQuitWarningPanel getQuitWarningPanel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The load file event is emitted when the user chose to discard the current
|
||||||
|
* game to save another
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
|
public IEvent1<File> getLoadFileEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loading a game
|
||||||
|
*/
|
||||||
|
public void load();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the connect panel visible
|
||||||
|
*
|
||||||
|
* @param show
|
||||||
|
* is visible
|
||||||
|
*/
|
||||||
|
public void showConnectPanel(boolean show);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for connect panel
|
||||||
|
*
|
||||||
|
* @return the panel
|
||||||
|
*/
|
||||||
|
public IConnectPanel getConnectPanel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Different types of bottom panels
|
* Different types of bottom panels
|
||||||
*/
|
*/
|
||||||
|
@ -316,14 +361,4 @@ public interface IView {
|
||||||
/** */
|
/** */
|
||||||
WIN_PANEL
|
WIN_PANEL
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQuitWarningPanel getQuitWarningPanel();
|
|
||||||
|
|
||||||
public IEvent1<File> getLoadFileEvent();
|
|
||||||
|
|
||||||
public void load();
|
|
||||||
|
|
||||||
public void showConnectPanel(boolean show);
|
|
||||||
|
|
||||||
public IConnectPanel getConnectPanel();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
package jrummikub.view;
|
package jrummikub.view;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum summarizing the different kinds of login errors
|
||||||
|
*/
|
||||||
public enum LoginError {
|
public enum LoginError {
|
||||||
/** */
|
/** Error cannot be dissolved to a specific type */
|
||||||
UNKNOWN_ERROR,
|
UNKNOWN_ERROR,
|
||||||
/** */
|
/** No answer from network */
|
||||||
TIMEOUT,
|
TIMEOUT,
|
||||||
/** */
|
/** Connection denied by server */
|
||||||
CONNECTION_REFUSED,
|
CONNECTION_REFUSED,
|
||||||
/** */
|
/** Password or username incorrect */
|
||||||
AUTHENTICATION_FAILED,
|
AUTHENTICATION_FAILED,
|
||||||
/** */
|
/** Username already occurs in the same channel */
|
||||||
RESOURCE_CONFLICT,
|
RESOURCE_CONFLICT,
|
||||||
/** */
|
/** Server not found */
|
||||||
UNKNOWN_HOST,
|
UNKNOWN_HOST,
|
||||||
/** */
|
/** Channel not found */
|
||||||
UNKNOWN_CHANNEL
|
UNKNOWN_CHANNEL
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,20 @@ import jrummikub.util.IEvent;
|
||||||
import jrummikub.view.IConnectPanel;
|
import jrummikub.view.IConnectPanel;
|
||||||
import jrummikub.view.LoginError;
|
import jrummikub.view.LoginError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Panel shown during network connecting process and showing errors
|
||||||
|
*/
|
||||||
public class ConnectPanel extends JPanel implements IConnectPanel {
|
public class ConnectPanel extends JPanel implements IConnectPanel {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private JLabel messageLabel;
|
private JLabel messageLabel;
|
||||||
private JProgressBar foobar;
|
private JProgressBar foobar;
|
||||||
private JButton cancelButton;
|
private JButton cancelButton;
|
||||||
|
|
||||||
private Event cancelEvent = new Event();
|
private Event cancelEvent = new Event();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new connection panel
|
||||||
|
*/
|
||||||
public ConnectPanel() {
|
public ConnectPanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
@ -61,8 +68,8 @@ public class ConnectPanel extends JPanel implements IConnectPanel {
|
||||||
});
|
});
|
||||||
add(cancelButton, c);
|
add(cancelButton, c);
|
||||||
|
|
||||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
|
||||||
10, 10, 10, 10)));
|
new EmptyBorder(10, 10, 10, 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,11 @@ import jrummikub.util.Event;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.view.IQuitWarningPanel;
|
import jrummikub.view.IQuitWarningPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warning panel to inform users if their actions would end the current game
|
||||||
|
*/
|
||||||
public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private JButton cancelButton;
|
private JButton cancelButton;
|
||||||
private JButton quitButton;
|
private JButton quitButton;
|
||||||
private QuitMode quitMode;
|
private QuitMode quitMode;
|
||||||
|
@ -26,6 +30,9 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
private Event cancelEvent = new Event();
|
private Event cancelEvent = new Event();
|
||||||
private JLabel messageLabel;
|
private JLabel messageLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new quit warning panel
|
||||||
|
*/
|
||||||
public QuitWarningPanel() {
|
public QuitWarningPanel() {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
@ -50,8 +57,8 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
c.gridx = 1;
|
c.gridx = 1;
|
||||||
add(quitButton, c);
|
add(quitButton, c);
|
||||||
|
|
||||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
|
||||||
10, 10, 10, 10)));
|
new EmptyBorder(10, 10, 10, 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private JButton createButton(String title, final Event event) {
|
private JButton createButton(String title, final Event event) {
|
||||||
|
@ -70,7 +77,8 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
this.quitMode = mode;
|
this.quitMode = mode;
|
||||||
switch (quitMode) {
|
switch (quitMode) {
|
||||||
case QUIT_PROCESS:
|
case QUIT_PROCESS:
|
||||||
messageLabel.setText("Beim Beenden geht das aktuelle Spiel verloren");
|
messageLabel
|
||||||
|
.setText("Beim Beenden geht das aktuelle Spiel verloren");
|
||||||
break;
|
break;
|
||||||
case QUIT_GAME:
|
case QUIT_GAME:
|
||||||
messageLabel.setText("Der aktuelle Spielstand geht verloren");
|
messageLabel.setText("Der aktuelle Spielstand geht verloren");
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLayeredPane;
|
import javax.swing.JLayeredPane;
|
||||||
|
@ -43,7 +42,6 @@ import jrummikub.view.IHandPanel;
|
||||||
import jrummikub.view.ILoginPanel;
|
import jrummikub.view.ILoginPanel;
|
||||||
import jrummikub.view.IPlayerPanel;
|
import jrummikub.view.IPlayerPanel;
|
||||||
import jrummikub.view.IQuitWarningPanel;
|
import jrummikub.view.IQuitWarningPanel;
|
||||||
import jrummikub.view.IQuitWarningPanel.QuitMode;
|
|
||||||
import jrummikub.view.IScorePanel;
|
import jrummikub.view.IScorePanel;
|
||||||
import jrummikub.view.ISettingsPanel;
|
import jrummikub.view.ISettingsPanel;
|
||||||
import jrummikub.view.ISidePanel;
|
import jrummikub.view.ISidePanel;
|
||||||
|
@ -232,7 +230,6 @@ public class View extends JFrame implements IView {
|
||||||
loadItem.addActionListener(new ActionListener() {
|
loadItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
File file = new File("");
|
|
||||||
loadEvent.emit();
|
loadEvent.emit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -314,6 +311,19 @@ public class View extends JFrame implements IView {
|
||||||
|
|
||||||
createSettingsPanel();
|
createSettingsPanel();
|
||||||
|
|
||||||
|
createLayeredPane();
|
||||||
|
|
||||||
|
addComponentListener(new ComponentAdapter() {
|
||||||
|
@Override
|
||||||
|
public void componentResized(ComponentEvent e) {
|
||||||
|
rescale();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createLayeredPane() {
|
||||||
layeredPane.setLayer(settingsPanel, JLayeredPane.POPUP_LAYER);
|
layeredPane.setLayer(settingsPanel, JLayeredPane.POPUP_LAYER);
|
||||||
layeredPane.add(settingsPanel);
|
layeredPane.add(settingsPanel);
|
||||||
|
|
||||||
|
@ -341,15 +351,6 @@ public class View extends JFrame implements IView {
|
||||||
scorePanel.setVisible(false);
|
scorePanel.setVisible(false);
|
||||||
layeredPane.setLayer(scorePanel, JLayeredPane.POPUP_LAYER);
|
layeredPane.setLayer(scorePanel, JLayeredPane.POPUP_LAYER);
|
||||||
layeredPane.add(scorePanel);
|
layeredPane.add(scorePanel);
|
||||||
|
|
||||||
addComponentListener(new ComponentAdapter() {
|
|
||||||
@Override
|
|
||||||
public void componentResized(ComponentEvent e) {
|
|
||||||
rescale();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSettingsPanel() {
|
private void createSettingsPanel() {
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class SaveControlTest {
|
||||||
|
|
||||||
saveControl.getLoadEvent().add(
|
saveControl.getLoadEvent().add(
|
||||||
new IListener3<GameSettings, GameState, IRoundState>() {
|
new IListener3<GameSettings, GameState, IRoundState>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(GameSettings settings, GameState gameState,
|
public void handle(GameSettings settings, GameState gameState,
|
||||||
IRoundState roundState) {
|
IRoundState roundState) {
|
||||||
|
@ -66,7 +65,8 @@ public class SaveControlTest {
|
||||||
});
|
});
|
||||||
|
|
||||||
view.loadEvent.emit();
|
view.loadEvent.emit();
|
||||||
|
view.getQuitWarningPanel().quitEvent.emit();
|
||||||
|
view.loadFileEvent.emit(file);
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue