mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Fix so combo box constraints retained when switching skins
This commit is contained in:
@@ -353,7 +353,7 @@ public class ImportDialog {
|
||||
});
|
||||
_unknownDeckLabel = new FLabel.Builder().text("Treat unknown decks as:").build();
|
||||
unknownDeckPanel.add(_unknownDeckLabel);
|
||||
unknownDeckPanel.add(_unknownDeckCombo.getComponent());
|
||||
_unknownDeckCombo.addTo(unknownDeckPanel);
|
||||
knownDeckPanel.add(unknownDeckPanel, "span");
|
||||
cbPanel.add(knownDeckPanel, "aligny top");
|
||||
|
||||
|
||||
@@ -268,15 +268,11 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
return new RegisteredPlayer(getDeck());
|
||||
}
|
||||
|
||||
public final boolean isAi() {
|
||||
return isAi;
|
||||
}
|
||||
|
||||
public void populate() {
|
||||
setupUI();
|
||||
removeAll();
|
||||
this.setLayout(new MigLayout("insets 0, gap 0, flowy"));
|
||||
this.add(decksComboBox.getComponent(), "w 10:100%, h 30px!, gapbottom 5px");
|
||||
decksComboBox.addTo(this, "w 10:100%, h 30px!, gapbottom 5px");
|
||||
this.add(new ItemManagerContainer(lstDecks), "w 10:100%, growy, pushy");
|
||||
this.add(btnRandom, "w 10:100%, h 30px!, gaptop 5px");
|
||||
if (isShowing()) {
|
||||
@@ -285,7 +281,11 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsAiDeck(boolean isAiDeck) {
|
||||
public final boolean isAi() {
|
||||
return isAi;
|
||||
}
|
||||
|
||||
public void setIsAi(boolean isAiDeck) {
|
||||
this.isAi = isAiDeck;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import forge.deck.DeckSection;
|
||||
import forge.gui.deckeditor.controllers.ACEditorBase;
|
||||
import forge.gui.toolbox.FButton;
|
||||
import forge.gui.toolbox.FCheckBox;
|
||||
import forge.gui.toolbox.FComboBoxWrapper;
|
||||
import forge.gui.toolbox.FComboBox;
|
||||
import forge.gui.toolbox.FHtmlViewer;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FOptionPane;
|
||||
@@ -98,8 +98,8 @@ public class DeckImport<TItem extends InventoryItem, TModel extends DeckBase> ex
|
||||
private final FCheckBox newEditionCheck = new FCheckBox("Import latest version of card", true);
|
||||
private final FCheckBox dateTimeCheck = new FCheckBox("Use only sets released before:", false);
|
||||
|
||||
private final FComboBoxWrapper<String> monthDropdown = new FComboBoxWrapper<>();
|
||||
private final FComboBoxWrapper<Integer> yearDropdown = new FComboBoxWrapper<>();
|
||||
private final FComboBox<String> monthDropdown = new FComboBox<String>(); //don't need wrappers since skin can't change while this dialog is open
|
||||
private final FComboBox<Integer> yearDropdown = new FComboBox<Integer>();
|
||||
|
||||
/** The tokens. */
|
||||
private final List<DeckRecognizer.Token> tokens = new ArrayList<DeckRecognizer.Token>();
|
||||
@@ -135,8 +135,8 @@ public class DeckImport<TItem extends InventoryItem, TModel extends DeckBase> ex
|
||||
this.add(this.newEditionCheck, "cell 0 1, w 50%, ax c");
|
||||
this.add(this.dateTimeCheck, "cell 0 2, w 50%, ax c");
|
||||
|
||||
this.add(monthDropdown.getComponent(), "cell 0 3, w 20%, ax left, split 2, pad 0 4 0 0");
|
||||
this.add(yearDropdown.getComponent(), "w 15%");
|
||||
this.add(monthDropdown, "cell 0 3, w 20%, ax left, split 2, pad 0 4 0 0");
|
||||
this.add(yearDropdown, "w 15%");
|
||||
fillDateDropdowns();
|
||||
|
||||
this.add(this.scrollOutput, "cell 1 0, w 50%, growy, pushy");
|
||||
@@ -211,9 +211,9 @@ public class DeckImport<TItem extends InventoryItem, TModel extends DeckBase> ex
|
||||
Element e;
|
||||
|
||||
DeckRecognizer recognizer = new DeckRecognizer(newEditionCheck.isSelected(), Singletons.getMagicDb().getCommonCards());
|
||||
if(dateTimeCheck.isSelected())
|
||||
recognizer.setDateConstraint(monthDropdown.getSelectedIndex(), yearDropdown.getSelectedItem());
|
||||
|
||||
if (dateTimeCheck.isSelected()) {
|
||||
recognizer.setDateConstraint(monthDropdown.getSelectedIndex(), (Integer)yearDropdown.getSelectedItem());
|
||||
}
|
||||
while ((e = it.next()) != null) {
|
||||
if (!e.isLeaf()) {
|
||||
continue;
|
||||
|
||||
@@ -20,7 +20,6 @@ package forge.gui.deckeditor.controllers;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
|
||||
@@ -111,7 +111,7 @@ public enum VSubmenuChallenges implements IVSubmenu<CSubmenuChallenges>, IVQuest
|
||||
pnlStats.add(lblWorld, constraints);
|
||||
pnlStats.add(cbPlant, constraints);
|
||||
pnlStats.add(cbCharm, constraints);
|
||||
pnlStats.add(cbxPet.getComponent(), constraints);
|
||||
cbxPet.addTo(pnlStats, constraints);
|
||||
pnlStats.add(lblZep, "w 130px!, h 60px!, gap 0 0 0 5px");
|
||||
pnlStats.setOpaque(false);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public enum VSubmenuDuels implements IVSubmenu<CSubmenuDuels>, IVQuestStats {
|
||||
pnlStats.add(lblWorld, constraints);
|
||||
pnlStats.add(cbPlant, constraints);
|
||||
pnlStats.add(cbCharm, constraints);
|
||||
pnlStats.add(cbxPet.getComponent(), constraints);
|
||||
cbxPet.addTo(pnlStats, constraints);
|
||||
pnlStats.setOpaque(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -322,28 +322,28 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
|
||||
|
||||
|
||||
pnlRestrictions.add(lblStartingPool, constraints + lblWidthStart);
|
||||
pnlRestrictions.add(cbxStartingPool.getComponent(), constraints + cboWidthStart);
|
||||
cbxStartingPool.addTo(pnlRestrictions, constraints + cboWidthStart);
|
||||
|
||||
/* out of these 3 groups only one will be visible */
|
||||
pnlRestrictions.add(lblUnrestricted, constraints + hidemode + "spanx 2");
|
||||
|
||||
pnlRestrictions.add(lblPreconDeck, constraints + lblWidthStart);
|
||||
pnlRestrictions.add(cbxPreconDeck.getComponent(), constraints + cboWidthStart);
|
||||
cbxPreconDeck.addTo(pnlRestrictions, constraints + cboWidthStart);
|
||||
|
||||
pnlRestrictions.add(lblCustomDeck, constraints + lblWidthStart);
|
||||
pnlRestrictions.add(cbxCustomDeck.getComponent(), constraints + cboWidthStart); // , skip 1
|
||||
cbxCustomDeck.addTo(pnlRestrictions, constraints + cboWidthStart); // , skip 1
|
||||
|
||||
pnlRestrictions.add(lblFormat, constraints + lblWidthStart);
|
||||
pnlRestrictions.add(cbxFormat.getComponent(), constraints + cboWidthStart); // , skip 1
|
||||
cbxFormat.addTo(pnlRestrictions, constraints + cboWidthStart); // , skip 1
|
||||
|
||||
pnlRestrictions.add(btnDefineCustomFormat, constraints + hidemode + "spanx 2, w 240px");
|
||||
|
||||
// Prized cards options
|
||||
pnlRestrictions.add(lblPrizedCards, constraints + lblWidth);
|
||||
pnlRestrictions.add(cbxPrizedCards.getComponent(), constraints + cboWidth);
|
||||
cbxPrizedCards.addTo(pnlRestrictions, constraints + cboWidth);
|
||||
|
||||
pnlRestrictions.add(lblPrizeFormat, constraints + lblWidthStart);
|
||||
pnlRestrictions.add(cbxPrizeFormat.getComponent(), constraints + cboWidthStart); // , skip 1
|
||||
cbxPrizeFormat.addTo(pnlRestrictions, constraints + cboWidthStart); // , skip 1
|
||||
pnlRestrictions.add(btnPrizeDefineCustomFormat, constraints + hidemode + "spanx 2, w 240px");
|
||||
pnlRestrictions.add(lblPrizeSameAsStarting, constraints + hidemode + "spanx 2");
|
||||
pnlRestrictions.add(lblPrizeUnrestricted, constraints + hidemode + "spanx 2");
|
||||
@@ -352,10 +352,10 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
|
||||
|
||||
|
||||
pnlRestrictions.add(lblPreferredColor, constraints + lblWidthStart);
|
||||
pnlRestrictions.add(cbxPreferredColor.getComponent(), constraints + cboWidthStart + ", wrap");
|
||||
cbxPreferredColor.addTo(pnlRestrictions, constraints + cboWidthStart + ", wrap");
|
||||
|
||||
pnlRestrictions.add(lblStartingWorld, constraints + lblWidthStart);
|
||||
pnlRestrictions.add(cbxStartingWorld.getComponent(), constraints + cboWidthStart);
|
||||
cbxStartingWorld.addTo(pnlRestrictions, constraints + cboWidthStart);
|
||||
|
||||
// cboAllowUnlocks.setOpaque(false);
|
||||
pnlRestrictions.setOpaque(false);
|
||||
|
||||
@@ -138,7 +138,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
variantsPanel.add(vntCommander);
|
||||
variantsPanel.add(vntPlanechase);
|
||||
variantsPanel.add(vntArchenemy);
|
||||
variantsPanel.add(comboArchenemy.getComponent());
|
||||
comboArchenemy.addTo(variantsPanel);
|
||||
|
||||
constructedFrame.add(new FScrollPanel(variantsPanel, true), "w 100%, gapbottom 10px, spanx 2, wrap");
|
||||
|
||||
|
||||
@@ -133,7 +133,17 @@ public class FComboBoxWrapper<E> {
|
||||
return this.comboBox.getAutoSizeWidth();
|
||||
}
|
||||
|
||||
public JComponent getComponent() { //disguise as component for sake of rare places that need to access component in wrapper
|
||||
public void addTo(Container container) {
|
||||
this.addTo(container, null);
|
||||
}
|
||||
public void addTo(Container container, Object constraints0) {
|
||||
container.add(this.comboBox, constraints0);
|
||||
this.constraints = constraints0;
|
||||
}
|
||||
|
||||
//disguise as component for sake of rare places that need to access component in wrapper
|
||||
//use addTo instead if you want constraints remembered after refreshing skin
|
||||
public JComponent getComponent() {
|
||||
return this.comboBox;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
|
||||
this.add(this.btnFilters);
|
||||
this.add(this.lblCaption);
|
||||
this.add(this.lblRatio);
|
||||
this.add(this.cbViews.getComponent());
|
||||
this.cbViews.addTo(this);
|
||||
this.add(this.viewScroller);
|
||||
|
||||
final Runnable cmdAddCurrentSearch = new Runnable() {
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CardSearchFilter extends TextSearchFilter<PaperCard> {
|
||||
cbSearchMode = new FComboBoxWrapper<String>();
|
||||
cbSearchMode.addItem("in");
|
||||
cbSearchMode.addItem("not in");
|
||||
widget.add(cbSearchMode.getComponent());
|
||||
cbSearchMode.addTo(widget);
|
||||
cbSearchMode.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent arg0) {
|
||||
|
||||
Reference in New Issue
Block a user