mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
added some client window management + suppress calls when TablesPane is not visible
This commit is contained in:
parent
79583a6ec2
commit
d8fca737fd
27 changed files with 239 additions and 196 deletions
|
|
@ -38,7 +38,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.9</version>
|
<version>1.2.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mortennobel</groupId>
|
<groupId>com.mortennobel</groupId>
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
private Rectangle titleRectangle;
|
private Rectangle titleRectangle;
|
||||||
private final static MageVersion version = new MageVersion(0, 7, 3);
|
private final static MageVersion version = new MageVersion(0, 7, 3);
|
||||||
private UUID clientId;
|
private UUID clientId;
|
||||||
|
private static MagePane activeFrame;
|
||||||
|
|
||||||
private static Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
|
private static Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
|
||||||
private static Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>();
|
private static Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>();
|
||||||
|
|
@ -368,21 +369,15 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
MagePaneMenuItem menuItem;
|
MagePaneMenuItem menuItem;
|
||||||
|
|
||||||
for (int i = 0; i < windows.length; i++) {
|
for (int i = 0; i < windows.length; i++) {
|
||||||
JInternalFrame window = windows[i];
|
MagePane window = (MagePane) windows[i];
|
||||||
if (window.isVisible()) {
|
if (window.isVisible()) {
|
||||||
menuItem = new MagePaneMenuItem(window);
|
menuItem = new MagePaneMenuItem(window);
|
||||||
menuItem.setState(i == 0);
|
menuItem.setState(i == 0);
|
||||||
menuItem.addActionListener(new ActionListener() {
|
menuItem.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent ae) {
|
public void actionPerformed(ActionEvent ae) {
|
||||||
JInternalFrame frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
|
MagePane frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
|
||||||
frame.toFront();
|
setActive(frame);
|
||||||
frame.setVisible(true);
|
|
||||||
//frame.moveToFront();
|
|
||||||
try {
|
|
||||||
frame.setSelected(true);
|
|
||||||
} catch (PropertyVetoException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menuItem.setIcon(window.getFrameIcon());
|
menuItem.setIcon(window.getFrameIcon());
|
||||||
|
|
@ -418,69 +413,96 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setActive(MagePane frame) {
|
||||||
|
if (frame == null)
|
||||||
|
return;
|
||||||
|
logger.debug("Setting " + frame.getTitle() + " active");
|
||||||
|
if (activeFrame != null)
|
||||||
|
activeFrame.deactivated();
|
||||||
|
activeFrame = frame;
|
||||||
|
activeFrame.toFront();
|
||||||
|
try {
|
||||||
|
activeFrame.setSelected(true);
|
||||||
|
} catch (PropertyVetoException ex) {}
|
||||||
|
activeFrame.activated();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void deactivate(MagePane frame) {
|
||||||
|
frame.setVisible(false);
|
||||||
|
MagePane topmost = getTopMost(frame);
|
||||||
|
if (activeFrame != frame)
|
||||||
|
frame.deactivated();
|
||||||
|
setActive(topmost);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MagePane getTopMost(MagePane exclude) {
|
||||||
|
MagePane topmost = null;
|
||||||
|
int best = Integer.MAX_VALUE;
|
||||||
|
for (JInternalFrame frame: desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER)) {
|
||||||
|
if (frame.isVisible()) {
|
||||||
|
int z = desktopPane.getComponentZOrder(frame);
|
||||||
|
if (z < best) {
|
||||||
|
best = z;
|
||||||
|
topmost = (MagePane) frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return topmost;
|
||||||
|
}
|
||||||
|
|
||||||
public void showGame(UUID gameId, UUID playerId) {
|
public void showGame(UUID gameId, UUID playerId) {
|
||||||
try {
|
try {
|
||||||
GamePane gamePane = new GamePane();
|
GamePane gamePane = new GamePane();
|
||||||
desktopPane.add(gamePane, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||||
gamePane.setMaximum(true);
|
gamePane.setMaximum(true);
|
||||||
gamePane.setVisible(true);
|
gamePane.setVisible(true);
|
||||||
gamePane.toFront();
|
|
||||||
gamePane.showGame(gameId, playerId);
|
gamePane.showGame(gameId, playerId);
|
||||||
} catch (PropertyVetoException ex) {
|
setActive(gamePane);
|
||||||
logger.fatal(null, ex);
|
} catch (PropertyVetoException ex) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void watchGame(UUID gameId) {
|
public void watchGame(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
GamePane gamePane = new GamePane();
|
GamePane gamePane = new GamePane();
|
||||||
desktopPane.add(gamePane, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||||
gamePane.setMaximum(true);
|
gamePane.setMaximum(true);
|
||||||
gamePane.setVisible(true);
|
gamePane.setVisible(true);
|
||||||
gamePane.toFront();
|
|
||||||
gamePane.watchGame(gameId);
|
gamePane.watchGame(gameId);
|
||||||
} catch (PropertyVetoException ex) {
|
setActive(gamePane);
|
||||||
logger.fatal(null, ex);
|
} catch (PropertyVetoException ex) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replayGame(UUID gameId) {
|
public void replayGame(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
GamePane gamePane = new GamePane();
|
GamePane gamePane = new GamePane();
|
||||||
desktopPane.add(gamePane, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
desktopPane.add(gamePane, JLayeredPane.DEFAULT_LAYER);
|
||||||
gamePane.setMaximum(true);
|
gamePane.setMaximum(true);
|
||||||
gamePane.setVisible(true);
|
gamePane.setVisible(true);
|
||||||
gamePane.toFront();
|
|
||||||
gamePane.replayGame(gameId);
|
gamePane.replayGame(gameId);
|
||||||
} catch (PropertyVetoException ex) {
|
setActive(gamePane);
|
||||||
logger.fatal(null, ex);
|
} catch (PropertyVetoException ex) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDraft(UUID draftId) {
|
public void showDraft(UUID draftId) {
|
||||||
try {
|
try {
|
||||||
DraftPane draftPane = new DraftPane();
|
DraftPane draftPane = new DraftPane();
|
||||||
desktopPane.add(draftPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
desktopPane.add(draftPane, JLayeredPane.DEFAULT_LAYER);
|
||||||
draftPane.setMaximum(true);
|
draftPane.setMaximum(true);
|
||||||
draftPane.setVisible(true);
|
draftPane.setVisible(true);
|
||||||
draftPane.toFront();
|
|
||||||
draftPane.showDraft(draftId);
|
draftPane.showDraft(draftId);
|
||||||
} catch (PropertyVetoException ex) {
|
setActive(draftPane);
|
||||||
logger.fatal(null, ex);
|
} catch (PropertyVetoException ex) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTournament(UUID tournamentId) {
|
public void showTournament(UUID tournamentId) {
|
||||||
try {
|
try {
|
||||||
TournamentPane tournamentPane = new TournamentPane();
|
TournamentPane tournamentPane = new TournamentPane();
|
||||||
desktopPane.add(tournamentPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
desktopPane.add(tournamentPane, JLayeredPane.DEFAULT_LAYER);
|
||||||
tournamentPane.setMaximum(true);
|
tournamentPane.setMaximum(true);
|
||||||
tournamentPane.setVisible(true);
|
tournamentPane.setVisible(true);
|
||||||
tournamentPane.toFront();
|
|
||||||
tournamentPane.showTournament(tournamentId);
|
tournamentPane.showTournament(tournamentId);
|
||||||
} catch (PropertyVetoException ex) {
|
setActive(tournamentPane);
|
||||||
logger.fatal(null, ex);
|
} catch (PropertyVetoException ex) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean connect(Connection connection) {
|
public static boolean connect(Connection connection) {
|
||||||
|
|
@ -722,8 +744,8 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
|
|
||||||
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
|
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
|
||||||
this.tablesPane.setVisible(true);
|
this.tablesPane.setVisible(true);
|
||||||
this.tablesPane.toFront();
|
|
||||||
this.tablesPane.showTables();
|
this.tablesPane.showTables();
|
||||||
|
setActive(tablesPane);
|
||||||
}//GEN-LAST:event_btnGamesActionPerformed
|
}//GEN-LAST:event_btnGamesActionPerformed
|
||||||
|
|
||||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
||||||
|
|
@ -743,7 +765,7 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
|
|
||||||
private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed
|
private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed
|
||||||
AboutDialog aboutDialog = new AboutDialog();
|
AboutDialog aboutDialog = new AboutDialog();
|
||||||
desktopPane.add(aboutDialog);
|
desktopPane.add(aboutDialog, JLayeredPane.POPUP_LAYER);
|
||||||
aboutDialog.showDialog(version);
|
aboutDialog.showDialog(version);
|
||||||
}//GEN-LAST:event_btnAboutActionPerformed
|
}//GEN-LAST:event_btnAboutActionPerformed
|
||||||
|
|
||||||
|
|
@ -773,7 +795,7 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideGames() {
|
public void hideGames() {
|
||||||
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
|
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
|
||||||
for (JInternalFrame window: windows) {
|
for (JInternalFrame window: windows) {
|
||||||
if (window instanceof GamePane) {
|
if (window instanceof GamePane) {
|
||||||
GamePane gamePane = (GamePane) window;
|
GamePane gamePane = (GamePane) window;
|
||||||
|
|
@ -785,11 +807,11 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
|
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
|
||||||
try {
|
try {
|
||||||
DeckEditorPane deckEditorPane = new DeckEditorPane();
|
DeckEditorPane deckEditorPane = new DeckEditorPane();
|
||||||
desktopPane.add(deckEditorPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
desktopPane.add(deckEditorPane, JLayeredPane.DEFAULT_LAYER);
|
||||||
deckEditorPane.setMaximum(true);
|
deckEditorPane.setMaximum(true);
|
||||||
deckEditorPane.setVisible(true);
|
deckEditorPane.setVisible(true);
|
||||||
deckEditorPane.toFront();
|
|
||||||
deckEditorPane.show(mode, deck, tableId, time);
|
deckEditorPane.show(mode, deck, tableId, time);
|
||||||
|
setActive(deckEditorPane);
|
||||||
} catch (PropertyVetoException ex) {
|
} catch (PropertyVetoException ex) {
|
||||||
logger.fatal(null, ex);
|
logger.fatal(null, ex);
|
||||||
}
|
}
|
||||||
|
|
@ -797,7 +819,7 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
|
|
||||||
public void showCollectionViewer() {
|
public void showCollectionViewer() {
|
||||||
this.collectionViewerPane.setVisible(true);
|
this.collectionViewerPane.setVisible(true);
|
||||||
this.collectionViewerPane.toFront();
|
setActive(collectionViewerPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void renderSplashFrame(Graphics2D g) {
|
static void renderSplashFrame(Graphics2D g) {
|
||||||
|
|
@ -932,14 +954,14 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
||||||
private JInternalFrame frame;
|
private MagePane frame;
|
||||||
|
|
||||||
public MagePaneMenuItem(JInternalFrame frame) {
|
public MagePaneMenuItem(MagePane frame) {
|
||||||
super(frame.getTitle());
|
super(frame.getTitle());
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JInternalFrame getFrame() {
|
public MagePane getFrame() {
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -34,19 +34,16 @@
|
||||||
|
|
||||||
package mage.client;
|
package mage.client;
|
||||||
|
|
||||||
import java.beans.PropertyVetoException;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.swing.JLayeredPane;
|
|
||||||
import javax.swing.event.InternalFrameEvent;
|
|
||||||
import javax.swing.event.InternalFrameListener;
|
|
||||||
import javax.swing.plaf.basic.BasicInternalFrameUI;
|
import javax.swing.plaf.basic.BasicInternalFrameUI;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class MagePane extends javax.swing.JInternalFrame implements InternalFrameListener {
|
public abstract class MagePane extends javax.swing.JInternalFrame {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MagePane.class);
|
||||||
|
|
||||||
/** Creates new form MagePane */
|
/** Creates new form MagePane */
|
||||||
public MagePane() {
|
public MagePane() {
|
||||||
|
|
@ -65,6 +62,17 @@ public class MagePane extends javax.swing.JInternalFrame implements InternalFram
|
||||||
hideTitle();
|
hideTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hideFrame() {
|
||||||
|
MageFrame.deactivate(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void activated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deactivated() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
|
|
@ -95,36 +103,4 @@ public class MagePane extends javax.swing.JInternalFrame implements InternalFram
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameOpened(InternalFrameEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameClosing(InternalFrameEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameClosed(InternalFrameEvent e) {
|
|
||||||
try {
|
|
||||||
MageFrame.getDesktop().getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER)[0].setSelected(true);
|
|
||||||
} catch (PropertyVetoException ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameIconified(InternalFrameEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameDeiconified(InternalFrameEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameActivated(InternalFrameEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameDeactivated(InternalFrameEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null)
|
if (c != null)
|
||||||
c.setVisible(false);
|
((DeckEditorPane)c).hideFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigCard getBigCard() {
|
private BigCard getBigCard() {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel3" pref="48" max="32767" attributes="0"/>
|
<Component id="jLabel3" pref="52" max="32767" attributes="0"/>
|
||||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||||
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
|
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
|
||||||
import mage.utils.MageVersion;
|
import mage.utils.MageVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,7 +122,7 @@ public class AboutDialog extends MageDialog {
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnOkActionPerformed
|
}//GEN-LAST:event_btnOkActionPerformed
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
||||||
|
|
@ -213,7 +213,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
for (int i = 0; i < nSwamp; i++) {
|
for (int i = 0; i < nSwamp; i++) {
|
||||||
deck.getCards().add(Sets.findCard("Swamp", true));
|
deck.getCards().add(Sets.findCard("Swamp", true));
|
||||||
}
|
}
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnAddActionPerformed
|
}//GEN-LAST:event_btnAddActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,10 +111,11 @@ public class CombatDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void hideDialog() {
|
public void hideDialog() {
|
||||||
this.lastX = this.getX();
|
this.lastX = this.getX();
|
||||||
this.lastY = this.getY();
|
this.lastY = this.getY();
|
||||||
this.setVisible(false);
|
super.hideDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="pnlProxy" min="-2" max="-2" attributes="0"/>
|
<Component id="pnlProxy" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace pref="30" max="32767" attributes="0"/>
|
<EmptySpace pref="34" max="32767" attributes="0"/>
|
||||||
<Component id="pnlProxyAuth" min="-2" max="-2" attributes="0"/>
|
<Component id="pnlProxyAuth" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
@ -383,7 +385,7 @@ public class ConnectDialog extends MageDialog {
|
||||||
if (task != null && !task.isDone())
|
if (task != null && !task.isDone())
|
||||||
task.cancel(true);
|
task.cancel(true);
|
||||||
else
|
else
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
||||||
|
|
@ -443,22 +445,28 @@ public class ConnectDialog extends MageDialog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
try {
|
||||||
btnConnect.setEnabled(true);
|
get();
|
||||||
if (result) {
|
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
lblStatus.setText("");
|
btnConnect.setEnabled(true);
|
||||||
connected();
|
if (result) {
|
||||||
}
|
lblStatus.setText("");
|
||||||
else {
|
connected();
|
||||||
lblStatus.setText("Could not connect");
|
}
|
||||||
}
|
else {
|
||||||
|
lblStatus.setText("Could not connect");
|
||||||
|
}
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
logger.fatal("Update Players Task error", ex);
|
||||||
|
} catch (ExecutionException ex) {
|
||||||
|
logger.fatal("Update Players Task error", ex);
|
||||||
|
} catch (CancellationException ex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connected() {
|
private void connected() {
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public class ExileZoneDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hide();
|
this.hideDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ public class JoinTableDialog extends MageDialog {
|
||||||
|
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
this.joined = false;
|
this.joined = false;
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
|
|
@ -140,7 +140,7 @@ public class JoinTableDialog extends MageDialog {
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
}
|
}
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnOKActionPerformed
|
}//GEN-LAST:event_btnOKActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<EmptySpace min="0" pref="310" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="314" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,8 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean value) {
|
public void setVisible(boolean value) {
|
||||||
super.setVisible(value);
|
super.setVisible(value);
|
||||||
this.toFront();
|
if (value)
|
||||||
|
this.toFront();
|
||||||
if (modal) {
|
if (modal) {
|
||||||
this.setClosable(false);
|
this.setClosable(false);
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|
@ -151,6 +152,10 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
return this.modal;
|
return this.modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void hideDialog() {
|
||||||
|
this.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
this.table = null;
|
this.table = null;
|
||||||
this.playerId = null;
|
this.playerId = null;
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
|
|
@ -332,7 +332,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
|
|
@ -421,7 +421,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
setGameOptions();
|
setGameOptions();
|
||||||
this.setLocation(150, 100);
|
this.setLocation(150, 100);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableView getTable() {
|
public TableView getTable() {
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
@ -333,7 +333,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
this.table = null;
|
this.table = null;
|
||||||
this.playerId = null;
|
this.playerId = null;
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
private void spnNumPlayersStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumPlayersStateChanged
|
private void spnNumPlayersStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumPlayersStateChanged
|
||||||
|
|
|
||||||
|
|
@ -132,11 +132,11 @@ public class PickChoiceDialog extends MageDialog {
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnOkActionPerformed
|
}//GEN-LAST:event_btnOkActionPerformed
|
||||||
|
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
|
|
||||||
|
|
@ -145,12 +145,12 @@ public class PickNumberDialog extends MageDialog {
|
||||||
|
|
||||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||||
this.cancel = false;
|
this.cancel = false;
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnOkActionPerformed
|
}//GEN-LAST:event_btnOkActionPerformed
|
||||||
|
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
this.cancel = true;
|
this.cancel = true;
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
|
|
||||||
|
|
@ -119,12 +119,12 @@ public class QuestionDialog extends MageDialog {
|
||||||
|
|
||||||
private void btnYesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnYesActionPerformed
|
private void btnYesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnYesActionPerformed
|
||||||
this.answer = true;
|
this.answer = true;
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnYesActionPerformed
|
}//GEN-LAST:event_btnYesActionPerformed
|
||||||
|
|
||||||
private void btnNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoActionPerformed
|
private void btnNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoActionPerformed
|
||||||
this.answer = false;
|
this.answer = false;
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}//GEN-LAST:event_btnNoActionPerformed
|
}//GEN-LAST:event_btnNoActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,24 +172,19 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
this.setVisible(false);
|
this.hideDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mousePressed(MouseEvent e) {
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ package mage.client.dialog;
|
||||||
import mage.client.*;
|
import mage.client.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
|
|
@ -134,7 +136,7 @@ public class TableWaitingDialog extends MageDialog {
|
||||||
public void closeDialog() {
|
public void closeDialog() {
|
||||||
if (updateTask != null) updateTask.cancel(true);
|
if (updateTask != null) updateTask.cancel(true);
|
||||||
this.chatPanel.disconnect();
|
this.chatPanel.disconnect();
|
||||||
setVisible(false);
|
this.hideDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -379,4 +381,15 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||||
dialog.update(view.get(0));
|
dialog.update(view.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
try {
|
||||||
|
get();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
logger.fatal("Update Seats Task error", ex);
|
||||||
|
} catch (ExecutionException ex) {
|
||||||
|
logger.fatal("Update Seats Task error", ex);
|
||||||
|
} catch (CancellationException ex) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -133,8 +133,9 @@ public class DraftPanel extends javax.swing.JPanel {
|
||||||
while (c != null && !(c instanceof DraftPane)) {
|
while (c != null && !(c instanceof DraftPane)) {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null)
|
if (c != null) {
|
||||||
c.setVisible(false);
|
((DraftPane)c).hideFrame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setMessage(String message) {
|
protected void setMessage(String message) {
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ package mage.client.game;
|
||||||
|
|
||||||
import mage.client.*;
|
import mage.client.*;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.event.InternalFrameEvent;
|
|
||||||
import javax.swing.event.InternalFrameListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -48,39 +46,11 @@ public class GamePane extends MagePane {
|
||||||
/** Creates new form GamePane */
|
/** Creates new form GamePane */
|
||||||
public GamePane() {
|
public GamePane() {
|
||||||
initComponents();
|
initComponents();
|
||||||
addInternalFrameListener(new InternalFrameListener()
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameOpened(InternalFrameEvent e) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameClosing(InternalFrameEvent e) {
|
|
||||||
gamePanel.cleanUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameClosed(InternalFrameEvent e) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameIconified(InternalFrameEvent e) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameDeiconified(InternalFrameEvent e) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameActivated(InternalFrameEvent e) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void internalFrameDeactivated(InternalFrameEvent e) { }
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showGame(UUID gameId, UUID playerId) {
|
public void showGame(UUID gameId, UUID playerId) {
|
||||||
this.setTitle("Game " + gameId);
|
this.setTitle("Game " + gameId);
|
||||||
gamePanel.showGame(gameId, playerId);
|
gamePanel.showGame(gameId, playerId);
|
||||||
this.toFront();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideGame() {
|
public void hideGame() {
|
||||||
|
|
@ -90,13 +60,11 @@ public class GamePane extends MagePane {
|
||||||
public void watchGame(UUID gameId) {
|
public void watchGame(UUID gameId) {
|
||||||
this.setTitle("Watching " + gameId);
|
this.setTitle("Watching " + gameId);
|
||||||
gamePanel.watchGame(gameId);
|
gamePanel.watchGame(gameId);
|
||||||
this.toFront();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replayGame(UUID gameId) {
|
public void replayGame(UUID gameId) {
|
||||||
this.setTitle("Replaying " + gameId);
|
this.setTitle("Replaying " + gameId);
|
||||||
gamePanel.replayGame(gameId);
|
gamePanel.replayGame(gameId);
|
||||||
this.toFront();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
|
|
@ -133,4 +101,9 @@ public class GamePane extends MagePane {
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deactivated() {
|
||||||
|
gamePanel.cleanUp();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,13 +139,17 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
|
this.chatPanel.disconnect();
|
||||||
|
this.players.clear();
|
||||||
|
logger.debug("players clear.");
|
||||||
|
this.pnlBattlefield.removeAll();
|
||||||
combat.hideDialog();
|
combat.hideDialog();
|
||||||
pickNumber.hide();
|
pickNumber.hideDialog();
|
||||||
for (ExileZoneDialog exile: exiles.values()) {
|
for (ExileZoneDialog exile: exiles.values()) {
|
||||||
exile.hide();
|
exile.hideDialog();
|
||||||
}
|
}
|
||||||
for (ShowCardsDialog reveal: revealed.values()) {
|
for (ShowCardsDialog reveal: revealed.values()) {
|
||||||
reveal.hide();
|
reveal.hideDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,7 +164,6 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
this.btnConcede.setVisible(true);
|
this.btnConcede.setVisible(true);
|
||||||
this.pnlReplay.setVisible(false);
|
this.pnlReplay.setVisible(false);
|
||||||
this.btnStopWatching.setVisible(false);
|
this.btnStopWatching.setVisible(false);
|
||||||
this.setVisible(true);
|
|
||||||
this.chatPanel.clear();
|
this.chatPanel.clear();
|
||||||
this.chatPanel.connect(session.getGameChatId(gameId));
|
this.chatPanel.connect(session.getGameChatId(gameId));
|
||||||
if (!session.joinGame(gameId))
|
if (!session.joinGame(gameId))
|
||||||
|
|
@ -177,7 +180,6 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
this.btnConcede.setVisible(false);
|
this.btnConcede.setVisible(false);
|
||||||
this.btnStopWatching.setVisible(true);
|
this.btnStopWatching.setVisible(true);
|
||||||
this.pnlReplay.setVisible(false);
|
this.pnlReplay.setVisible(false);
|
||||||
this.setVisible(true);
|
|
||||||
this.chatPanel.clear();
|
this.chatPanel.clear();
|
||||||
this.chatPanel.connect(session.getGameChatId(gameId));
|
this.chatPanel.connect(session.getGameChatId(gameId));
|
||||||
if (!session.watchGame(gameId))
|
if (!session.watchGame(gameId))
|
||||||
|
|
@ -193,24 +195,19 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
this.btnConcede.setVisible(false);
|
this.btnConcede.setVisible(false);
|
||||||
this.btnStopWatching.setVisible(false);
|
this.btnStopWatching.setVisible(false);
|
||||||
this.pnlReplay.setVisible(true);
|
this.pnlReplay.setVisible(true);
|
||||||
this.setVisible(true);
|
|
||||||
this.chatPanel.clear();
|
this.chatPanel.clear();
|
||||||
if (!session.startReplay(gameId))
|
if (!session.startReplay(gameId))
|
||||||
hideGame();
|
hideGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideGame() {
|
public void hideGame() {
|
||||||
this.chatPanel.disconnect();
|
cleanUp();
|
||||||
this.players.clear();
|
|
||||||
logger.debug("players clear.");
|
|
||||||
this.pnlBattlefield.removeAll();
|
|
||||||
combat.hideDialog();
|
|
||||||
Component c = this.getParent();
|
Component c = this.getParent();
|
||||||
while (c != null && !(c instanceof GamePane)) {
|
while (c != null && !(c instanceof GamePane)) {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null)
|
if (c != null)
|
||||||
c.setVisible(false);
|
((GamePane)c).hideFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void init(GameView game) {
|
public synchronized void init(GameView game) {
|
||||||
|
|
|
||||||
|
|
@ -127,4 +127,13 @@ public class TablesPane extends MagePane {
|
||||||
private mage.client.table.TablesPanel tablesPanel;
|
private mage.client.table.TablesPanel tablesPanel;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activated() {
|
||||||
|
tablesPanel.startTasks();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deactivated() {
|
||||||
|
tablesPanel.stopTasks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ import java.awt.event.ActionEvent;
|
||||||
import java.beans.PropertyVetoException;
|
import java.beans.PropertyVetoException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -171,32 +173,49 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startTasks() {
|
||||||
|
if (session != null) {
|
||||||
|
if (updateTask == null || updateTask.isDone()) {
|
||||||
|
updateTask = new UpdateTablesTask(session, roomId, this);
|
||||||
|
updateTask.execute();
|
||||||
|
}
|
||||||
|
if (updatePlayersTask == null || updatePlayersTask.isDone()) {
|
||||||
|
updatePlayersTask = new UpdatePlayersTask(session, roomId, this.chatPanel);
|
||||||
|
updatePlayersTask.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopTasks() {
|
||||||
|
if (updateTask != null)
|
||||||
|
updateTask.cancel(true);
|
||||||
|
if (updatePlayersTask != null)
|
||||||
|
updatePlayersTask.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
public void showTables(UUID roomId) {
|
public void showTables(UUID roomId) {
|
||||||
|
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
updateTask = new UpdateTablesTask(session, roomId, this);
|
|
||||||
updatePlayersTask = new UpdatePlayersTask(session, roomId, this.chatPanel);
|
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
btnQuickStart.setVisible(session.isTestMode());
|
btnQuickStart.setVisible(session.isTestMode());
|
||||||
}
|
}
|
||||||
if (newTableDialog == null) {
|
if (newTableDialog == null) {
|
||||||
newTableDialog = new NewTableDialog();
|
newTableDialog = new NewTableDialog();
|
||||||
MageFrame.getDesktop().add(newTableDialog);
|
MageFrame.getDesktop().add(newTableDialog, JLayeredPane.MODAL_LAYER);
|
||||||
}
|
}
|
||||||
if (newTournamentDialog == null) {
|
if (newTournamentDialog == null) {
|
||||||
newTournamentDialog = new NewTournamentDialog();
|
newTournamentDialog = new NewTournamentDialog();
|
||||||
MageFrame.getDesktop().add(newTournamentDialog);
|
MageFrame.getDesktop().add(newTournamentDialog, JLayeredPane.MODAL_LAYER);
|
||||||
}
|
}
|
||||||
if (joinTableDialog == null) {
|
if (joinTableDialog == null) {
|
||||||
joinTableDialog = new JoinTableDialog();
|
joinTableDialog = new JoinTableDialog();
|
||||||
MageFrame.getDesktop().add(joinTableDialog);
|
MageFrame.getDesktop().add(joinTableDialog, JLayeredPane.MODAL_LAYER);
|
||||||
}
|
}
|
||||||
UUID chatRoomId = session.getRoomChatId(roomId);
|
UUID chatRoomId = session.getRoomChatId(roomId);
|
||||||
if (chatRoomId != null) {
|
if (chatRoomId != null) {
|
||||||
this.chatPanel.connect(chatRoomId);
|
this.chatPanel.connect(chatRoomId);
|
||||||
updateTask.execute();
|
startTasks();
|
||||||
updatePlayersTask.execute();
|
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
@ -213,10 +232,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
((TableWaitingDialog)component).closeDialog();
|
((TableWaitingDialog)component).closeDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updateTask != null)
|
stopTasks();
|
||||||
updateTask.cancel(true);
|
|
||||||
if (updatePlayersTask != null)
|
|
||||||
updatePlayersTask.cancel(true);
|
|
||||||
this.chatPanel.disconnect();
|
this.chatPanel.disconnect();
|
||||||
|
|
||||||
Component c = this.getParent();
|
Component c = this.getParent();
|
||||||
|
|
@ -224,7 +240,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null)
|
if (c != null)
|
||||||
c.setVisible(false);
|
((TablesPane)c).hideFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showTableWaitingDialog(UUID roomId, UUID tableId, boolean isTournament) {
|
private void showTableWaitingDialog(UUID roomId, UUID tableId, boolean isTournament) {
|
||||||
|
|
@ -349,8 +365,6 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
}//GEN-LAST:event_btnQuickStartActionPerformed
|
}//GEN-LAST:event_btnQuickStartActionPerformed
|
||||||
|
|
||||||
private void btnNewTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTournamentActionPerformed
|
private void btnNewTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTournamentActionPerformed
|
||||||
newTournamentDialog = new NewTournamentDialog();
|
|
||||||
MageFrame.getDesktop().add(newTournamentDialog);
|
|
||||||
newTournamentDialog.showDialog(roomId);
|
newTournamentDialog.showDialog(roomId);
|
||||||
if (newTournamentDialog.getTable() != null) {
|
if (newTournamentDialog.getTable() != null) {
|
||||||
showTableWaitingDialog(roomId, newTournamentDialog.getTable().getTableId(), true);
|
showTableWaitingDialog(roomId, newTournamentDialog.getTable().getTableId(), true);
|
||||||
|
|
@ -483,6 +497,18 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
|
||||||
protected void process(List<Collection<TableView>> view) {
|
protected void process(List<Collection<TableView>> view) {
|
||||||
panel.update(view.get(0));
|
panel.update(view.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
try {
|
||||||
|
get();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
logger.fatal("Update Tables Task error", ex);
|
||||||
|
} catch (ExecutionException ex) {
|
||||||
|
logger.fatal("Update Tables Task error", ex);
|
||||||
|
} catch (CancellationException ex) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdatePlayersTask extends SwingWorker<Void, Collection<String>> {
|
class UpdatePlayersTask extends SwingWorker<Void, Collection<String>> {
|
||||||
|
|
@ -512,4 +538,16 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<String>> {
|
||||||
protected void process(List<Collection<String>> players) {
|
protected void process(List<Collection<String>> players) {
|
||||||
chat.setPlayers(players.get(0));
|
chat.setPlayers(players.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
try {
|
||||||
|
get();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
logger.fatal("Update Players Task error", ex);
|
||||||
|
} catch (ExecutionException ex) {
|
||||||
|
logger.fatal("Update Players Task error", ex);
|
||||||
|
} catch (CancellationException ex) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +115,13 @@ public class TournamentPanel extends javax.swing.JPanel implements Observer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideTournament() {
|
public void hideTournament() {
|
||||||
this.setVisible(false);
|
Component c = this.getParent();
|
||||||
|
while (c != null && !(c instanceof TournamentPane)) {
|
||||||
|
c = c.getParent();
|
||||||
|
}
|
||||||
|
if (c != null) {
|
||||||
|
((TournamentPane)c).hideFrame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue