Implemented login error messages
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@500 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
ace7175f1a
commit
4df5c0e665
13 changed files with 330 additions and 121 deletions
|
@ -12,6 +12,7 @@ import jrummikub.util.IEvent2;
|
||||||
import jrummikub.util.MockEvent;
|
import jrummikub.util.MockEvent;
|
||||||
import jrummikub.util.MockEvent1;
|
import jrummikub.util.MockEvent1;
|
||||||
import jrummikub.util.MockEvent2;
|
import jrummikub.util.MockEvent2;
|
||||||
|
import jrummikub.view.LoginError;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public class MockConnectionControl implements IConnectionControl {
|
public class MockConnectionControl implements IConnectionControl {
|
||||||
|
@ -20,7 +21,7 @@ public class MockConnectionControl implements IConnectionControl {
|
||||||
/** */
|
/** */
|
||||||
public MockEvent connectedEvent = new MockEvent();
|
public MockEvent connectedEvent = new MockEvent();
|
||||||
/** */
|
/** */
|
||||||
public MockEvent connectionFailedEvent = new MockEvent();
|
public MockEvent1<LoginError> connectionFailedEvent = new MockEvent1<LoginError>();
|
||||||
/** */
|
/** */
|
||||||
public MockEvent1<GameData> gameOfferEvent = new MockEvent1<GameData>();
|
public MockEvent1<GameData> gameOfferEvent = new MockEvent1<GameData>();
|
||||||
/** */
|
/** */
|
||||||
|
@ -66,7 +67,7 @@ public class MockConnectionControl implements IConnectionControl {
|
||||||
@Override
|
@Override
|
||||||
public void connect() {
|
public void connect() {
|
||||||
if (failOnConnect) {
|
if (failOnConnect) {
|
||||||
connectionFailedEvent.emit();
|
connectionFailedEvent.emit(LoginError.UNKNOWN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
connected = true;
|
connected = true;
|
||||||
connectedEvent.emit();
|
connectedEvent.emit();
|
||||||
|
@ -84,7 +85,7 @@ public class MockConnectionControl implements IConnectionControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getConnectionFailedEvent() {
|
public IEvent1<LoginError> getConnectionFailedEvent() {
|
||||||
return connectionFailedEvent;
|
return connectionFailedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,12 @@ public class MockView implements IView {
|
||||||
return gameListPanel;
|
return gameListPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IConnectPanel getConnectPanel() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInitialMeldError(int points) {
|
public void setInitialMeldError(int points) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -295,4 +301,10 @@ 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
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ApplicationControl {
|
||||||
* Creates a new application control
|
* Creates a new application control
|
||||||
*
|
*
|
||||||
* @param view
|
* @param view
|
||||||
* the view to use
|
* the view to use
|
||||||
*/
|
*/
|
||||||
public ApplicationControl(final IView view) {
|
public ApplicationControl(final IView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
@ -43,15 +43,16 @@ public class ApplicationControl {
|
||||||
public void handle() {
|
public void handle() {
|
||||||
view.getQuitWarningPanel().setMode(QuitMode.QUIT_GAME);
|
view.getQuitWarningPanel().setMode(QuitMode.QUIT_GAME);
|
||||||
view.showQuitWarningPanel(true);
|
view.showQuitWarningPanel(true);
|
||||||
tempConnection = view.getQuitWarningPanel().getQuitEvent().add(new IListener() {
|
tempConnection = view.getQuitWarningPanel().getQuitEvent()
|
||||||
@Override
|
.add(new IListener() {
|
||||||
public void handle() {
|
@Override
|
||||||
abortControls();
|
public void handle() {
|
||||||
startApplication();
|
abortControls();
|
||||||
view.showQuitWarningPanel(false);
|
startApplication();
|
||||||
tempConnection.remove();
|
view.showQuitWarningPanel(false);
|
||||||
}
|
tempConnection.remove();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.getMenuQuitEvent().add(new IListener() {
|
view.getMenuQuitEvent().add(new IListener() {
|
||||||
|
@ -89,7 +90,7 @@ public class ApplicationControl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view.getQuitWarningPanel().getCancelEvent().add(new IListener() {
|
view.getQuitWarningPanel().getCancelEvent().add(new IListener() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
@ -97,16 +98,22 @@ public class ApplicationControl {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addLoginControlListeners();
|
view.getNetworkGameEvent().add(new IListener() {
|
||||||
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
abortControls();
|
||||||
|
|
||||||
|
createLoginControl();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
saveControl.getLoadEvent().add(
|
saveControl.getLoadEvent().add(
|
||||||
new IListener3<GameSettings, GameState, IRoundState>() {
|
new IListener3<GameSettings, GameState, IRoundState>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(GameSettings settings,
|
public void handle(GameSettings settings, GameState gameState,
|
||||||
GameState gameState, IRoundState roundState) {
|
IRoundState roundState) {
|
||||||
abortControls();
|
abortControls();
|
||||||
gameControl = new GameControl(settings, saveControl,
|
gameControl = new GameControl(settings, saveControl, view);
|
||||||
view);
|
|
||||||
addGameControlListeners(gameControl);
|
addGameControlListeners(gameControl);
|
||||||
gameControl.continueGame(gameState, roundState);
|
gameControl.continueGame(gameState, roundState);
|
||||||
}
|
}
|
||||||
|
@ -119,28 +126,21 @@ public class ApplicationControl {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLoginControlListeners() {
|
private void createLoginControl() {
|
||||||
view.getNetworkGameEvent().add(new IListener() {
|
loginControl = new LoginControl(view);
|
||||||
|
loginControl.getLoginEvent().add(new IListener1<LoginData>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle(LoginData loginData) {
|
||||||
abortControls();
|
createNetworkControl(loginData);
|
||||||
|
|
||||||
loginControl = new LoginControl(view);
|
|
||||||
loginControl.getLoginEvent().add(new IListener1<LoginData>() {
|
|
||||||
@Override
|
|
||||||
public void handle(LoginData loginData) {
|
|
||||||
createNetworkControl(loginData);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
loginControl.getCancelEvent().add(new IListener() {
|
|
||||||
@Override
|
|
||||||
public void handle() {
|
|
||||||
startApplication();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
loginControl.startLogin();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
loginControl.getCancelEvent().add(new IListener() {
|
||||||
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
startApplication();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loginControl.startLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abortControls() {
|
private void abortControls() {
|
||||||
|
@ -215,6 +215,14 @@ public class ApplicationControl {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
networkControl.getBackToLoginEvent().add(new IListener() {
|
||||||
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
networkControl = null;
|
||||||
|
createLoginControl();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
networkControl.startNetwork();
|
networkControl.startNetwork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class LoginControl {
|
||||||
* Constructor for login Control
|
* Constructor for login Control
|
||||||
*
|
*
|
||||||
* @param view
|
* @param view
|
||||||
* for events which need handling
|
* for events which need handling
|
||||||
*/
|
*/
|
||||||
public LoginControl(final IView view) {
|
public LoginControl(final IView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
@ -36,18 +36,18 @@ public class LoginControl {
|
||||||
@Override
|
@Override
|
||||||
public void handle(LoginData loginData) {
|
public void handle(LoginData loginData) {
|
||||||
abort();
|
abort();
|
||||||
|
// TODO connectPanel anzeigen
|
||||||
loginEvent.emit(loginData);
|
loginEvent.emit(loginData);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
connections.add(view.getLoginPanel().getCancelEvent()
|
connections.add(view.getLoginPanel().getCancelEvent().add(new IListener() {
|
||||||
.add(new IListener() {
|
@Override
|
||||||
@Override
|
public void handle() {
|
||||||
public void handle() {
|
abort();
|
||||||
abort();
|
cancelEvent.emit();
|
||||||
cancelEvent.emit();
|
}
|
||||||
}
|
}));
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IEvent1;
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.util.IEvent2;
|
import jrummikub.util.IEvent2;
|
||||||
import jrummikub.util.LoginData;
|
import jrummikub.util.LoginData;
|
||||||
|
import jrummikub.view.LoginError;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.Connection;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
|
@ -46,7 +47,7 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
private volatile MultiUserChat muc;
|
private volatile MultiUserChat muc;
|
||||||
|
|
||||||
private Event connectedEvent = new Event();
|
private Event connectedEvent = new Event();
|
||||||
private Event connectionFailedEvent = new Event();
|
private Event1<LoginError> connectionFailedEvent = new Event1<LoginError>();
|
||||||
|
|
||||||
private Event1<GameData> gameOfferEvent = new Event1<GameData>();
|
private Event1<GameData> gameOfferEvent = new Event1<GameData>();
|
||||||
private Event1<UUID> gameWithdrawalEvent = new Event1<UUID>();
|
private Event1<UUID> gameWithdrawalEvent = new Event1<UUID>();
|
||||||
|
@ -72,7 +73,7 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
* Creates new connection control
|
* Creates new connection control
|
||||||
*
|
*
|
||||||
* @param loginData
|
* @param loginData
|
||||||
* player's login data
|
* player's login data
|
||||||
*/
|
*/
|
||||||
public ConnectionControl(LoginData loginData) {
|
public ConnectionControl(LoginData loginData) {
|
||||||
this.loginData = loginData;
|
this.loginData = loginData;
|
||||||
|
@ -91,7 +92,7 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
@Override
|
@Override
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
connectedEvent = new Event();
|
connectedEvent = new Event();
|
||||||
connectionFailedEvent = new Event();
|
connectionFailedEvent = new Event1<LoginError>();
|
||||||
run(new Runnable() {
|
run(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -111,7 +112,7 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getConnectionFailedEvent() {
|
public IEvent1<LoginError> getConnectionFailedEvent() {
|
||||||
return connectionFailedEvent;
|
return connectionFailedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,8 +253,7 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
protected void addData(DefaultPacketExtension extension) {
|
protected void addData(DefaultPacketExtension extension) {
|
||||||
extension.setValue("messageType", "change_color");
|
extension.setValue("messageType", "change_color");
|
||||||
extension.setValue("uuid", uuid.toString());
|
extension.setValue("uuid", uuid.toString());
|
||||||
extension.setValue("color",
|
extension.setValue("color", Base64.encodeObject(color, Base64.GZIP));
|
||||||
Base64.encodeObject(color, Base64.GZIP));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -316,8 +316,8 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
protected void addData(DefaultPacketExtension extension) {
|
protected void addData(DefaultPacketExtension extension) {
|
||||||
extension.setValue("messageType", "game_offer");
|
extension.setValue("messageType", "game_offer");
|
||||||
extension.setValue("uuid", data.getGameID().toString());
|
extension.setValue("uuid", data.getGameID().toString());
|
||||||
extension.setValue("gameSettings", Base64.encodeObject(
|
extension.setValue("gameSettings",
|
||||||
data.getGameSettings(), Base64.GZIP));
|
Base64.encodeObject(data.getGameSettings(), Base64.GZIP));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -340,6 +340,15 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> void emitLater(final Event1<T> event, final T arg) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
event.emit(arg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private Message createMessage(PacketExtension extension) {
|
private Message createMessage(PacketExtension extension) {
|
||||||
Message message = muc.createMessage();
|
Message message = muc.createMessage();
|
||||||
message.addExtension(extension);
|
message.addExtension(extension);
|
||||||
|
@ -355,8 +364,8 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
.getExtension(ELEMENT_NAME, NAMESPACE);
|
.getExtension(ELEMENT_NAME, NAMESPACE);
|
||||||
|
|
||||||
if (((Message) packet).getType() == Message.Type.error) {
|
if (((Message) packet).getType() == Message.Type.error) {
|
||||||
System.err.println("Received error message from '"
|
System.err.println("Received error message from '" + packet.getFrom()
|
||||||
+ packet.getFrom() + "'");
|
+ "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,14 +381,13 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
String sender, String messageType) {
|
String sender, String messageType) {
|
||||||
if (messageType.equals("game_offer")) {
|
if (messageType.equals("game_offer")) {
|
||||||
UUID uuid = UUID.fromString(extension.getValue("uuid"));
|
UUID uuid = UUID.fromString(extension.getValue("uuid"));
|
||||||
GameSettings settings = (GameSettings) Base64
|
GameSettings settings = (GameSettings) Base64.decodeToObject(extension
|
||||||
.decodeToObject(extension.getValue("gameSettings"));
|
.getValue("gameSettings"));
|
||||||
|
|
||||||
GameData gameData = new GameData(uuid, settings, sender);
|
GameData gameData = new GameData(uuid, settings, sender);
|
||||||
gameOfferEvent.emit(gameData);
|
gameOfferEvent.emit(gameData);
|
||||||
} else if (messageType.equals("game_withdrawal")) {
|
} else if (messageType.equals("game_withdrawal")) {
|
||||||
gameWithdrawalEvent
|
gameWithdrawalEvent.emit(UUID.fromString(extension.getValue("uuid")));
|
||||||
.emit(UUID.fromString(extension.getValue("uuid")));
|
|
||||||
} else if (messageType.equals("game_request")) {
|
} else if (messageType.equals("game_request")) {
|
||||||
if (offeredGame != null) {
|
if (offeredGame != null) {
|
||||||
sendGameOffer();
|
sendGameOffer();
|
||||||
|
@ -447,10 +455,26 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
connection = null;
|
connection = null;
|
||||||
|
|
||||||
// TODO Auto-generated catch block
|
XMPPError xmppError = e.getXMPPError();
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
emitLater(connectionFailedEvent);
|
if (xmppError != null) {
|
||||||
|
int code = xmppError.getCode();
|
||||||
|
if (code == 504) {
|
||||||
|
emitLater(connectionFailedEvent, LoginError.UNKNOWN_HOST);
|
||||||
|
return;
|
||||||
|
} else if (code == 404) {
|
||||||
|
emitLater(connectionFailedEvent, LoginError.UNKNOWN_CHANNEL);
|
||||||
|
return;
|
||||||
|
} else if (code == 503) {
|
||||||
|
emitLater(connectionFailedEvent, LoginError.RESOURCE_CONFLICT);
|
||||||
|
return;
|
||||||
|
} else if (code == 401 || code == 402 || code == 407) {
|
||||||
|
emitLater(connectionFailedEvent, LoginError.AUTHENTICATION_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.printStackTrace();
|
||||||
|
emitLater(connectionFailedEvent, LoginError.UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,8 +495,7 @@ public class ConnectionControl implements IConnectionControl {
|
||||||
break; // Join was successful, break the loop
|
break; // Join was successful, break the loop
|
||||||
} catch (XMPPException e) {
|
} catch (XMPPException e) {
|
||||||
XMPPError error = e.getXMPPError();
|
XMPPError error = e.getXMPPError();
|
||||||
if (error.getType() == Type.CANCEL
|
if (error.getType() == Type.CANCEL && error.getCode() == 409) {
|
||||||
&& error.getCode() == 409) {
|
|
||||||
// There was a conflict, try again with another
|
// There was a conflict, try again with another
|
||||||
// nickname
|
// nickname
|
||||||
nickname += "_";
|
nickname += "_";
|
||||||
|
|
|
@ -9,6 +9,7 @@ import jrummikub.util.GameData;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IEvent1;
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.util.IEvent2;
|
import jrummikub.util.IEvent2;
|
||||||
|
import jrummikub.view.LoginError;
|
||||||
|
|
||||||
interface IConnectionControl {
|
interface IConnectionControl {
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ interface IConnectionControl {
|
||||||
|
|
||||||
public IEvent getConnectedEvent();
|
public IEvent getConnectedEvent();
|
||||||
|
|
||||||
public IEvent getConnectionFailedEvent();
|
public IEvent1<LoginError> getConnectionFailedEvent();
|
||||||
|
|
||||||
public IEvent1<GameData> getGameOfferEvent();
|
public IEvent1<GameData> getGameOfferEvent();
|
||||||
|
|
||||||
|
@ -65,5 +66,4 @@ interface IConnectionControl {
|
||||||
public void endTurn(ITable table);
|
public void endTurn(ITable table);
|
||||||
|
|
||||||
public void startTurn(IRoundState state);
|
public void startTurn(IRoundState state);
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@ import jrummikub.util.IListener;
|
||||||
import jrummikub.util.IListener1;
|
import jrummikub.util.IListener1;
|
||||||
import jrummikub.util.LoginData;
|
import jrummikub.util.LoginData;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
import jrummikub.view.LoginError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class dealing with network connection, offering and choice of network games
|
* Class dealing with network connection, offering and choice of network games
|
||||||
|
@ -24,6 +25,7 @@ public class NetworkControl {
|
||||||
private IView view;
|
private IView view;
|
||||||
private List<Connection> connections = new ArrayList<Connection>();
|
private List<Connection> connections = new ArrayList<Connection>();
|
||||||
private Event stopNetworkEvent = new Event();
|
private Event stopNetworkEvent = new Event();
|
||||||
|
private Event backToLoginEvent = new Event();
|
||||||
|
|
||||||
private NetworkSettingsControl settingsControl;
|
private NetworkSettingsControl settingsControl;
|
||||||
private GameOfferControl gameOfferControl;
|
private GameOfferControl gameOfferControl;
|
||||||
|
@ -36,11 +38,11 @@ public class NetworkControl {
|
||||||
* Creates a new network control
|
* Creates a new network control
|
||||||
*
|
*
|
||||||
* @param loginData
|
* @param loginData
|
||||||
* user's login data
|
* user's login data
|
||||||
* @param connectionControl
|
* @param connectionControl
|
||||||
* current connection for events and messages
|
* current connection for events and messages
|
||||||
* @param view
|
* @param view
|
||||||
* for events and handlers
|
* for events and handlers
|
||||||
*/
|
*/
|
||||||
public NetworkControl(final LoginData loginData,
|
public NetworkControl(final LoginData loginData,
|
||||||
IConnectionControl connectionControl, final IView view) {
|
IConnectionControl connectionControl, final IView view) {
|
||||||
|
@ -85,7 +87,7 @@ public class NetworkControl {
|
||||||
* Adds the listeners for connection control events
|
* Adds the listeners for connection control events
|
||||||
*
|
*
|
||||||
* @param view
|
* @param view
|
||||||
* view for events
|
* view for events
|
||||||
*/
|
*/
|
||||||
public void addConnectionControlListeners(final IView view) {
|
public void addConnectionControlListeners(final IView view) {
|
||||||
connections.add(connectionControl.getGameOfferEvent().add(
|
connections.add(connectionControl.getGameOfferEvent().add(
|
||||||
|
@ -133,22 +135,29 @@ public class NetworkControl {
|
||||||
|
|
||||||
private void addConnectionSetupListeners(final LoginData loginData,
|
private void addConnectionSetupListeners(final LoginData loginData,
|
||||||
final IView view) {
|
final IView view) {
|
||||||
connections.add(connectionControl.getConnectedEvent().add(
|
connections.add(connectionControl.getConnectedEvent().add(new IListener() {
|
||||||
new IListener() {
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
view.getGameListPanel().setChannelName(loginData.getChannelName());
|
||||||
|
view.showGameListPanel(true);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
connections.add(connectionControl.getConnectionFailedEvent().add(
|
||||||
|
new IListener1<LoginError>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle(LoginError error) {
|
||||||
view.getGameListPanel().setChannelName(
|
view.getConnectPanel().setMode(error);
|
||||||
loginData.getChannelName());
|
view.showConnectPanel(true);
|
||||||
view.showGameListPanel(true);
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
connections.add(connectionControl.getConnectionFailedEvent().add(
|
connections.add(view.getConnectPanel().getCancelEvent()
|
||||||
new IListener() {
|
.add(new IListener() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
// TODO Auto-generated method stub
|
abort();
|
||||||
|
backToLoginEvent.emit();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -181,9 +190,11 @@ public class NetworkControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new network connection with the sepcified data
|
* Starts a new network connection with the specified data
|
||||||
*/
|
*/
|
||||||
public void startNetwork() {
|
public void startNetwork() {
|
||||||
|
view.showConnectPanel(true);
|
||||||
|
view.getConnectPanel().setMode(null);
|
||||||
connectionControl.connect();
|
connectionControl.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +206,7 @@ public class NetworkControl {
|
||||||
c.remove();
|
c.remove();
|
||||||
}
|
}
|
||||||
view.showGameListPanel(false);
|
view.showGameListPanel(false);
|
||||||
|
view.showConnectPanel(false);
|
||||||
|
|
||||||
if (settingsControl != null) {
|
if (settingsControl != null) {
|
||||||
settingsControl.abort();
|
settingsControl.abort();
|
||||||
|
@ -218,6 +230,10 @@ public class NetworkControl {
|
||||||
return stopNetworkEvent;
|
return stopNetworkEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEvent getBackToLoginEvent() {
|
||||||
|
return backToLoginEvent;
|
||||||
|
}
|
||||||
|
|
||||||
private void createSettingsControl() {
|
private void createSettingsControl() {
|
||||||
if (settingsControl != null) {
|
if (settingsControl != null) {
|
||||||
return;
|
return;
|
||||||
|
@ -247,8 +263,7 @@ public class NetworkControl {
|
||||||
if (gameOfferControl != null) {
|
if (gameOfferControl != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gameOfferControl = new GameOfferControl(connectionControl, settings,
|
gameOfferControl = new GameOfferControl(connectionControl, settings, view);
|
||||||
view);
|
|
||||||
gameOfferControl.getBackEvent().add(new IListener() {
|
gameOfferControl.getBackEvent().add(new IListener() {
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
|
11
src/jrummikub/view/IConnectPanel.java
Normal file
11
src/jrummikub/view/IConnectPanel.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package jrummikub.view;
|
||||||
|
|
||||||
|
import jrummikub.util.IEvent;
|
||||||
|
|
||||||
|
public interface IConnectPanel {
|
||||||
|
|
||||||
|
public void setMode(LoginError error);
|
||||||
|
|
||||||
|
public IEvent getCancelEvent();
|
||||||
|
|
||||||
|
}
|
|
@ -59,7 +59,7 @@ public interface IView {
|
||||||
* Sets the current player's name
|
* Sets the current player's name
|
||||||
*
|
*
|
||||||
* @param playerName
|
* @param playerName
|
||||||
* the player name
|
* the player name
|
||||||
*/
|
*/
|
||||||
public void setCurrentPlayerName(String playerName);
|
public void setCurrentPlayerName(String playerName);
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public interface IView {
|
||||||
* Sets the stones that are to be painted selected
|
* Sets the stones that are to be painted selected
|
||||||
*
|
*
|
||||||
* @param stones
|
* @param stones
|
||||||
* the stones to be painted selected
|
* the stones to be painted selected
|
||||||
*/
|
*/
|
||||||
public void setSelectedStones(Collection<Stone> stones);
|
public void setSelectedStones(Collection<Stone> stones);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public interface IView {
|
||||||
* Shows or hides the game settings panel
|
* Shows or hides the game settings panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* specifies if the panel shall be shown or hidden
|
* specifies if the panel shall be shown or hidden
|
||||||
*/
|
*/
|
||||||
public void showSettingsPanel(boolean show);
|
public void showSettingsPanel(boolean show);
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public interface IView {
|
||||||
* Shows or hides the score panel
|
* Shows or hides the score panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* specifies if the panel shall be shown or hidden
|
* specifies if the panel shall be shown or hidden
|
||||||
*/
|
*/
|
||||||
public void showScorePanel(boolean show);
|
public void showScorePanel(boolean show);
|
||||||
|
|
||||||
|
@ -121,16 +121,16 @@ public interface IView {
|
||||||
* along with the name
|
* along with the name
|
||||||
*
|
*
|
||||||
* @param color
|
* @param color
|
||||||
* the current player's color
|
* the current player's color
|
||||||
*/
|
*/
|
||||||
public void setCurrentPlayerColor(Color color);
|
public void setCurrentPlayerColor(Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is used for the PlayerPanel to display if a player has laid out along
|
* Is used for the PlayerPanel to display if a player has laid out along with
|
||||||
* with the name
|
* 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
|
||||||
*/
|
*/
|
||||||
public void setCurrentPlayerHasLaidOut(boolean hasLaidOut);
|
public void setCurrentPlayerHasLaidOut(boolean hasLaidOut);
|
||||||
|
|
||||||
|
@ -145,13 +145,13 @@ public interface IView {
|
||||||
* Sets the bottom panels type
|
* Sets the bottom panels type
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* the type of the bottom panel
|
* the type of the bottom panel
|
||||||
*/
|
*/
|
||||||
public void setBottomPanel(BottomPanelType type);
|
public void setBottomPanel(BottomPanelType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The menu new game event is emitted when the user selects the new game
|
* The menu new game event is emitted when the user selects the new game menu
|
||||||
* menu entry
|
* entry
|
||||||
*
|
*
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
|
@ -226,7 +226,7 @@ public interface IView {
|
||||||
* Show/hide login panel
|
* Show/hide login panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* true = login panel is shown
|
* true = login panel is shown
|
||||||
*/
|
*/
|
||||||
public void showLoginPanel(boolean show);
|
public void showLoginPanel(boolean show);
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ public interface IView {
|
||||||
* Enable/disable pause mode
|
* Enable/disable pause mode
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
* true = enable
|
* true = enable
|
||||||
*/
|
*/
|
||||||
public void enablePauseMode(boolean enable);
|
public void enablePauseMode(boolean enable);
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ public interface IView {
|
||||||
* Show/hide game list panel
|
* Show/hide game list panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* true = show
|
* true = show
|
||||||
*/
|
*/
|
||||||
public void showGameListPanel(boolean show);
|
public void showGameListPanel(boolean show);
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ public interface IView {
|
||||||
* Show/hide side panel
|
* Show/hide side panel
|
||||||
*
|
*
|
||||||
* @param show
|
* @param show
|
||||||
* true to show
|
* true to show
|
||||||
*/
|
*/
|
||||||
void showSidePanel(boolean show);
|
void showSidePanel(boolean show);
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ public interface IView {
|
||||||
* Is set if a player tried to lay out less than initial meld threshold
|
* Is set if a player tried to lay out less than initial meld threshold
|
||||||
*
|
*
|
||||||
* @param points
|
* @param points
|
||||||
* initial meld threshold
|
* initial meld threshold
|
||||||
*/
|
*/
|
||||||
public void setInitialMeldError(int points);
|
public void setInitialMeldError(int points);
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ public interface IView {
|
||||||
* Show stone collection
|
* Show stone collection
|
||||||
*
|
*
|
||||||
* @param enable
|
* @param enable
|
||||||
* showing collection
|
* showing collection
|
||||||
*/
|
*/
|
||||||
public void setStoneCollectionHidden(boolean enable);
|
public void setStoneCollectionHidden(boolean enable);
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ public interface IView {
|
||||||
* Set invalid sets to enable showing
|
* Set invalid sets to enable showing
|
||||||
*
|
*
|
||||||
* @param sets
|
* @param sets
|
||||||
* invalid sets on table
|
* invalid sets on table
|
||||||
*/
|
*/
|
||||||
public void setInvalidStoneSets(Collection<StoneSet> sets);
|
public void setInvalidStoneSets(Collection<StoneSet> sets);
|
||||||
|
|
||||||
|
@ -322,4 +322,8 @@ public interface IView {
|
||||||
public IEvent1<File> getLoadFileEvent();
|
public IEvent1<File> getLoadFileEvent();
|
||||||
|
|
||||||
public void load();
|
public void load();
|
||||||
|
|
||||||
|
public void showConnectPanel(boolean show);
|
||||||
|
|
||||||
|
public IConnectPanel getConnectPanel();
|
||||||
}
|
}
|
||||||
|
|
18
src/jrummikub/view/LoginError.java
Normal file
18
src/jrummikub/view/LoginError.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package jrummikub.view;
|
||||||
|
|
||||||
|
public enum LoginError {
|
||||||
|
/** */
|
||||||
|
UNKNOWN_ERROR,
|
||||||
|
/** */
|
||||||
|
TIMEOUT,
|
||||||
|
/** */
|
||||||
|
CONNECTION_REFUSED,
|
||||||
|
/** */
|
||||||
|
AUTHENTICATION_FAILED,
|
||||||
|
/** */
|
||||||
|
RESOURCE_CONFLICT,
|
||||||
|
/** */
|
||||||
|
UNKNOWN_HOST,
|
||||||
|
/** */
|
||||||
|
UNKNOWN_CHANNEL
|
||||||
|
}
|
109
src/jrummikub/view/impl/ConnectPanel.java
Normal file
109
src/jrummikub/view/impl/ConnectPanel.java
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
package jrummikub.view.impl;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.border.LineBorder;
|
||||||
|
|
||||||
|
import jrummikub.util.Event;
|
||||||
|
import jrummikub.util.IEvent;
|
||||||
|
import jrummikub.view.IConnectPanel;
|
||||||
|
import jrummikub.view.LoginError;
|
||||||
|
|
||||||
|
public class ConnectPanel extends JPanel implements IConnectPanel {
|
||||||
|
private JLabel messageLabel;
|
||||||
|
private JProgressBar foobar;
|
||||||
|
private JButton cancelButton;
|
||||||
|
|
||||||
|
private Event cancelEvent = new Event();
|
||||||
|
|
||||||
|
public ConnectPanel() {
|
||||||
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 0;
|
||||||
|
c.weightx = 1;
|
||||||
|
c.weighty = 1;
|
||||||
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
c.anchor = GridBagConstraints.CENTER;
|
||||||
|
|
||||||
|
messageLabel = new JLabel();
|
||||||
|
messageLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
add(messageLabel, c);
|
||||||
|
|
||||||
|
c.gridy = 1;
|
||||||
|
c.insets = new Insets(5, 5, 5, 5);
|
||||||
|
|
||||||
|
foobar = new JProgressBar();
|
||||||
|
foobar.setIndeterminate(true);
|
||||||
|
add(foobar, c);
|
||||||
|
|
||||||
|
c.gridy = 2;
|
||||||
|
|
||||||
|
cancelButton = new JButton();
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
cancelEvent.emit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(cancelButton, c);
|
||||||
|
|
||||||
|
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
||||||
|
10, 10, 10, 10)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMode(LoginError error) {
|
||||||
|
if (error == null) {
|
||||||
|
foobar.setVisible(true);
|
||||||
|
messageLabel.setText("Verbindung wird hergestellt");
|
||||||
|
cancelButton.setText("Abbrechen");
|
||||||
|
} else {
|
||||||
|
foobar.setVisible(false);
|
||||||
|
String text = "";
|
||||||
|
switch (error) {
|
||||||
|
case UNKNOWN_ERROR:
|
||||||
|
text = "Ein unbekannter Fehler ist aufgetreten";
|
||||||
|
break;
|
||||||
|
case AUTHENTICATION_FAILED:
|
||||||
|
text = "Die Authentifizierung ist fehlgeschlagen";
|
||||||
|
break;
|
||||||
|
case CONNECTION_REFUSED:
|
||||||
|
text = "Die Verbindung wurde abgelehnt";
|
||||||
|
break;
|
||||||
|
case RESOURCE_CONFLICT:
|
||||||
|
text = "Es gibt bereits einen solchen Spieler";
|
||||||
|
break;
|
||||||
|
case TIMEOUT:
|
||||||
|
text = "Der Server reagiert nicht";
|
||||||
|
break;
|
||||||
|
case UNKNOWN_CHANNEL:
|
||||||
|
text = "Der Channel konnte nicht gefunden werden";
|
||||||
|
break;
|
||||||
|
case UNKNOWN_HOST:
|
||||||
|
text = "Der Server konnte nicht gefunden werden";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
messageLabel.setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEvent getCancelEvent() {
|
||||||
|
return cancelEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,6 @@ import jrummikub.util.IEvent;
|
||||||
import jrummikub.view.IQuitWarningPanel;
|
import jrummikub.view.IQuitWarningPanel;
|
||||||
|
|
||||||
public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
private JPanel buttonPanel;
|
|
||||||
private JButton cancelButton;
|
private JButton cancelButton;
|
||||||
private JButton quitButton;
|
private JButton quitButton;
|
||||||
private QuitMode quitMode;
|
private QuitMode quitMode;
|
||||||
|
@ -51,8 +50,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),
|
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
||||||
new EmptyBorder(10, 10, 10, 10)));
|
10, 10, 10, 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private JButton createButton(String title, final Event event) {
|
private JButton createButton(String title, final Event event) {
|
||||||
|
@ -71,8 +70,7 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||||
this.quitMode = mode;
|
this.quitMode = mode;
|
||||||
switch (quitMode) {
|
switch (quitMode) {
|
||||||
case QUIT_PROCESS:
|
case QUIT_PROCESS:
|
||||||
messageLabel
|
messageLabel.setText("Beim Beenden geht das aktuelle Spiel verloren");
|
||||||
.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,6 +14,7 @@ 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;
|
||||||
|
@ -36,6 +37,7 @@ import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IEvent1;
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
import jrummikub.util.Pair;
|
import jrummikub.util.Pair;
|
||||||
|
import jrummikub.view.IConnectPanel;
|
||||||
import jrummikub.view.IGameListPanel;
|
import jrummikub.view.IGameListPanel;
|
||||||
import jrummikub.view.IHandPanel;
|
import jrummikub.view.IHandPanel;
|
||||||
import jrummikub.view.ILoginPanel;
|
import jrummikub.view.ILoginPanel;
|
||||||
|
@ -73,7 +75,7 @@ public class View extends JFrame implements IView {
|
||||||
private GameListPanel gameListPanel;
|
private GameListPanel gameListPanel;
|
||||||
private SidePanel sidePanel;
|
private SidePanel sidePanel;
|
||||||
private QuitWarningPanel quitWarningPanel;
|
private QuitWarningPanel quitWarningPanel;
|
||||||
|
private ConnectPanel connectPanel;
|
||||||
private BottomPanelType bottomPanelType;
|
private BottomPanelType bottomPanelType;
|
||||||
|
|
||||||
private JFileChooser chooser;
|
private JFileChooser chooser;
|
||||||
|
@ -131,6 +133,11 @@ public class View extends JFrame implements IView {
|
||||||
return quitWarningPanel;
|
return quitWarningPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IConnectPanel getConnectPanel() {
|
||||||
|
return connectPanel;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IGameListPanel getGameListPanel() {
|
public IGameListPanel getGameListPanel() {
|
||||||
return gameListPanel;
|
return gameListPanel;
|
||||||
|
@ -150,9 +157,9 @@ public class View extends JFrame implements IView {
|
||||||
public IEvent1<File> getLoadFileEvent() {
|
public IEvent1<File> getLoadFileEvent() {
|
||||||
return loadFileEvent;
|
return loadFileEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getLoadEvent(){
|
public IEvent getLoadEvent() {
|
||||||
return loadEvent;
|
return loadEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +294,7 @@ public class View extends JFrame implements IView {
|
||||||
|
|
||||||
setSize(1000, 700);
|
setSize(1000, 700);
|
||||||
setMinimumSize(new Dimension(750, 550));
|
setMinimumSize(new Dimension(750, 550));
|
||||||
|
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -312,19 +319,21 @@ public class View extends JFrame implements IView {
|
||||||
|
|
||||||
loginPanel = new LoginPanel();
|
loginPanel = new LoginPanel();
|
||||||
loginPanel.setVisible(false);
|
loginPanel.setVisible(false);
|
||||||
|
|
||||||
layeredPane.setLayer(loginPanel, JLayeredPane.POPUP_LAYER);
|
layeredPane.setLayer(loginPanel, JLayeredPane.POPUP_LAYER);
|
||||||
layeredPane.add(loginPanel);
|
layeredPane.add(loginPanel);
|
||||||
|
|
||||||
gameListPanel = new GameListPanel();
|
gameListPanel = new GameListPanel();
|
||||||
gameListPanel.setVisible(false);
|
gameListPanel.setVisible(false);
|
||||||
|
|
||||||
layeredPane.setLayer(gameListPanel, JLayeredPane.POPUP_LAYER);
|
layeredPane.setLayer(gameListPanel, JLayeredPane.POPUP_LAYER);
|
||||||
layeredPane.add(gameListPanel);
|
layeredPane.add(gameListPanel);
|
||||||
|
|
||||||
|
connectPanel = new ConnectPanel();
|
||||||
|
connectPanel.setVisible(false);
|
||||||
|
layeredPane.setLayer(connectPanel, JLayeredPane.POPUP_LAYER);
|
||||||
|
layeredPane.add(connectPanel);
|
||||||
|
|
||||||
quitWarningPanel = new QuitWarningPanel();
|
quitWarningPanel = new QuitWarningPanel();
|
||||||
quitWarningPanel.setVisible(false);
|
quitWarningPanel.setVisible(false);
|
||||||
|
|
||||||
layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER);
|
layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER);
|
||||||
layeredPane.add(quitWarningPanel);
|
layeredPane.add(quitWarningPanel);
|
||||||
|
|
||||||
|
@ -386,10 +395,6 @@ public class View extends JFrame implements IView {
|
||||||
winPanel.setVisible(false);
|
winPanel.setVisible(false);
|
||||||
mainLayer.add(winPanel);
|
mainLayer.add(winPanel);
|
||||||
|
|
||||||
quitWarningPanel = new QuitWarningPanel();
|
|
||||||
quitWarningPanel.setVisible(false);
|
|
||||||
mainLayer.add(quitWarningPanel);
|
|
||||||
|
|
||||||
sidePanel = new SidePanel();
|
sidePanel = new SidePanel();
|
||||||
sidePanel.setVisible(false);
|
sidePanel.setVisible(false);
|
||||||
mainLayer.add(sidePanel);
|
mainLayer.add(sidePanel);
|
||||||
|
@ -440,7 +445,8 @@ public class View extends JFrame implements IView {
|
||||||
rescaleSubpanel(loginPanel, 1 / 3.0, 1 / 3.0, 200, 200);
|
rescaleSubpanel(loginPanel, 1 / 3.0, 1 / 3.0, 200, 200);
|
||||||
rescaleSubpanel(gameListPanel, 1 / 2.0, 1 / 2.0, 475, 300);
|
rescaleSubpanel(gameListPanel, 1 / 2.0, 1 / 2.0, 475, 300);
|
||||||
rescaleSubpanel(quitWarningPanel, 1 / 2.0, 1 / 6.0, 400, 150);
|
rescaleSubpanel(quitWarningPanel, 1 / 2.0, 1 / 6.0, 400, 150);
|
||||||
}
|
rescaleSubpanel(connectPanel, 1 / 2.0, 1 / 6.0, 400, 150);
|
||||||
|
}
|
||||||
|
|
||||||
private void rescaleSubpanel(JPanel sub, double widthFactor,
|
private void rescaleSubpanel(JPanel sub, double widthFactor,
|
||||||
double heightFactor, int minWidth, int minHeight) {
|
double heightFactor, int minWidth, int minHeight) {
|
||||||
|
@ -504,6 +510,11 @@ public class View extends JFrame implements IView {
|
||||||
quitWarningPanel.setVisible(show);
|
quitWarningPanel.setVisible(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showConnectPanel(boolean show) {
|
||||||
|
connectPanel.setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentPlayerName(String playerName) {
|
public void setCurrentPlayerName(String playerName) {
|
||||||
playerPanel.setCurrentPlayerName(playerName);
|
playerPanel.setCurrentPlayerName(playerName);
|
||||||
|
@ -600,7 +611,6 @@ public class View extends JFrame implements IView {
|
||||||
@Override
|
@Override
|
||||||
public void setBottomPanel(BottomPanelType type) {
|
public void setBottomPanel(BottomPanelType type) {
|
||||||
bottomPanelType = type;
|
bottomPanelType = type;
|
||||||
|
|
||||||
doSetBottomPanel(type);
|
doSetBottomPanel(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue