Improve Constructed screen layout

This commit is contained in:
drdev
2014-01-17 04:40:35 +00:00
parent 89598ab48c
commit c0e9d82ff6
9 changed files with 120 additions and 248 deletions

View File

@@ -36,14 +36,14 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
private DeckType selectedDeckType = DeckType.COLOR_DECK; private DeckType selectedDeckType = DeckType.COLOR_DECK;
private final DeckManager lstDecks = new DeckManager(GameType.Constructed); private final DeckManager lstDecks = new DeckManager(GameType.Constructed);
private final FLabel btnRandom = new FLabel.ButtonBuilder().text("Random").fontSize(16).build(); private final FLabel btnRandom = new FLabel.ButtonBuilder().text("Random").fontSize(14).build();
private boolean isAi; private boolean isAi;
private final ForgePreferences prefs = Singletons.getModel().getPreferences(); private final ForgePreferences prefs = Singletons.getModel().getPreferences();
private FPref stateSetting = null; private FPref stateSetting = null;
public FDeckChooser(final String titleText, boolean forAi, boolean canSwitchType) { public FDeckChooser(boolean forAi) {
setOpaque(false); setOpaque(false);
isAi = forAi; isAi = forAi;
lstDecks.setItemActivateCommand(new Command() { lstDecks.setItemActivateCommand(new Command() {
@@ -56,10 +56,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
}); });
} }
public FDeckChooser(String titleText, boolean forAi) {
this(titleText, forAi, false);
}
public void initialize() { public void initialize() {
initialize(DeckType.COLOR_DECK); initialize(DeckType.COLOR_DECK);
} }
@@ -291,9 +287,9 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
setupUI(); setupUI();
removeAll(); removeAll();
this.setLayout(new MigLayout("insets 0, gap 0, flowy")); this.setLayout(new MigLayout("insets 0, gap 0, flowy"));
this.add(decksComboBox.getComponent(), "w 10:100%, h 30px!, gapbottom 3px"); this.add(decksComboBox.getComponent(), "w 10:100%, h 30px!, gapbottom 5px");
this.add(new ItemManagerContainer(lstDecks), "w 10:100%, growy, pushy"); this.add(new ItemManagerContainer(lstDecks), "w 10:100%, growy, pushy");
this.add(btnRandom, "w 10:100%, h 26px!, gaptop 3px"); this.add(btnRandom, "w 10:100%, h 30px!, gaptop 5px");
if (isShowing()) { if (isShowing()) {
validate(); validate();
repaint(); repaint();

View File

@@ -49,7 +49,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu<CSubmenuGauntletBuild> {
private final JPanel pnlStrut = new JPanel(); private final JPanel pnlStrut = new JPanel();
private final JPanel pnlDirections = new JPanel(); private final JPanel pnlDirections = new JPanel();
private final FDeckChooser lstLeft = new FDeckChooser("Deck", false); private final FDeckChooser lstLeft = new FDeckChooser(false);
private final JList<String> lstRight = new FList<String>(); private final JList<String> lstRight = new FList<String>();
private final JScrollPane scrRight = new FScrollPane(lstRight, private final JScrollPane scrRight = new FScrollPane(lstRight,

View File

@@ -46,7 +46,7 @@ public enum VSubmenuGauntletContests implements IVSubmenu<CSubmenuGauntletContes
private final SkinnedPanel pnlLoad = new SkinnedPanel(new MigLayout("insets 0, gap 0, wrap")); private final SkinnedPanel pnlLoad = new SkinnedPanel(new MigLayout("insets 0, gap 0, wrap"));
private final ContestGauntletLister gauntletList = new ContestGauntletLister(); private final ContestGauntletLister gauntletList = new ContestGauntletLister();
private final FDeckChooser lstDecks = new FDeckChooser("Deck", false); private final FDeckChooser lstDecks = new FDeckChooser(false);
private final JScrollPane scrLeft = new FScrollPane(gauntletList, private final JScrollPane scrLeft = new FScrollPane(gauntletList,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

View File

@@ -57,7 +57,7 @@ public enum VSubmenuGauntletQuick implements IVSubmenu<CSubmenuGauntletQuick> {
private final JCheckBox boxColorDecks = new FCheckBox("Fully random color Decks"); private final JCheckBox boxColorDecks = new FCheckBox("Fully random color Decks");
private final JCheckBox boxThemeDecks = new FCheckBox("Semi-random theme Decks"); private final JCheckBox boxThemeDecks = new FCheckBox("Semi-random theme Decks");
private final FDeckChooser lstDecks = new FDeckChooser("Deck", false); private final FDeckChooser lstDecks = new FDeckChooser(false);
private final QuickGauntletLister gauntletList = new QuickGauntletLister(); private final QuickGauntletLister gauntletList = new QuickGauntletLister();
private final JLabel lblOptions = new FLabel.Builder().fontSize(16) private final JLabel lblOptions = new FLabel.Builder().fontSize(16)

View File

@@ -7,10 +7,7 @@ import java.awt.event.FocusEvent;
import java.awt.event.FocusListener; import java.awt.event.FocusListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -19,13 +16,13 @@ import java.util.TreeSet;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JScrollPane;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import forge.Command; import forge.Command;
import forge.Singletons; import forge.Singletons;
import forge.deck.Deck; import forge.deck.Deck;
@@ -43,6 +40,7 @@ import forge.gui.home.VHomeUI;
import forge.gui.toolbox.FCheckBox; import forge.gui.toolbox.FCheckBox;
import forge.gui.toolbox.FComboBox; import forge.gui.toolbox.FComboBox;
import forge.gui.toolbox.FLabel; import forge.gui.toolbox.FLabel;
import forge.gui.toolbox.FMouseAdapter;
import forge.gui.toolbox.FPanel; import forge.gui.toolbox.FPanel;
import forge.gui.toolbox.FRadioButton; import forge.gui.toolbox.FRadioButton;
import forge.gui.toolbox.FScrollPanel; import forge.gui.toolbox.FScrollPanel;
@@ -61,7 +59,6 @@ import forge.util.NameGenerator;
* *
*/ */
public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> { public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
/** */
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
private final static ForgePreferences prefs = Singletons.getModel().getPreferences(); private final static ForgePreferences prefs = Singletons.getModel().getPreferences();
@@ -69,22 +66,21 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
private DragCell parentCell; private DragCell parentCell;
private final DragTab tab = new DragTab("Constructed Mode"); private final DragTab tab = new DragTab("Constructed Mode");
/** */ // General variables
// General variables
private final LblHeader lblTitle = new LblHeader("Sanctioned Format: Constructed"); private final LblHeader lblTitle = new LblHeader("Sanctioned Format: Constructed");
private int activePlayersNum = 2; private int activePlayersNum = 2;
private int playerWithFocus = 0; // index of the player that currently has focus private int playerWithFocus = 0; // index of the player that currently has focus
private final JCheckBox cbSingletons = new FCheckBox("Singleton Mode"); private final FCheckBox cbSingletons = new FCheckBox("Singleton Mode");
private final JCheckBox cbArtifacts = new FCheckBox("Remove Artifacts"); private final FCheckBox cbArtifacts = new FCheckBox("Remove Artifacts");
private final JCheckBox cbRemoveSmall = new FCheckBox("Remove Small Creatures"); private final FCheckBox cbRemoveSmall = new FCheckBox("Remove Small Creatures");
private final StartButton btnStart = new StartButton(); private final StartButton btnStart = new StartButton();
private final JPanel pnlStart = new JPanel(new MigLayout("insets 0, gap 0, wrap 2")); private final JPanel pnlStart = new JPanel(new MigLayout("insets 0, gap 0, wrap 2"));
private final JPanel constructedFrame = new JPanel(new MigLayout("insets 0, gap 5, wrap 2, fill")); // Main content frame private final JPanel constructedFrame = new JPanel(new MigLayout("insets 0, gap 0, wrap 2, fill")); // Main content frame
// Variants frame and variables // Variants frame and variables
private final Set<GameType> appliedVariants = new TreeSet<GameType>(); private final Set<GameType> appliedVariants = new TreeSet<GameType>();
private final FPanel variantsPanel = new FPanel(new MigLayout("insets 10, gapx 20, fillx, hmax 100, nogrid")); private final FPanel variantsPanel = new FPanel(new MigLayout("insets 10, gapx 10"));
private final FCheckBox vntVanguard = new FCheckBox("Vanguard"); private final FCheckBox vntVanguard = new FCheckBox("Vanguard");
private final FCheckBox vntCommander = new FCheckBox("Commander"); private final FCheckBox vntCommander = new FCheckBox("Commander");
private final FCheckBox vntPlanechase = new FCheckBox("Planechase"); private final FCheckBox vntPlanechase = new FCheckBox("Planechase");
@@ -94,25 +90,24 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
"Classic Archenemy (player 1 is Archenemy)", "Archenemy Rumble (All players are Archenemies)"}); "Classic Archenemy (player 1 is Archenemy)", "Archenemy Rumble (All players are Archenemies)"});
// Player frame elements // Player frame elements
private final FPanel playersFrame = new FPanel(new MigLayout("insets 0, gapx 20, fill, w 50%")); private final JPanel playersFrame = new JPanel(new MigLayout("insets 0, gap 0 5, wrap, hidemode 3"));
private final FScrollPanel playersScroll = new FScrollPanel(new MigLayout("insets 8, gapx 20, fill")); private final FScrollPanel playersScroll = new FScrollPanel(new MigLayout("insets 0, gap 0, wrap, hidemode 3"),
true, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
private final List<FPanel> playerPanelList = new ArrayList<FPanel>(8); private final List<FPanel> playerPanelList = new ArrayList<FPanel>(8);
private final List<FPanel> activePlayerPanelList = new ArrayList<FPanel>(8); private final List<FPanel> activePlayerPanelList = new ArrayList<FPanel>(8);
private final List<FPanel> inactivePlayerPanelList = new ArrayList<FPanel>(6); private final List<FPanel> inactivePlayerPanelList = new ArrayList<FPanel>(6);
private final List<FTextField> playerNameBtnList = new ArrayList<FTextField>(8); private final List<FTextField> playerNameBtnList = new ArrayList<FTextField>(8);
private final List<String> playerNames = new ArrayList<String>(8); private final List<String> playerNames = new ArrayList<String>(8);
private final List<JRadioButton> playerTypeRadios = new ArrayList<JRadioButton>(8); private final List<FRadioButton> playerTypeRadios = new ArrayList<FRadioButton>(8);
private final List<FLabel> avatarList = new ArrayList<FLabel>(8); private final List<FLabel> avatarList = new ArrayList<FLabel>(8);
private final TreeMap<Integer, Integer> usedAvatars = new TreeMap<Integer, Integer>(); private final TreeMap<Integer, Integer> usedAvatars = new TreeMap<Integer, Integer>();
private final List<FLabel> closePlayerBtnList = new ArrayList<FLabel>(6); private final List<FLabel> closePlayerBtnList = new ArrayList<FLabel>(6);
private final FLabel addPlayerBtn = new FLabel.Builder().opaque(true).hoverable(true).text("Add a Player").build(); private final FLabel addPlayerBtn = new FLabel.ButtonBuilder().fontSize(14).text("Add a Player").build();
// Deck frame elements // Deck frame elements
private final FPanel decksFrame = new FPanel(new MigLayout("insets 8, gapx 20, w 50%")); private final JPanel decksFrame = new JPanel(new MigLayout("insets 0, gap 0, wrap, hidemode 3"));
private final List<FPanel> deckPanelListMain = new ArrayList<FPanel>(8);
private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>(8); private final List<FDeckChooser> deckChoosers = new ArrayList<FDeckChooser>(8);
private final FLabel deckChooserHeader = new FLabel.Builder().opaque(true).fontStyle(1).build();
private final List<FLabel> deckSelectorBtns = new ArrayList<FLabel>(8); private final List<FLabel> deckSelectorBtns = new ArrayList<FLabel>(8);
// CTR // CTR
@@ -131,41 +126,53 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
comboArchenemy.setEnabled(vntArchenemy.isSelected()); comboArchenemy.setEnabled(vntArchenemy.isSelected());
comboArchenemy.addActionListener(aeComboListener); comboArchenemy.addActionListener(aeComboListener);
constructedFrame.add(newLabel("Variants:"), "wrap");
variantsPanel.setOpaque(false); variantsPanel.setOpaque(false);
variantsPanel.add(vntVanguard, "growx"); variantsPanel.add(newLabel("Variants:"));
variantsPanel.add(vntCommander, "growx"); variantsPanel.add(vntVanguard);
variantsPanel.add(vntPlanechase, "growx, wrap"); variantsPanel.add(vntCommander);
variantsPanel.add(vntPlanechase);
variantsPanel.add(vntArchenemy); variantsPanel.add(vntArchenemy);
variantsPanel.add(comboArchenemy, "pushx"); variantsPanel.add(comboArchenemy);
constructedFrame.add(variantsPanel, "growx, spanx 2"); constructedFrame.add(variantsPanel, "w 100%, gapbottom 5px, spanx 2, wrap");
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
///////////////////// Player Panel ///////////////////// ///////////////////// Player Panel /////////////////////
// Construct individual player panels // Construct individual player panels
String constraints = "pushx, growx, wrap, hidemode 3";
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
buildPlayerPanel(i); buildPlayerPanel(i);
FPanel player = playerPanelList.get(i); FPanel player = playerPanelList.get(i);
// Populate players panel // Populate players panel
if (i < activePlayersNum) { if (i < activePlayersNum) {
playersScroll.add(player, "pushx, growx, wrap, hidemode 3"); playersScroll.add(player, constraints);
activePlayerPanelList.add(player); activePlayerPanelList.add(player);
} else { }
else {
player.setVisible(false); player.setVisible(false);
playersScroll.add(player, "pushx, growx, wrap, hidemode 3"); playersScroll.add(player, constraints);
inactivePlayerPanelList.add(player); inactivePlayerPanelList.add(player);
} }
if (i == 0) {
constraints += ", gaptop 5px";
}
} }
playersFrame.setOpaque(false);
playersFrame.add(playersScroll, "grow, push");
addPlayerBtn.setFocusable(true); addPlayerBtn.setFocusable(true);
addPlayerBtn.addMouseListener(addOrRemoveMouseListener); addPlayerBtn.setCommand(new Runnable() {
addPlayerBtn.addKeyListener(addOrRemoveKeyListener); @Override
playersScroll.add(addPlayerBtn, "height 40px, growx, pushx"); public void run() {
playersFrame.add(playersScroll, "grow, pushx, NORTH"); addPlayer();
constructedFrame.add(playersFrame, "grow, push"); }
});
playersFrame.add(addPlayerBtn, "height 30px!, growx, pushx");
constructedFrame.add(playersFrame, "gapright 6px, w 50%-3px, growy, pushy");
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
////////////////////// Deck Panel ////////////////////// ////////////////////// Deck Panel //////////////////////
@@ -176,6 +183,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
populateDeckPanel(true); populateDeckPanel(true);
constructedFrame.add(decksFrame, "grow, push"); constructedFrame.add(decksFrame, "grow, push");
constructedFrame.setOpaque(false); constructedFrame.setOpaque(false);
decksFrame.setOpaque(false);
// Start Button // Start Button
final String strCheckboxConstraints = "h 30px!, gap 0 20px 0 0"; final String strCheckboxConstraints = "h 30px!, gap 0 20px 0 0";
@@ -188,18 +196,22 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
private FPanel buildPlayerPanel(final int playerIndex) { private FPanel buildPlayerPanel(final int playerIndex) {
FPanel playerPanel = new FPanel(); FPanel playerPanel = new FPanel();
playerPanel.setLayout(new MigLayout("insets 10, gap 5px")); playerPanel.setLayout(new MigLayout("insets 10px, gap 5px"));
// Add a button to players 3+ to remove them from the setup // Add a button to players 3+ to remove them from the setup
if (playerIndex >= 2) { if (playerIndex >= 2) {
final FLabel closeBtn = new FLabel.Builder().tooltip("Close").iconInBackground(false) final FLabel closeBtn = new FLabel.Builder().tooltip("Close").iconInBackground(false)
.icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_CLOSE)).hoverable(true).build(); .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_CLOSE)).hoverable(true).build();
closeBtn.addMouseListener(addOrRemoveMouseListener); closeBtn.setCommand(new Runnable() {
closeBtn.addKeyListener(addOrRemoveKeyListener); @Override
public void run() {
removePlayer(closePlayerBtnList.indexOf(closeBtn) + 2);
}
});
playerPanel.add(closeBtn, "w 20, h 20, pos (container.w-20) 0"); playerPanel.add(closeBtn, "w 20, h 20, pos (container.w-20) 0");
closePlayerBtnList.add(closeBtn); closePlayerBtnList.add(closeBtn);
} }
// Avatar // Avatar
final FLabel avatar = new FLabel.Builder().opaque(true).hoverable(true) final FLabel avatar = new FLabel.Builder().opaque(true).hoverable(true)
.iconScaleFactor(0.99f).iconInBackground(true).build(); .iconScaleFactor(0.99f).iconInBackground(true).build();
@@ -216,7 +228,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
avatar.addFocusListener(avatarFocusListener); avatar.addFocusListener(avatarFocusListener);
avatar.addMouseListener(avatarMouseListener); avatar.addMouseListener(avatarMouseListener);
avatarList.add(avatar); avatarList.add(avatar);
playerPanel.add(avatar, "spany 2, width 80px, height 80px"); playerPanel.add(avatar, "spany 2, width 80px, height 80px");
// Name // Name
@@ -230,12 +242,13 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
name = NameGenerator.getRandomName("Any", "Any", playerNames); name = NameGenerator.getRandomName("Any", "Any", playerNames);
} }
playerNames.add(name); playerNames.add(name);
final FTextField playerNameField = new FTextField.Builder().ghostText(name).text(name).build(); final FTextField playerNameField = new FTextField.Builder().text(name).build();
playerNameField.setFocusable(true); playerNameField.setFocusable(true);
playerNameField.setFont(FSkin.getFont(14));
playerNameField.addActionListener(nameListener); playerNameField.addActionListener(nameListener);
playerNameField.addFocusListener(nameFocusListener); playerNameField.addFocusListener(nameFocusListener);
playerPanel.add(newLabel("Player Name:"),"height 35px, gapx rel"); playerPanel.add(newLabel("Name:"), "height 30px, gaptop 5px, gapx rel");
playerPanel.add(playerNameField, "height 35px, gapy 5px, gapx unrel, pushx, growx, wrap 5"); playerPanel.add(playerNameField, "height 30px, pushx, growx");
playerNameBtnList.add(playerNameField); playerNameBtnList.add(playerNameField);
// PlayerType // PlayerType
@@ -248,23 +261,25 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
tmpAI.setText("AI"); tmpAI.setText("AI");
tmpAI.setSelected(playerIndex != 0); tmpAI.setSelected(playerIndex != 0);
tmpAI.addFocusListener(radioFocusListener); tmpAI.addFocusListener(radioFocusListener);
FPanel typeBtnPanel = new FPanel();
typeBtnPanel.add(tmpHuman);
typeBtnPanel.add(tmpAI);
playerPanel.add(newLabel("Player Type:"), "height 35px, gapx rel");
playerPanel.add(typeBtnPanel, "height 35px, gapy 5px, gapx unrel, pushx, growx, wrap");
tempBtnGroup.add(tmpHuman); tempBtnGroup.add(tmpHuman);
tempBtnGroup.add(tmpAI); tempBtnGroup.add(tmpAI);
playerTypeRadios.add(tmpHuman); playerTypeRadios.add(tmpHuman);
playerTypeRadios.add(tmpAI); playerTypeRadios.add(tmpAI);
playerPanel.add(tmpHuman, "gapright 5px");
playerPanel.add(tmpAI, "wrap");
// Deck selector button // Deck selector button
FLabel deckBtn = new FLabel.ButtonBuilder().text("Select a deck").build(); final FLabel deckBtn = new FLabel.ButtonBuilder().text("Select a deck").build();
deckBtn.addFocusListener(deckLblFocusListener); deckBtn.addFocusListener(deckLblFocusListener);
deckBtn.addMouseListener(deckLblMouseListener); deckBtn.setCommand(new Runnable() {
playerPanel.add(deckBtn, "height 30px, gapy 5px, growx, wrap, span 3 1"); @Override
public void run() {
changePlayerFocus(deckSelectorBtns.indexOf(deckBtn));
}
});
playerPanel.add(newLabel("Deck:"), "height 30px, gapx rel");
playerPanel.add(deckBtn, "height 30px, growx, pushx, spanx 3");
deckSelectorBtns.add(deckBtn); deckSelectorBtns.add(deckBtn);
playerPanelList.add(playerPanel); playerPanelList.add(playerPanel);
@@ -314,7 +329,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
public void updatePlayerName(int playerIndex) { public void updatePlayerName(int playerIndex) {
String name = prefs.getPref(FPref.PLAYER_NAME); String name = prefs.getPref(FPref.PLAYER_NAME);
playerNameBtnList.get(0).setGhostText(name);
playerNameBtnList.get(0).setText(name); playerNameBtnList.get(0).setText(name);
} }
@@ -331,12 +345,12 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
} }
} }
/** Applies a random avatar, avoiding avatars already used. /** Applies a random avatar, avoiding avatars already used.
* @param playerIndex */ * @param playerIndex */
private void setRandomAvatar(FLabel avatar, int playerIndex) { private void setRandomAvatar(FLabel avatar, int playerIndex) {
int random = 0; int random = 0;
do { do {
random = MyRandom.getRandom().nextInt(FSkin.getAvatars().size()); random = MyRandom.getRandom().nextInt(FSkin.getAvatars().size());
} while (usedAvatars.values().contains(random)); } while (usedAvatars.values().contains(random));
avatar.setIcon(FSkin.getAvatars().get(random)); avatar.setIcon(FSkin.getAvatars().get(random));
@@ -349,12 +363,12 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
@SuppressWarnings("serial") @SuppressWarnings("serial")
private void buildDeckPanel(final int playerIndex) { private void buildDeckPanel(final int playerIndex) {
String sectionConstraints = "insets 8"; String sectionConstraints = "insets 8";
// Main deck // Main deck
FPanel mainDeckPanel = new FPanel(); FPanel mainDeckPanel = new FPanel();
mainDeckPanel.setLayout(new MigLayout(sectionConstraints)); mainDeckPanel.setLayout(new MigLayout(sectionConstraints));
final FDeckChooser mainChooser = new FDeckChooser("Main deck:", isPlayerAI(playerIndex)); final FDeckChooser mainChooser = new FDeckChooser(isPlayerAI(playerIndex));
mainChooser.initialize(); mainChooser.initialize();
mainChooser.getLstDecks().setSelectCommand(new Command() { mainChooser.getLstDecks().setSelectCommand(new Command() {
@Override @Override
@@ -364,7 +378,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
}); });
deckChoosers.add(mainChooser); deckChoosers.add(mainChooser);
mainDeckPanel.add(mainChooser, "grow, push, wrap"); mainDeckPanel.add(mainChooser, "grow, push, wrap");
deckPanelListMain.add(mainDeckPanel);
} }
protected void onDeckClicked(int iPlayer, DeckType type, Iterable<Deck> selectedDecks) { protected void onDeckClicked(int iPlayer, DeckType type, Iterable<Deck> selectedDecks) {
@@ -376,11 +389,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
private void populateDeckPanel(final boolean firstBuild) { private void populateDeckPanel(final boolean firstBuild) {
if (!firstBuild) { decksFrame.removeAll(); } if (!firstBuild) { decksFrame.removeAll(); }
String name = getPlayerName(playerWithFocus); decksFrame.add(deckChoosers.get(playerWithFocus), "grow, push");
deckChooserHeader.setText("Select a deck for " + name);
decksFrame.add(deckChooserHeader, "gap 0, pushx, growx, w 100%, h 35, wrap");
decksFrame.add(deckPanelListMain.get(playerWithFocus), "gap 0, grow, push, wrap");
} }
/** Updates the deck selector button in all player panels. */ /** Updates the deck selector button in all player panels. */
@@ -407,7 +416,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
public EMenuGroup getGroupEnum() { public EMenuGroup getGroupEnum() {
return EMenuGroup.SANCTIONED; return EMenuGroup.SANCTIONED;
} }
public final FDeckChooser getDeckChooser(int playernum) { public final FDeckChooser getDeckChooser(int playernum) {
return deckChoosers.get(playernum); return deckChoosers.get(playernum);
} }
@@ -445,7 +454,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
fdc.populate(); fdc.populate();
} }
updateDeckSelectorLabels(); updateDeckSelectorLabels();
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(constructedFrame, "gap 20px 20px 20px 0px, push, grow"); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(constructedFrame, "gap 20px 20px 20px 0px, push, grow");
VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStart, "gap 0 0 3.5%! 3.5%!, ax center"); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStart, "gap 0 0 3.5%! 3.5%!, ax center");
@@ -465,11 +474,11 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
// so playernum * 2 + 1 points to the appropriate AI radio. // so playernum * 2 + 1 points to the appropriate AI radio.
return playerTypeRadios.get(playernum * 2 + 1).isSelected(); return playerTypeRadios.get(playernum * 2 + 1).isSelected();
} }
public int getNumPlayers() { public int getNumPlayers() {
return activePlayersNum; return activePlayersNum;
} }
public final List<Integer> getParticipants() { public final List<Integer> getParticipants() {
final List<Integer> participants = new ArrayList<Integer>(activePlayersNum); final List<Integer> participants = new ArrayList<Integer>(activePlayersNum);
for (final FPanel panel : activePlayerPanelList) { for (final FPanel panel : activePlayerPanelList) {
@@ -477,7 +486,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
} }
return participants; return participants;
} }
public final String getPlayerName(int playerIndex) { public final String getPlayerName(int playerIndex) {
return playerNameBtnList.get(playerIndex).getText(); return playerNameBtnList.get(playerIndex).getText();
} }
@@ -490,11 +499,11 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
/** Revalidates the player and deck sections. Necessary after adding or hiding any panels. */ /** Revalidates the player and deck sections. Necessary after adding or hiding any panels. */
private void refreshPanels(boolean refreshPlayerFrame, boolean refreshDeckFrame) { private void refreshPanels(boolean refreshPlayerFrame, boolean refreshDeckFrame) {
if (refreshPlayerFrame) { if (refreshPlayerFrame) {
playersFrame.validate(); playersScroll.validate();
playersFrame.repaint(); playersScroll.repaint();
} }
if (refreshDeckFrame) { if (refreshDeckFrame) {
decksFrame.validate(); decksFrame.validate();
decksFrame.repaint(); decksFrame.repaint();
} }
} }
@@ -514,7 +523,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
}*/ }*/
changeAvatarFocus(); changeAvatarFocus();
playersScroll.getViewport().scrollRectToVisible(playerPanel.getBounds()); playersScroll.getViewport().scrollRectToVisible(playerPanel.getBounds());
populateDeckPanel(false); populateDeckPanel(false);
refreshPanels(true, true); refreshPanels(true, true);
@@ -548,9 +557,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
/** Adds a pre-styled FLabel component with the specified title. */ /** Adds a pre-styled FLabel component with the specified title. */
private FLabel newLabel(String title) { private FLabel newLabel(String title) {
FLabel label = new FLabel.Builder().text(title).fontSize(11).fontStyle(Font.ITALIC).build(); return new FLabel.Builder().text(title).fontSize(14).fontStyle(Font.ITALIC).build();
return label;
} }
///////////////////////////////////////////// /////////////////////////////////////////////
@@ -558,8 +565,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
/** This listener unlocks the relevant buttons for players /** This listener unlocks the relevant buttons for players
* and enables/disables archenemy combobox as appropriate. */ * and enables/disables archenemy combobox as appropriate. */
ItemListener iListenerVariants = new ItemListener() { private ItemListener iListenerVariants = new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent arg0) { public void itemStateChanged(ItemEvent arg0) {
FCheckBox cb = (FCheckBox) arg0.getSource(); FCheckBox cb = (FCheckBox) arg0.getSource();
@@ -600,8 +606,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
}; };
// Listens to the archenemy combo box // Listens to the archenemy combo box
ActionListener aeComboListener = new ActionListener() { private ActionListener aeComboListener = new ActionListener() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@@ -616,7 +621,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
/** Listens to avatar buttons and gives the appropriate player focus. */ /** Listens to avatar buttons and gives the appropriate player focus. */
private FocusListener avatarFocusListener = new FocusListener() { private FocusListener avatarFocusListener = new FocusListener() {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
int avatarOwnerID = avatarList.indexOf((FLabel)e.getSource()); int avatarOwnerID = avatarList.indexOf((FLabel)e.getSource());
@@ -625,74 +629,41 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
@Override @Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
} }
}; };
private MouseListener avatarMouseListener = new MouseListener() { private FMouseAdapter avatarMouseListener = new FMouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void onLeftClick(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
FLabel avatar = (FLabel)e.getSource(); FLabel avatar = (FLabel)e.getSource();
int playerIndex = avatarList.indexOf(avatar); int playerIndex = avatarList.indexOf(avatar);
changePlayerFocus(playerIndex); changePlayerFocus(playerIndex);
if (e.getButton() == 1) { avatar.grabFocus();
avatar.grabFocus(); // TODO: Do avatar selection, giving current avatar focus for keyboard control
// TODO: Do avatar selection, giving current avatar focus for keyboard control
}
if (e.getButton() == 3) {
setRandomAvatar(avatar, playerIndex);
avatar.grabFocus();
}
if (playerIndex < 2) { updateAvatarPrefs(); } if (playerIndex < 2) { updateAvatarPrefs(); }
} }
@Override @Override
public void mouseEntered(MouseEvent e) { public void onRightClick(MouseEvent e) {
FLabel avatar = (FLabel)e.getSource();
} int playerIndex = avatarList.indexOf(avatar);
@Override changePlayerFocus(playerIndex);
public void mouseExited(MouseEvent e) {
setRandomAvatar(avatar, playerIndex);
} avatar.grabFocus();
if (playerIndex < 2) { updateAvatarPrefs(); }
}
}; };
/** Listens to the name text field and resets the adjusts player 1's name preference. */
private ActionListener nameListener = new ActionListener() { private ActionListener nameListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
FTextField nField = (FTextField)e.getSource(); FTextField nField = (FTextField)e.getSource();
String newName = nField.getText().trim();
String oldName = nField.getGhostText().trim();
if (!StringUtils.isEmpty(newName) && !StringUtils.isBlank(newName)
&& StringUtils.isAlphanumericSpace(newName) && !newName.equals(oldName)) {
nField.setGhostText(newName);
deckChooserHeader.setText("Select a deck for " + newName);
if (playerNameBtnList.indexOf(nField) == 0) {
prefs.setPref(FPref.PLAYER_NAME, newName);
prefs.save();
}
}
nField.transferFocus(); nField.transferFocus();
} }
}; };
@@ -700,7 +671,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
/** Listens to name text fields and gives the appropriate player focus. /** Listens to name text fields and gives the appropriate player focus.
* Also saves the name preference when leaving player one's text field. */ * Also saves the name preference when leaving player one's text field. */
private FocusListener nameFocusListener = new FocusListener() { private FocusListener nameFocusListener = new FocusListener() {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
FTextField nField = (FTextField)e.getSource(); FTextField nField = (FTextField)e.getSource();
@@ -711,26 +681,19 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
@Override @Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
FTextField nField = (FTextField)e.getSource(); FTextField nField = (FTextField)e.getSource();
String newName = nField.getText().trim(); if (playerNameBtnList.indexOf(nField) == 0) {
String oldName = nField.getGhostText().trim(); String newName = nField.getText().trim();
if (!StringUtils.isBlank(newName) && StringUtils.isAlphanumericSpace(newName) &&
if (!StringUtils.isEmpty(newName) && !StringUtils.isBlank(newName) prefs.getPref(FPref.PLAYER_NAME) != newName) {
&& StringUtils.isAlphanumericSpace(newName) && !newName.equals(oldName)) { prefs.setPref(FPref.PLAYER_NAME, newName);
nField.setGhostText(newName); prefs.save();
}
deckChooserHeader.setText("Select a deck for " + newName); }
if (playerNameBtnList.indexOf(nField) == 0) {
prefs.setPref(FPref.PLAYER_NAME, newName);
prefs.save();
}
}
} }
}; };
/** Listens to name player type radio buttons and gives the appropriate player focus. */ /** Listens to name player type radio buttons and gives the appropriate player focus. */
private FocusListener radioFocusListener = new FocusListener() { private FocusListener radioFocusListener = new FocusListener() {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
int radioID = playerTypeRadios.indexOf((FRadioButton)e.getSource()); int radioID = playerTypeRadios.indexOf((FRadioButton)e.getSource());
@@ -740,13 +703,12 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
@Override @Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
} }
}; };
/** Listens to deck select buttons and gives the appropriate player focus. */ /** Listens to deck select buttons and gives the appropriate player focus. */
private FocusListener deckLblFocusListener = new FocusListener() { private FocusListener deckLblFocusListener = new FocusListener() {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
int deckLblID = deckSelectorBtns.indexOf((FLabel)e.getSource()); int deckLblID = deckSelectorBtns.indexOf((FLabel)e.getSource());
@@ -756,93 +718,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
@Override @Override
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
}
};
private MouseListener deckLblMouseListener = new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
FLabel deckLbl = (FLabel)e.getSource();
changePlayerFocus(deckSelectorBtns.indexOf(deckLbl));
// TODO: Give focus to deck chooser
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
};
private MouseListener addOrRemoveMouseListener = new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
FLabel btn = (FLabel)e.getSource();
if (btn == addPlayerBtn) {
addPlayer();
} else {
removePlayer(closePlayerBtnList.indexOf(btn) + 2);
}
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
};
private KeyListener addOrRemoveKeyListener = new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
FLabel btn = (FLabel)e.getSource();
if (btn == addPlayerBtn) {
addPlayer();
} else {
removePlayer(closePlayerBtnList.indexOf(btn) + 2);
}
} }
}; };
@@ -888,5 +764,4 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
public DragCell getParentCell() { public DragCell getParentCell() {
return parentCell; return parentCell;
} }
} }

View File

@@ -122,7 +122,7 @@ public enum VSubmenuArchenemy implements IVSubmenu<CSubmenuArchenemy> {
FPanel tempPanel = new FPanel(); FPanel tempPanel = new FPanel();
tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center")); tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center"));
FDeckChooser tempChooser = new FDeckChooser("Select deck:", i != 0); FDeckChooser tempChooser = new FDeckChooser(i != 0);
tempChooser.initialize(); tempChooser.initialize();
deckChoosers.add(tempChooser); deckChoosers.add(tempChooser);

View File

@@ -125,7 +125,7 @@ public enum VSubmenuPlanechase implements IVSubmenu<CSubmenuPlanechase> {
tempPanel = new FPanel(); tempPanel = new FPanel();
tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center")); tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center"));
tempChooser = new FDeckChooser("Select deck:", i != 0); tempChooser = new FDeckChooser(i != 0);
tempChooser.initialize(); tempChooser.initialize();
deckChoosers.add(tempChooser); deckChoosers.add(tempChooser);

View File

@@ -172,7 +172,7 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
tempPanel = new FPanel(); tempPanel = new FPanel();
tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center")); tempPanel.setLayout(new MigLayout("insets 0, gap 0 , wrap 2, flowy, ax center"));
tempChooser = new FDeckChooser("Select deck:", i != 0); tempChooser = new FDeckChooser(i != 0);
tempChooser.initialize(); tempChooser.initialize();
tempList = new FList<Object>(); tempList = new FList<Object>();

View File

@@ -16,6 +16,7 @@ public class FCheckBox extends SkinnedCheckBox {
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
this.setFont(FSkin.getFont(14)); this.setFont(FSkin.getFont(14));
this.setOpaque(false); this.setOpaque(false);
this.setFocusable(false);
} }
public FCheckBox(final String s0, boolean checked) { public FCheckBox(final String s0, boolean checked) {