mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
handle table join and waiting
This commit is contained in:
parent
c47da1f5b3
commit
dcd2907112
28 changed files with 538 additions and 151 deletions
|
|
@ -604,59 +604,79 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
* @param gameId
|
||||
* @param playerId
|
||||
*/
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
try {
|
||||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setMaximum(true);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.showGame(gameId, playerId);
|
||||
setActive(gamePane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
try {
|
||||
for(Component component :desktopPane.getComponents()) {
|
||||
if (component instanceof GamePane
|
||||
&& ((GamePane) component).getGameId().equals(gameId)) {
|
||||
setActive((GamePane) component);
|
||||
return;
|
||||
public void showGame(final UUID gameId, final UUID playerId) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setMaximum(true);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.showGame(gameId, playerId);
|
||||
setActive(gamePane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
}
|
||||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setMaximum(true);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.watchGame(gameId);
|
||||
setActive(gamePane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
try {
|
||||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setMaximum(true);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.replayGame(gameId);
|
||||
setActive(gamePane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
public void watchGame(final UUID gameId) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for(Component component :desktopPane.getComponents()) {
|
||||
if (component instanceof GamePane
|
||||
&& ((GamePane) component).getGameId().equals(gameId)) {
|
||||
setActive((GamePane) component);
|
||||
return;
|
||||
}
|
||||
}
|
||||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setMaximum(true);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.watchGame(gameId);
|
||||
setActive(gamePane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showDraft(UUID draftId) {
|
||||
try {
|
||||
DraftPane draftPane = new DraftPane();
|
||||
desktopPane.add(draftPane, JLayeredPane.DEFAULT_LAYER);
|
||||
draftPane.setMaximum(true);
|
||||
draftPane.setVisible(true);
|
||||
draftPane.showDraft(draftId);
|
||||
setActive(draftPane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
public void replayGame(final UUID gameId) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
GamePane gamePane = new GamePane();
|
||||
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||
gamePane.setMaximum(true);
|
||||
gamePane.setVisible(true);
|
||||
gamePane.replayGame(gameId);
|
||||
setActive(gamePane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showDraft(final UUID draftId) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DraftPane draftPane = new DraftPane();
|
||||
desktopPane.add(draftPane, JLayeredPane.DEFAULT_LAYER);
|
||||
draftPane.setMaximum(true);
|
||||
draftPane.setVisible(true);
|
||||
draftPane.showDraft(draftId);
|
||||
setActive(draftPane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void endDraft(UUID draftId) {
|
||||
|
|
@ -669,35 +689,50 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
}
|
||||
|
||||
public void showTournament(UUID tournamentId) {
|
||||
try {
|
||||
for(Component component :desktopPane.getComponents()) {
|
||||
if (component instanceof TournamentPane &&
|
||||
((TournamentPane) component).getTournamentId().equals(tournamentId)) {
|
||||
setActive((TournamentPane) component);
|
||||
return;
|
||||
public void showTournament(final UUID tournamentId) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for(Component component :desktopPane.getComponents()) {
|
||||
if (component instanceof TournamentPane &&
|
||||
((TournamentPane) component).getTournamentId().equals(tournamentId)) {
|
||||
setActive((TournamentPane) component);
|
||||
return;
|
||||
}
|
||||
}
|
||||
TournamentPane tournamentPane = new TournamentPane();
|
||||
desktopPane.add(tournamentPane, JLayeredPane.DEFAULT_LAYER);
|
||||
tournamentPane.setMaximum(true);
|
||||
tournamentPane.setVisible(true);
|
||||
tournamentPane.showTournament(tournamentId);
|
||||
setActive(tournamentPane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
}
|
||||
TournamentPane tournamentPane = new TournamentPane();
|
||||
desktopPane.add(tournamentPane, JLayeredPane.DEFAULT_LAYER);
|
||||
tournamentPane.setMaximum(true);
|
||||
tournamentPane.setVisible(true);
|
||||
tournamentPane.showTournament(tournamentId);
|
||||
setActive(tournamentPane);
|
||||
} catch (PropertyVetoException ex) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showGameEndDialog(GameEndView gameEndView) {
|
||||
GameEndDialog gameEndDialog = new GameEndDialog(gameEndView);
|
||||
desktopPane.add(gameEndDialog, JLayeredPane.MODAL_LAYER);
|
||||
gameEndDialog.showDialog();
|
||||
public void showGameEndDialog(final GameEndView gameEndView) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GameEndDialog gameEndDialog = new GameEndDialog(gameEndView);
|
||||
desktopPane.add(gameEndDialog, JLayeredPane.MODAL_LAYER);
|
||||
gameEndDialog.showDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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 void showTableWaitingDialog(final UUID roomId, final UUID tableId, final UUID chatId, final boolean owner, final boolean tournament) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TableWaitingDialog tableWaitingDialog = new TableWaitingDialog();
|
||||
desktopPane.add(tableWaitingDialog, JLayeredPane.MODAL_LAYER);
|
||||
tableWaitingDialog.showDialog(roomId, tableId, chatId, owner, tournament);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean connect(Connection connection) {
|
||||
|
|
@ -1358,29 +1393,21 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
|
||||
public void showMessage(final String title, final String message) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
JOptionPane.showMessageDialog(desktopPane, message, title, JOptionPane.INFORMATION_MESSAGE);
|
||||
} else {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JOptionPane.showMessageDialog(desktopPane, message, title, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JOptionPane.showMessageDialog(desktopPane, message, title, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showError(final String title, final String message) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
JOptionPane.showMessageDialog(desktopPane, message, title, JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JOptionPane.showMessageDialog(desktopPane, message, title, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JOptionPane.showMessageDialog(desktopPane, message, title, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
|
@ -1438,6 +1465,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
return serverState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinedTable(UUID roomId, UUID tableId, UUID chatId, boolean owner, boolean tournament) {
|
||||
showTableWaitingDialog(roomId, tableId, chatId, owner, tournament);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
||||
|
|
|
|||
|
|
@ -110,13 +110,13 @@ public class TableWaitingDialog extends MageDialog {
|
|||
}
|
||||
}
|
||||
|
||||
public void showDialog(UUID roomId, UUID tableId, boolean isTournament) {
|
||||
public void showDialog(UUID roomId, UUID tableId, UUID chatId, boolean owner, boolean isTournament) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.isTournament = isTournament;
|
||||
client = MageFrame.getClient();
|
||||
updateTask = new UpdateSeatsTask(client, roomId, tableId, this);
|
||||
if (client.isTableOwner(roomId, tableId)) {
|
||||
if (owner) {
|
||||
this.btnStart.setVisible(true);
|
||||
this.btnMoveDown.setVisible(true);
|
||||
this.btnMoveUp.setVisible(true);
|
||||
|
|
@ -125,7 +125,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
this.btnMoveDown.setVisible(false);
|
||||
this.btnMoveUp.setVisible(false);
|
||||
}
|
||||
UUID chatId = client.getTableChatId(tableId);
|
||||
// UUID chatId = client.getTableChatId(tableId);
|
||||
if (chatId != null) {
|
||||
this.chatPanel.connect(chatId);
|
||||
updateTask.execute();
|
||||
|
|
|
|||
|
|
@ -161,12 +161,12 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
} break;
|
||||
case "joinedTable":
|
||||
{
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
||||
break;
|
||||
}
|
||||
// case "joinedTable":
|
||||
// {
|
||||
// TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
// joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
||||
// break;
|
||||
// }
|
||||
case "replayInit":
|
||||
{
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
|
|
@ -425,13 +425,13 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
// }
|
||||
// }
|
||||
|
||||
private void joinedTable(UUID roomId, UUID tableId, boolean isTournament) {
|
||||
try {
|
||||
frame.showTableWaitingDialog(roomId, tableId, isTournament);
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
// 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 {
|
||||
|
|
|
|||
|
|
@ -122,6 +122,11 @@ public class MultiConnectTest {
|
|||
public ServerState getServerState() {
|
||||
return serverState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinedTable(UUID roomId, UUID tableId, UUID chatId, boolean owner, boolean tournament) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue