show Table Waiting dialog on reconnect

This commit is contained in:
BetaSteward 2011-08-18 22:47:12 -04:00
parent 161404242f
commit 2ad50b2983
7 changed files with 82 additions and 29 deletions

View file

@ -526,7 +526,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} catch (PropertyVetoException ex) {}
}
public static boolean connect(Connection connection) {
public void showTableWaitingDialog(UUID roomId, UUID tableId, boolean isTournament) {
TableWaitingDialog tableWaitingDialog = new TableWaitingDialog();
desktopPane.add(tableWaitingDialog, JLayeredPane.MODAL_LAYER);
tableWaitingDialog.showDialog(roomId, tableId, isTournament);
}
public static boolean connect(Connection connection) {
return session.connect(connection);
}
@ -776,7 +782,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}//GEN-LAST:event_btnPreferencesActionPerformed
public void exitApp() {
session.disconnect(false);
if (session.isConnected()) {
if (JOptionPane.showConfirmDialog(this, "You are currently connected. Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
session.disconnect(false);
}
Plugins.getInstance().shutdown();
dispose();
System.exit(0);

View file

@ -105,6 +105,10 @@ public class CallbackClientImpl implements CallbackClient {
}
}
}
else if (callback.getMethod().equals("joinedTable")) {
TableClientMessage message = (TableClientMessage) callback.getData();
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
}
else if (callback.getMethod().equals("replayInit")) {
GamePanel panel = frame.getGame(callback.getObjectId());
if (panel != null)
@ -264,6 +268,15 @@ public class CallbackClientImpl implements CallbackClient {
return clientId;
}
private void joinedTable(UUID roomId, UUID tableId, boolean isTournament) {
try {
frame.showTableWaitingDialog(roomId, tableId, isTournament);
}
catch (Exception ex) {
handleException(ex);
}
}
protected void gameStarted(final UUID gameId, final UUID playerId) {
try {
frame.showGame(gameId, playerId);

View file

@ -133,15 +133,11 @@ public class TablesPanel extends javax.swing.JPanel {
}
if (isTournament) {
logger.info("Joining tournament " + tableId);
if (session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1)) {
showTableWaitingDialog(roomId, tableId, true);
}
session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1);
}
else {
logger.info("Joining table " + tableId);
joinTableDialog.showDialog(roomId, tableId);
if (joinTableDialog.isJoined())
showTableWaitingDialog(roomId, tableId, false);
}
} else if (state.equals("Watch")) {
logger.info("Watching table " + tableId);
@ -264,12 +260,6 @@ public class TablesPanel extends javax.swing.JPanel {
if (c != null)
((TablesPane)c).hideFrame();
}
private void showTableWaitingDialog(UUID roomId, UUID tableId, boolean isTournament) {
TableWaitingDialog tableWaitingDialog = new TableWaitingDialog();
MageFrame.getDesktop().add(tableWaitingDialog, JLayeredPane.MODAL_LAYER);
tableWaitingDialog.showDialog(roomId, tableId, isTournament);
}
/** This method is called from within the constructor to
* initialize the form.
@ -418,9 +408,6 @@ public class TablesPanel extends javax.swing.JPanel {
private void btnNewTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTournamentActionPerformed
newTournamentDialog.showDialog(roomId);
if (newTournamentDialog.getTable() != null) {
showTableWaitingDialog(roomId, newTournamentDialog.getTable().getTableId(), true);
}
}//GEN-LAST:event_btnNewTournamentActionPerformed
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
@ -444,9 +431,6 @@ public class TablesPanel extends javax.swing.JPanel {
private void btnNewTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTableActionPerformed
newTableDialog.showDialog(roomId);
if (newTableDialog.getTable() != null) {
showTableWaitingDialog(roomId, newTableDialog.getTable().getTableId(), false);
}
}//GEN-LAST:event_btnNewTableActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed