From 21323a4f72a99180fbd45866b13752be27f7c2ac Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 1 Jun 2015 20:04:38 +0000 Subject: [PATCH] - Added an option to display color identity of cards in the card detail panel (details in CHANGES.txt). --- .../home/settings/CSubmenuPreferences.java | 10 +++++++ .../home/settings/VSubmenuPreferences.java | 8 +++++ .../forge/screens/settings/SettingsPage.java | 5 ++++ forge-gui/CHANGES.txt | 11 +++++++ .../main/java/forge/card/CardDetailUtil.java | 29 +++++++++++++++++++ .../forge/properties/ForgePreferences.java | 1 + 6 files changed, 64 insertions(+) diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuPreferences.java b/forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuPreferences.java index 7512cb38629..d0165c03a77 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuPreferences.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/settings/CSubmenuPreferences.java @@ -172,6 +172,7 @@ public enum CSubmenuPreferences implements ICDoc { initializeGameLogVerbosityComboBox(); initializeCloseActionComboBox(); initializeAiProfilesComboBox(); + initializeColorIdentityCombobox(); initializePlayerNameButton(); } @@ -298,6 +299,15 @@ public enum CSubmenuPreferences implements ICDoc { panel.setComboBox(comboBox, selectedItem); } + private void initializeColorIdentityCombobox() { + final String[] elems = {"Never", "Only Multicolor", "Always"}; + final FPref userSetting = FPref.UI_DISPLAY_COLOR_IDENTITY; + final FComboBoxPanel panel = this.view.getDisplayColorIdentity(); + final FComboBox comboBox = createComboBox(elems, userSetting); + final String selectedItem = this.prefs.getPref(userSetting); + panel.setComboBox(comboBox, selectedItem); + } + private FComboBox createComboBox(final E[] items, final ForgePreferences.FPref setting) { final FComboBox comboBox = new FComboBox<>(items); addComboBoxListener(comboBox, setting); diff --git a/forge-gui-desktop/src/main/java/forge/screens/home/settings/VSubmenuPreferences.java b/forge-gui-desktop/src/main/java/forge/screens/home/settings/VSubmenuPreferences.java index a2f4abf517a..f88e1424215 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/home/settings/VSubmenuPreferences.java +++ b/forge-gui-desktop/src/main/java/forge/screens/home/settings/VSubmenuPreferences.java @@ -89,6 +89,7 @@ public enum VSubmenuPreferences implements IVSubmenu { private final FComboBoxPanel cbpGameLogEntryType = new FComboBoxPanel<>("Game Log Verbosity:"); private final FComboBoxPanel cbpCloseAction = new FComboBoxPanel<>("Close Action:"); private final FComboBoxPanel cbpAiProfiles = new FComboBoxPanel<>("AI Personality:"); + private final FComboBoxPanel cbpDisplayColorIdentity = new FComboBoxPanel<>("Display Color Identity:"); /** * Constructor. @@ -224,6 +225,9 @@ public enum VSubmenuPreferences implements IVSubmenu { pnlPrefs.add(cbStackCreatures, regularConstraints); pnlPrefs.add(new NoteLabel("Stacks identical creatures on the battlefield like lands, artifacts, and enchantments."), regularConstraints); + pnlPrefs.add(cbpDisplayColorIdentity, "w 80%!, gap 10% 0 0 10px, span 2 1"); + pnlPrefs.add(new NoteLabel("Displays the color identity of cards in the card detail information panel."), regularConstraints); + // Sound options pnlPrefs.add(new SectionLabel("Sound Options"), sectionConstraints + ", gaptop 2%"); @@ -494,6 +498,10 @@ public enum VSubmenuPreferences implements IVSubmenu { return cbpGameLogEntryType; } + public FComboBoxPanel getDisplayColorIdentity() { + return cbpDisplayColorIdentity; + } + public FComboBoxPanel getCloseActionComboBoxPanel() { return cbpCloseAction; } diff --git a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java index 71242d72fd1..0efe4315dcd 100644 --- a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java +++ b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java @@ -162,6 +162,11 @@ public class SettingsPage extends TabPage { "Show Match Background", "Show match background image on battlefield, otherwise background texture shown instead."), 4); + lstSettings.addItem(new CustomSelectSetting(FPref.UI_DISPLAY_COLOR_IDENTITY, + "Display Color Identity", + "Displays the color identity of cards in the card detail information panel.", + new String[]{"Never", "Only Multicolor", "Always"}), + 4); //Card Overlays lstSettings.addItem(new BooleanSetting(FPref.UI_SHOW_CARD_OVERLAYS, diff --git a/forge-gui/CHANGES.txt b/forge-gui/CHANGES.txt index 588d8fb2b62..9299da2699d 100644 --- a/forge-gui/CHANGES.txt +++ b/forge-gui/CHANGES.txt @@ -31,6 +31,17 @@ The interface has received several small changes. The command zone panels have been removed. +- Display Color Identity - +There's a new option "Display Color Identity" in both desktop and mobile Forge +that allows you to display the current color identity of cards. It's disabled +by default (set to "Never") but can be toggled to "Always" (which displays color +identity for all cards, even mono-color) or to "Only Multicolor" (which only +displays color identity of cards that are currently of two or more colors). This +might help with effects such as Painter's Servant which add colors to cards and +which make all cards display with the gold border. The option is currently found +under "Graphic Options" for both versions of Forge. + + - Display tokens on the same row as other cards / on their own row - By default the game now displays tokens on the same row as non-token cards (and to the right of them), which makes the game use the battlefield space more diff --git a/forge-gui/src/main/java/forge/card/CardDetailUtil.java b/forge-gui/src/main/java/forge/card/CardDetailUtil.java index 7d3b48f2be4..21e70bfbd04 100644 --- a/forge-gui/src/main/java/forge/card/CardDetailUtil.java +++ b/forge-gui/src/main/java/forge/card/CardDetailUtil.java @@ -18,6 +18,8 @@ import forge.game.card.CounterType; import forge.item.InventoryItemFromSet; import forge.item.PreconDeck; import forge.item.SealedProduct; +import forge.model.FModel; +import forge.properties.ForgePreferences; import forge.util.Lang; public class CardDetailUtil { @@ -153,6 +155,19 @@ public class CardDetailUtil { return borderColors; } + public static String getColorIdentity(final CardStateView c) { + ColorSet identity = c.getColors(); + String strIdentity = ""; + + if (identity.hasWhite()) { strIdentity += "{W}"; } + if (identity.hasBlue()) { strIdentity += "{U}"; } + if (identity.hasBlack()) { strIdentity += "{B}"; } + if (identity.hasRed()) { strIdentity += "{R}"; } + if (identity.hasGreen()) { strIdentity += "{G}"; } + + return strIdentity; + } + public static DetailColors getRarityColor(final CardRarity rarity) { switch (rarity) { case Uncommon: @@ -492,6 +507,20 @@ public class CardDetailUtil { area.append("Must block " + mustBlockThese); } + //show card color identity if enabled + String colorIdentMode = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_DISPLAY_COLOR_IDENTITY); + if (!colorIdentMode.equals("Never")) { + final String colorIdent = getColorIdentity(state); + final int numColors = state.getColors().countColors(); + if (!colorIdentMode.equals("Only Multicolor") || numColors > 1) { + if (area.length() != 0) { + area.append("\n\n"); + } + area.append("Color identity: "); + area.append(colorIdent.isEmpty() ? "colorless" : colorIdent); + } + } + //show current storm count for storm cards if (state.hasStorm()) { if (gameView != null) { diff --git a/forge-gui/src/main/java/forge/properties/ForgePreferences.java b/forge-gui/src/main/java/forge/properties/ForgePreferences.java index 4d689a8026b..c742d6103ec 100644 --- a/forge-gui/src/main/java/forge/properties/ForgePreferences.java +++ b/forge-gui/src/main/java/forge/properties/ForgePreferences.java @@ -78,6 +78,7 @@ public class ForgePreferences extends PreferencesStore { UI_MANA_LOST_PROMPT ("false"), // Prompt on losing mana when passing priority UI_PAUSE_WHILE_MINIMIZED("false"), UI_TOKENS_IN_SEPARATE_ROW("false"), // Display tokens in their own battlefield row. + UI_DISPLAY_COLOR_IDENTITY("Never"), UI_FOR_TOUCHSCREN("false"),