mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Further work on home screen.
This commit is contained in:
8
.gitattributes
vendored
8
.gitattributes
vendored
@@ -11340,9 +11340,17 @@ src/main/java/forge/gui/home/constructed/VSubmenuCustom.java -text
|
||||
src/main/java/forge/gui/home/constructed/VSubmenuQuestEvents.java -text
|
||||
src/main/java/forge/gui/home/constructed/VSubmenuThemes.java -text
|
||||
src/main/java/forge/gui/home/draft/CSubmenuDraft.java -text
|
||||
src/main/java/forge/gui/home/draft/CSubmenuSealed.java -text
|
||||
src/main/java/forge/gui/home/draft/VSubmenuDraft.java -text
|
||||
src/main/java/forge/gui/home/draft/VSubmenuSealed.java -text
|
||||
src/main/java/forge/gui/home/quest/CSubmenuDuels.java -text
|
||||
src/main/java/forge/gui/home/quest/VSubmenuDuels.java -text
|
||||
src/main/java/forge/gui/home/settings/CSubmenuAvatars.java -text
|
||||
src/main/java/forge/gui/home/settings/CSubmenuPreferences.java -text
|
||||
src/main/java/forge/gui/home/settings/VSubmenuAvatars.java -text
|
||||
src/main/java/forge/gui/home/settings/VSubmenuPreferences.java -text
|
||||
src/main/java/forge/gui/home/utilities/CSubmenuDeckEditor.java -text
|
||||
src/main/java/forge/gui/home/utilities/VSubmenuDeckEditor.java -text
|
||||
src/main/java/forge/gui/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/item/BoosterPack.java -text
|
||||
src/main/java/forge/item/CardDb.java -text
|
||||
|
||||
@@ -47,7 +47,7 @@ public enum VSubmenuColors implements IVSubmenu {
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return null;
|
||||
return EMenuGroup.CONSTRUCTED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -45,7 +45,7 @@ public enum VSubmenuCustom implements IVSubmenu {
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return null;
|
||||
return EMenuGroup.CONSTRUCTED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -45,7 +45,7 @@ public enum VSubmenuQuestEvents implements IVSubmenu {
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return null;
|
||||
return EMenuGroup.QUEST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -45,7 +45,7 @@ public enum VSubmenuThemes implements IVSubmenu {
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return null;
|
||||
return EMenuGroup.CONSTRUCTED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
189
src/main/java/forge/gui/home/draft/CSubmenuSealed.java
Normal file
189
src/main/java/forge/gui/home/draft/CSubmenuSealed.java
Normal file
@@ -0,0 +1,189 @@
|
||||
package forge.gui.home.draft;
|
||||
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import net.slightlymagic.braids.util.UtilFunctions;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckGroup;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GameType;
|
||||
import forge.game.limited.SealedDeck;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.home.ICSubmenu;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPool;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public enum CSubmenuSealed implements ICSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private Map<String, Deck> aiDecks;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
final VSubmenuSealed view = VSubmenuSealed.SINGLETON_INSTANCE;
|
||||
|
||||
view.populate();
|
||||
CSubmenuSealed.SINGLETON_INSTANCE.update();
|
||||
|
||||
VSubmenuSealed.SINGLETON_INSTANCE.getBtnBuildDeck().addMouseListener(
|
||||
new MouseAdapter() { @Override
|
||||
public void mousePressed(MouseEvent e) { setupSealed(); } });
|
||||
|
||||
VSubmenuSealed.SINGLETON_INSTANCE.getBtnStart().addMouseListener(
|
||||
new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(final MouseEvent e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startGame();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
VSubmenuSealed.SINGLETON_INSTANCE.showDirections();
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#getCommand()
|
||||
*/
|
||||
@Override
|
||||
public Command getMenuCommand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
List<Deck> humanDecks = new ArrayList<Deck>();
|
||||
aiDecks = new HashMap<String, Deck>();
|
||||
|
||||
// Since AI decks are tied directly to the human choice,
|
||||
// they're just mapped in a parallel map and grabbed when the game starts.
|
||||
for (DeckGroup d : Singletons.getModel().getDecks().getSealed()) {
|
||||
aiDecks.put(d.getName(), d.getAiDecks().get(0));
|
||||
humanDecks.add(d.getHumanDeck());
|
||||
}
|
||||
|
||||
VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setDecks(humanDecks);
|
||||
}
|
||||
|
||||
private void startGame() {
|
||||
Deck human = VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().getSelectedDeck();
|
||||
|
||||
if (human == null) {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"Please build and/or select a deck for yourself.",
|
||||
"No deck", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
GuiUtils.startGameOverlay().showOverlay();
|
||||
|
||||
Constant.Runtime.HUMAN_DECK[0] = human;
|
||||
Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(human.getName()).getAiDecks().get(0);
|
||||
|
||||
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
|
||||
}
|
||||
|
||||
/** */
|
||||
private void setupSealed() {
|
||||
ArrayList<String> sealedTypes = new ArrayList<String>();
|
||||
sealedTypes.add("Full Cardpool");
|
||||
sealedTypes.add("Block / Set");
|
||||
sealedTypes.add("Custom");
|
||||
|
||||
final String prompt = "Choose Sealed Deck Format:";
|
||||
final Object o = GuiUtils.getChoice(prompt, sealedTypes.toArray());
|
||||
|
||||
SealedDeck sd = null;
|
||||
|
||||
if (o.toString().equals(sealedTypes.get(0))) {
|
||||
sd = new SealedDeck("Full");
|
||||
}
|
||||
|
||||
else if (o.toString().equals(sealedTypes.get(1))) {
|
||||
sd = new SealedDeck("Block");
|
||||
}
|
||||
|
||||
else if (o.toString().equals(sealedTypes.get(2))) {
|
||||
sd = new SealedDeck("Custom");
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("choice <<" + UtilFunctions.safeToString(o)
|
||||
+ ">> does not equal any of the sealedTypes.");
|
||||
}
|
||||
|
||||
if (sd.getCardpool().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String sDeckName = JOptionPane.showInputDialog(null,
|
||||
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_MSG),
|
||||
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL),
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
if (StringUtils.isBlank(sDeckName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// May check for name uniqueness here
|
||||
|
||||
final ItemPool<CardPrinted> sDeck = sd.getCardpool();
|
||||
|
||||
Deck deck = new Deck(sDeckName);
|
||||
deck.getSideboard().addAll(sDeck);
|
||||
|
||||
for (final String element : Constant.Color.BASIC_LANDS) {
|
||||
deck.getSideboard().add(element, sd.getLandSetCode()[0], 18);
|
||||
}
|
||||
|
||||
DeckGroup sealed = new DeckGroup(sDeckName);
|
||||
sealed.setHumanDeck(deck);
|
||||
sealed.addAiDeck(sd.buildAIDeck(sDeck.toForgeCardList()));
|
||||
Singletons.getModel().getDecks().getSealed().add(sealed);
|
||||
|
||||
Singletons.getControl().getControlHome().getControlUtilities().showDeckEditor(GameType.Sealed, sealed);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public enum VSubmenuDraft implements IVSubmenu {
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return null;
|
||||
return EMenuGroup.LIMITED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
161
src/main/java/forge/gui/home/draft/VSubmenuSealed.java
Normal file
161
src/main/java/forge/gui/home/draft/VSubmenuSealed.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package forge.gui.home.draft;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.StyledDocument;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Command;
|
||||
import forge.game.GameType;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.home.EMenuGroup;
|
||||
import forge.gui.home.IVSubmenu;
|
||||
import forge.view.home.StartButton;
|
||||
import forge.view.toolbox.DeckLister;
|
||||
import forge.view.toolbox.FButton;
|
||||
import forge.view.toolbox.FLabel;
|
||||
import forge.view.toolbox.FOverlay;
|
||||
import forge.view.toolbox.FPanel;
|
||||
import forge.view.toolbox.FScrollPane;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* Singleton instance of "Draft" submenu in "Constructed" group.
|
||||
*/
|
||||
public enum VSubmenuSealed implements IVSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final Command cmdExit = new Command() { @Override
|
||||
public void execute() { CSubmenuDraft.SINGLETON_INSTANCE.update(); } };
|
||||
|
||||
/** */
|
||||
private final JPanel pnl = new JPanel();
|
||||
private final StartButton btnStart = new StartButton();
|
||||
private final DeckLister lstDecks = new DeckLister(GameType.Draft, cmdExit);
|
||||
private final JLabel btnBuildDeck = new FLabel.Builder()
|
||||
.fontScaleAuto(false).fontSize(16)
|
||||
.opaque(true).hoverable(true).text("Build a Sealed Deck").build();
|
||||
private final JLabel btnDirections = new FLabel.Builder()
|
||||
.fontScaleAuto(false).fontSize(16)
|
||||
.text("Click For Directions").fontAlign(SwingConstants.CENTER).build();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
pnl.removeAll();
|
||||
pnl.setOpaque(false);
|
||||
pnl.setLayout(new MigLayout("insets 0, gap 0, hidemode 2, wrap"));
|
||||
|
||||
btnStart.setEnabled(false);
|
||||
|
||||
// Title
|
||||
final JLabel lblTitle = new JLabel("Select a deck for yourself, or build a new one: ");
|
||||
lblTitle.setFont(FSkin.getBoldFont(14));
|
||||
lblTitle.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
// Add components
|
||||
pnl.add(lblTitle, "w 100%!, gap 0 0 2% 2%");
|
||||
pnl.add(new FScrollPane(lstDecks), "w 90%!, h 35%!, gap 5% 0 2% 2%");
|
||||
pnl.add(btnBuildDeck, "w 50%!, h 5%!, gap 25% 0 0 0");
|
||||
pnl.add(btnStart, "ax center, gaptop 5%");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getGroup()
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return EMenuGroup.LIMITED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getPanel()
|
||||
*/
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
return pnl;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JLabel} */
|
||||
public JLabel getBtnDirections() {
|
||||
return this.btnDirections;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JLabel} */
|
||||
public JLabel getBtnBuildDeck() {
|
||||
return this.btnBuildDeck;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JButton} */
|
||||
public JButton getBtnStart() {
|
||||
return this.btnStart;
|
||||
}
|
||||
|
||||
/** @return {@link forge.view.toolbox.DeckLister} */
|
||||
public DeckLister getLstDecks() {
|
||||
return lstDecks;
|
||||
}
|
||||
|
||||
/** */
|
||||
public void showDirections() {
|
||||
final FOverlay overlay = GuiUtils.genericOverlay();
|
||||
final int w = overlay.getWidth();
|
||||
|
||||
final String instructions = "SEALED DECK MODE INSTRUCTIONS"
|
||||
+ "\r\n\r\n"
|
||||
+ "In Sealed Deck tournaments, each player receives six booster packs"
|
||||
+ "from which to build their deck."
|
||||
+ "\r\n\r\n"
|
||||
+ "Depending on which sets are to be used in a sealed deck event, "
|
||||
+ "the distribution of packs can vary greatly."
|
||||
+ "\r\n\r\n"
|
||||
+ "Credit: Wikipedia";
|
||||
|
||||
// Init directions text pane
|
||||
final JTextPane tpnDirections = new JTextPane();
|
||||
tpnDirections.setOpaque(false);
|
||||
tpnDirections.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
tpnDirections.setFont(FSkin.getFont(15));
|
||||
tpnDirections.setAlignmentX(SwingConstants.CENTER);
|
||||
tpnDirections.setFocusable(false);
|
||||
tpnDirections.setEditable(false);
|
||||
tpnDirections.setBorder(null);
|
||||
tpnDirections.setText(instructions);
|
||||
|
||||
final StyledDocument doc = tpnDirections.getStyledDocument();
|
||||
final SimpleAttributeSet center = new SimpleAttributeSet();
|
||||
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
|
||||
doc.setParagraphAttributes(0, doc.getLength(), center, false);
|
||||
|
||||
final JButton btnCloseBig = new FButton("OK");
|
||||
btnCloseBig.setBounds(new Rectangle((w / 2 - 100), 510, 200, 30));
|
||||
btnCloseBig.addActionListener(new ActionListener() { @Override
|
||||
public void actionPerformed(final ActionEvent arg0) { overlay.hideOverlay(); } });
|
||||
|
||||
final FPanel pnl = new FPanel();
|
||||
pnl.setCornerDiameter(0);
|
||||
pnl.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE));
|
||||
pnl.setLayout(new MigLayout("insets 0, gap 0"));
|
||||
pnl.add(tpnDirections, "w 90%!, h 90%!, gap 5% 0 5% 0");
|
||||
pnl.setBounds(new Rectangle((w / 2 - 250), 80, 500, 400));
|
||||
|
||||
overlay.setLayout(null);
|
||||
overlay.add(btnCloseBig);
|
||||
overlay.add(pnl);
|
||||
overlay.showOverlay();
|
||||
}
|
||||
}
|
||||
38
src/main/java/forge/gui/home/settings/CSubmenuAvatars.java
Normal file
38
src/main/java/forge/gui/home/settings/CSubmenuAvatars.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package forge.gui.home.settings;
|
||||
|
||||
import forge.Command;
|
||||
import forge.gui.home.ICSubmenu;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public enum CSubmenuAvatars implements ICSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
VSubmenuAvatars.SINGLETON_INSTANCE.populate();
|
||||
CSubmenuAvatars.SINGLETON_INSTANCE.update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#getCommand()
|
||||
*/
|
||||
@Override
|
||||
public Command getMenuCommand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
}
|
||||
}
|
||||
228
src/main/java/forge/gui/home/settings/CSubmenuPreferences.java
Normal file
228
src/main/java/forge/gui/home/settings/CSubmenuPreferences.java
Normal file
@@ -0,0 +1,228 @@
|
||||
package forge.gui.home.settings;
|
||||
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.gui.home.ICSubmenu;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public enum CSubmenuPreferences implements ICSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@Override
|
||||
public void initialize() {
|
||||
VSubmenuPreferences.SINGLETON_INSTANCE.populate();
|
||||
CSubmenuPreferences.SINGLETON_INSTANCE.update();
|
||||
|
||||
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
||||
final ForgePreferences prefs = Singletons.getModel().getPreferences();
|
||||
|
||||
view.getLstChooseSkin().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting()) { return; }
|
||||
updateSkin();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbAnte().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbAnte().isSelected();
|
||||
prefs.setPref(FPref.UI_ANTE, String.valueOf(toggle));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbScaleLarger().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbScaleLarger().isSelected();
|
||||
prefs.setPref(FPref.UI_SCALE_LARGER, String.valueOf(toggle));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbDevMode().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbDevMode().isSelected();
|
||||
prefs.setPref(FPref.DEV_MODE_ENABLED, String.valueOf(toggle));
|
||||
Constant.Runtime.DEV_MODE[0] = toggle;
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbRemoveSmall().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbRemoveSmall().isSelected();
|
||||
prefs.setPref(FPref.DECKGEN_NOSMALL, String.valueOf(toggle));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbRemoveArtifacts().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbRemoveArtifacts().isSelected();
|
||||
prefs.setPref(FPref.DECKGEN_ARTIFACTS, String.valueOf(toggle));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbSingletons().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbSingletons().isSelected();
|
||||
prefs.setPref(FPref.DECKGEN_SINGLETONS, String.valueOf(toggle));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbUploadDraft().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbUploadDraft().isSelected();
|
||||
prefs.setPref(FPref.UI_UPLOAD_DRAFT , String.valueOf(toggle));
|
||||
Constant.Runtime.UPLOAD_DRAFT[0] = toggle;
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbStackLand().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbStackLand().isSelected();
|
||||
prefs.setPref(FPref.UI_SMOOTH_LAND, String.valueOf(toggle));
|
||||
Constant.Runtime.SMOOTH[0] = toggle;
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbRandomFoil().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbRandomFoil().isSelected();
|
||||
prefs.setPref(FPref.UI_RANDOM_FOIL, String.valueOf(toggle));
|
||||
Constant.Runtime.RANDOM_FOIL[0] = toggle;
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getCbTextMana().addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent arg0) {
|
||||
final boolean toggle = view.getCbTextMana().isSelected();
|
||||
prefs.setPref(FPref.UI_CARD_OVERLAY, String.valueOf(toggle));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
view.getBtnReset().setCommand(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Singletons.getModel().getPreferences().reset();
|
||||
Singletons.getView().getViewHome().resetSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#getCommand()
|
||||
*/
|
||||
@Override
|
||||
public Command getMenuCommand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
||||
final ForgePreferences prefs = Singletons.getModel().getPreferences();
|
||||
updateSkinNames();
|
||||
|
||||
view.getCbRemoveSmall().setSelected(prefs.getPrefBoolean(FPref.DECKGEN_NOSMALL));
|
||||
view.getCbSingletons().setSelected(prefs.getPrefBoolean(FPref.DECKGEN_SINGLETONS));
|
||||
view.getCbRemoveArtifacts().setSelected(prefs.getPrefBoolean(FPref.DECKGEN_ARTIFACTS));
|
||||
view.getCbAnte().setSelected(prefs.getPrefBoolean(FPref.UI_ANTE));
|
||||
view.getCbUploadDraft().setSelected(prefs.getPrefBoolean(FPref.UI_UPLOAD_DRAFT));
|
||||
view.getCbStackLand().setSelected(prefs.getPrefBoolean(FPref.UI_SMOOTH_LAND));
|
||||
view.getCbDevMode().setSelected(prefs.getPrefBoolean(FPref.DEV_MODE_ENABLED));
|
||||
view.getCbRandomFoil().setSelected(prefs.getPrefBoolean(FPref.UI_RANDOM_FOIL));
|
||||
view.getCbScaleLarger().setSelected(prefs.getPrefBoolean(FPref.UI_SCALE_LARGER));
|
||||
view.getCbTextMana().setSelected(prefs.getPrefBoolean(FPref.UI_CARD_OVERLAY));
|
||||
}
|
||||
|
||||
private void updateSkinNames() {
|
||||
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
||||
final String[] uglyNames = FSkin.getSkins().toArray(new String[0]);
|
||||
final String[] prettyNames = new String[uglyNames.length];
|
||||
final String currentName = Singletons.getModel().getPreferences().getPref(FPref.UI_SKIN);
|
||||
int currentIndex = 0;
|
||||
|
||||
for (int i = 0; i < uglyNames.length; i++) {
|
||||
prettyNames[i] = WordUtils.capitalize(uglyNames[i].replace('_', ' '));
|
||||
if (currentName.equalsIgnoreCase(uglyNames[i])) { currentIndex = i; }
|
||||
}
|
||||
|
||||
view.getLstChooseSkin().setListData(prettyNames);
|
||||
view.getLstChooseSkin().setSelectedIndex(currentIndex);
|
||||
view.getLstChooseSkin().ensureIndexIsVisible(view.getLstChooseSkin().getSelectedIndex());
|
||||
}
|
||||
|
||||
private void updateSkin() {
|
||||
final VSubmenuPreferences view = VSubmenuPreferences.SINGLETON_INSTANCE;
|
||||
final ForgePreferences prefs = Singletons.getModel().getPreferences();
|
||||
|
||||
view.getLblTitleSkin().setText(" Loading...");
|
||||
view.getLblTitleSkin().setIcon(new ImageIcon("res/images/skins/default/loader.gif"));
|
||||
|
||||
final String name = view.getLstChooseSkin().getSelectedValue().toString();
|
||||
|
||||
final SwingWorker<Object, Object> w = new SwingWorker<Object, Object>() {
|
||||
@Override
|
||||
public String doInBackground() {
|
||||
FSkin.loadLight(name);
|
||||
FSkin.loadFull();
|
||||
|
||||
prefs.setPref(FPref.UI_SKIN, name);
|
||||
prefs.save();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
Singletons.getView().instantiateCachedUIStates();
|
||||
Singletons.getControl().changeState(FControl.HOME_SCREEN);
|
||||
Singletons.getView().getViewHome().showSettingsMenu();
|
||||
}
|
||||
};
|
||||
w.execute();
|
||||
}
|
||||
}
|
||||
228
src/main/java/forge/gui/home/settings/VSubmenuAvatars.java
Normal file
228
src/main/java/forge/gui/home/settings/VSubmenuAvatars.java
Normal file
@@ -0,0 +1,228 @@
|
||||
package forge.gui.home.settings;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.PlayerType;
|
||||
import forge.Singletons;
|
||||
import forge.gui.home.EMenuGroup;
|
||||
import forge.gui.home.IVSubmenu;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.view.toolbox.FScrollPane;
|
||||
import forge.view.toolbox.FSkin;
|
||||
import forge.view.toolbox.WrapLayout;
|
||||
|
||||
/**
|
||||
* Singleton instance of "Draft" submenu in "Constructed" group.
|
||||
*/
|
||||
public enum VSubmenuAvatars implements IVSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/** */
|
||||
private final JPanel pnl = new JPanel();
|
||||
private final JPanel pnlAvatars = new JPanel();
|
||||
|
||||
private AvatarLabel avatarHuman, avatarAI;
|
||||
private List<AvatarLabel> lstAvatars;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
populateAvatars();
|
||||
|
||||
pnl.removeAll();
|
||||
pnl.setOpaque(false);
|
||||
pnl.setLayout(new MigLayout("insets 0, gap 0"));
|
||||
pnl.add(new FScrollPane(pnlAvatars,
|
||||
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), " w 100%!, h 100%!");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getGroup()
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return EMenuGroup.SETTINGS;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getPanel()
|
||||
*/
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
return pnl;
|
||||
}
|
||||
|
||||
private void populateAvatars() {
|
||||
pnlAvatars.removeAll();
|
||||
pnlAvatars.setLayout(new WrapLayout());
|
||||
pnlAvatars.setOpaque(false);
|
||||
|
||||
lstAvatars = new ArrayList<AvatarLabel>();
|
||||
int counter = 0;
|
||||
for (final Image i : FSkin.getAvatars().values()) {
|
||||
lstAvatars.add(new AvatarLabel(i, counter++));
|
||||
pnlAvatars.add(lstAvatars.get(lstAvatars.size() - 1));
|
||||
}
|
||||
|
||||
final String[] indexes = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(",");
|
||||
int humanIndex = Integer.parseInt(indexes[0]);
|
||||
int aiIndex = Integer.parseInt(indexes[1]);
|
||||
|
||||
// Set human avatar from preferences
|
||||
if (humanIndex >= lstAvatars.size()) {
|
||||
humanIndex = (int) (Math.random() * (lstAvatars.size() - 1));
|
||||
}
|
||||
|
||||
avatarHuman = lstAvatars.get(humanIndex);
|
||||
avatarHuman.setOwner(PlayerType.HUMAN);
|
||||
avatarHuman.repaintOnlyThisLabel();
|
||||
|
||||
if (humanIndex == aiIndex || aiIndex >= lstAvatars.size()) {
|
||||
aiIndex = humanIndex;
|
||||
while (aiIndex == humanIndex) {
|
||||
aiIndex = (int) (Math.random() * (lstAvatars.size() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
avatarAI = lstAvatars.get(aiIndex);
|
||||
avatarAI.setOwner(PlayerType.COMPUTER);
|
||||
avatarAI.repaintOnlyThisLabel();
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private class AvatarLabel extends JLabel {
|
||||
private final Image img;
|
||||
private final int index;
|
||||
private PlayerType owner;
|
||||
private boolean hovered = false;
|
||||
|
||||
public AvatarLabel(final Image img0, final int index0) {
|
||||
super();
|
||||
img = img0;
|
||||
index = index0;
|
||||
setMaximumSize(new Dimension(100, 120));
|
||||
setMinimumSize(new Dimension(100, 120));
|
||||
setPreferredSize(new Dimension(100, 120));
|
||||
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(final MouseEvent evt) { hovered = true; repaintOnlyThisLabel(); }
|
||||
|
||||
@Override
|
||||
public void mouseExited(final MouseEvent evt) { hovered = false; repaintOnlyThisLabel(); }
|
||||
|
||||
@Override
|
||||
public void mouseClicked(final MouseEvent evt) { cycleOwner(AvatarLabel.this); repaintOnlyThisLabel(); }
|
||||
});
|
||||
}
|
||||
|
||||
public void setOwner(final PlayerType player0) {
|
||||
this.owner = player0;
|
||||
}
|
||||
|
||||
public PlayerType getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public void repaintOnlyThisLabel() {
|
||||
final Dimension d = AvatarLabel.this.getSize();
|
||||
repaint(0, 0, d.width, d.height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(final Graphics graphics0) {
|
||||
if (hovered) {
|
||||
graphics0.setColor(FSkin.getColor(FSkin.Colors.CLR_HOVER));
|
||||
graphics0.fillRect(0, 0, 100, 120);
|
||||
}
|
||||
|
||||
graphics0.drawImage(img, 0, 20, null);
|
||||
if (owner == null) { return; }
|
||||
|
||||
graphics0.setColor(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
graphics0.drawRect(0, 0, 99, 119);
|
||||
graphics0.setFont(FSkin.getBoldFont(14));
|
||||
graphics0.drawString(owner.toString(), 5, 15);
|
||||
}
|
||||
}
|
||||
|
||||
/** Surprisingly complicated - be careful when modifying! */
|
||||
private void cycleOwner(final AvatarLabel lbl0) {
|
||||
if (lbl0.getOwner() == null) {
|
||||
lbl0.setOwner(PlayerType.HUMAN);
|
||||
lbl0.repaintOnlyThisLabel();
|
||||
|
||||
if (avatarHuman != null) {
|
||||
avatarHuman.setOwner(null);
|
||||
avatarHuman.repaintOnlyThisLabel();
|
||||
}
|
||||
|
||||
avatarHuman = lbl0;
|
||||
}
|
||||
else if (lbl0.getOwner() == PlayerType.HUMAN) {
|
||||
// Re-assign avatar to human
|
||||
avatarHuman.setOwner(null);
|
||||
avatarHuman.repaintOnlyThisLabel();
|
||||
|
||||
for (int i = 0; i < lstAvatars.size(); i++) {
|
||||
if (lstAvatars.get(i) != lbl0) {
|
||||
avatarHuman = lstAvatars.get(i);
|
||||
avatarHuman.setOwner(PlayerType.HUMAN);
|
||||
avatarHuman.repaintOnlyThisLabel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Assign computer
|
||||
lbl0.setOwner(PlayerType.COMPUTER);
|
||||
lbl0.repaintOnlyThisLabel();
|
||||
|
||||
if (avatarAI != null) {
|
||||
avatarAI.setOwner(null);
|
||||
avatarAI.repaintOnlyThisLabel();
|
||||
}
|
||||
|
||||
avatarAI = lbl0;
|
||||
}
|
||||
else {
|
||||
lbl0.setOwner(null);
|
||||
lbl0.repaintOnlyThisLabel();
|
||||
|
||||
// Re-assign avatar to computer
|
||||
avatarAI.setOwner(null);
|
||||
avatarAI.repaintOnlyThisLabel();
|
||||
|
||||
for (int i = 0; i < lstAvatars.size(); i++) {
|
||||
if (lstAvatars.get(i) != avatarHuman) {
|
||||
avatarAI = lstAvatars.get(i);
|
||||
avatarAI.setOwner(PlayerType.COMPUTER);
|
||||
avatarAI.repaintOnlyThisLabel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Singletons.getModel().getPreferences().setPref(
|
||||
FPref.UI_AVATARS, avatarHuman.getIndex() + "," + avatarAI.getIndex());
|
||||
Singletons.getModel().getPreferences().save();
|
||||
}
|
||||
}
|
||||
361
src/main/java/forge/gui/home/settings/VSubmenuPreferences.java
Normal file
361
src/main/java/forge/gui/home/settings/VSubmenuPreferences.java
Normal file
@@ -0,0 +1,361 @@
|
||||
package forge.gui.home.settings;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.MatteBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.control.KeyboardShortcuts;
|
||||
import forge.control.KeyboardShortcuts.Shortcut;
|
||||
import forge.gui.home.EMenuGroup;
|
||||
import forge.gui.home.IVSubmenu;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants.Lang.OldGuiNewGame.NewGameText;
|
||||
import forge.view.toolbox.FLabel;
|
||||
import forge.view.toolbox.FList;
|
||||
import forge.view.toolbox.FScrollPane;
|
||||
import forge.view.toolbox.FSkin;
|
||||
|
||||
/**
|
||||
* Singleton instance of "Draft" submenu in "Constructed" group.
|
||||
*/
|
||||
public enum VSubmenuPreferences implements IVSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/** */
|
||||
private final JPanel pnl = new JPanel();
|
||||
|
||||
private final FLabel btnReset = new FLabel.Builder().opaque(true)
|
||||
.hoverable(true).text("Reset to defaults").build();
|
||||
|
||||
private final FLabel lblTitleSkin = new FLabel.Builder()
|
||||
.text("Choose Skin").fontScaleAuto(false).fontStyle(Font.BOLD).fontSize(14).build();
|
||||
|
||||
private final JList lstChooseSkin = new FList();
|
||||
|
||||
private final JCheckBox cbRemoveSmall = new OptionsCheckBox("Remove Small Creatures");
|
||||
private final JCheckBox cbSingletons = new OptionsCheckBox("Singleton Mode");
|
||||
private final JCheckBox cbRemoveArtifacts = new OptionsCheckBox("Remove Artifacts");
|
||||
private final JCheckBox cbAnte = new OptionsCheckBox("Play for Ante");
|
||||
private final JCheckBox cbUploadDraft = new OptionsCheckBox("Upload Draft Pics");
|
||||
private final JCheckBox cbStackLand = new OptionsCheckBox("Stack AI Land");
|
||||
private final JCheckBox cbDevMode = new OptionsCheckBox(ForgeProps.getLocalized(NewGameText.DEV_MODE));
|
||||
private final JCheckBox cbTextMana = new OptionsCheckBox("Text / Mana Overlay");
|
||||
private final JCheckBox cbScaleLarger = new OptionsCheckBox("Scale Image Larger");
|
||||
private final JCheckBox cbRandomFoil = new OptionsCheckBox("Random Foil");
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
pnl.removeAll();
|
||||
pnl.setOpaque(false);
|
||||
pnl.setLayout(new MigLayout("insets 0, gap 0"));
|
||||
|
||||
final JPanel pnlPrefs = new JPanel();
|
||||
pnlPrefs.setOpaque(false);
|
||||
pnlPrefs.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
|
||||
|
||||
// Spacing between components is defined here.
|
||||
final String sectionConstraints = "w 80%!, h 42px!, gap 10% 0 10px 10px, span 2 1";
|
||||
final String regularConstraints = "w 80%!, h 22px!, gap 10% 0 0 10px, span 2 1";
|
||||
|
||||
// Deck building options
|
||||
pnlPrefs.add(new SectionLabel("Deck Building Options"), sectionConstraints + ", gaptop 2%");
|
||||
|
||||
pnlPrefs.add(cbRemoveSmall, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Disables 1/1 and 0/X creatures in generated decks."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbSingletons, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Disables non-land duplicates in generated decks."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbRemoveArtifacts, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Disables artifact cards in generated decks."), regularConstraints);
|
||||
|
||||
// Gameplay Options
|
||||
pnlPrefs.add(new SectionLabel("Gameplay Options"), sectionConstraints);
|
||||
|
||||
pnlPrefs.add(cbAnte, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Determines whether or not the game is played for ante."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbUploadDraft, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Sends draft picks to Forge servers for analysis, to improve draft AI."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbStackLand, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Minimizes mana lock in AI hands, giving a slight advantage to computer."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbDevMode, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Enables menu with functions for testing during development."), regularConstraints);
|
||||
|
||||
// Graphic Options
|
||||
pnlPrefs.add(new SectionLabel("Graphic Options"), sectionConstraints);
|
||||
|
||||
pnlPrefs.add(lblTitleSkin, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Various user-created themes for Forge backgrounds, fonts, and colors."), regularConstraints);
|
||||
pnlPrefs.add(new FScrollPane(lstChooseSkin), "h 120px!, w 150px!, gap 10% 0 0 2%, wrap");
|
||||
|
||||
pnlPrefs.add(new FLabel.Builder().text("Card Size").fontStyle(Font.BOLD).build(), regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Size of cards in hand and playing field, when possible"), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbRandomFoil, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Adds foiled effects to random cards."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbScaleLarger, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Allows card pictures to be expanded larger than their original size."), regularConstraints);
|
||||
|
||||
pnlPrefs.add(cbTextMana, regularConstraints);
|
||||
pnlPrefs.add(new NoteLabel("Overlays each card with basic card-specific information."), regularConstraints);
|
||||
|
||||
// Keyboard shortcuts
|
||||
final JLabel lblShortcuts = new SectionLabel("Keyboard Shortcuts");
|
||||
pnlPrefs.add(lblShortcuts, sectionConstraints);
|
||||
|
||||
final List<Shortcut> shortcuts = Singletons.getControl().getShortcuts();
|
||||
|
||||
for (final Shortcut s : shortcuts) {
|
||||
pnlPrefs.add(new FLabel.Builder().text(s.getDescription())
|
||||
.fontAlign(SwingConstants.RIGHT).build(), "w 50%!, h 22px!, gap 0 2% 0 1%");
|
||||
pnlPrefs.add(new KeyboardShortcutField(s), "w 25%!");
|
||||
}
|
||||
|
||||
// Reset button
|
||||
pnlPrefs.add(new SectionLabel(" "), sectionConstraints);
|
||||
pnlPrefs.add(btnReset, sectionConstraints);
|
||||
|
||||
pnl.add(new FScrollPane(pnlPrefs,
|
||||
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), "w 100%!, h 100%!");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getGroup()
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return EMenuGroup.SETTINGS;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getPanel()
|
||||
*/
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
return pnl;
|
||||
}
|
||||
|
||||
/** Consolidates checkbox styling in one place. */
|
||||
@SuppressWarnings("serial")
|
||||
private class OptionsCheckBox extends JCheckBox {
|
||||
public OptionsCheckBox(final String txt0) {
|
||||
super();
|
||||
setText(txt0);
|
||||
setFont(FSkin.getBoldFont(12));
|
||||
setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
setBackground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
|
||||
setOpaque(false);
|
||||
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(final MouseEvent evt) {
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(final MouseEvent evt) {
|
||||
setOpaque(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Consolidates section title label styling in one place. */
|
||||
@SuppressWarnings("serial")
|
||||
private class SectionLabel extends JLabel {
|
||||
public SectionLabel(final String txt0) {
|
||||
super(txt0);
|
||||
setBorder(new MatteBorder(0, 0, 1, 0, FSkin.getColor(FSkin.Colors.CLR_BORDERS)));
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
setFont(FSkin.getBoldFont(16));
|
||||
setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
}
|
||||
}
|
||||
|
||||
/** Consolidates notation label styling in one place. */
|
||||
@SuppressWarnings("serial")
|
||||
private class NoteLabel extends JLabel {
|
||||
public NoteLabel(final String txt0) {
|
||||
super(txt0);
|
||||
setFont(FSkin.getItalicFont(12));
|
||||
setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A JTextField plus a "codeString" property, that stores keycodes for the
|
||||
* shortcut. Also, an action listener that handles translation of keycodes
|
||||
* into characters and (dis)assembly of keycode stack.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class KeyboardShortcutField extends JTextField {
|
||||
private String codeString;
|
||||
|
||||
/**
|
||||
* A JTextField plus a "codeString" property, that stores keycodes for
|
||||
* the shortcut. Also, an action listener that handles translation of
|
||||
* keycodes into characters and (dis)assembly of keycode stack.
|
||||
*
|
||||
* @param shortcut0   Shortcut object
|
||||
*/
|
||||
public KeyboardShortcutField(final Shortcut shortcut0) {
|
||||
super();
|
||||
this.setEditable(false);
|
||||
this.setFont(FSkin.getFont(14));
|
||||
this.setCodeString(Singletons.getModel().getPreferences().getPref(shortcut0.getPrefKey()));
|
||||
|
||||
this.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(final KeyEvent evt) {
|
||||
KeyboardShortcuts.addKeyCode(evt);
|
||||
}
|
||||
});
|
||||
|
||||
this.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(final FocusEvent evt) {
|
||||
KeyboardShortcutField.this.setBackground(FSkin.getColor(FSkin.Colors.CLR_ACTIVE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(final FocusEvent evt) {
|
||||
Singletons.getModel().getPreferences().setPref(
|
||||
shortcut0.getPrefKey(), getCodeString());
|
||||
Singletons.getModel().getPreferences().save();
|
||||
shortcut0.attach();
|
||||
KeyboardShortcutField.this.setBackground(Color.white);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the code string.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public final String getCodeString() {
|
||||
return this.codeString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the code string.
|
||||
*
|
||||
* @param str0
|
||||
*   The new code string (space delimited)
|
||||
*/
|
||||
public final void setCodeString(final String str0) {
|
||||
if ("null".equals(str0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.codeString = str0.trim();
|
||||
|
||||
final List<String> codes = new ArrayList<String>(Arrays.asList(this.codeString.split(" ")));
|
||||
final List<String> displayText = new ArrayList<String>();
|
||||
|
||||
for (final String s : codes) {
|
||||
if (!s.isEmpty()) {
|
||||
displayText.add(KeyEvent.getKeyText(Integer.valueOf(s)));
|
||||
}
|
||||
}
|
||||
|
||||
this.setText(StringUtils.join(displayText, ' '));
|
||||
}
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JList} */
|
||||
public final JList getLstChooseSkin() {
|
||||
return lstChooseSkin;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public final JCheckBox getCbRemoveSmall() {
|
||||
return cbRemoveSmall;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public final JCheckBox getCbSingletons() {
|
||||
return cbSingletons;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbRemoveArtifacts() {
|
||||
return cbRemoveArtifacts;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbUploadDraft() {
|
||||
return cbUploadDraft;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbStackLand() {
|
||||
return cbStackLand;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbTextMana() {
|
||||
return cbTextMana;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbRandomFoil() {
|
||||
return cbRandomFoil;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbAnte() {
|
||||
return cbAnte;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbScaleLarger() {
|
||||
return cbScaleLarger;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JCheckBox} */
|
||||
public JCheckBox getCbDevMode() {
|
||||
return cbDevMode;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.FLabel} */
|
||||
public FLabel getLblTitleSkin() {
|
||||
return lblTitleSkin;
|
||||
}
|
||||
|
||||
/** @return {@link forge.view.toolbox.FLabel} */
|
||||
public FLabel getBtnReset() {
|
||||
return btnReset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package forge.gui.home.utilities;
|
||||
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.game.GameType;
|
||||
import forge.gui.deckeditor.DeckEditorBase;
|
||||
import forge.gui.deckeditor.DeckEditorConstructed;
|
||||
import forge.gui.deckeditor.DeckEditorLimited;
|
||||
import forge.gui.home.ICSubmenu;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public enum CSubmenuDeckEditor implements ICSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
VSubmenuDeckEditor.SINGLETON_INSTANCE.populate();
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#getCommand()
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@Override
|
||||
public Command getMenuCommand() {
|
||||
return new Command() { @Override
|
||||
public void execute() { showDeckEditor(GameType.Constructed, null); } };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void update() { }
|
||||
|
||||
/**
|
||||
* @param <T>  
|
||||
* @param gt0   GameType
|
||||
* @param d0   Deck
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> void showDeckEditor(GameType gt0, T d0) {
|
||||
|
||||
DeckEditorBase<?, T> editor = null;
|
||||
if (gt0 == GameType.Constructed) {
|
||||
editor = (DeckEditorBase<?, T>) new DeckEditorConstructed();
|
||||
} else if (gt0 == GameType.Draft) {
|
||||
editor = (DeckEditorBase<?, T>) new DeckEditorLimited(Singletons.getModel().getDecks().getDraft());
|
||||
} else if (gt0 == GameType.Sealed) {
|
||||
editor = (DeckEditorBase<?, T>) new DeckEditorLimited(Singletons.getModel().getDecks().getSealed());
|
||||
}
|
||||
|
||||
|
||||
final Command exit = new Command() {
|
||||
private static final long serialVersionUID = -9133358399503226853L;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Singletons.getControl().getControlHome().getControlConstructed().updateDeckLists();
|
||||
}
|
||||
};
|
||||
|
||||
editor.show(exit);
|
||||
|
||||
if (d0 != null) {
|
||||
editor.getController().setModel(d0);
|
||||
}
|
||||
|
||||
editor.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package forge.gui.home.utilities;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.home.EMenuGroup;
|
||||
import forge.gui.home.IVSubmenu;
|
||||
import forge.view.toolbox.FLabel;
|
||||
|
||||
/**
|
||||
* Singleton instance of "Colors" submenu in "Constructed" group.
|
||||
*
|
||||
*/
|
||||
public enum VSubmenuDeckEditor implements IVSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/** */
|
||||
private final JPanel pnl = new JPanel();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
pnl.setLayout(new MigLayout("insets 0, gap 0, align center"));
|
||||
pnl.setOpaque(false);
|
||||
|
||||
pnl.add(new FLabel.Builder().text("Open Deck Editor").opaque(true)
|
||||
.hoverable(true).cmdClick(CSubmenuDeckEditor.SINGLETON_INSTANCE.getMenuCommand())
|
||||
.fontScaleAuto(false).fontSize(16).build(), "w 200px!, h 40px!");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getGroup()
|
||||
*/
|
||||
@Override
|
||||
public EMenuGroup getGroup() {
|
||||
return EMenuGroup.CONSTRUCTED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getPanel()
|
||||
*/
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
return pnl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user