mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Non modal tablewaiting dialog (allows to chat, to create several games). Pressing "Join" causes all your games appear on top. Updated logging. Fixed removing table not working (but not fully, as game ending still doesn't work).
This commit is contained in:
parent
fa2a993275
commit
4133a13120
3 changed files with 61 additions and 28 deletions
|
|
@ -37,14 +37,13 @@ package mage.client.dialog;
|
|||
import mage.client.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.remote.Session;
|
||||
import mage.util.Logging;
|
||||
import mage.view.SeatView;
|
||||
import mage.view.TableView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -52,7 +51,7 @@ import mage.view.TableView;
|
|||
*/
|
||||
public class TableWaitingDialog extends MageDialog {
|
||||
|
||||
// private final static Logger logger = Logging.getLogger(TableWaitingDialog.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
|
||||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
|
|
@ -124,7 +123,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
if (chatId != null) {
|
||||
this.chatPanel.connect(chatId);
|
||||
updateTask.execute();
|
||||
this.setModal(true);
|
||||
this.setModal(false);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
|
@ -134,7 +133,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
}
|
||||
|
||||
public void closeDialog() {
|
||||
updateTask.cancel(true);
|
||||
if (updateTask != null) updateTask.cancel(true);
|
||||
this.chatPanel.disconnect();
|
||||
setVisible(false);
|
||||
}
|
||||
|
|
@ -245,10 +244,15 @@ public class TableWaitingDialog extends MageDialog {
|
|||
}//GEN-LAST:event_btnStartActionPerformed
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
if (session.isTableOwner(roomId, tableId)) {
|
||||
session.removeTable(roomId, tableId);
|
||||
} else {
|
||||
session.leaveTable(roomId, tableId);
|
||||
try {
|
||||
if (session.isTableOwner(roomId, tableId)) {
|
||||
session.removeTable(roomId, tableId);
|
||||
} else {
|
||||
session.leaveTable(roomId, tableId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//swallow exception
|
||||
logger.error(e);
|
||||
}
|
||||
closeDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
|
@ -352,7 +356,7 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
|||
private UUID tableId;
|
||||
private TableWaitingDialog dialog;
|
||||
|
||||
private final static Logger logger = Logging.getLogger(TableWaitingDialog.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
|
||||
UpdateSeatsTask(Session session, UUID roomId, UUID tableId, TableWaitingDialog dialog) {
|
||||
this.session = session;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@
|
|||
|
||||
package mage.client.table;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import mage.Constants.MultiplayerAttackOption;
|
||||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.client.MageFrame;
|
||||
|
|
@ -43,6 +41,7 @@ import mage.client.chat.ChatPanel;
|
|||
import mage.client.components.MageComponents;
|
||||
import mage.client.dialog.JoinTableDialog;
|
||||
import mage.client.dialog.NewTableDialog;
|
||||
import mage.client.dialog.NewTournamentDialog;
|
||||
import mage.client.dialog.TableWaitingDialog;
|
||||
import mage.client.remote.MageRemoteException;
|
||||
import mage.client.remote.Session;
|
||||
|
|
@ -51,18 +50,16 @@ import mage.game.match.MatchOptions;
|
|||
import mage.sets.Sets;
|
||||
import mage.util.Logging;
|
||||
import mage.view.TableView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.client.dialog.NewTournamentDialog;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +68,7 @@ import mage.client.dialog.NewTournamentDialog;
|
|||
*/
|
||||
public class TablesPanel extends javax.swing.JPanel {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(TablesPanel.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(TablesPanel.class);
|
||||
|
||||
private TableTableModel tableModel;
|
||||
private UUID roomId;
|
||||
|
|
@ -102,8 +99,31 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
UUID gameId = (UUID)tableModel.getValueAt(modelRow, 7);
|
||||
String state = (String)tableModel.getValueAt(modelRow, 5);
|
||||
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 6);
|
||||
String owner = (String)tableModel.getValueAt(modelRow, 1);
|
||||
|
||||
if (state.equals("Join")) {
|
||||
if (owner.equals(session.getUserName())) {
|
||||
try {
|
||||
JDesktopPane desktopPane = (JDesktopPane)session.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||
for (JInternalFrame frame : windows) {
|
||||
if (frame.getTitle().equals("Waiting for players")) {
|
||||
frame.toFront();
|
||||
frame.setVisible(true);
|
||||
try {
|
||||
frame.setSelected(true);
|
||||
} catch (PropertyVetoException ve) {
|
||||
ve.printStackTrace();
|
||||
logger.error(ve);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isTournament) {
|
||||
logger.info("Joining tournament " + tableId);
|
||||
if (session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1))
|
||||
|
|
@ -174,10 +194,10 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
joinTableDialog = new JoinTableDialog();
|
||||
MageFrame.getDesktop().add(joinTableDialog);
|
||||
}
|
||||
if (tableWaitingDialog == null) {
|
||||
/*if (tableWaitingDialog == null) {
|
||||
tableWaitingDialog = new TableWaitingDialog();
|
||||
MageFrame.getDesktop().add(tableWaitingDialog);
|
||||
}
|
||||
}*/
|
||||
UUID chatRoomId = session.getRoomChatId(roomId);
|
||||
if (chatRoomId != null) {
|
||||
this.chatPanel.connect(chatRoomId);
|
||||
|
|
@ -194,8 +214,13 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public void hideTables() {
|
||||
if (tableWaitingDialog != null && tableWaitingDialog.isVisible()) {
|
||||
/*if (tableWaitingDialog != null && tableWaitingDialog.isVisible()) {
|
||||
tableWaitingDialog.closeDialog();
|
||||
}*/
|
||||
for (Component component : MageFrame.getDesktop().getComponents()) {
|
||||
if (component instanceof TableWaitingDialog) {
|
||||
((TableWaitingDialog)component).closeDialog();
|
||||
}
|
||||
}
|
||||
if (updateTask != null)
|
||||
updateTask.cancel(true);
|
||||
|
|
@ -304,6 +329,8 @@ 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) {
|
||||
tableWaitingDialog = new TableWaitingDialog();
|
||||
MageFrame.getDesktop().add(tableWaitingDialog);
|
||||
tableWaitingDialog.showDialog(roomId, newTableDialog.getTable().getTableId(), false);
|
||||
}
|
||||
}//GEN-LAST:event_btnNewTableActionPerformed
|
||||
|
|
@ -328,6 +355,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
}//GEN-LAST:event_btnQuickStartActionPerformed
|
||||
|
||||
private void btnNewTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTournamentActionPerformed
|
||||
newTournamentDialog = new NewTournamentDialog();
|
||||
MageFrame.getDesktop().add(newTournamentDialog);
|
||||
newTournamentDialog.showDialog(roomId);
|
||||
if (newTournamentDialog.getTable() != null) {
|
||||
tableWaitingDialog.showDialog(roomId, newTournamentDialog.getTable().getTableId(), true);
|
||||
|
|
@ -335,7 +364,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
}//GEN-LAST:event_btnNewTournamentActionPerformed
|
||||
|
||||
private void handleError(Exception ex) {
|
||||
logger.log(Level.SEVERE, "Error loading deck", ex);
|
||||
logger.fatal("Error loading deck: ", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
|
|
@ -439,7 +468,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
|||
private UUID roomId;
|
||||
private TablesPanel panel;
|
||||
|
||||
private final static Logger logger = Logging.getLogger(UpdateTablesTask.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(UpdateTablesTask.class);
|
||||
|
||||
UpdateTablesTask(Session session, UUID roomId, TablesPanel panel) {
|
||||
this.session = session;
|
||||
|
|
@ -468,7 +497,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<String>> {
|
|||
private UUID roomId;
|
||||
private ChatPanel chat;
|
||||
|
||||
private final static Logger logger = Logging.getLogger(UpdatePlayersTask.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(UpdatePlayersTask.class);
|
||||
|
||||
UpdatePlayersTask(Session session, UUID roomId, ChatPanel chat) {
|
||||
this.session = session;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue