Deprecated SubButton in favor of FLabel builder.

Fixed display bug in title bar of sealed/draft.
Updated quest deck lister to recall previous deck if exists.
This commit is contained in:
Doublestrike
2012-02-06 11:22:21 +00:00
parent 9af4563249
commit 697f3aaf86
19 changed files with 210 additions and 356 deletions

1
.gitattributes vendored
View File

@@ -11262,7 +11262,6 @@ src/main/java/forge/view/toolbox/FScrollPane.java -text
src/main/java/forge/view/toolbox/FSkin.java -text src/main/java/forge/view/toolbox/FSkin.java -text
src/main/java/forge/view/toolbox/FTextArea.java -text src/main/java/forge/view/toolbox/FTextArea.java -text
src/main/java/forge/view/toolbox/FVerticalTabPanel.java -text src/main/java/forge/view/toolbox/FVerticalTabPanel.java -text
src/main/java/forge/view/toolbox/SubButton.java -text
src/main/java/forge/view/toolbox/SubTab.java -text src/main/java/forge/view/toolbox/SubTab.java -text
src/main/java/forge/view/toolbox/package-info.java svneol=native#text/plain src/main/java/forge/view/toolbox/package-info.java svneol=native#text/plain
src/main/java/net/slightlymagic/braids/LICENSE.txt svneol=native#text/plain src/main/java/net/slightlymagic/braids/LICENSE.txt svneol=native#text/plain

View File

@@ -53,10 +53,10 @@ public class ControlQuest {
private final MouseAdapter madStartGame, madDuels, madChallenges, private final MouseAdapter madStartGame, madDuels, madChallenges,
madQuests, madDecks, madPreferences; madQuests, madDecks, madPreferences;
private final ActionListener actPetSelect, actPlantSelect, private final ActionListener actPetSelect, actPlantSelect;
actSpellShop, actBazaar, actEmbark, actNewDeck, actCurrentDeck, actResetPrefs; private final Command cmdSpellShop, cmdBazaar,
private final Command cmdDeckExit, cmdDeckDelete, cmdDeckSelect, cmdEmbark, cmdNewDeck, cmdCurrentDeck, cmdResetPrefs, cmdDeckExit,
cmdQuestSelect, cmdQuestDelete; cmdDeckDelete, cmdDeckSelect, cmdQuestSelect, cmdQuestDelete;
private Deck currentDeck; private Deck currentDeck;
private Map<String, QuestData> arrQuests; private Map<String, QuestData> arrQuests;
@@ -128,29 +128,29 @@ public class ControlQuest {
} }
}; };
actSpellShop = new ActionListener() { @Override cmdSpellShop = new Command() { @Override
public void actionPerformed(ActionEvent e) { showSpellShop(); } }; public void execute() { showSpellShop(); } };
actBazaar = new ActionListener() { @Override cmdBazaar = new Command() { @Override
public void actionPerformed(ActionEvent e) { showBazaar(); } }; public void execute() { showBazaar(); } };
actEmbark = new ActionListener() { @Override cmdEmbark = new Command() { @Override
public void actionPerformed(ActionEvent e) { newQuest(); } }; public void execute() { newQuest(); } };
actCurrentDeck = new ActionListener() { @Override cmdCurrentDeck = new Command() { @Override
public void actionPerformed(ActionEvent e) { view.showDecksTab(); } }; public void execute() { view.showDecksTab(); } };
actNewDeck = new ActionListener() { @Override cmdNewDeck = new Command() { @Override
public void actionPerformed(ActionEvent e) { public void execute() {
final DeckEditorQuest editor = new DeckEditorQuest(qData); final DeckEditorQuest editor = new DeckEditorQuest(qData);
editor.show(cmdDeckExit); editor.show(cmdDeckExit);
editor.setVisible(true); editor.setVisible(true);
} }
}; };
actResetPrefs = new ActionListener() { cmdResetPrefs = new Command() {
@Override @Override
public void actionPerformed(final ActionEvent arg0) { public void execute() {
qPrefs.reset(); qPrefs.reset();
qPrefs.save(); qPrefs.save();
view.resetPrefs(); view.resetPrefs();
@@ -171,6 +171,7 @@ public class ControlQuest {
@Override @Override
public void execute() { public void execute() {
currentDeck = view.getLstDecks().getSelectedDeck(); currentDeck = view.getLstDecks().getSelectedDeck();
qPrefs.setPreference(QPref.CURRENT_DECK, currentDeck.toString());
view.setCurrentDeckStatus(); view.setCurrentDeckStatus();
} }
}; };
@@ -246,36 +247,27 @@ public class ControlQuest {
view.getTabPreferences().removeMouseListener(madPreferences); view.getTabPreferences().removeMouseListener(madPreferences);
view.getTabPreferences().addMouseListener(madPreferences); view.getTabPreferences().addMouseListener(madPreferences);
view.getBtnEmbark().removeActionListener(actEmbark);
view.getBtnEmbark().addActionListener(actEmbark);
view.getLstQuests().setSelectCommand(cmdQuestSelect); view.getLstQuests().setSelectCommand(cmdQuestSelect);
view.getLstQuests().setEditCommand(cmdQuestDelete); view.getLstQuests().setEditCommand(cmdQuestDelete);
view.getLstQuests().setDeleteCommand(cmdQuestDelete); view.getLstQuests().setDeleteCommand(cmdQuestDelete);
view.getBtnResetPrefs().removeActionListener(actResetPrefs); view.getBtnEmbark().setCommand(cmdEmbark);
view.getBtnResetPrefs().addActionListener(actResetPrefs); view.getBtnResetPrefs().setCommand(cmdResetPrefs);
if (this.qem != null) { if (this.qem != null) {
view.getBtnStart().removeMouseListener(madStartGame); view.getBtnStart().removeMouseListener(madStartGame);
view.getBtnStart().addMouseListener(madStartGame); view.getBtnStart().addMouseListener(madStartGame);
view.getBtnBazaar().removeActionListener(actBazaar); view.getBtnBazaar().setCommand(cmdBazaar);
view.getBtnBazaar().addActionListener(actBazaar);
view.getBtnNewDeck().removeActionListener(actNewDeck); view.getBtnNewDeck().setCommand(cmdNewDeck);
view.getBtnNewDeck().addActionListener(actNewDeck);
view.getBtnCurrentDeck().removeActionListener(actCurrentDeck); view.getBtnCurrentDeck().setCommand(cmdCurrentDeck);
view.getBtnCurrentDeck().addActionListener(actCurrentDeck);
view.getBtnSpellShop().removeActionListener(actSpellShop); view.getBtnSpellShop().setCommand(cmdSpellShop);
view.getBtnSpellShop().addActionListener(actSpellShop);
view.getCbxPet().removeActionListener(actPetSelect);
view.getCbxPet().addActionListener(actPetSelect); view.getCbxPet().addActionListener(actPetSelect);
view.getCbPlant().removeActionListener(actPlantSelect);
view.getCbPlant().addActionListener(actPlantSelect); view.getCbPlant().addActionListener(actPlantSelect);
view.getLstDecks().setSelectCommand(cmdDeckSelect); view.getLstDecks().setSelectCommand(cmdDeckSelect);
@@ -405,19 +397,23 @@ public class ControlQuest {
/** Resets decks, then retrieves and sets current deck. */ /** Resets decks, then retrieves and sets current deck. */
public void refreshDecks() { public void refreshDecks() {
// Retrieve and set all decks
Deck[] temp = (qData == null ? new Deck[] {} : qData.getDecks().toArray(new Deck[0])); Deck[] temp = (qData == null ? new Deck[] {} : qData.getDecks().toArray(new Deck[0]));
view.getLstDecks().setDecks(temp); view.getLstDecks().setDecks(temp);
if (!view.getLstDecks().setSelectedDeck(currentDeck)) { // Look through list for preferred deck from prefs
if (!view.getLstDecks().setSelectedIndex(0)) { currentDeck = null;
currentDeck = null; final String cd = qPrefs.getPreference(QPref.CURRENT_DECK);
} for (Deck d : temp) {
else { if (d.getName().equals(cd)) {
currentDeck = view.getLstDecks().getSelectedDeck(); currentDeck = d;
view.getLstDecks().setSelectedDeck(d);
break;
} }
} }
// Not found? Set first one. Still not found? OK, throw to setCurrentDeckStatus().
if (currentDeck == null) { view.getLstDecks().setSelectedIndex(0); }
view.setCurrentDeckStatus(); view.setCurrentDeckStatus();
} }

View File

@@ -10,6 +10,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import forge.AllZone; import forge.AllZone;
import forge.Command;
import forge.Constant; import forge.Constant;
import forge.Singletons; import forge.Singletons;
import forge.properties.ForgePreferences; import forge.properties.ForgePreferences;
@@ -46,6 +47,7 @@ public class ControlSettings {
} }
/** */ /** */
@SuppressWarnings("serial")
public void addListeners() { public void addListeners() {
this.view.getLstChooseSkin().addListSelectionListener(new ListSelectionListener() { this.view.getLstChooseSkin().addListSelectionListener(new ListSelectionListener() {
@Override @Override
@@ -149,9 +151,9 @@ public class ControlSettings {
} }
}); });
this.view.getBtnReset().addActionListener(new ActionListener() { this.view.getBtnReset().setCommand(new Command() {
@Override @Override
public void actionPerformed(final ActionEvent arg0) { public void execute() {
Singletons.getModel().getPreferences().reset(); Singletons.getModel().getPreferences().reset();
view.getParentView().resetSettings(); view.getParentView().resetSettings();
} }

View File

@@ -1,7 +1,5 @@
package forge.control.home; package forge.control.home;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@@ -32,8 +30,8 @@ import forge.view.toolbox.FSkin;
public class ControlUtilities { public class ControlUtilities {
private ViewUtilities view; private ViewUtilities view;
private final MouseAdapter madLicensing; private final MouseAdapter madLicensing;
private final ActionListener actDeckEditor, actPicDownload, actSetDownload, private final Command cmdDeckEditor, cmdPicDownload, cmdSetDownload,
actQuestImages, actReportBug, actImportPictures, actHowToPlay, actDownloadPrices; cmdQuestImages, cmdReportBug, cmdImportPictures, cmdHowToPlay, cmdDownloadPrices;
/** /**
* *
@@ -41,6 +39,7 @@ public class ControlUtilities {
* *
* @param v0 &emsp; ViewUtilities * @param v0 &emsp; ViewUtilities
*/ */
@SuppressWarnings("serial")
public ControlUtilities(ViewUtilities v0) { public ControlUtilities(ViewUtilities v0) {
this.view = v0; this.view = v0;
@@ -59,53 +58,37 @@ public class ControlUtilities {
} }
}; };
actDeckEditor = new ActionListener() { cmdDeckEditor = new Command() { @Override
@Override public void execute() { showDeckEditor(null, null); } };
public void actionPerformed(final ActionEvent arg0) {
showDeckEditor(null, null);
}
};
actPicDownload = new ActionListener() { cmdPicDownload = new Command() { @Override
@Override public void execute() { doDownloadPics(); } };
public void actionPerformed(final ActionEvent arg0) {
doDownloadPics();
}
};
actSetDownload = new ActionListener() { cmdSetDownload = new Command() { @Override
@Override public void execute() { doDownloadSetPics(); } };
public void actionPerformed(final ActionEvent arg0) {
doDownloadSetPics();
}
};
actQuestImages = new ActionListener() { cmdQuestImages = new Command() { @Override
@Override public void execute() { doDownloadQuestImages(); } };
public void actionPerformed(final ActionEvent arg0) {
doDownloadQuestImages();
}
};
actReportBug = new ActionListener() { cmdReportBug = new Command() {
@Override @Override
public void actionPerformed(final ActionEvent arg0) { public void execute() {
final BugzReporter br = new BugzReporter(); final BugzReporter br = new BugzReporter();
br.setVisible(true); br.setVisible(true);
} }
}; };
actImportPictures = new ActionListener() { cmdImportPictures = new Command() {
@Override @Override
public void actionPerformed(final ActionEvent arg0) { public void execute() {
final GuiImportPicture ip = new GuiImportPicture(null); final GuiImportPicture ip = new GuiImportPicture(null);
ip.setVisible(true); ip.setVisible(true);
} }
}; };
actHowToPlay = new ActionListener() { cmdHowToPlay = new Command() {
@Override @Override
public void actionPerformed(final ActionEvent arg0) { public void execute() {
final String text = ForgeProps.getLocalized(Lang.HowTo.MESSAGE); final String text = ForgeProps.getLocalized(Lang.HowTo.MESSAGE);
final JTextArea area = new JTextArea(text, 25, 40); final JTextArea area = new JTextArea(text, 25, 40);
@@ -119,9 +102,9 @@ public class ControlUtilities {
} }
}; };
actDownloadPrices = new ActionListener() { cmdDownloadPrices = new Command() {
@Override @Override
public void actionPerformed(final ActionEvent arg0) { public void execute() {
final GuiDownloadPrices gdp = new GuiDownloadPrices(); final GuiDownloadPrices gdp = new GuiDownloadPrices();
gdp.setVisible(true); gdp.setVisible(true);
} }
@@ -137,22 +120,15 @@ public class ControlUtilities {
/** */ /** */
public void addListeners() { public void addListeners() {
this.view.getBtnDownloadPics().removeActionListener(actPicDownload); this.view.getBtnDownloadPics().setCommand(cmdPicDownload);
this.view.getBtnDownloadPics().addActionListener(actPicDownload); this.view.getBtnDownloadSetPics().setCommand(cmdSetDownload);
this.view.getBtnDownloadSetPics().removeActionListener(actSetDownload); this.view.getBtnDownloadQuestImages().setCommand(cmdQuestImages);
this.view.getBtnDownloadSetPics().addActionListener(actSetDownload); this.view.getBtnReportBug().setCommand(cmdReportBug);
this.view.getBtnDownloadQuestImages().removeActionListener(actQuestImages); this.view.getBtnImportPictures().setCommand(cmdImportPictures);
this.view.getBtnDownloadQuestImages().addActionListener(actQuestImages); this.view.getBtnHowToPlay().setCommand(cmdHowToPlay);
this.view.getBtnReportBug().removeActionListener(actReportBug); this.view.getBtnDownloadPrices().setCommand(cmdDownloadPrices);
this.view.getBtnReportBug().addActionListener(actReportBug); this.view.getBtnDeckEditor().setCommand(cmdDeckEditor);
this.view.getBtnImportPictures().removeActionListener(actImportPictures);
this.view.getBtnImportPictures().addActionListener(actImportPictures);
this.view.getBtnHowToPlay().removeActionListener(actHowToPlay);
this.view.getBtnHowToPlay().addActionListener(actHowToPlay);
this.view.getBtnDownloadPrices().removeActionListener(actDownloadPrices);
this.view.getBtnDownloadPrices().addActionListener(actDownloadPrices);
this.view.getBtnDeckEditor().removeActionListener(actDeckEditor);
this.view.getBtnDeckEditor().addActionListener(actDeckEditor);
this.view.getLblLicensing().removeMouseListener(madLicensing); this.view.getLblLicensing().removeMouseListener(madLicensing);
this.view.getLblLicensing().addMouseListener(madLicensing); this.view.getLblLicensing().addMouseListener(madLicensing);
} }

View File

@@ -56,6 +56,7 @@ public class QuestPreferences implements Serializable {
PENALTY_LOSS ("15"), /** */ PENALTY_LOSS ("15"), /** */
CURRENT_QUEST ("DEFAULT"), /** */ CURRENT_QUEST ("DEFAULT"), /** */
CURRENT_DECK ("DEFAULT"), /** */
REWARDS_BASE ("25"), /** */ REWARDS_BASE ("25"), /** */
REWARDS_UNDEFEATED ("25"), /** */ REWARDS_UNDEFEATED ("25"), /** */

View File

@@ -51,14 +51,11 @@ public class BazaarTopLevel extends FPanel {
private void populateStalls() { private void populateStalls() {
for (final String s : QuestStallManager.getStallNames()) { for (final String s : QuestStallManager.getStallNames()) {
final FLabel lbl = new FLabel.Builder().text(s + " ").fontAlign(SwingConstants.RIGHT).build(); final FLabel lbl = new FLabel.Builder().text(s + " ")
.fontAlign(SwingConstants.RIGHT).iconInBackground(true)
.fontScaleFactor(0.3).opaque(true).hoverable(true)
.icon(QuestStallManager.getStall(s).getIcon()).selectable(true).build();
lbl.setIcon(QuestStallManager.getStall(s).getIcon());
lbl.setIconInBackground(true);
lbl.setFontScaleFactor(0.3);
lbl.setOpaque(true);
lbl.setHoverable(true);
lbl.setSelectable(true);
pnlAllStalls.add(lbl, "h 80px!, w 90%!, gap 0 0 10px 10px"); pnlAllStalls.add(lbl, "h 80px!, w 90%!, gap 0 0 10px 10px");
lbl.setCommand(new Command() { lbl.setCommand(new Command() {

View File

@@ -1,13 +1,12 @@
package forge.view.bazaar; package forge.view.bazaar;
import java.awt.Font; import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import forge.AllZone; import forge.AllZone;
import forge.Command;
import forge.Singletons; import forge.Singletons;
import forge.quest.data.bazaar.QuestStallPurchasable; import forge.quest.data.bazaar.QuestStallPurchasable;
import forge.view.GuiTopLevel; import forge.view.GuiTopLevel;
@@ -15,32 +14,24 @@ import forge.view.toolbox.FLabel;
import forge.view.toolbox.FRoundedPanel; import forge.view.toolbox.FRoundedPanel;
import forge.view.toolbox.FSkin; import forge.view.toolbox.FSkin;
import forge.view.toolbox.FTextArea; import forge.view.toolbox.FTextArea;
import forge.view.toolbox.SubButton;
/** An update-able panel instance representing a single item. */ /** An update-able panel instance representing a single item. */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ViewItem extends FRoundedPanel { public class ViewItem extends FRoundedPanel {
private final FLabel lblIcon, lblName, lblPrice; private final FLabel lblIcon, lblName, lblPrice, btnPurchase;
private final FTextArea tarDesc; private final FTextArea tarDesc;
private final SubButton btnPurchase;
private QuestStallPurchasable item; private QuestStallPurchasable item;
/** An update-able panel instance representing a single item. */ /** An update-able panel instance representing a single item. */
public ViewItem() { public ViewItem() {
// Final inits // Final inits
lblIcon = new FLabel.Builder().build(); lblIcon = new FLabel.Builder().iconScaleFactor(1).iconInBackground(true).build();
lblName = new FLabel.Builder().build(); lblName = new FLabel.Builder().fontStyle(Font.BOLD).build();
lblPrice = new FLabel.Builder().build(); lblPrice = new FLabel.Builder().fontStyle(Font.BOLD).fontScaleFactor(0.8).build();
tarDesc = new FTextArea(); tarDesc = new FTextArea();
btnPurchase = new SubButton("Buy"); btnPurchase = new FLabel.Builder().text("Buy").opaque(true).fontScaleFactor(0.2).hoverable(true).build();
// Component styling
this.setBackground(Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_THEME2)); this.setBackground(Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_THEME2));
this.lblName.setFontStyle(Font.BOLD);
this.lblPrice.setFontStyle(Font.BOLD);
this.lblPrice.setFontScaleFactor(0.8);
this.lblIcon.setIconInBackground(true);
this.lblIcon.setIconScaleFactor(1);
// Layout // Layout
this.setLayout(new MigLayout("insets 0, gap 0")); this.setLayout(new MigLayout("insets 0, gap 0"));
@@ -52,9 +43,9 @@ public class ViewItem extends FRoundedPanel {
this.add(tarDesc, "w 60%!, gap 0 0 0 10px, wrap"); this.add(tarDesc, "w 60%!, gap 0 0 0 10px, wrap");
this.add(lblPrice, "w 60%!, h 20px!, gap 0 0 0 5px"); this.add(lblPrice, "w 60%!, h 20px!, gap 0 0 0 5px");
btnPurchase.addActionListener(new ActionListener() { btnPurchase.setCommand(new Command() {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void execute() {
AllZone.getQuestData().subtractCredits(getItem().getBuyingPrice()); AllZone.getQuestData().subtractCredits(getItem().getBuyingPrice());
AllZone.getQuestData().addCredits(getItem().getSellingPrice()); AllZone.getQuestData().addCredits(getItem().getSellingPrice());
getItem().onPurchase(); getItem().onPurchase();

View File

@@ -68,7 +68,9 @@ public class ViewStall extends JPanel {
this.lblEmpty = new FLabel.Builder() this.lblEmpty = new FLabel.Builder()
.text("The merchant does not have anything useful for sale.") .text("The merchant does not have anything useful for sale.")
.fontAlign(SwingConstants.CENTER).build(); .fontAlign(SwingConstants.CENTER).build();
this.lblStats = new FLabel.Builder().build(); this.lblStats = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.fontScaleFactor(0.9).build();
this.tpnFluff = new JTextPane(); this.tpnFluff = new JTextPane();
this.pnlInventory = new JPanel(); this.pnlInventory = new JPanel();
this.scrInventory = new FScrollPane(pnlInventory); this.scrInventory = new FScrollPane(pnlInventory);
@@ -97,9 +99,6 @@ public class ViewStall extends JPanel {
scrInventory.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrInventory.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrInventory.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrInventory.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
lblStats.setHorizontalAlignment(SwingConstants.CENTER);
lblStats.setFontScaleFactor(0.9);
// Layout // Layout
this.setLayout(new MigLayout("insets 0, gap 0, wrap, ay center")); this.setLayout(new MigLayout("insets 0, gap 0, wrap, ay center"));
this.add(lblStallName, "w 90%!, h 40px!, gap 5% 0 10px 0"); this.add(lblStallName, "w 90%!, h 40px!, gap 5% 0 10px 0");

View File

@@ -59,7 +59,6 @@ public class QuestPreferencesHandler extends JPanel {
lblErrDifficulty.setForeground(Color.red); lblErrDifficulty.setForeground(Color.red);
lblErrBooster.setForeground(Color.red); lblErrBooster.setForeground(Color.red);
lblErrShop.setForeground(Color.red); lblErrShop.setForeground(Color.red);
lblErrShop.setFontStyle(Font.BOLD);
// Rewards panel // Rewards panel
pnlRewards.setOpaque(false); pnlRewards.setOpaque(false);

View File

@@ -11,11 +11,11 @@ import javax.swing.SwingConstants;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import forge.Singletons; import forge.Singletons;
import forge.control.home.ControlConstructed; import forge.control.home.ControlConstructed;
import forge.view.toolbox.FLabel;
import forge.view.toolbox.FList; import forge.view.toolbox.FList;
import forge.view.toolbox.FProgressBar; import forge.view.toolbox.FProgressBar;
import forge.view.toolbox.FScrollPane; import forge.view.toolbox.FScrollPane;
import forge.view.toolbox.FSkin; import forge.view.toolbox.FSkin;
import forge.view.toolbox.SubButton;
/** /**
* Assembles swing components for "Constructed" mode menu. * Assembles swing components for "Constructed" mode menu.
@@ -29,7 +29,7 @@ public class ViewConstructed extends JPanel {
private final JButton btnStart; private final JButton btnStart;
private final FProgressBar barProgress; private final FProgressBar barProgress;
private SubButton btnHumanRandomTheme, btnHumanRandomDeck, btnAIRandomTheme, btnAIRandomDeck; private FLabel btnHumanRandomTheme, btnHumanRandomDeck, btnAIRandomTheme, btnAIRandomDeck;
private JList lstDecksAI; private JList lstDecksAI;
private FList lstColorsHuman, lstThemesHuman, lstDecksHuman, lstColorsAI, lstThemesAI; private FList lstColorsHuman, lstThemesHuman, lstDecksHuman, lstColorsAI, lstThemesAI;
@@ -107,8 +107,10 @@ public class ViewConstructed extends JPanel {
lblDecklistInfo.setHorizontalAlignment(SwingConstants.CENTER); lblDecklistInfo.setHorizontalAlignment(SwingConstants.CENTER);
// Random theme and pre-constructed buttons // Random theme and pre-constructed buttons
btnHumanRandomTheme = new SubButton("Random Theme Deck"); btnHumanRandomTheme = new FLabel.Builder().opaque(true)
btnHumanRandomDeck = new SubButton("Random Deck"); .hoverable(true).text("Random Theme Deck").build();
btnHumanRandomDeck = new FLabel.Builder().opaque(true)
.hoverable(true).text("Random Deck").build();
// Add components to human area // Add components to human area
JPanel colorsContainer = new JPanel(); JPanel colorsContainer = new JPanel();
@@ -180,8 +182,10 @@ public class ViewConstructed extends JPanel {
lblDecklistInfo.setHorizontalAlignment(SwingConstants.CENTER); lblDecklistInfo.setHorizontalAlignment(SwingConstants.CENTER);
// Random theme and pre-constructed deck buttons // Random theme and pre-constructed deck buttons
btnAIRandomTheme = new SubButton("Random Theme Deck"); btnAIRandomTheme = new FLabel.Builder().opaque(true)
btnAIRandomDeck = new SubButton("Random Deck"); .hoverable(true).text("Random Theme Deck").build();
btnAIRandomDeck = new FLabel.Builder().opaque(true)
.hoverable(true).text("Random Deck").build();
// Add components to AI area // Add components to AI area
JPanel colorsContainer = new JPanel(); JPanel colorsContainer = new JPanel();
@@ -256,23 +260,23 @@ public class ViewConstructed extends JPanel {
return lstDecksAI; return lstDecksAI;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnHumanRandomTheme() { public FLabel getBtnHumanRandomTheme() {
return btnHumanRandomTheme; return btnHumanRandomTheme;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnAIRandomTheme() { public FLabel getBtnAIRandomTheme() {
return btnAIRandomTheme; return btnAIRandomTheme;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnHumanRandomDeck() { public FLabel getBtnHumanRandomDeck() {
return btnHumanRandomDeck; return btnHumanRandomDeck;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnAIRandomDeck() { public FLabel getBtnAIRandomDeck() {
return btnAIRandomDeck; return btnAIRandomDeck;
} }

View File

@@ -23,13 +23,13 @@ import forge.control.home.ControlDraft;
import forge.game.GameType; import forge.game.GameType;
import forge.view.toolbox.DeckLister; import forge.view.toolbox.DeckLister;
import forge.view.toolbox.FButton; import forge.view.toolbox.FButton;
import forge.view.toolbox.FLabel;
import forge.view.toolbox.FList; import forge.view.toolbox.FList;
import forge.view.toolbox.FOverlay; import forge.view.toolbox.FOverlay;
import forge.view.toolbox.FPanel; import forge.view.toolbox.FPanel;
import forge.view.toolbox.FProgressBar; import forge.view.toolbox.FProgressBar;
import forge.view.toolbox.FScrollPane; import forge.view.toolbox.FScrollPane;
import forge.view.toolbox.FSkin; import forge.view.toolbox.FSkin;
import forge.view.toolbox.SubButton;
/** /**
* Assembles swing components for "Draft" mode menu. * Assembles swing components for "Draft" mode menu.
@@ -45,7 +45,8 @@ public class ViewDraft extends JPanel {
private final DeckLister lstHumanDecks; private final DeckLister lstHumanDecks;
private final JTextPane tpnDirections; private final JTextPane tpnDirections;
private final JLabel lblDirections; private final JLabel lblDirections;
private final JButton btnBuildDeck, btnStart; private final JButton btnStart;
private final FLabel btnBuildDeck;
private String[] opponentNames = new String[] { private String[] opponentNames = new String[] {
"Abigail", "Ada", "Adeline", "Adriana", "Agatha", "Agnes", "Aileen", "Alba", "Alcyon", "Abigail", "Ada", "Adeline", "Adriana", "Agatha", "Agnes", "Aileen", "Alba", "Alcyon",
@@ -174,7 +175,7 @@ public class ViewDraft extends JPanel {
lstAI = new FList(ai); lstAI = new FList(ai);
this.add(new FScrollPane(lstAI), "w 25%!, h 37%!, gap 0 0 2% 0, span 1 2, wrap"); this.add(new FScrollPane(lstAI), "w 25%!, h 37%!, gap 0 0 2% 0, span 1 2, wrap");
btnBuildDeck = new SubButton("Build A New Deck"); btnBuildDeck = new FLabel.Builder().opaque(true).hoverable(true).text("Build A New Deck").build();
this.add(btnBuildDeck, "w 60%!, h 5%!, gap 5% 5% 0 0, wrap"); this.add(btnBuildDeck, "w 60%!, h 5%!, gap 5% 5% 0 0, wrap");
lblDirections = new JLabel("Click For Directions"); lblDirections = new JLabel("Click For Directions");
@@ -244,8 +245,8 @@ public class ViewDraft extends JPanel {
return lblDirections; return lblDirections;
} }
/** @return JButton */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnBuildDeck() { public FLabel getBtnBuildDeck() {
return btnBuildDeck; return btnBuildDeck;
} }

View File

@@ -37,7 +37,6 @@ import forge.view.toolbox.FRoundedPanel;
import forge.view.toolbox.FScrollPane; import forge.view.toolbox.FScrollPane;
import forge.view.toolbox.FSkin; import forge.view.toolbox.FSkin;
import forge.view.toolbox.FTextArea; import forge.view.toolbox.FTextArea;
import forge.view.toolbox.SubButton;
import forge.view.toolbox.SubTab; import forge.view.toolbox.SubTab;
/** /**
@@ -56,11 +55,11 @@ public class ViewQuest extends JScrollPane {
pnlDecks, pnlLoadQuest, pnlPrefs, pnlDecks, pnlLoadQuest, pnlPrefs,
tabDuels, tabChallenges, tabDecks, tabQuests, tabPreferences; tabDuels, tabChallenges, tabDecks, tabQuests, tabPreferences;
private final FLabel lblTitle, lblLife, lblCredits, private final FLabel lblTitle, lblLife, lblCredits,
lblWins, lblLosses, lblNextChallengeInWins, lblWinStreak; lblWins, lblLosses, lblNextChallengeInWins, lblWinStreak, btnBazaar, btnSpellShop, btnEmbark,
private final JButton btnBazaar, btnSpellShop, btnStart, btnEmbark,
btnResetPrefs, btnNewDeck, btnCurrentDeck; btnResetPrefs, btnNewDeck, btnCurrentDeck;
private final StartButton btnStart;
private final JCheckBox cbPlant, cbZep, cbStandardStart; private final JCheckBox cbPlant, cbZep, cbStandardStart;
private final JComboBox cbxPet; private final JComboBox cbxPet;
private final JRadioButton radEasy, radMedium, radHard, radExpert, radFantasy, radClassic; private final JRadioButton radEasy, radMedium, radHard, radExpert, radFantasy, radClassic;
@@ -107,7 +106,8 @@ public class ViewQuest extends JScrollPane {
pnlLoadQuest = new JPanel(); pnlLoadQuest = new JPanel();
pnlPrefs = new JPanel(); pnlPrefs = new JPanel();
lblTitle = new FLabel.Builder().text("New Quest").fontAlign(SwingConstants.CENTER).build(); lblTitle = new FLabel.Builder().text("New Quest").fontAlign(SwingConstants.CENTER)
.fontScaleBy(SwingConstants.HORIZONTAL).fontScaleFactor(0.035).build();
lblLife = new FLabel.Builder().build(); lblLife = new FLabel.Builder().build();
lblCredits = new FLabel.Builder().build(); lblCredits = new FLabel.Builder().build();
lblWins = new FLabel.Builder().build(); lblWins = new FLabel.Builder().build();
@@ -122,13 +122,17 @@ public class ViewQuest extends JScrollPane {
radFantasy = new FRadioButton("Fantasy"); radFantasy = new FRadioButton("Fantasy");
radClassic = new FRadioButton("Classic"); radClassic = new FRadioButton("Classic");
btnCurrentDeck = new SubButton(); btnCurrentDeck = new FLabel.Builder().opaque(true).hoverable(true).build();
btnBazaar = new SubButton("Bazaar"); btnBazaar = new FLabel.Builder().selectable(true).opaque(true).hoverable(true).text("Bazaar")
btnSpellShop = new SubButton("Spell Shop"); .fontScaleAuto(false).tooltip("Peruse the Bazaar").build();
btnBazaar.setFont(Singletons.getView().getSkin().getFont(14));
btnSpellShop = new FLabel.Builder().opaque(true).hoverable(true).text("Spell Shop")
.fontScaleAuto(false).tooltip("Travel to the Spell Shop").build();
btnSpellShop.setFont(Singletons.getView().getSkin().getFont(14));
btnStart = new StartButton(parentView); btnStart = new StartButton(parentView);
btnEmbark = new SubButton("Embark!"); btnEmbark = new FLabel.Builder().opaque(true).hoverable(true).text("Embark!").build();
btnNewDeck = new SubButton("Build a New Deck"); btnNewDeck = new FLabel.Builder().opaque(true).hoverable(true).text("Build a New Deck").build();
btnResetPrefs = new SubButton("Reset to Defaults"); btnResetPrefs = new FLabel.Builder().opaque(true).hoverable(true).text("Reset to Defaults").build();
cbxPet = new JComboBox(); cbxPet = new JComboBox();
cbStandardStart = new FCheckBox("Standard (Type 2) Starting Pool"); cbStandardStart = new FCheckBox("Standard (Type 2) Starting Pool");
cbPlant = new FCheckBox("Summon Plant"); cbPlant = new FCheckBox("Summon Plant");
@@ -207,8 +211,6 @@ public class ViewQuest extends JScrollPane {
pnlTitle.setBackground(skin.getColor(FSkin.Colors.CLR_THEME2)); pnlTitle.setBackground(skin.getColor(FSkin.Colors.CLR_THEME2));
((FRoundedPanel) pnlTitle).setBorderColor(clrBorders); ((FRoundedPanel) pnlTitle).setBorderColor(clrBorders);
((FLabel) lblTitle).setFontScaleBy(SwingConstants.HORIZONTAL);
((FLabel) lblTitle).setFontScaleFactor(0.035);
pnlTitle.add(lblTitle, "w 98%!, h 70%!, gap 0 0 15%! 15%!"); pnlTitle.add(lblTitle, "w 98%!, h 70%!, gap 0 0 15%! 15%!");
} }
@@ -222,8 +224,6 @@ public class ViewQuest extends JScrollPane {
lblWins.setIcon(skin.getIcon(FSkin.QuestIcons.ICO_PLUS)); lblWins.setIcon(skin.getIcon(FSkin.QuestIcons.ICO_PLUS));
lblLosses.setIcon(skin.getIcon(FSkin.QuestIcons.ICO_MINUS)); lblLosses.setIcon(skin.getIcon(FSkin.QuestIcons.ICO_MINUS));
lblNextChallengeInWins.setText("No challenges available."); lblNextChallengeInWins.setText("No challenges available.");
btnBazaar.setToolTipText("Peruse the Bazaar");
btnSpellShop.setToolTipText("Travel to the Spell Shop");
} }
/** Layout permanent parts of duels panel. */ /** Layout permanent parts of duels panel. */
@@ -705,8 +705,8 @@ public class ViewQuest extends JScrollPane {
return lblWinStreak; return lblWinStreak;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnCurrentDeck() { public FLabel getBtnCurrentDeck() {
return btnCurrentDeck; return btnCurrentDeck;
} }
@@ -715,28 +715,28 @@ public class ViewQuest extends JScrollPane {
return btnStart; return btnStart;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnBazaar() { public FLabel getBtnBazaar() {
return btnBazaar; return btnBazaar;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnSpellShop() { public FLabel getBtnSpellShop() {
return btnSpellShop; return btnSpellShop;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnEmbark() { public FLabel getBtnEmbark() {
return btnEmbark; return btnEmbark;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnResetPrefs() { public FLabel getBtnResetPrefs() {
return btnResetPrefs; return btnResetPrefs;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnNewDeck() { public FLabel getBtnNewDeck() {
return btnNewDeck; return btnNewDeck;
} }

View File

@@ -10,10 +10,10 @@ import forge.Singletons;
import forge.control.home.ControlSealed; import forge.control.home.ControlSealed;
import forge.game.GameType; import forge.game.GameType;
import forge.view.toolbox.DeckLister; import forge.view.toolbox.DeckLister;
import forge.view.toolbox.FLabel;
import forge.view.toolbox.FProgressBar; import forge.view.toolbox.FProgressBar;
import forge.view.toolbox.FScrollPane; import forge.view.toolbox.FScrollPane;
import forge.view.toolbox.FSkin; import forge.view.toolbox.FSkin;
import forge.view.toolbox.SubButton;
/** /**
* Assembles swing components for "Sealed" mode menu. * Assembles swing components for "Sealed" mode menu.
@@ -25,7 +25,8 @@ public class ViewSealed extends JPanel {
private final HomeTopLevel parentView; private final HomeTopLevel parentView;
private final ControlSealed control; private final ControlSealed control;
private DeckLister lstHumanDecks; private DeckLister lstHumanDecks;
private final JButton btnBuild, btnStart; private final JButton btnStart;
private final FLabel btnBuild;
private final FProgressBar barProgress; private final FProgressBar barProgress;
/** /**
@@ -51,7 +52,7 @@ public class ViewSealed extends JPanel {
lstHumanDecks = new DeckLister(GameType.Sealed, control.getExitCommand()); lstHumanDecks = new DeckLister(GameType.Sealed, control.getExitCommand());
// Build button // Build button
btnBuild = new SubButton("Build A New Deck"); btnBuild = new FLabel.Builder().opaque(true).hoverable(true).text("Build A New Deck").build();
// Start button // Start button
btnStart = new StartButton(parentView); btnStart = new StartButton(parentView);
@@ -84,8 +85,8 @@ public class ViewSealed extends JPanel {
return control; return control;
} }
/** @return {@link javax.swing.JButton} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnBuild() { public FLabel getBtnBuild() {
return btnBuild; return btnBuild;
} }

View File

@@ -15,7 +15,6 @@ import java.util.List;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
@@ -43,7 +42,6 @@ import forge.view.toolbox.FLabel;
import forge.view.toolbox.FList; import forge.view.toolbox.FList;
import forge.view.toolbox.FScrollPane; import forge.view.toolbox.FScrollPane;
import forge.view.toolbox.FSkin; import forge.view.toolbox.FSkin;
import forge.view.toolbox.SubButton;
/** /**
* Assembles swing components for "Settings" mode menu. * Assembles swing components for "Settings" mode menu.
@@ -54,7 +52,7 @@ public class ViewSettings extends JScrollPane {
private final ControlSettings control; private final ControlSettings control;
private final FSkin skin; private final FSkin skin;
private final JPanel viewport; private final JPanel viewport;
private final JButton btnReset; private final FLabel btnReset;
private HomeTopLevel parentView; private HomeTopLevel parentView;
private JList lstChooseSkin; private JList lstChooseSkin;
@@ -200,7 +198,7 @@ public class ViewSettings extends JScrollPane {
final JLabel lblReset = new SectionLabel(" "); final JLabel lblReset = new SectionLabel(" ");
viewport.add(lblReset, sectionConstraints); viewport.add(lblReset, sectionConstraints);
btnReset = new SubButton("Reset to defaults"); btnReset = new FLabel.Builder().opaque(true).hoverable(true).text("Reset to defaults").build();
viewport.add(btnReset, sectionConstraints); viewport.add(btnReset, sectionConstraints);
this.control = new ControlSettings(this); this.control = new ControlSettings(this);
@@ -467,8 +465,8 @@ public class ViewSettings extends JScrollPane {
return parentView; return parentView;
} }
/** @return {@link forge.view.home.HomeTopLevel} */ /** @return {@link forge.view.toolbox.FLabel} */
public JButton getBtnReset() { public FLabel getBtnReset() {
return btnReset; return btnReset;
} }
} }

View File

@@ -22,7 +22,6 @@ import forge.view.toolbox.FLabel;
import forge.view.toolbox.FOverlay; import forge.view.toolbox.FOverlay;
import forge.view.toolbox.FPanel; import forge.view.toolbox.FPanel;
import forge.view.toolbox.FSkin; import forge.view.toolbox.FSkin;
import forge.view.toolbox.SubButton;
/** /**
* Assembles swing components for "Utilities" mode menu. * Assembles swing components for "Utilities" mode menu.
@@ -36,7 +35,7 @@ public class ViewUtilities extends JPanel {
private final JTextPane tpnLicensing; private final JTextPane tpnLicensing;
private final JLabel lblLicensing; private final JLabel lblLicensing;
private SubButton btnDownloadSetPics, btnDownloadPics, btnDownloadQuestImages, btnReportBug, btnImportPictures, private FLabel btnDownloadSetPics, btnDownloadPics, btnDownloadQuestImages, btnReportBug, btnImportPictures,
btnHowToPlay, btnDownloadPrices, btnDeckEditor; btnHowToPlay, btnDownloadPrices, btnDeckEditor;
private final String license = "Forge License Information" + "\r\n\r\n" private final String license = "Forge License Information" + "\r\n\r\n"
@@ -67,14 +66,16 @@ public class ViewUtilities extends JPanel {
final String constraintsLBL = "w 90%!, h 20px!, gap 5% 0 3px 8px"; final String constraintsLBL = "w 90%!, h 20px!, gap 5% 0 3px 8px";
final String constraintsBTN = "h 30px!, w 50%!, gap 25% 0 0 0"; final String constraintsBTN = "h 30px!, w 50%!, gap 25% 0 0 0";
btnDownloadPics = new SubButton("Download LQ Card Pictures"); btnDownloadPics = new FLabel.Builder().opaque(true).hoverable(true)
.text("Download LQ Card Pictures").fontScaleFactor(0.5).build();
final FLabel lblPics = new FLabel.Builder().fontAlign(SwingConstants.CENTER) final FLabel lblPics = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.text("Download default card picture for each card.").fontStyle(Font.ITALIC).build(); .text("Download default card picture for each card.").fontStyle(Font.ITALIC).build();
this.add(btnDownloadPics, constraintsBTN); this.add(btnDownloadPics, constraintsBTN);
this.add(lblPics, constraintsLBL); this.add(lblPics, constraintsLBL);
btnDownloadSetPics = new SubButton("Download LQ Set Pictures"); btnDownloadSetPics = new FLabel.Builder().opaque(true).hoverable(true)
.text("Download LQ Set Pictures").fontScaleFactor(0.5).build();
final FLabel lblSets = new FLabel.Builder().fontAlign(SwingConstants.CENTER) final FLabel lblSets = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.text("Download full card picture sets for all cards from legacy releases of MTG.") .text("Download full card picture sets for all cards from legacy releases of MTG.")
.fontStyle(Font.ITALIC).build(); .fontStyle(Font.ITALIC).build();
@@ -82,14 +83,16 @@ public class ViewUtilities extends JPanel {
this.add(btnDownloadSetPics, constraintsBTN); this.add(btnDownloadSetPics, constraintsBTN);
this.add(lblSets, constraintsLBL); this.add(lblSets, constraintsLBL);
btnDownloadQuestImages = new SubButton("Download Quest Images"); btnDownloadQuestImages = new FLabel.Builder().opaque(true).hoverable(true)
.text("Download Quest Images").fontScaleFactor(0.5).build();
final FLabel lblQuest = new FLabel.Builder().fontAlign(SwingConstants.CENTER) final FLabel lblQuest = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.text("Download tokens and icons used in Quest mode.").fontStyle(Font.ITALIC).build(); .text("Download tokens and icons used in Quest mode.").fontStyle(Font.ITALIC).build();
this.add(btnDownloadQuestImages, constraintsBTN); this.add(btnDownloadQuestImages, constraintsBTN);
this.add(lblQuest, constraintsLBL); this.add(lblQuest, constraintsLBL);
btnDownloadPrices = new SubButton("Download Card Prices"); btnDownloadPrices = new FLabel.Builder().opaque(true).hoverable(true)
.text("Download Card Prices").fontScaleFactor(0.5).build();
final FLabel lblPrices = new FLabel.Builder().fontAlign(SwingConstants.CENTER) final FLabel lblPrices = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.text("Download up-to-date price list for in-game card shops.") .text("Download up-to-date price list for in-game card shops.")
.fontStyle(Font.ITALIC).build(); .fontStyle(Font.ITALIC).build();
@@ -97,28 +100,31 @@ public class ViewUtilities extends JPanel {
this.add(btnDownloadPrices, constraintsBTN); this.add(btnDownloadPrices, constraintsBTN);
this.add(lblPrices, constraintsLBL); this.add(lblPrices, constraintsLBL);
btnImportPictures = new SubButton("Import Pictures"); btnImportPictures = new FLabel.Builder().opaque(true).hoverable(true)
.text("Import Pictures").fontScaleFactor(0.5).build();
final FLabel lblImport = new FLabel.Builder().fontAlign(SwingConstants.CENTER) final FLabel lblImport = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.text("Import card pictures from a local version of Forge.") .text("Import card pictures from a local version of Forge.")
.fontStyle(Font.ITALIC).build(); .fontStyle(Font.ITALIC).build();
this.add(btnImportPictures, constraintsBTN); this.add(btnImportPictures, constraintsBTN);
this.add(lblImport, constraintsLBL); this.add(lblImport, constraintsLBL);
btnReportBug = new SubButton("Report a Bug"); btnReportBug = new FLabel.Builder().opaque(true).hoverable(true)
.text("Report a Bug").fontScaleFactor(0.5).build();
final FLabel lblReport = new FLabel.Builder().fontAlign(SwingConstants.CENTER) final FLabel lblReport = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.text("Something broken?").fontStyle(Font.ITALIC).build(); .text("Something broken?").fontStyle(Font.ITALIC).build();
this.add(btnReportBug, constraintsBTN); this.add(btnReportBug, constraintsBTN);
this.add(lblReport, constraintsLBL); this.add(lblReport, constraintsLBL);
btnDeckEditor = new SubButton("Deck Editor"); btnDeckEditor = new FLabel.Builder().opaque(true).hoverable(true)
.text("Deck Editor").fontScaleFactor(0.5).build();
final FLabel lblEditor = new FLabel.Builder().fontAlign(SwingConstants.CENTER) final FLabel lblEditor = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
.text("Build or edit a deck using all cards available in Forge.") .text("Build or edit a deck using all cards available in Forge.")
.fontStyle(Font.ITALIC).build(); .fontStyle(Font.ITALIC).build();
this.add(btnDeckEditor, constraintsBTN); this.add(btnDeckEditor, constraintsBTN);
this.add(lblEditor, constraintsLBL); this.add(lblEditor, constraintsLBL);
btnHowToPlay = new SubButton("How To Play"); btnHowToPlay = new FLabel.Builder().opaque(true).hoverable(true).text("How To Play");
this.add(btnHowToPlay, constraintsBTN); this.add(btnHowToPlay, constraintsBTN);
tpnLicensing = new JTextPane(); tpnLicensing = new JTextPane();
@@ -171,43 +177,43 @@ public class ViewUtilities extends JPanel {
overlay.showOverlay(); overlay.showOverlay();
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnDownloadPics() { public FLabel getBtnDownloadPics() {
return btnDownloadPics; return btnDownloadPics;
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnDownloadSetPics() { public FLabel getBtnDownloadSetPics() {
return btnDownloadSetPics; return btnDownloadSetPics;
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnDownloadQuestImages() { public FLabel getBtnDownloadQuestImages() {
return btnDownloadQuestImages; return btnDownloadQuestImages;
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnReportBug() { public FLabel getBtnReportBug() {
return btnReportBug; return btnReportBug;
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnImportPictures() { public FLabel getBtnImportPictures() {
return btnImportPictures; return btnImportPictures;
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnHowToPlay() { public FLabel getBtnHowToPlay() {
return btnHowToPlay; return btnHowToPlay;
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnDownloadPrices() { public FLabel getBtnDownloadPrices() {
return btnDownloadPrices; return btnDownloadPrices;
} }
/** @return SubButton */ /** @return {@link forge.view.toolbox.FLabel} */
public SubButton getBtnDeckEditor() { public FLabel getBtnDeckEditor() {
return btnDeckEditor; return btnDeckEditor;
} }

View File

@@ -116,6 +116,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
@Override @Override
public final void startNextRound() { public final void startNextRound() {
AllZone.getDisplay().savePrefs(); AllZone.getDisplay().savePrefs();
this.model.qPrefs.save();
if (Constant.Quest.FANTASY_QUEST[0]) { if (Constant.Quest.FANTASY_QUEST[0]) {
int extraLife = 0; int extraLife = 0;
@@ -299,7 +300,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
AllZone.setQuestEvent(null); AllZone.setQuestEvent(null);
this.model.qData.saveData(); this.model.qData.saveData();
this.model.qPrefs.save();
AllZone.getDisplay().savePrefs(); AllZone.getDisplay().savePrefs();
FControl g = ((GuiTopLevel) AllZone.getDisplay()).getController(); FControl g = ((GuiTopLevel) AllZone.getDisplay()).getController();
@@ -546,7 +547,6 @@ public class QuestWinLoseHandler extends ControlWinLose {
final GameFormat selected = ch.getSelectedValue(); final GameFormat selected = ch.getSelectedValue();
this.model.qPrefs.setPreference(QPref.BOOSTER_FORMAT, selected.toString()); this.model.qPrefs.setPreference(QPref.BOOSTER_FORMAT, selected.toString());
this.model.qPrefs.save();
final List<CardPrinted> cardsWon = this.model.qData.getCards().addCards(selected.getFilterPrinted()); final List<CardPrinted> cardsWon = this.model.qData.getCards().addCards(selected.getFilterPrinted());

View File

@@ -95,11 +95,15 @@ public class DeckLister extends JPanel {
rowTitle.setBackground(skin.getColor(FSkin.Colors.CLR_ZEBRA)); rowTitle.setBackground(skin.getColor(FSkin.Colors.CLR_ZEBRA));
rowTitle.setLayout(new MigLayout("insets 0, gap 0")); rowTitle.setLayout(new MigLayout("insets 0, gap 0"));
rowTitle.add(new FLabel.Builder().text("Delete").fontAlign(SwingConstants.CENTER), "w 10%!, h 20px!, gaptop 5px"); rowTitle.add(new FLabel.Builder().text("Delete").fontAlign(SwingConstants.CENTER).build(),
rowTitle.add(new FLabel.Builder().text("Edit").fontAlign(SwingConstants.CENTER), "w 10%!, h 20px!, gaptop 5px"); "w 10%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Deck Name").fontAlign(SwingConstants.CENTER), "w 60%!, h 20px!, gaptop 5px"); rowTitle.add(new FLabel.Builder().text("Edit").fontAlign(SwingConstants.CENTER).build(),
rowTitle.add(new FLabel.Builder().text("Main").fontAlign(SwingConstants.CENTER), "w 10%!, h 20px!, gaptop 5px"); "w 10%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Side").fontAlign(SwingConstants.CENTER), "w 10%!, h 20px!, gaptop 5px"); rowTitle.add(new FLabel.Builder().text("Deck Name").fontAlign(SwingConstants.CENTER).build(), "w 60%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Main").fontAlign(SwingConstants.CENTER).build(),
"w 10%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Side").fontAlign(SwingConstants.CENTER).build(),
"w 10%!, h 20px!, gaptop 5px");
this.add(rowTitle, "w 98%!, h 30px!, gapleft 1%"); this.add(rowTitle, "w 98%!, h 30px!, gapleft 1%");
RowPanel row; RowPanel row;

View File

@@ -20,11 +20,11 @@ import forge.Command;
import forge.Singletons; import forge.Singletons;
/** /**
* Uses the Builder pattern to facilitate/encourage inline styling. * Uses the Builder pattern to facilitate/encourage inline styling.
* Credit to Effective Java 2 (Joshua Bloch). * Credit to Effective Java 2 (Joshua Bloch).
* Methods in builder can be chained. To declare: * Methods in builder can be chained. To declare:
* <code>new FLabel.Builder().method1(foo).method2(bar).method3(baz)...</code> * <code>new FLabel.Builder().method1(foo).method2(bar).method3(baz)...</code>
* <br>and then call build() to make the label. * <br>and then call build() to make the label (don't forget that part).
* <br><br> * <br><br>
* Adjustable features of FLabel:<br> * Adjustable features of FLabel:<br>
* - Automatic font scaling (60% size by default, can toggle on/off)<br> * - Automatic font scaling (60% size by default, can toggle on/off)<br>
@@ -41,7 +41,7 @@ public class FLabel extends JLabel {
* Credit to Effective Java 2 (Joshua Bloch), a fantastic book. * Credit to Effective Java 2 (Joshua Bloch), a fantastic book.
* Methods in builder can be chained. To declare: * Methods in builder can be chained. To declare:
* <code>new FLabel.Builder().method1(foo).method2(bar).method3(baz)...</code> * <code>new FLabel.Builder().method1(foo).method2(bar).method3(baz)...</code>
* <br>and then call build() to make the label. * <br>and then call build() to make the label (don't forget that part).
*/ */
public static class Builder extends FLabel { public static class Builder extends FLabel {
//========== Default values for FLabel are set here. //========== Default values for FLabel are set here.
@@ -144,22 +144,24 @@ public class FLabel extends JLabel {
// Init fields from builder // Init fields from builder
this.fontScaleFactor = b0.bldFontScaleFactor; this.fontScaleFactor = b0.bldFontScaleFactor;
this.iconScaleFactor = b0.bldIconScaleFactor; this.iconScaleFactor = b0.bldIconScaleFactor;
this.fontScaleBy = b0.bldFontScaleBy;
this.fontStyle = b0.bldFontStyle;
this.selectable = b0.bldSelectable;
this.hoverable = b0.bldHoverable;
this.opaque = b0.bldOpaque; this.opaque = b0.bldOpaque;
this.iconInBackground = b0.bldIconInBackground; this.iconInBackground = b0.bldIconInBackground;
this.fontScaleAuto = b0.bldFontScaleAuto; this.fontScaleAuto = b0.bldFontScaleAuto;
this.iconScaleAuto = b0.bldIconScaleAuto; this.iconScaleAuto = b0.bldIconScaleAuto;
this.selectable = b0.bldSelectable;
this.setIcon(b0.bldIcon); this.setFontScaleBy(b0.bldFontScaleBy);
this.setFontStyle(b0.bldFontStyle);
this.setIconAlpha(b0.bldIconAlpha); this.setIconAlpha(b0.bldIconAlpha);
this.setCommand(b0.bldCmd); this.setCommand(b0.bldCmd);
this.setFontAlign(b0.bldFontAlign); this.setFontAlign(b0.bldFontAlign);
this.setText(b0.bldText); this.setText(b0.bldText);
this.setToolTipText(b0.bldToolTip); this.setToolTipText(b0.bldToolTip);
this.setHoverable(b0.bldHoverable);
// Call this last; to allow the properties which affect icons to already be in place.
this.setIcon(b0.bldIcon);
// Non-custom display properties // Non-custom display properties
this.setForeground(clrText); this.setForeground(clrText);
@@ -176,8 +178,8 @@ public class FLabel extends JLabel {
private final Color clrText = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_TEXT); private final Color clrText = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_TEXT);
private final Color clrBorders = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_BORDERS); private final Color clrBorders = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_BORDERS);
private final Color clrHover = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_HOVER); private final Color clrHover = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_HOVER);
private final Color clrInactive = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_ACTIVE); private final Color clrInactive = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_INACTIVE);
private final Color clrActive = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_INACTIVE); private final Color clrActive = Singletons.getView().getSkin().getColor(FSkin.Colors.CLR_ACTIVE);
// Custom properties, assigned either at realization (using builder) // Custom properties, assigned either at realization (using builder)
// or dynamically (using methods below). // or dynamically (using methods below).
@@ -233,14 +235,15 @@ public class FLabel extends JLabel {
public void mouseExited(MouseEvent e) { hovered = false; repaint(); } public void mouseExited(MouseEvent e) { hovered = false; repaint(); }
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
cmdClick.execute();
if (!selectable) { return; } if (!selectable) { return; }
if (selected) { setSelected(false); } if (selected) { setSelected(false); }
else { setSelected(true); } else { setSelected(true); }
cmdClick.execute();
} }
}; };
/** @param b0 &emsp; boolean */ /** @param b0 &emsp; boolean */
// Must be public.
public void setHoverable(boolean b0) { public void setHoverable(boolean b0) {
this.hoverable = b0; this.hoverable = b0;
if (!b0) { this.removeMouseListener(madEvents); } if (!b0) { this.removeMouseListener(madEvents); }
@@ -248,55 +251,23 @@ public class FLabel extends JLabel {
} }
/** @param b0 &emsp; boolean */ /** @param b0 &emsp; boolean */
public void setSelectable(boolean b0) { // Must be public.
this.selectable = b0;
}
/** @param b0 &emsp; boolean */
public void setSelected(boolean b0) { public void setSelected(boolean b0) {
this.selected = b0; this.selected = b0;
repaint(); repaint();
} }
/** @param d0 &emsp; Scale factor for font size relative to label height, percent.
* If your font is "blowing up", try setting an explicity height/width for this label. */
public void setFontScaleFactor(final double d0) {
this.fontScaleFactor = d0;
}
/** @param b0 &emsp; {@link java.lang.boolean} */
public void setFontScaleAuto(final boolean b0) {
this.fontScaleAuto = b0;
}
/** @param d0 &emsp; Scale factor for icon size relative to label height, percent. */
public void setIconScaleFactor(final double d0) {
this.iconScaleFactor = d0;
}
/** @param b0 &emsp; Font drawn in background, or positioned by default. */
public void setIconInBackground(final boolean b0) {
this.iconInBackground = b0;
// Reset icon in case this method has been called after setIcon().
if (b0 && img != null) { setIcon(new ImageIcon(img)); }
}
/** @param b0 &emsp; {@link java.lang.boolean} */
public void setIconScaleAuto(final boolean b0) {
this.iconScaleAuto = b0;
// Reset icon in case this method has been called after setIcon().
if (!b0 && img != null) { setIcon(new ImageIcon(img)); }
}
/** Sets alpha if icon is in background. /** Sets alpha if icon is in background.
* @param f0 &emsp; float */ * @param f0 &emsp; float */
public void setIconAlpha(float f0) { // NOT public; must be set when label is built.
private void setIconAlpha(float f0) {
this.alphaDim = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, f0); this.alphaDim = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, f0);
this.alphaStrong = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f); this.alphaStrong = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
} }
/** @param i0 &emsp; int, must be SwingConstants.HORIZONTAL or VERTICAL */ /** @param i0 &emsp; int, must be SwingConstants.HORIZONTAL or VERTICAL */
public void setFontScaleBy(int i0) { // NOT public; must be set when label is built.
private void setFontScaleBy(int i0) {
if (i0 != SwingConstants.HORIZONTAL && i0 != SwingConstants.VERTICAL) { if (i0 != SwingConstants.HORIZONTAL && i0 != SwingConstants.VERTICAL) {
throw new IllegalArgumentException("FLabel$setScaleBy " throw new IllegalArgumentException("FLabel$setScaleBy "
+ "must be passed either SwingConstants.HORIZONTAL " + "must be passed either SwingConstants.HORIZONTAL "
@@ -307,7 +278,8 @@ public class FLabel extends JLabel {
} }
/** @param i0 &emsp; Font.PLAIN, .BOLD, or .ITALIC */ /** @param i0 &emsp; Font.PLAIN, .BOLD, or .ITALIC */
public void setFontStyle(int i0) { // NOT public; must be set when label is built.
private void setFontStyle(int i0) {
if (i0 != Font.PLAIN && i0 != Font.BOLD && i0 != Font.ITALIC) { if (i0 != Font.PLAIN && i0 != Font.BOLD && i0 != Font.ITALIC) {
throw new IllegalArgumentException("FLabel$setFontStyle " throw new IllegalArgumentException("FLabel$setFontStyle "
+ "must be passed either Font.PLAIN, Font.BOLD, or Font.ITALIC."); + "must be passed either Font.PLAIN, Font.BOLD, or Font.ITALIC.");
@@ -316,7 +288,8 @@ public class FLabel extends JLabel {
} }
/** @param i0 &emsp; SwingConstants.CENTER, .LEFT or .RIGHT */ /** @param i0 &emsp; SwingConstants.CENTER, .LEFT or .RIGHT */
public void setFontAlign(int i0) { // NOT public; must be set when label is built.
private void setFontAlign(int i0) {
if (i0 != SwingConstants.CENTER && i0 != SwingConstants.LEFT && i0 != SwingConstants.RIGHT) { if (i0 != SwingConstants.CENTER && i0 != SwingConstants.LEFT && i0 != SwingConstants.RIGHT) {
throw new IllegalArgumentException("FLabel$setFontStyle " throw new IllegalArgumentException("FLabel$setFontStyle "
+ "must be passed either SwingConstants.CENTER, " + "must be passed either SwingConstants.CENTER, "
@@ -326,6 +299,7 @@ public class FLabel extends JLabel {
} }
@Override @Override
// Must be public.
public void setIcon(final Icon i0) { public void setIcon(final Icon i0) {
if (i0 == null) { this.img = null; return; } if (i0 == null) { this.img = null; return; }
// Will need image (not icon) for scaled and non-scaled. // Will need image (not icon) for scaled and non-scaled.
@@ -347,11 +321,6 @@ public class FLabel extends JLabel {
this.cmdClick = c0; this.cmdClick = c0;
} }
/** @return {@link forge.Command} on click */
public Command getCommand() {
return this.cmdClick;
}
@Override @Override
public void setOpaque(final boolean b0) { public void setOpaque(final boolean b0) {
// Must be overridden to allow drawing order of background, icon, string // Must be overridden to allow drawing order of background, icon, string

View File

@@ -1,89 +0,0 @@
package forge.view.toolbox;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
import forge.Singletons;
/**
* Standard button used for for submenus on the home screen.
*
*/
@SuppressWarnings("serial")
public class SubButton extends JButton {
private FSkin skin;
private final Color clrHover, clrInactive;
/** */
public SubButton() {
this("");
}
/**
*
* Standard button used for for submenus on the home screen.
*
* @param txt0 &emsp; String
*/
public SubButton(String txt0) {
super(txt0);
this.skin = Singletons.getView().getSkin();
this.clrHover = skin.getColor(FSkin.Colors.CLR_HOVER);
this.clrInactive = skin.getColor(FSkin.Colors.CLR_INACTIVE);
setBorder(new LineBorder(skin.getColor(FSkin.Colors.CLR_BORDERS), 1));
setBackground(clrInactive);
setForeground(skin.getColor(FSkin.Colors.CLR_TEXT));
setVerticalTextPosition(SwingConstants.CENTER);
setFocusPainted(false);
this.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
if (isEnabled() && !isSelected()) { setBackground(clrHover); }
}
public void mouseExited(MouseEvent e) {
if (isEnabled() && !isSelected()) { setBackground(clrInactive); }
}
});
this.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
int px = (int) (SubButton.this.getHeight() / 2);
px = (px < 10 ? 10 : px);
px = (px > 15 ? 15 : px);
SubButton.this.setFont(Singletons.getView().getSkin().getFont(px));
}
});
}
@Override
public void setEnabled(boolean b0) {
super.setEnabled(b0);
if (b0) { setBackground(skin.getColor(FSkin.Colors.CLR_INACTIVE)); }
else { setBackground(new Color(220, 220, 220)); }
}
@Override
public void setSelected(boolean b0) {
super.setSelected(b0);
}
@Override
public void paintComponent(Graphics g) {
g.setColor(getBackground());
g.clearRect(0, 0, getWidth(), getHeight());
g.fillRect(0, 0, getWidth(), getHeight());
super.paintComponent(g);
}
}