forked from External/mage
Removed more memory leaks in game and editor panes and panels of client.
This commit is contained in:
parent
48a7e52701
commit
dda33f86a4
12 changed files with 199 additions and 95 deletions
|
|
@ -68,6 +68,10 @@ public abstract class MagePane extends javax.swing.JInternalFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideFrame() {
|
public void hideFrame() {
|
||||||
|
MageFrame.deactivate(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFrame() {
|
||||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
|
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
|
||||||
try {
|
try {
|
||||||
this.setClosed(true);
|
this.setClosed(true);
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,9 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
cardEventSource.clearListeners();
|
cardEventSource.clearListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void hidePopup() {
|
||||||
|
Plugins.getInstance().getActionCallback().mouseExited(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
|
|
@ -173,6 +176,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||||
Object obj = e.getSource();
|
Object obj = e.getSource();
|
||||||
if (obj instanceof MageCard) {
|
if (obj instanceof MageCard) {
|
||||||
this.cardEventSource.doubleClick(((MageCard)obj).getOriginal(), "pick-a-card");
|
this.cardEventSource.doubleClick(((MageCard)obj).getOriginal(), "pick-a-card");
|
||||||
|
this.hidePopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,12 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
for(MouseListener ml: this.getMouseListeners()) {
|
||||||
|
this.removeMouseListener(ml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void show(AbilityPickerView choices, Point p) {
|
public void show(AbilityPickerView choices, Point p) {
|
||||||
this.choices = new ArrayList<Object>();
|
this.choices = new ArrayList<Object>();
|
||||||
this.selected = true; // to stop previous modal
|
this.selected = true; // to stop previous modal
|
||||||
|
|
@ -111,7 +117,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
//startModal();
|
//startModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initComponents() {
|
private void initComponents() {
|
||||||
JLabel jLabel1;
|
JLabel jLabel1;
|
||||||
JLabel jLabel3;
|
JLabel jLabel3;
|
||||||
|
|
||||||
|
|
@ -156,7 +162,9 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
rows.setMaximumSize(new Dimension(32767, 32767));
|
rows.setMaximumSize(new Dimension(32767, 32767));
|
||||||
rows.setMinimumSize(new Dimension(67, 16));
|
rows.setMinimumSize(new Dimension(67, 16));
|
||||||
rows.setOpaque(false);
|
rows.setOpaque(false);
|
||||||
|
|
||||||
rows.addMouseListener(new MouseAdapter() {
|
rows.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
public void mousePressed(MouseEvent evt) {
|
public void mousePressed(MouseEvent evt) {
|
||||||
if (evt.getButton() == MouseEvent.BUTTON1) {
|
if (evt.getButton() == MouseEvent.BUTTON1) {
|
||||||
objectMouseClicked(evt);
|
objectMouseClicked(evt);
|
||||||
|
|
@ -230,6 +238,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
|
|
||||||
public final Map<String, String> cache = new HashMap<String, String>();
|
public final Map<String, String> cache = new HashMap<String, String>();
|
||||||
|
|
||||||
|
@Override
|
||||||
public Component getListCellRendererComponent(
|
public Component getListCellRendererComponent(
|
||||||
javax.swing.JList list,
|
javax.swing.JList list,
|
||||||
Object value,
|
Object value,
|
||||||
|
|
@ -302,6 +311,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
|
|
||||||
class ImageRenderer extends DefaultListCellRenderer {
|
class ImageRenderer extends DefaultListCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
|
||||||
|
|
@ -310,7 +320,9 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
label.setOpaque(false);
|
label.setOpaque(false);
|
||||||
label.setForeground(Color.white);
|
label.setForeground(Color.white);
|
||||||
|
|
||||||
if (choices.size() <= index) return label;
|
if (choices.size() <= index) {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
Object object = choices.get(index);
|
Object object = choices.get(index);
|
||||||
String name = object.toString();
|
String name = object.toString();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
package mage.client.components.ext.dlg;
|
package mage.client.components.ext.dlg;
|
||||||
|
|
||||||
import mage.client.cards.BigCard;
|
import java.awt.Component;
|
||||||
import mage.client.game.FeedbackPanel;
|
import java.awt.Rectangle;
|
||||||
import mage.view.CardsView;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
|
|
@ -13,6 +9,10 @@ import java.awt.event.MouseWheelEvent;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import mage.client.cards.BigCard;
|
||||||
|
import mage.client.game.FeedbackPanel;
|
||||||
|
import mage.view.CardsView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author mw, noxx
|
* @author mw, noxx
|
||||||
|
|
@ -20,8 +20,7 @@ import java.util.UUID;
|
||||||
public class DialogManager extends JComponent implements MouseListener,
|
public class DialogManager extends JComponent implements MouseListener,
|
||||||
MouseMotionListener {
|
MouseMotionListener {
|
||||||
|
|
||||||
private static Map<UUID, DialogManager> dialogManagers = new HashMap<UUID, DialogManager>();
|
private final static Map<UUID, DialogManager> dialogManagers = new HashMap<UUID, DialogManager>();
|
||||||
//private static final Logger log = Logger.getLogger(DialogManager.class);
|
|
||||||
|
|
||||||
public static DialogManager getManager(UUID gameId) {
|
public static DialogManager getManager(UUID gameId) {
|
||||||
if (!dialogManagers.containsKey(gameId)) {
|
if (!dialogManagers.containsKey(gameId)) {
|
||||||
|
|
@ -44,6 +43,21 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
ChooseDeckDialog, ChooseCommonDialog, RevealDialog
|
ChooseDeckDialog, ChooseCommonDialog, RevealDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the DialogManager of the gameId
|
||||||
|
*
|
||||||
|
* @param gameId
|
||||||
|
*/
|
||||||
|
public static void removeGame(UUID gameId) {
|
||||||
|
if (!dialogManagers.containsKey(gameId)) {
|
||||||
|
synchronized (dialogManagers) {
|
||||||
|
DialogManager dialogManager = dialogManagers.get(gameId);
|
||||||
|
dialogManager.cleanUp();
|
||||||
|
dialogManagers.remove(gameId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private MTGDialogs currentDialog = MTGDialogs.none;
|
private MTGDialogs currentDialog = MTGDialogs.none;
|
||||||
|
|
||||||
private DialogContainer dialogContainer = null;
|
private DialogContainer dialogContainer = null;
|
||||||
|
|
@ -62,7 +76,14 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
public DialogManager() {
|
public DialogManager() {
|
||||||
addMouseListener(this);
|
addMouseListener(this);
|
||||||
addMouseMotionListener(this);
|
addMouseMotionListener(this);
|
||||||
//addMouseWheelListener(this);
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
this.currentDialog = null;
|
||||||
|
this.dialogContainer = null;
|
||||||
|
this.removeMouseListener(this);
|
||||||
|
this.removeMouseMotionListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScreenWidth(int screen_width) {
|
public void setScreenWidth(int screen_width) {
|
||||||
|
|
@ -224,6 +245,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
validate();
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void mouseDragged(MouseEvent e) {
|
public void mouseDragged(MouseEvent e) {
|
||||||
if (bDragged == true) {
|
if (bDragged == true) {
|
||||||
dx = e.getX() - mx;
|
dx = e.getX() - mx;
|
||||||
|
|
@ -244,18 +266,23 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||||
j = (JComponent) getComponentAt(e.getX(), e.getY());
|
j = (JComponent) getComponentAt(e.getX(), e.getY());
|
||||||
|
|
@ -269,6 +296,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
bDragged = false;
|
bDragged = false;
|
||||||
if (j instanceof DialogManager) {
|
if (j instanceof DialogManager) {
|
||||||
|
|
@ -279,18 +307,21 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
j.setBounds(rec);
|
j.setBounds(rec);
|
||||||
}
|
}
|
||||||
oldRec = null;
|
oldRec = null;
|
||||||
if (rec == null)
|
if (rec == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (rec.x < 0) {
|
if (rec.x < 0) {
|
||||||
rec.x = 0;
|
rec.x = 0;
|
||||||
if (j != null)
|
if (j != null) {
|
||||||
j.setBounds(rec);
|
j.setBounds(rec);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (rec.y < 0) {
|
if (rec.y < 0) {
|
||||||
rec.y = 0;
|
rec.y = 0;
|
||||||
if (j != null)
|
if (j != null) {
|
||||||
j.setBounds(rec);
|
j.setBounds(rec);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
j = null;
|
j = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
setTimeout(0);
|
setTimeout(0);
|
||||||
countdown.stop();
|
countdown.stop();
|
||||||
hideDeckEditor();
|
removeDeckEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -130,6 +130,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
updateDeckTask.cancel(true);
|
updateDeckTask.cancel(true);
|
||||||
}
|
}
|
||||||
if (countdown != null) {
|
if (countdown != null) {
|
||||||
|
if (countdown.isRunning()) {
|
||||||
|
countdown.stop();
|
||||||
|
}
|
||||||
for (ActionListener al : countdown.getActionListeners()) {
|
for (ActionListener al : countdown.getActionListeners()) {
|
||||||
countdown.removeActionListener(al);
|
countdown.removeActionListener(al);
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +156,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.txtTimeRemaining.setVisible(true);
|
this.txtTimeRemaining.setVisible(true);
|
||||||
case Sideboard:
|
case Sideboard:
|
||||||
this.btnSubmit.setVisible(true);
|
this.btnSubmit.setVisible(true);
|
||||||
|
if (deck != null) {
|
||||||
this.cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
|
this.cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
|
||||||
|
}
|
||||||
// TODO: take from preferences
|
// TODO: take from preferences
|
||||||
this.cardSelector.switchToGrid();
|
this.cardSelector.switchToGrid();
|
||||||
|
|
||||||
|
|
@ -312,7 +317,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
Plugins.getInstance().getActionCallback().mouseExited(null, null);
|
Plugins.getInstance().getActionCallback().mouseExited(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideDeckEditor() {
|
public void removeDeckEditor() {
|
||||||
|
hidePopup();
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
||||||
Component c = this.getParent();
|
Component c = this.getParent();
|
||||||
|
|
@ -320,7 +326,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
((DeckEditorPane) c).hideFrame();
|
((DeckEditorPane) c).removeFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -610,7 +616,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}//GEN-LAST:event_btnNewActionPerformed
|
}//GEN-LAST:event_btnNewActionPerformed
|
||||||
|
|
||||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
||||||
hideDeckEditor();
|
removeDeckEditor();
|
||||||
}//GEN-LAST:event_btnExitActionPerformed
|
}//GEN-LAST:event_btnExitActionPerformed
|
||||||
|
|
||||||
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
|
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
|
||||||
|
|
@ -655,7 +661,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists())) {
|
if (MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists())) {
|
||||||
hideDeckEditor();
|
removeDeckEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* ************************ U N U S E D *********************************
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -50,7 +52,7 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||||
private Session session;
|
private Session session;
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
|
|
||||||
public AbilityPicker() {
|
public AbilityPicker(String ThisIsnotUsedAnymore) {
|
||||||
this.addPopupMenuListener(this);
|
this.addPopupMenuListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,8 +61,14 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
this.removePopupMenuListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void show(AbilityPickerView choices, Point p) {
|
public void show(AbilityPickerView choices, Point p) {
|
||||||
if (p == null) return;
|
if (p == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.removeAll();
|
this.removeAll();
|
||||||
for (Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
for (Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||||
this.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
this.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,9 @@
|
||||||
|
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.KeyboardFocusManager;
|
import java.awt.KeyboardFocusManager;
|
||||||
import java.beans.PropertyVetoException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import mage.client.MageFrame;
|
|
||||||
import mage.client.MagePane;
|
import mage.client.MagePane;
|
||||||
import mage.client.dialog.MageDialog;
|
import mage.client.dialog.MageDialog;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
@ -72,32 +69,16 @@ public class GamePane extends MagePane {
|
||||||
gamePanel.showGame(gameId, playerId);
|
gamePanel.showGame(gameId, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
gamePanel.cleanUp();
|
||||||
|
this.getInputMap().clear();
|
||||||
|
this.getActionMap().clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void hideGame() {
|
public void hideGame() {
|
||||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
|
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
|
||||||
gamePanel.cleanUp();
|
this.cleanUp();
|
||||||
|
this.removeFrame();
|
||||||
try {
|
|
||||||
this.setClosed(true);
|
|
||||||
} catch (PropertyVetoException ex) {
|
|
||||||
logger.fatal("Closing Game: setClosed - ", ex);
|
|
||||||
}
|
|
||||||
MageFrame.deactivate(this);
|
|
||||||
MageFrame.getDesktop().remove(this);
|
|
||||||
|
|
||||||
logger.warn("Remove Dialog " + this.getClass().getName() + " Components left: "+ this.getComponentCount());
|
|
||||||
|
|
||||||
for (Component comp: this.getComponents()) {
|
|
||||||
logger.warn("Existing Component: " + comp.getClass().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.getUI().uninstallUI(this);
|
|
||||||
// this.removeAll();
|
|
||||||
// this.dispose();
|
|
||||||
// this.setClosed(true);
|
|
||||||
// } catch (PropertyVetoException ex) {
|
|
||||||
// Logger.getLogger(GamePane.class.getName()).log(Level.SEVERE, "GamePane could not be closed", ex);
|
|
||||||
// this.dispose();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void watchGame(UUID gameId) {
|
public void watchGame(UUID gameId) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.awt.event.ComponentListener;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
|
|
@ -199,39 +200,28 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
MageFrame.removeGame(gameId);
|
MageFrame.removeGame(gameId);
|
||||||
saveDividerLocations();
|
saveDividerLocations();
|
||||||
this.gameChatPanel.disconnect();
|
this.gameChatPanel.disconnect();
|
||||||
|
this.userChatPanel.disconnect();
|
||||||
|
|
||||||
for (MouseListener ml :this.getMouseListeners()) {
|
this.removeListener();
|
||||||
this.removeMouseListener(ml);
|
|
||||||
}
|
|
||||||
for (MouseListener ml :this.btnConcede.getMouseListeners()) {
|
|
||||||
this.btnConcede.removeMouseListener(ml);
|
|
||||||
}
|
|
||||||
for (MouseListener ml :this.btnEndTurn.getMouseListeners()) {
|
|
||||||
this.btnEndTurn.removeMouseListener(ml);
|
|
||||||
}
|
|
||||||
for (MouseListener ml :this.btnSwitchHands.getMouseListeners()) {
|
|
||||||
this.btnSwitchHands.removeMouseListener(ml);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ActionListener al :this.btnStopWatching.getActionListeners()) {
|
|
||||||
this.btnStopWatching.removeActionListener(al);
|
|
||||||
}
|
|
||||||
for (ActionListener al :this.btnNextPlay.getActionListeners()) {
|
|
||||||
this.btnNextPlay.removeActionListener(al);
|
|
||||||
}
|
|
||||||
for(Map.Entry<UUID, PlayAreaPanel> playAreaPanelEntry: players.entrySet()) {
|
for(Map.Entry<UUID, PlayAreaPanel> playAreaPanelEntry: players.entrySet()) {
|
||||||
playAreaPanelEntry.getValue().CleanUp();
|
playAreaPanelEntry.getValue().CleanUp();
|
||||||
// playAreaPanelEntry.getValue().getUI().uninstallUI(playAreaPanelEntry.getValue());
|
|
||||||
// playAreaPanelEntry.getValue().removeAll();
|
|
||||||
}
|
}
|
||||||
this.players.clear();
|
this.players.clear();
|
||||||
|
|
||||||
this.pnlBattlefield.removeAll();
|
jLayeredPane.remove(abilityPicker);
|
||||||
|
this.abilityPicker.cleanUp();
|
||||||
|
|
||||||
this.getUI().uninstallUI(this);
|
jLayeredPane.remove(DialogManager.getManager(gameId));
|
||||||
|
DialogManager.removeGame(gameId);
|
||||||
|
|
||||||
|
this.getInputMap().clear();
|
||||||
|
this.getActionMap().clear();
|
||||||
|
|
||||||
|
// this.pnlBattlefield.removeAll();
|
||||||
|
// this.getUI().uninstallUI(this);
|
||||||
|
|
||||||
if (pickNumber != null) {
|
if (pickNumber != null) {
|
||||||
MageFrame.getDesktop().remove(pickNumber);
|
|
||||||
pickNumber.removeDialog();
|
pickNumber.removeDialog();
|
||||||
}
|
}
|
||||||
for (ExileZoneDialog exile: exiles.values()) {
|
for (ExileZoneDialog exile: exiles.values()) {
|
||||||
|
|
@ -240,8 +230,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
for (ShowCardsDialog reveal: revealed.values()) {
|
for (ShowCardsDialog reveal: revealed.values()) {
|
||||||
reveal.hideDialog();
|
reveal.hideDialog();
|
||||||
}
|
}
|
||||||
this.jSplitPane0.getUI().uninstallUI(jSplitPane0);
|
|
||||||
this.jSplitPane0.removeAll();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||||
|
|
@ -249,7 +237,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
logger.fatal("popupContainer error:", ex);
|
logger.fatal("popupContainer error:", ex);
|
||||||
}
|
}
|
||||||
// this.removeAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveDividerLocations() {
|
private void saveDividerLocations() {
|
||||||
|
|
@ -877,8 +864,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
int c = JComponent.WHEN_IN_FOCUSED_WINDOW;
|
int c = JComponent.WHEN_IN_FOCUSED_WINDOW;
|
||||||
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0);
|
|
||||||
|
|
||||||
|
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0);
|
||||||
this.getInputMap(c).put(ks, "F4_PRESS");
|
this.getInputMap(c).put(ks, "F4_PRESS");
|
||||||
this.getActionMap().put("F4_PRESS", new AbstractAction() {
|
this.getActionMap().put("F4_PRESS", new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1028,6 +1015,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Replay panel to control replay of games
|
||||||
javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
|
javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
|
||||||
pnlReplay.setLayout(gl_pnlReplay);
|
pnlReplay.setLayout(gl_pnlReplay);
|
||||||
gl_pnlReplay.setHorizontalGroup(
|
gl_pnlReplay.setHorizontalGroup(
|
||||||
|
|
@ -1052,6 +1040,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
|
.addComponent(btnPreviousPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 31, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Game info panel (buttons on the right panel)
|
||||||
javax.swing.GroupLayout gl_pnlGameInfo = new javax.swing.GroupLayout(pnlGameInfo);
|
javax.swing.GroupLayout gl_pnlGameInfo = new javax.swing.GroupLayout(pnlGameInfo);
|
||||||
pnlGameInfo.setLayout(gl_pnlGameInfo);
|
pnlGameInfo.setLayout(gl_pnlGameInfo);
|
||||||
gl_pnlGameInfo.setHorizontalGroup(
|
gl_pnlGameInfo.setHorizontalGroup(
|
||||||
|
|
@ -1222,6 +1211,57 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeListener() {
|
||||||
|
for (MouseListener ml :this.getMouseListeners()) {
|
||||||
|
this.removeMouseListener(ml);
|
||||||
|
}
|
||||||
|
for (MouseListener ml :this.btnConcede.getMouseListeners()) {
|
||||||
|
this.btnConcede.removeMouseListener(ml);
|
||||||
|
}
|
||||||
|
for (MouseListener ml :this.btnEndTurn.getMouseListeners()) {
|
||||||
|
this.btnEndTurn.removeMouseListener(ml);
|
||||||
|
}
|
||||||
|
for (MouseListener ml :this.btnSwitchHands.getMouseListeners()) {
|
||||||
|
this.btnSwitchHands.removeMouseListener(ml);
|
||||||
|
}
|
||||||
|
for (ActionListener al :this.btnPlay.getActionListeners()) {
|
||||||
|
this.btnPlay.removeActionListener(al);
|
||||||
|
}
|
||||||
|
for (ActionListener al :this.btnStopWatching.getActionListeners()) {
|
||||||
|
this.btnStopWatching.removeActionListener(al);
|
||||||
|
}
|
||||||
|
for (ActionListener al :this.btnStopReplay.getActionListeners()) {
|
||||||
|
this.btnStopReplay.removeActionListener(al);
|
||||||
|
}
|
||||||
|
for (ActionListener al :this.btnNextPlay.getActionListeners()) {
|
||||||
|
this.btnNextPlay.removeActionListener(al);
|
||||||
|
}
|
||||||
|
for (ActionListener al :this.btnNextPlay.getActionListeners()) {
|
||||||
|
this.btnNextPlay.removeActionListener(al);
|
||||||
|
}
|
||||||
|
for (ActionListener al :this.btnPreviousPlay.getActionListeners()) {
|
||||||
|
this.btnPreviousPlay.removeActionListener(al);
|
||||||
|
}
|
||||||
|
for (ActionListener al :this.btnSkipForward.getActionListeners()) {
|
||||||
|
this.btnSkipForward.removeActionListener(al);
|
||||||
|
}
|
||||||
|
|
||||||
|
final BasicSplitPaneUI myUi = (BasicSplitPaneUI) jSplitPane0.getUI();
|
||||||
|
final BasicSplitPaneDivider divider = myUi.getDivider();
|
||||||
|
final JButton upArrowButton = (JButton) divider.getComponent(0);
|
||||||
|
for (ActionListener al: upArrowButton.getActionListeners()) {
|
||||||
|
upArrowButton.removeActionListener(al);
|
||||||
|
}
|
||||||
|
final JButton downArrowButton = (JButton) divider.getComponent(1);
|
||||||
|
for (ActionListener al: downArrowButton.getActionListeners()) {
|
||||||
|
downArrowButton.removeActionListener(al);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ComponentListener cl : this.getComponentListeners()) {
|
||||||
|
this.removeComponentListener(cl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
if (modalQuestion("Are you sure you want to concede?", "Confirm concede") == JOptionPane.YES_OPTION) {
|
if (modalQuestion("Are you sure you want to concede?", "Confirm concede") == JOptionPane.YES_OPTION) {
|
||||||
session.concedeGame(gameId);
|
session.concedeGame(gameId);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ public class HelperPanel extends JPanel {
|
||||||
//private javax.swing.JButton btnStopTimer;
|
//private javax.swing.JButton btnStopTimer;
|
||||||
|
|
||||||
private MageTextArea textArea;
|
private MageTextArea textArea;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
|
||||||
|
|
||||||
private javax.swing.JButton linkLeft;
|
private javax.swing.JButton linkLeft;
|
||||||
private javax.swing.JButton linkRight;
|
private javax.swing.JButton linkRight;
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,13 @@ import javax.swing.LayoutStyle.ComponentPlacement;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import javax.swing.event.MenuKeyListener;
|
||||||
|
import javax.swing.plaf.basic.BasicPopupMenuUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -49,6 +52,7 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public class PlayAreaPanel extends javax.swing.JPanel {
|
public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
|
private final JPopupMenu popupMenu;
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private boolean smallMode = false;
|
private boolean smallMode = false;
|
||||||
|
|
@ -63,8 +67,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
initComponents();
|
initComponents();
|
||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
battlefieldPanel.setOpaque(false);
|
battlefieldPanel.setOpaque(false);
|
||||||
|
popupMenu = new JPopupMenu();
|
||||||
if (isPlayer) {
|
if (isPlayer) {
|
||||||
addPopupMenu();
|
addPopupMenuPlayer();
|
||||||
} else {
|
} else {
|
||||||
addPopupMenuWatcher();
|
addPopupMenuWatcher();
|
||||||
}
|
}
|
||||||
|
|
@ -81,15 +86,31 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
for (MouseListener ml :battlefieldPanel.getMainPanel().getMouseListeners()) {
|
for (MouseListener ml :battlefieldPanel.getMainPanel().getMouseListeners()) {
|
||||||
battlefieldPanel.getMainPanel().removeMouseListener(ml);
|
battlefieldPanel.getMainPanel().removeMouseListener(ml);
|
||||||
}
|
}
|
||||||
this.removeAll();
|
playerPanel.cleanUp();
|
||||||
this.getUI().uninstallUI(this);
|
for (KeyListener kl: popupMenu.getKeyListeners()) {
|
||||||
|
popupMenu.removeKeyListener(kl);
|
||||||
|
}
|
||||||
|
for (MenuKeyListener mkl: popupMenu.getMenuKeyListeners()) {
|
||||||
|
popupMenu.removeMenuKeyListener(mkl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPopupMenu() {
|
for (Component child : popupMenu.getComponents()) {
|
||||||
final JPopupMenu popupMenu;
|
if (child instanceof JMenuItem) {
|
||||||
JMenuItem menuItem;
|
JMenuItem menuItem = (JMenuItem) child;
|
||||||
|
for (ActionListener al: menuItem.getActionListeners()) {
|
||||||
|
menuItem.removeActionListener(al);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (MouseListener ml :battlefieldPanel.getMainPanel().getMouseListeners()) {
|
||||||
|
battlefieldPanel.getMainPanel().removeMouseListener(ml);
|
||||||
|
}
|
||||||
|
|
||||||
popupMenu = new JPopupMenu();
|
}
|
||||||
|
|
||||||
|
private void addPopupMenuPlayer() {
|
||||||
|
|
||||||
|
JMenuItem menuItem;
|
||||||
|
|
||||||
menuItem = new JMenuItem("F2 - Confirm");
|
menuItem = new JMenuItem("F2 - Confirm");
|
||||||
popupMenu.add(menuItem);
|
popupMenu.add(menuItem);
|
||||||
|
|
@ -170,11 +191,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Pmenu.addSeparator();
|
|
||||||
//
|
|
||||||
// menuItem = new JMenuItem("Cancel");
|
|
||||||
// Pmenu.add(menuItem);
|
|
||||||
|
|
||||||
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent Me) {
|
public void mouseReleased(MouseEvent Me) {
|
||||||
|
|
@ -186,11 +202,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPopupMenuWatcher() {
|
private void addPopupMenuWatcher() {
|
||||||
final JPopupMenu popupMenu;
|
|
||||||
JMenuItem menuItem;
|
JMenuItem menuItem;
|
||||||
|
|
||||||
popupMenu = new JPopupMenu();
|
|
||||||
|
|
||||||
menuItem = new JMenuItem("Stop watching");
|
menuItem = new JMenuItem("Stop watching");
|
||||||
popupMenu.add(menuItem);
|
popupMenu.add(menuItem);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,10 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
this.timer.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
public void update(PlayerView player) {
|
public void update(PlayerView player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
int playerLife = player.getLife();
|
int playerLife = player.getLife();
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,9 @@ public class PriorityTimer extends TimerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) logger.debug("Count is: " + count);
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Count is: " + count);
|
||||||
|
}
|
||||||
//System.out.println("Count is: " + count);
|
//System.out.println("Count is: " + count);
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
cancel();
|
cancel();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue