mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* GUI: fixed that deck editor doesn't restore settings after games (cards list hides after draft/sideboarding, see #4350);
This commit is contained in:
parent
5585e1d878
commit
e07dd273f2
3 changed files with 713 additions and 697 deletions
|
@ -31,7 +31,6 @@ public class DeckArea extends javax.swing.JPanel {
|
||||||
private BigCard lastBigCard = null;
|
private BigCard lastBigCard = null;
|
||||||
private int dividerLocationNormal = 0;
|
private int dividerLocationNormal = 0;
|
||||||
private int dividerLocationLimited = 0;
|
private int dividerLocationLimited = 0;
|
||||||
private static final boolean isLimitedBuildingOrientation = false;
|
|
||||||
|
|
||||||
public DeckCardLayout getCardLayout() {
|
public DeckCardLayout getCardLayout() {
|
||||||
return deckList.getCardLayout();
|
return deckList.getCardLayout();
|
||||||
|
@ -163,7 +162,7 @@ public class DeckArea extends javax.swing.JPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings saveSettings() {
|
public Settings saveSettings(boolean isLimitedBuildingOrientation) {
|
||||||
Settings settings = new Settings();
|
Settings settings = new Settings();
|
||||||
settings.maindeckSettings = deckList.saveSettings();
|
settings.maindeckSettings = deckList.saveSettings();
|
||||||
settings.sideboardSetings = sideboardList.saveSettings();
|
settings.sideboardSetings = sideboardList.saveSettings();
|
||||||
|
@ -177,7 +176,7 @@ public class DeckArea extends javax.swing.JPanel {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadSettings(Settings s) {
|
public void loadSettings(Settings s, boolean isLimitedBuildingOrientation) {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
deckList.loadSettings(s.maindeckSettings);
|
deckList.loadSettings(s.maindeckSettings);
|
||||||
sideboardList.loadSettings(s.sideboardSetings);
|
sideboardList.loadSettings(s.sideboardSetings);
|
||||||
|
@ -208,8 +207,8 @@ public class DeckArea extends javax.swing.JPanel {
|
||||||
private void setGUISize() {
|
private void setGUISize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrientation(boolean limitedBuildingOrientation) {
|
public void setOrientation(boolean isLimitedBuildingOrientation) {
|
||||||
if (limitedBuildingOrientation) {
|
if (isLimitedBuildingOrientation) {
|
||||||
deckAreaSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
deckAreaSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
||||||
if (dividerLocationLimited != 0) {
|
if (dividerLocationLimited != 0) {
|
||||||
deckAreaSplitPane.setDividerLocation(dividerLocationLimited);
|
deckAreaSplitPane.setDividerLocation(dividerLocationLimited);
|
||||||
|
|
|
@ -78,7 +78,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
deckArea.setOpaque(false);
|
deckArea.setOpaque(false);
|
||||||
panelLeft.setOpaque(false);
|
panelLeft.setOpaque(false);
|
||||||
panelRight.setOpaque(false);
|
panelRight.setOpaque(false);
|
||||||
restoreDividerLocationsAndDeckAreaSettings();
|
|
||||||
countdown = new javax.swing.Timer(1000,
|
countdown = new javax.swing.Timer(1000,
|
||||||
e -> {
|
e -> {
|
||||||
if (--timeout > 0) {
|
if (--timeout > 0) {
|
||||||
|
@ -93,13 +92,18 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set up tracking to save the deck editor settings when the deck editor is hidden.
|
// save editor settings dynamicly on hides (e.g. app close)
|
||||||
addHierarchyListener((HierarchyEvent e) -> {
|
addHierarchyListener((HierarchyEvent e) -> {
|
||||||
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
|
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
|
||||||
if (!isShowing()) {
|
if (!isShowing()) {
|
||||||
|
// It's bugged and called on sideboarding creates too (before load). So:
|
||||||
|
// * for free mode - save here
|
||||||
|
// * for draft/sideboarding - save on cleanup call
|
||||||
|
if (mode == DeckEditorMode.FREE_BUILDING) {
|
||||||
saveDividerLocationsAndDeckAreaSettings();
|
saveDividerLocationsAndDeckAreaSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,21 +131,32 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveDividerLocationsAndDeckAreaSettings() {
|
private void saveDividerLocationsAndDeckAreaSettings() {
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION, Integer.toString(panelRight.getDividerLocation()));
|
boolean isLimitedBuildingOrientation = (mode != DeckEditorMode.FREE_BUILDING);
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, this.deckArea.saveSettings().toString());
|
if (isLimitedBuildingOrientation) {
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_LIMITED, Integer.toString(panelRight.getDividerLocation()));
|
||||||
|
} else {
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_NORMAL, Integer.toString(panelRight.getDividerLocation()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, this.deckArea.saveSettings(isLimitedBuildingOrientation).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreDividerLocationsAndDeckAreaSettings() {
|
private void restoreDividerLocationsAndDeckAreaSettings() {
|
||||||
// Load horizontal split position setting
|
String dividerLocation = "";
|
||||||
String dividerLocation = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION, "");
|
boolean isLimitedBuildingOrientation = (mode != DeckEditorMode.FREE_BUILDING);
|
||||||
|
if (isLimitedBuildingOrientation) {
|
||||||
|
dividerLocation = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_LIMITED, "");
|
||||||
|
} else {
|
||||||
|
dividerLocation = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_NORMAL, "");
|
||||||
|
}
|
||||||
if (!dividerLocation.isEmpty()) {
|
if (!dividerLocation.isEmpty()) {
|
||||||
panelRight.setDividerLocation(Integer.parseInt(dividerLocation));
|
panelRight.setDividerLocation(Integer.parseInt(dividerLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load deck area settings
|
// Load deck area settings
|
||||||
this.deckArea.loadSettings(
|
this.deckArea.loadSettings(
|
||||||
DeckArea.Settings.parse(
|
DeckArea.Settings.parse(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, "")),
|
||||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_EDITOR_DECKAREA_SETTINGS, "")));
|
isLimitedBuildingOrientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeGUISize() {
|
public void changeGUISize() {
|
||||||
|
@ -157,11 +172,12 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
this.btnAddLand.setVisible(false);
|
this.btnAddLand.setVisible(false);
|
||||||
|
|
||||||
|
restoreDividerLocationsAndDeckAreaSettings();
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case LIMITED_BUILDING:
|
case LIMITED_BUILDING:
|
||||||
this.btnAddLand.setVisible(true);
|
this.btnAddLand.setVisible(true);
|
||||||
this.txtTimeRemaining.setVisible(true);
|
this.txtTimeRemaining.setVisible(true);
|
||||||
// Fall through to sideboarding
|
// Fall through to sideboarding (no break)
|
||||||
case SIDEBOARDING:
|
case SIDEBOARDING:
|
||||||
this.btnSubmit.setVisible(true);
|
this.btnSubmit.setVisible(true);
|
||||||
this.btnSubmitTimer.setVisible(true);
|
this.btnSubmitTimer.setVisible(true);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package mage.client.dialog;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
import mage.client.components.KeyBindButton;
|
import mage.client.components.KeyBindButton;
|
||||||
|
import mage.client.themes.ThemeType;
|
||||||
import mage.client.util.CardLanguage;
|
import mage.client.util.CardLanguage;
|
||||||
import mage.client.util.ClientDefaultSettings;
|
import mage.client.util.ClientDefaultSettings;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
|
@ -15,7 +16,6 @@ import mage.remote.Connection;
|
||||||
import mage.remote.Connection.ProxyType;
|
import mage.remote.Connection.ProxyType;
|
||||||
import mage.view.UserRequestMessage;
|
import mage.view.UserRequestMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import mage.client.themes.ThemeType;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
|
@ -160,7 +160,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
public static final String KEY_TABLES_DIVIDER_LOCATION_4 = "tablePanelDividerLocation4";
|
public static final String KEY_TABLES_DIVIDER_LOCATION_4 = "tablePanelDividerLocation4";
|
||||||
|
|
||||||
// Positions of deck editor divider bars
|
// Positions of deck editor divider bars
|
||||||
public static final String KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION = "editorHorizontalDividerLocation";
|
public static final String KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_NORMAL = "editorHorizontalDividerLocationNormal";
|
||||||
|
public static final String KEY_EDITOR_HORIZONTAL_DIVIDER_LOCATION_LIMITED = "editorHorizontalDividerLocationLimited";
|
||||||
public static final String KEY_EDITOR_DECKAREA_SETTINGS = "editorDeckAreaSettings";
|
public static final String KEY_EDITOR_DECKAREA_SETTINGS = "editorDeckAreaSettings";
|
||||||
|
|
||||||
// user list
|
// user list
|
||||||
|
@ -807,7 +808,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
main_battlefield.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Battlefield"));
|
main_battlefield.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Battlefield"));
|
||||||
|
|
||||||
cbBattlefieldFeedbackColorizingMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Disable colorizing", "Enable one color for all phases", "Enable multicolor for different phases" }));
|
cbBattlefieldFeedbackColorizingMode.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Disable colorizing", "Enable one color for all phases", "Enable multicolor for different phases"}));
|
||||||
cbBattlefieldFeedbackColorizingMode.setToolTipText("Battlefield feedback panel colorizing on your turn (e.g. use green color if you must select card or answer to request)");
|
cbBattlefieldFeedbackColorizingMode.setToolTipText("Battlefield feedback panel colorizing on your turn (e.g. use green color if you must select card or answer to request)");
|
||||||
cbBattlefieldFeedbackColorizingMode.addActionListener(new java.awt.event.ActionListener() {
|
cbBattlefieldFeedbackColorizingMode.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
@ -870,18 +871,18 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
tabGuiSize.setMaximumSize(new java.awt.Dimension(527, 423));
|
tabGuiSize.setMaximumSize(new java.awt.Dimension(527, 423));
|
||||||
tabGuiSize.setMinimumSize(new java.awt.Dimension(527, 423));
|
tabGuiSize.setMinimumSize(new java.awt.Dimension(527, 423));
|
||||||
java.awt.GridBagLayout tabGuiSizeLayout = new java.awt.GridBagLayout();
|
java.awt.GridBagLayout tabGuiSizeLayout = new java.awt.GridBagLayout();
|
||||||
tabGuiSizeLayout.columnWidths = new int[] {0};
|
tabGuiSizeLayout.columnWidths = new int[]{0};
|
||||||
tabGuiSizeLayout.rowHeights = new int[] {0, 20, 0};
|
tabGuiSizeLayout.rowHeights = new int[]{0, 20, 0};
|
||||||
tabGuiSizeLayout.columnWeights = new double[] {1.0};
|
tabGuiSizeLayout.columnWeights = new double[]{1.0};
|
||||||
tabGuiSizeLayout.rowWeights = new double[] {1.0, 0.0, 1.0};
|
tabGuiSizeLayout.rowWeights = new double[]{1.0, 0.0, 1.0};
|
||||||
tabGuiSize.setLayout(tabGuiSizeLayout);
|
tabGuiSize.setLayout(tabGuiSizeLayout);
|
||||||
|
|
||||||
guiSizeBasic.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Size basic elements"));
|
guiSizeBasic.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Size basic elements"));
|
||||||
guiSizeBasic.setMinimumSize(new java.awt.Dimension(600, 180));
|
guiSizeBasic.setMinimumSize(new java.awt.Dimension(600, 180));
|
||||||
guiSizeBasic.setPreferredSize(new java.awt.Dimension(600, 180));
|
guiSizeBasic.setPreferredSize(new java.awt.Dimension(600, 180));
|
||||||
java.awt.GridBagLayout guiSizeBasicLayout = new java.awt.GridBagLayout();
|
java.awt.GridBagLayout guiSizeBasicLayout = new java.awt.GridBagLayout();
|
||||||
guiSizeBasicLayout.columnWeights = new double[] {1.0, 1.0, 1.0};
|
guiSizeBasicLayout.columnWeights = new double[]{1.0, 1.0, 1.0};
|
||||||
guiSizeBasicLayout.rowWeights = new double[] {1.0, 0.2, 1.0, 0.2};
|
guiSizeBasicLayout.rowWeights = new double[]{1.0, 0.2, 1.0, 0.2};
|
||||||
guiSizeBasic.setLayout(guiSizeBasicLayout);
|
guiSizeBasic.setLayout(guiSizeBasicLayout);
|
||||||
|
|
||||||
sliderFontSize.setMajorTickSpacing(5);
|
sliderFontSize.setMajorTickSpacing(5);
|
||||||
|
@ -1070,8 +1071,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
guiSizeGame.setMinimumSize(new java.awt.Dimension(600, 180));
|
guiSizeGame.setMinimumSize(new java.awt.Dimension(600, 180));
|
||||||
guiSizeGame.setPreferredSize(new java.awt.Dimension(600, 180));
|
guiSizeGame.setPreferredSize(new java.awt.Dimension(600, 180));
|
||||||
java.awt.GridBagLayout guiSizeGameLayout = new java.awt.GridBagLayout();
|
java.awt.GridBagLayout guiSizeGameLayout = new java.awt.GridBagLayout();
|
||||||
guiSizeGameLayout.columnWeights = new double[] {1.0, 1.0, 1.0, 1.0};
|
guiSizeGameLayout.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0};
|
||||||
guiSizeGameLayout.rowWeights = new double[] {1.0, 0.2, 1.0, 0.2};
|
guiSizeGameLayout.rowWeights = new double[]{1.0, 0.2, 1.0, 0.2};
|
||||||
guiSizeGame.setLayout(guiSizeGameLayout);
|
guiSizeGame.setLayout(guiSizeGameLayout);
|
||||||
|
|
||||||
sliderCardSizeHand.setMajorTickSpacing(5);
|
sliderCardSizeHand.setMajorTickSpacing(5);
|
||||||
|
@ -1554,7 +1555,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
});
|
});
|
||||||
|
|
||||||
cbPreferedImageLanguage.setMaximumRowCount(20);
|
cbPreferedImageLanguage.setMaximumRowCount(20);
|
||||||
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
|
|
||||||
labelPreferedImageLanguage.setText("Default images language:");
|
labelPreferedImageLanguage.setText("Default images language:");
|
||||||
labelPreferedImageLanguage.setFocusable(false);
|
labelPreferedImageLanguage.setFocusable(false);
|
||||||
|
@ -1562,7 +1563,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
labelNumberOfDownloadThreads.setText("Number of download threads:");
|
labelNumberOfDownloadThreads.setText("Number of download threads:");
|
||||||
|
|
||||||
cbNumberOfDownloadThreads.setMaximumRowCount(20);
|
cbNumberOfDownloadThreads.setMaximumRowCount(20);
|
||||||
cbNumberOfDownloadThreads.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
cbNumberOfDownloadThreads.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||||
|
|
||||||
labelHint1.setText("(change it to 1-3 if image source bans your IP for too many connections)");
|
labelHint1.setText("(change it to 1-3 if image source bans your IP for too many connections)");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue