mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Refactor so variant checkboxes display same description in tooltip as used by mobile game
This commit is contained in:
@@ -29,6 +29,7 @@ import forge.screens.home.*;
|
|||||||
import forge.toolbox.*;
|
import forge.toolbox.*;
|
||||||
import forge.toolbox.FSkin.SkinColor;
|
import forge.toolbox.FSkin.SkinColor;
|
||||||
import forge.toolbox.FSkin.SkinImage;
|
import forge.toolbox.FSkin.SkinImage;
|
||||||
|
import forge.util.GuiDisplayUtil;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.NameGenerator;
|
import forge.util.NameGenerator;
|
||||||
@@ -78,12 +79,12 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
// 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 10"));
|
private final FPanel variantsPanel = new FPanel(new MigLayout("insets 10, gapx 10"));
|
||||||
private final FCheckBox vntVanguard = new FCheckBox("Vanguard");
|
private final VariantCheckBox vntVanguard = new VariantCheckBox(GameType.Vanguard);
|
||||||
private final FCheckBox vntMomirBasic = new FCheckBox("Momir Basic");
|
private final VariantCheckBox vntMomirBasic = new VariantCheckBox(GameType.MomirBasic);
|
||||||
private final FCheckBox vntCommander = new FCheckBox("Commander");
|
private final VariantCheckBox vntCommander = new VariantCheckBox(GameType.Commander);
|
||||||
private final FCheckBox vntPlanechase = new FCheckBox("Planechase");
|
private final VariantCheckBox vntPlanechase = new VariantCheckBox(GameType.Planechase);
|
||||||
private final FCheckBox vntArchenemy = new FCheckBox("Archenemy");
|
private final VariantCheckBox vntArchenemy = new VariantCheckBox(GameType.Archenemy);
|
||||||
private final FCheckBox vntArchenemyRumble = new FCheckBox("Archenemy Rumble");
|
private final VariantCheckBox vntArchenemyRumble = new VariantCheckBox(GameType.ArchenemyRumble);
|
||||||
|
|
||||||
// Player frame elements
|
// Player frame elements
|
||||||
private final JPanel playersFrame = new JPanel(new MigLayout("insets 0, gap 0 5, wrap, hidemode 3"));
|
private final JPanel playersFrame = new JPanel(new MigLayout("insets 0, gap 0 5, wrap, hidemode 3"));
|
||||||
@@ -127,14 +128,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//////////////////// Variants Panel ////////////////////
|
//////////////////// Variants Panel ////////////////////
|
||||||
|
|
||||||
// Populate and add variants panel
|
|
||||||
vntVanguard.addItemListener(iListenerVariants);
|
|
||||||
vntMomirBasic.addItemListener(iListenerVariants);
|
|
||||||
vntCommander.addItemListener(iListenerVariants);
|
|
||||||
vntPlanechase.addItemListener(iListenerVariants);
|
|
||||||
vntArchenemy.addItemListener(iListenerVariants);
|
|
||||||
vntArchenemyRumble.addItemListener(iListenerVariants);
|
|
||||||
|
|
||||||
variantsPanel.setOpaque(false);
|
variantsPanel.setOpaque(false);
|
||||||
variantsPanel.add(newLabel("Variants:"));
|
variantsPanel.add(newLabel("Variants:"));
|
||||||
variantsPanel.add(vntVanguard);
|
variantsPanel.add(vntVanguard);
|
||||||
@@ -1142,35 +1135,21 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
//========== Various listeners in build order
|
//========== Various listeners in build order
|
||||||
|
|
||||||
/** This listener unlocks the relevant buttons for players
|
@SuppressWarnings("serial")
|
||||||
* and enables/disables archenemy combobox as appropriate. */
|
private class VariantCheckBox extends FCheckBox {
|
||||||
private ItemListener iListenerVariants = new ItemListener() {
|
private final GameType variantType;
|
||||||
|
|
||||||
|
private VariantCheckBox(GameType variantType0) {
|
||||||
|
super(variantType0.toString());
|
||||||
|
|
||||||
|
variantType = variantType0;
|
||||||
|
|
||||||
|
setToolTipText(GuiDisplayUtil.getVariantDescription(variantType0));
|
||||||
|
|
||||||
|
addItemListener(new ItemListener() {
|
||||||
@Override
|
@Override
|
||||||
public void itemStateChanged(ItemEvent arg0) {
|
public void itemStateChanged(ItemEvent e) {
|
||||||
FCheckBox cb = (FCheckBox) arg0.getSource();
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||||
GameType variantType = null;
|
|
||||||
|
|
||||||
if (cb == vntVanguard) {
|
|
||||||
variantType = GameType.Vanguard;
|
|
||||||
}
|
|
||||||
else if (cb == vntMomirBasic) {
|
|
||||||
variantType = GameType.MomirBasic;
|
|
||||||
}
|
|
||||||
else if (cb == vntCommander) {
|
|
||||||
variantType = GameType.Commander;
|
|
||||||
}
|
|
||||||
else if (cb == vntPlanechase) {
|
|
||||||
variantType = GameType.Planechase;
|
|
||||||
}
|
|
||||||
else if (cb == vntArchenemy) {
|
|
||||||
variantType = GameType.Archenemy;
|
|
||||||
}
|
|
||||||
else if (cb == vntArchenemyRumble) {
|
|
||||||
variantType = GameType.ArchenemyRumble;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (variantType != null) {
|
|
||||||
if (arg0.getStateChange() == ItemEvent.SELECTED) {
|
|
||||||
appliedVariants.add(variantType);
|
appliedVariants.add(variantType);
|
||||||
currentGameMode = variantType;
|
currentGameMode = variantType;
|
||||||
|
|
||||||
@@ -1202,14 +1181,15 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
currentGameMode = GameType.Constructed;
|
currentGameMode = GameType.Constructed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (PlayerPanel pp : playerPanels) {
|
for (PlayerPanel pp : playerPanels) {
|
||||||
pp.toggleIsPlayerArchenemy();
|
pp.toggleIsPlayerArchenemy();
|
||||||
}
|
}
|
||||||
changePlayerFocus(playerWithFocus, currentGameMode);
|
changePlayerFocus(playerWithFocus, currentGameMode);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ActionListener nameListener = new ActionListener() {
|
private ActionListener nameListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import forge.toolbox.FOptionPane;
|
|||||||
import forge.toolbox.FScrollPane;
|
import forge.toolbox.FScrollPane;
|
||||||
import forge.toolbox.FTextField;
|
import forge.toolbox.FTextField;
|
||||||
import forge.util.Callback;
|
import forge.util.Callback;
|
||||||
|
import forge.util.GuiDisplayUtil;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
import forge.util.NameGenerator;
|
import forge.util.NameGenerator;
|
||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
@@ -935,12 +936,12 @@ public class ConstructedScreen extends LaunchScreen {
|
|||||||
super("Select Variants");
|
super("Select Variants");
|
||||||
|
|
||||||
lstVariants.setListItemRenderer(new VariantRenderer());
|
lstVariants.setListItemRenderer(new VariantRenderer());
|
||||||
lstVariants.addItem(new Variant(GameType.Vanguard, "Each player has a special \"Avatar\" card that affects the game."));
|
lstVariants.addItem(new Variant(GameType.Vanguard));
|
||||||
lstVariants.addItem(new Variant(GameType.MomirBasic, "Each player has a deck containing 60 basic lands and the Momir Vig avatar."));
|
lstVariants.addItem(new Variant(GameType.MomirBasic));
|
||||||
lstVariants.addItem(new Variant(GameType.Commander, "Each player has a legendary \"General\" card which can be cast at any time and determines deck colors."));
|
lstVariants.addItem(new Variant(GameType.Commander));
|
||||||
lstVariants.addItem(new Variant(GameType.Planechase, "Plane cards apply global effects. Plane card changed when a player rolls \"Chaos\" on the planar die."));
|
lstVariants.addItem(new Variant(GameType.Planechase));
|
||||||
lstVariants.addItem(new Variant(GameType.Archenemy, "One player is the Archenemy and can play scheme cards."));
|
lstVariants.addItem(new Variant(GameType.Archenemy));
|
||||||
lstVariants.addItem(new Variant(GameType.ArchenemyRumble, "All players are Archenemies and can play scheme cards."));
|
lstVariants.addItem(new Variant(GameType.ArchenemyRumble));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -952,9 +953,9 @@ public class ConstructedScreen extends LaunchScreen {
|
|||||||
private final GameType gameType;
|
private final GameType gameType;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
private Variant(GameType gameType0, String description0) {
|
private Variant(GameType gameType0) {
|
||||||
gameType = gameType0;
|
gameType = gameType0;
|
||||||
description = description0;
|
description = GuiDisplayUtil.getVariantDescription(gameType0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void draw(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
|
private void draw(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
|
||||||
|
|||||||
@@ -520,5 +520,22 @@ public final class GuiDisplayUtil {
|
|||||||
return text.replaceAll("(?i)human", playerName);
|
return text.replaceAll("(?i)human", playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getVariantDescription(GameType variant) {
|
||||||
|
switch (variant) {
|
||||||
|
case Archenemy:
|
||||||
|
return "One player is the Archenemy and can play scheme cards.";
|
||||||
|
case ArchenemyRumble:
|
||||||
|
return "All players are Archenemies and can play scheme cards.";
|
||||||
|
case Commander:
|
||||||
|
return "Each player has a legendary \"General\" card which can be cast at any time and determines deck colors.";
|
||||||
|
case MomirBasic:
|
||||||
|
return "Each player has a deck containing 60 basic lands and the Momir Vig avatar.";
|
||||||
|
case Planechase:
|
||||||
|
return "Plane cards apply global effects. Plane card changed when a player rolls \"Chaos\" on the planar die.";
|
||||||
|
case Vanguard:
|
||||||
|
return "Each player has a special \"Avatar\" card that affects the game.";
|
||||||
|
default:
|
||||||
|
return ""; //other game types don't need descriptions
|
||||||
|
}
|
||||||
|
}
|
||||||
} // end class GuiDisplayUtil
|
} // end class GuiDisplayUtil
|
||||||
|
|||||||
Reference in New Issue
Block a user