forked from External/mage
UI: fixed rare error with wrong dialog position after multiple popups (#4318);
This commit is contained in:
parent
14f90bfc77
commit
c58b28f94f
12 changed files with 185 additions and 173 deletions
|
|
@ -45,14 +45,14 @@ public class DeckExportClipboardDialog extends MageDialog {
|
||||||
this.setResizable(true);
|
this.setResizable(true);
|
||||||
getRootPane().setDefaultButton(buttonOK);
|
getRootPane().setDefaultButton(buttonOK);
|
||||||
|
|
||||||
this.makeWindowCentered();
|
|
||||||
|
|
||||||
// windows settings
|
// windows settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
|
this.makeWindowCentered();
|
||||||
|
|
||||||
// Close on "ESC"
|
// Close on "ESC"
|
||||||
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ public class DeckImportClipboardDialog extends MageDialog {
|
||||||
this.setResizable(true);
|
this.setResizable(true);
|
||||||
getRootPane().setDefaultButton(buttonOK);
|
getRootPane().setDefaultButton(buttonOK);
|
||||||
|
|
||||||
this.makeWindowCentered();
|
|
||||||
|
|
||||||
// windows settings
|
// windows settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
|
this.makeWindowCentered();
|
||||||
|
|
||||||
// Close on "ESC"
|
// Close on "ESC"
|
||||||
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
|
|
|
||||||
|
|
@ -114,14 +114,15 @@ public class AddLandDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
getRootPane().setDefaultButton(btnOK);
|
getRootPane().setDefaultButton(btnOK);
|
||||||
this.makeWindowCentered();
|
|
||||||
|
|
||||||
// windows settings
|
// windows settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
|
this.makeWindowCentered();
|
||||||
|
|
||||||
// Close on "ESC"
|
// Close on "ESC"
|
||||||
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
|
|
|
||||||
|
|
@ -63,19 +63,19 @@ public class DownloadImagesDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDialog(MageDialogState mageDialogState) {
|
public void showDialog(MageDialogState mageDialogState) {
|
||||||
showDownloadControls(false); // call to change window size
|
|
||||||
|
|
||||||
// window settings
|
// window settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
if (mageDialogState != null) {
|
if (mageDialogState != null) mageDialogState.setStateToDialog(this);
|
||||||
mageDialogState.setStateToDialog(this);
|
else this.makeWindowCentered();
|
||||||
} else {
|
|
||||||
this.makeWindowCentered();
|
showDownloadControls(false); // call to change window size
|
||||||
}
|
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ public class DownloadImagesDialog extends MageDialog {
|
||||||
public JButton getCancelButton() {
|
public JButton getCancelButton() {
|
||||||
return this.buttonCancel;
|
return this.buttonCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JButton getStopButton() {
|
public JButton getStopButton() {
|
||||||
return this.buttonStop;
|
return this.buttonStop;
|
||||||
}
|
}
|
||||||
|
|
@ -288,7 +288,7 @@ public class DownloadImagesDialog extends MageDialog {
|
||||||
panelSourceLeft.add(labelSource);
|
panelSourceLeft.add(labelSource);
|
||||||
|
|
||||||
comboSource.setMaximumRowCount(15);
|
comboSource.setMaximumRowCount(15);
|
||||||
comboSource.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
comboSource.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
comboSource.setMinimumSize(new java.awt.Dimension(300, 20));
|
comboSource.setMinimumSize(new java.awt.Dimension(300, 20));
|
||||||
comboSource.setPreferredSize(new java.awt.Dimension(400, 25));
|
comboSource.setPreferredSize(new java.awt.Dimension(400, 25));
|
||||||
panelSourceLeft.add(comboSource);
|
panelSourceLeft.add(comboSource);
|
||||||
|
|
@ -305,7 +305,7 @@ public class DownloadImagesDialog extends MageDialog {
|
||||||
panelSourceRight.add(labelLanguage);
|
panelSourceRight.add(labelLanguage);
|
||||||
|
|
||||||
comboLanguage.setMaximumRowCount(15);
|
comboLanguage.setMaximumRowCount(15);
|
||||||
comboLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
comboLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
comboLanguage.setPreferredSize(new java.awt.Dimension(90, 25));
|
comboLanguage.setPreferredSize(new java.awt.Dimension(90, 25));
|
||||||
panelSourceRight.add(comboLanguage);
|
panelSourceRight.add(comboLanguage);
|
||||||
|
|
||||||
|
|
@ -328,7 +328,7 @@ public class DownloadImagesDialog extends MageDialog {
|
||||||
panelModeSelect.setLayout(new javax.swing.BoxLayout(panelModeSelect, javax.swing.BoxLayout.X_AXIS));
|
panelModeSelect.setLayout(new javax.swing.BoxLayout(panelModeSelect, javax.swing.BoxLayout.X_AXIS));
|
||||||
|
|
||||||
comboSets.setMaximumRowCount(15);
|
comboSets.setMaximumRowCount(15);
|
||||||
comboSets.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
comboSets.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
comboSets.setPreferredSize(new java.awt.Dimension(373, 25));
|
comboSets.setPreferredSize(new java.awt.Dimension(373, 25));
|
||||||
panelModeSelect.add(comboSets);
|
panelModeSelect.add(comboSets);
|
||||||
panelModeSelect.add(fillerMode1);
|
panelModeSelect.add(fillerMode1);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||||
*/
|
*/
|
||||||
public class MageDialog extends javax.swing.JInternalFrame {
|
public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
|
|
||||||
|
|
@ -33,6 +33,22 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void printFramesOrder(String name) {
|
||||||
|
///*
|
||||||
|
JInternalFrame[] frames = MageFrame.getDesktop().getAllFrames();
|
||||||
|
System.out.println("--- " + name + " ---");
|
||||||
|
int order = 0;
|
||||||
|
for (JInternalFrame frame : frames) {
|
||||||
|
order++;
|
||||||
|
int zorder = -1;
|
||||||
|
if (frame.getParent() != null) {
|
||||||
|
zorder = frame.getParent().getComponentZOrder(frame);
|
||||||
|
}
|
||||||
|
System.out.println(order + ". " + frame.getClass() + " (" + frame.getTitle() + ") : layer = " + frame.getLayer() + ", zorder = " + zorder);
|
||||||
|
}
|
||||||
|
//*/
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
@ -45,17 +61,6 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
// - JLayeredPane.MODAL_LAYER: all modal dialogs (user required actions - select cards in game, new game window, error windows)
|
// - JLayeredPane.MODAL_LAYER: all modal dialogs (user required actions - select cards in game, new game window, error windows)
|
||||||
// - JLayeredPane.POPUP_LAYER: hints and other top level graphics
|
// - JLayeredPane.POPUP_LAYER: hints and other top level graphics
|
||||||
// - JLayeredPane.DRAG_LAYER: top most layer for critical actions and user controls
|
// - JLayeredPane.DRAG_LAYER: top most layer for critical actions and user controls
|
||||||
/*
|
|
||||||
JInternalFrame[] frames = MageFrame.getDesktop().getAllFrames();
|
|
||||||
System.out.println("---");
|
|
||||||
for(JInternalFrame frame: frames){
|
|
||||||
int zorder = -1;
|
|
||||||
if (frame.getParent() != null){
|
|
||||||
frame.getParent().getComponentZOrder(frame);
|
|
||||||
}
|
|
||||||
System.out.println(frame.getClass() + " (" + frame.getTitle() + ") : layer = " + frame.getLayer() + ", zorder = " + zorder);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (modal) {
|
if (modal) {
|
||||||
this.setClosable(false);
|
this.setClosable(false);
|
||||||
|
|
@ -71,9 +76,16 @@ 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);
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
this.toFront();
|
this.toFront();
|
||||||
|
try {
|
||||||
|
this.setSelected(true);
|
||||||
|
} catch (PropertyVetoException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modal) {
|
if (modal) {
|
||||||
this.setClosable(false);
|
this.setClosable(false);
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|
@ -195,7 +207,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void makeWindowCentered() {
|
public void makeWindowCentered() {
|
||||||
makeWindowCentered(this, getWidth(), getHeight());
|
makeWindowCentered(this, this.getWidth(), this.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void makeWindowCentered(Component component, int width, int height) {
|
public static void makeWindowCentered(Component component, int width, int height) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class PickCheckBoxDialog extends MageDialog {
|
||||||
if (!(obj instanceof java.awt.Component)) {
|
if (!(obj instanceof java.awt.Component)) {
|
||||||
throw new IllegalArgumentException("Must be a java.awt.Component!");
|
throw new IllegalArgumentException("Must be a java.awt.Component!");
|
||||||
}
|
}
|
||||||
this.scrollList.setViewportView((java.awt.Component) obj);
|
this.scrollList.setViewportView(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private javax.swing.JList get_a_Jlist_from_ScrollListView() {
|
private javax.swing.JList get_a_Jlist_from_ScrollListView() {
|
||||||
|
|
@ -181,16 +181,14 @@ public class PickCheckBoxDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
// window settings
|
// window settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
if (mageDialogState != null) {
|
if (mageDialogState != null) mageDialogState.setStateToDialog(this);
|
||||||
mageDialogState.setStateToDialog(this);
|
else this.makeWindowCentered();
|
||||||
} else {
|
|
||||||
this.makeWindowCentered();
|
|
||||||
}
|
|
||||||
|
|
||||||
// final load
|
// final load
|
||||||
loadData();
|
loadData();
|
||||||
|
|
@ -366,7 +364,7 @@ public class PickCheckBoxDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getObjectValue() {
|
public Object getObjectValue() {
|
||||||
return (CheckBoxList.CheckBoxListItem) this.objectValue;
|
return this.objectValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -145,17 +145,14 @@ public class PickChoiceDialog extends MageDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
// window settings
|
// window settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
if (mageDialogState != null) {
|
if (mageDialogState != null) mageDialogState.setStateToDialog(this);
|
||||||
mageDialogState.setStateToDialog(this);
|
else this.makeWindowCentered();
|
||||||
|
|
||||||
} else {
|
|
||||||
this.makeWindowCentered();
|
|
||||||
}
|
|
||||||
|
|
||||||
// final load
|
// final load
|
||||||
loadData();
|
loadData();
|
||||||
|
|
@ -404,7 +401,7 @@ public class PickChoiceDialog extends MageDialog {
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
|
|
||||||
panelCommandsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]{btCancel, btOK});
|
panelCommandsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, btCancel, btOK);
|
||||||
|
|
||||||
panelCommandsLayout.setVerticalGroup(
|
panelCommandsLayout.setVerticalGroup(
|
||||||
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,13 @@ public class PickNumberDialog extends MageDialog {
|
||||||
this.pack();
|
this.pack();
|
||||||
|
|
||||||
// window settings
|
// window settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getRootPane().setDefaultButton(this.btnOk); // restore default button after root panel change (no need actually)
|
this.getRootPane().setDefaultButton(this.btnOk); // restore default button after root panel change (no need actually)
|
||||||
|
|
||||||
// enable spinner's enter key like text (one enter press instead two)
|
// enable spinner's enter key like text (one enter press instead two)
|
||||||
|
|
|
||||||
|
|
@ -69,23 +69,20 @@ public class PickPileDialog extends MageDialog {
|
||||||
this.pile1.loadCardsNarrow(pile1, bigCard, gameId);
|
this.pile1.loadCardsNarrow(pile1, bigCard, gameId);
|
||||||
this.pile2.loadCardsNarrow(pile2, bigCard, gameId);
|
this.pile2.loadCardsNarrow(pile2, bigCard, gameId);
|
||||||
|
|
||||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
this.setModal(true);
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
|
||||||
}
|
|
||||||
pack();
|
pack();
|
||||||
|
|
||||||
this.makeWindowCentered();
|
// windows settings
|
||||||
|
MageFrame.getDesktop().remove(this);
|
||||||
this.revalidate();
|
|
||||||
this.repaint();
|
|
||||||
this.setModal(true);
|
|
||||||
|
|
||||||
// window settings
|
|
||||||
if (this.isModal()) {
|
if (this.isModal()) {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
} else {
|
} else {
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
}
|
}
|
||||||
|
this.makeWindowCentered();
|
||||||
|
|
||||||
|
this.revalidate(); // TODO: remove?
|
||||||
|
this.repaint(); // TODO: remove?
|
||||||
|
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,138 +1,137 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ShowCardsDialog.java
|
* ShowCardsDialog.java
|
||||||
*
|
*
|
||||||
* Created on 3-Feb-2010, 8:59:11 PM
|
* Created on 3-Feb-2010, 8:59:11 PM
|
||||||
*/
|
*/
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.Component;
|
import mage.client.MageFrame;
|
||||||
import java.awt.Point;
|
import mage.client.cards.BigCard;
|
||||||
import java.io.Serializable;
|
import mage.client.cards.CardArea;
|
||||||
import java.util.Map;
|
import mage.client.util.Event;
|
||||||
import java.util.UUID;
|
import mage.client.util.Listener;
|
||||||
import javax.swing.JLayeredPane;
|
import mage.client.util.SettingsManager;
|
||||||
import javax.swing.JPopupMenu;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import javax.swing.SwingUtilities;
|
import mage.game.events.PlayerQueryEvent.QueryType;
|
||||||
import mage.client.MageFrame;
|
import mage.view.CardsView;
|
||||||
import mage.client.cards.BigCard;
|
import org.mage.card.arcane.CardPanel;
|
||||||
import mage.client.cards.CardArea;
|
|
||||||
import mage.client.util.Event;
|
|
||||||
import mage.client.util.Listener;
|
|
||||||
import mage.client.util.SettingsManager;
|
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
|
||||||
import mage.game.events.PlayerQueryEvent.QueryType;
|
|
||||||
import mage.view.CardsView;
|
|
||||||
import org.mage.card.arcane.CardPanel;
|
|
||||||
|
|
||||||
/**
|
import javax.swing.*;
|
||||||
* @author BetaSteward_at_googlemail.com
|
import java.awt.*;
|
||||||
*/
|
import java.io.Serializable;
|
||||||
public class ShowCardsDialog extends MageDialog {
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
// remember if this dialog was already auto positioned, so don't do it after the first time
|
/**
|
||||||
private boolean positioned;
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public class ShowCardsDialog extends MageDialog {
|
||||||
|
|
||||||
/**
|
// remember if this dialog was already auto positioned, so don't do it after the first time
|
||||||
* Creates new form ShowCardsDialog
|
private boolean positioned;
|
||||||
*/
|
|
||||||
public ShowCardsDialog() {
|
|
||||||
this.positioned = false;
|
|
||||||
|
|
||||||
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
/**
|
||||||
initComponents();
|
* Creates new form ShowCardsDialog
|
||||||
|
*/
|
||||||
|
public ShowCardsDialog() {
|
||||||
|
this.positioned = false;
|
||||||
|
|
||||||
this.setModal(false);
|
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
initComponents();
|
||||||
|
|
||||||
}
|
this.setModal(false);
|
||||||
|
|
||||||
public void cleanUp() {
|
}
|
||||||
cardArea.cleanUp();
|
|
||||||
for (Component comp : cardArea.getComponents()) {
|
|
||||||
if (comp instanceof CardPanel) {
|
|
||||||
((CardPanel) comp).cleanUp();
|
|
||||||
cardArea.remove(comp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void cleanUp() {
|
||||||
public void changeGUISize() {
|
cardArea.cleanUp();
|
||||||
setGUISize();
|
for (Component comp : cardArea.getComponents()) {
|
||||||
cardArea.changeGUISize();
|
if (comp instanceof CardPanel) {
|
||||||
}
|
((CardPanel) comp).cleanUp();
|
||||||
|
cardArea.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setGUISize() {
|
@Override
|
||||||
|
public void changeGUISize() {
|
||||||
|
setGUISize();
|
||||||
|
cardArea.changeGUISize();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
private void setGUISize() {
|
||||||
|
|
||||||
public void loadCards(String name, CardsView showCards, BigCard bigCard,
|
}
|
||||||
UUID gameId, boolean modal, Map<String, Serializable> options,
|
|
||||||
JPopupMenu popupMenu, Listener<Event> eventListener) {
|
|
||||||
this.title = name;
|
|
||||||
this.setTitelBarToolTip(name);
|
|
||||||
cardArea.clearCardEventListeners();
|
|
||||||
cardArea.loadCards(showCards, bigCard, gameId);
|
|
||||||
if (options != null) {
|
|
||||||
if (options.containsKey("chosen")) {
|
|
||||||
java.util.List<UUID> chosenCards = (java.util.List<UUID>) options.get("chosen");
|
|
||||||
cardArea.selectCards(chosenCards);
|
|
||||||
}
|
|
||||||
if (options.containsKey("choosable")) {
|
|
||||||
java.util.List<UUID> choosableCards = (java.util.List<UUID>) options.get("choosable");
|
|
||||||
cardArea.markCards(choosableCards);
|
|
||||||
}
|
|
||||||
if (options.containsKey("queryType") && options.get("queryType") == QueryType.PICK_ABILITY) {
|
|
||||||
cardArea.setPopupMenu(popupMenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (popupMenu != null) {
|
|
||||||
this.cardArea.setPopupMenu(popupMenu);
|
|
||||||
}
|
|
||||||
if (eventListener != null) {
|
|
||||||
this.cardArea.addCardEventListener(eventListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
pack();
|
public void loadCards(String name, CardsView showCards, BigCard bigCard,
|
||||||
|
UUID gameId, boolean modal, Map<String, Serializable> options,
|
||||||
|
JPopupMenu popupMenu, Listener<Event> eventListener) {
|
||||||
|
this.title = name;
|
||||||
|
this.setTitelBarToolTip(name);
|
||||||
|
cardArea.clearCardEventListeners();
|
||||||
|
cardArea.loadCards(showCards, bigCard, gameId);
|
||||||
|
if (options != null) {
|
||||||
|
if (options.containsKey("chosen")) {
|
||||||
|
java.util.List<UUID> chosenCards = (java.util.List<UUID>) options.get("chosen");
|
||||||
|
cardArea.selectCards(chosenCards);
|
||||||
|
}
|
||||||
|
if (options.containsKey("choosable")) {
|
||||||
|
java.util.List<UUID> choosableCards = (java.util.List<UUID>) options.get("choosable");
|
||||||
|
cardArea.markCards(choosableCards);
|
||||||
|
}
|
||||||
|
if (options.containsKey("queryType") && options.get("queryType") == QueryType.PICK_ABILITY) {
|
||||||
|
cardArea.setPopupMenu(popupMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (popupMenu != null) {
|
||||||
|
this.cardArea.setPopupMenu(popupMenu);
|
||||||
|
}
|
||||||
|
if (eventListener != null) {
|
||||||
|
this.cardArea.addCardEventListener(eventListener);
|
||||||
|
}
|
||||||
|
|
||||||
this.revalidate();
|
pack();
|
||||||
this.repaint();
|
|
||||||
this.setModal(modal);
|
|
||||||
|
|
||||||
// window settings
|
this.revalidate();
|
||||||
if (this.isModal()){
|
this.repaint();
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
this.setModal(modal);
|
||||||
}else{
|
|
||||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
|
||||||
}
|
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
// window settings
|
||||||
if (!positioned) {
|
MageFrame.getDesktop().remove(this);
|
||||||
int width = ShowCardsDialog.this.getWidth();
|
if (this.isModal()) {
|
||||||
int height = ShowCardsDialog.this.getHeight();
|
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||||
if (width > 0 && height > 0) {
|
} else {
|
||||||
Point centered = SettingsManager.instance.getComponentPosition(width, height);
|
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||||
ShowCardsDialog.this.setLocation(centered.x, centered.y);
|
}
|
||||||
positioned = true;
|
|
||||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ShowCardsDialog.this.setVisible(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initComponents() {
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
if (!positioned) {
|
||||||
|
int width = ShowCardsDialog.this.getWidth();
|
||||||
|
int height = ShowCardsDialog.this.getHeight();
|
||||||
|
if (width > 0 && height > 0) {
|
||||||
|
Point centered = SettingsManager.instance.getComponentPosition(width, height);
|
||||||
|
ShowCardsDialog.this.setLocation(centered.x, centered.y);
|
||||||
|
positioned = true;
|
||||||
|
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ShowCardsDialog.this.setVisible(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
cardArea = new CardArea();
|
private void initComponents() {
|
||||||
|
|
||||||
setClosable(true);
|
cardArea = new CardArea();
|
||||||
setResizable(true);
|
|
||||||
getContentPane().setLayout(new java.awt.BorderLayout());
|
|
||||||
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
|
|
||||||
setGUISize();
|
|
||||||
pack();
|
|
||||||
}
|
|
||||||
|
|
||||||
private CardArea cardArea;
|
setClosable(true);
|
||||||
}
|
setResizable(true);
|
||||||
|
getContentPane().setLayout(new java.awt.BorderLayout());
|
||||||
|
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
|
||||||
|
setGUISize();
|
||||||
|
pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CardArea cardArea;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -193,8 +193,6 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
||||||
|
|
||||||
// PROGRESS BAR
|
// PROGRESS BAR
|
||||||
uiDialog.getProgressBar().setValue(0);
|
uiDialog.getProgressBar().setValue(0);
|
||||||
|
|
||||||
uiDialog.showDownloadControls(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void findMissingCards() {
|
public void findMissingCards() {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
|
||||||
public static final String MAGE_VERSION_MINOR_PATCH = "V5"; // default
|
public static final String MAGE_VERSION_MINOR_PATCH = "V5"; // default
|
||||||
// strict mode
|
// strict mode
|
||||||
private static final boolean MAGE_VERSION_MINOR_PATCH_MUST_BE_SAME = true; // set true on uncompatible github changes, set false after new major release (after MAGE_VERSION_PATCH changes)
|
private static final boolean MAGE_VERSION_MINOR_PATCH_MUST_BE_SAME = true; // set true on uncompatible github changes, set false after new major release (after MAGE_VERSION_PATCH changes)
|
||||||
|
public static final boolean MAGE_VERSION_SHOW_BUILD_TIME = true;
|
||||||
|
|
||||||
private final int major;
|
private final int major;
|
||||||
private final int minor;
|
private final int minor;
|
||||||
|
|
@ -26,7 +27,6 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
|
||||||
private final String minorPatch; // doesn't matter for compatibility
|
private final String minorPatch; // doesn't matter for compatibility
|
||||||
private final String buildTime;
|
private final String buildTime;
|
||||||
private String editionInfo;
|
private String editionInfo;
|
||||||
private final boolean showBuildTime = true;
|
|
||||||
|
|
||||||
public MageVersion(Class sourceClass) {
|
public MageVersion(Class sourceClass) {
|
||||||
this(MAGE_VERSION_MAJOR, MAGE_VERSION_MINOR, MAGE_VERSION_PATCH, MAGE_VERSION_MINOR_PATCH, MAGE_EDITION_INFO, sourceClass);
|
this(MAGE_VERSION_MAJOR, MAGE_VERSION_MINOR, MAGE_VERSION_PATCH, MAGE_VERSION_MINOR_PATCH, MAGE_EDITION_INFO, sourceClass);
|
||||||
|
|
@ -40,7 +40,7 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
|
||||||
this.editionInfo = editionInfo;
|
this.editionInfo = editionInfo;
|
||||||
|
|
||||||
// build time
|
// build time
|
||||||
this.buildTime = showBuildTime ? JarVersion.getBuildTime(sourceClass) : "";
|
this.buildTime = JarVersion.getBuildTime(sourceClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMajor() {
|
public int getMajor() {
|
||||||
|
|
@ -59,10 +59,18 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
|
||||||
return minorPatch;
|
return minorPatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(boolean showBuildTime) {
|
||||||
|
// 1.4.32-betaV0 (build: time)
|
||||||
|
String res = major + "." + minor + '.' + patch + editionInfo + minorPatch;
|
||||||
|
if (showBuildTime && !this.buildTime.isEmpty()) {
|
||||||
|
res += " (build: " + this.buildTime + ")";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// 1.4.32-betaV0 (build: time)
|
return toString(MAGE_VERSION_SHOW_BUILD_TIME);
|
||||||
return major + "." + minor + '.' + patch + editionInfo + minorPatch + (!this.buildTime.isEmpty() ? " (build: " + this.buildTime + ")" : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue