From 6bc484885764d5e3edfb76264ebe42fc7f285134 Mon Sep 17 00:00:00 2001 From: Agetian Date: Tue, 2 Jun 2015 05:07:10 +0000 Subject: [PATCH] - Added a new color identity display mode: "Changed" (displays color identity only for cards that had their identity altered). - Improved the use of related string constants. --- .../home/settings/CSubmenuPreferences.java | 3 +- .../forge/screens/settings/SettingsPage.java | 4 ++- forge-gui/CHANGES.txt | 12 ++++--- .../main/java/forge/card/CardDetailUtil.java | 36 +++++++++++++++++-- .../java/forge/properties/ForgeConstants.java | 3 +- 5 files changed, 47 insertions(+), 11 deletions(-) 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 0b3573a58e2..bb4b92ab28a 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 @@ -300,7 +300,8 @@ public enum CSubmenuPreferences implements ICDoc { } private void initializeColorIdentityCombobox() { - final String[] elems = {ForgeConstants.DISP_COLOR_IDENT_NEVER, ForgeConstants.DISP_COLOR_IDENT_MULTICOLOR, ForgeConstants.DISP_COLOR_IDENT_ALWAYS}; + final String[] elems = {ForgeConstants.DISP_COLOR_IDENT_NEVER, ForgeConstants.DISP_COLOR_IDENT_CHANGED, + ForgeConstants.DISP_COLOR_IDENT_MULTICOLOR, ForgeConstants.DISP_COLOR_IDENT_ALWAYS}; final FPref userSetting = FPref.UI_DISPLAY_COLOR_IDENTITY; final FComboBoxPanel panel = this.view.getDisplayColorIdentity(); final FComboBox comboBox = createComboBox(elems, userSetting); diff --git a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java index cbb4372fc45..d4da2e94131 100644 --- a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java +++ b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java @@ -166,7 +166,9 @@ public class SettingsPage extends TabPage { 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[]{ForgeConstants.DISP_COLOR_IDENT_NEVER, ForgeConstants.DISP_COLOR_IDENT_MULTICOLOR, ForgeConstants.DISP_COLOR_IDENT_ALWAYS}), + new String[]{ + ForgeConstants.DISP_COLOR_IDENT_NEVER, ForgeConstants.DISP_COLOR_IDENT_MULTICOLOR, + ForgeConstants.DISP_COLOR_IDENT_CHANGED, ForgeConstants.DISP_COLOR_IDENT_ALWAYS}), 4); //Card Overlays diff --git a/forge-gui/CHANGES.txt b/forge-gui/CHANGES.txt index 9299da2699d..bd098ddb2bd 100644 --- a/forge-gui/CHANGES.txt +++ b/forge-gui/CHANGES.txt @@ -35,11 +35,13 @@ The interface has received several small changes. 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. +identity for all cards, even mono-color), to "Changed" (which displays color +identity of all cards whose color identity has been altered compared to its +"pristine" state) or "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 - diff --git a/forge-gui/src/main/java/forge/card/CardDetailUtil.java b/forge-gui/src/main/java/forge/card/CardDetailUtil.java index 21e70bfbd04..5fd01ef0849 100644 --- a/forge-gui/src/main/java/forge/card/CardDetailUtil.java +++ b/forge-gui/src/main/java/forge/card/CardDetailUtil.java @@ -11,14 +11,17 @@ import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Sets; import forge.game.GameView; +import forge.game.card.Card; import forge.game.card.CardUtil; import forge.game.card.CardView; import forge.game.card.CardView.CardStateView; import forge.game.card.CounterType; import forge.item.InventoryItemFromSet; +import forge.item.PaperCard; import forge.item.PreconDeck; import forge.item.SealedProduct; import forge.model.FModel; +import forge.properties.ForgeConstants; import forge.properties.ForgePreferences; import forge.util.Lang; @@ -509,10 +512,37 @@ public class CardDetailUtil { //show card color identity if enabled String colorIdentMode = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_DISPLAY_COLOR_IDENTITY); - if (!colorIdentMode.equals("Never")) { + if (!colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_NEVER)) { final String colorIdent = getColorIdentity(state); - final int numColors = state.getColors().countColors(); - if (!colorIdentMode.equals("Only Multicolor") || numColors > 1) { + boolean showIdentity = false; + + if (colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_CHANGED)) { + String origIdent = ""; + PaperCard origPaperCard = null; + Card origCard = null; + try { + if (!card.getName().isEmpty()) { + origPaperCard = FModel.getMagicDb().getCommonCards().getCard(card.getName()); + } else { + // probably a morph, try to get its identity from the alternate state + origPaperCard = FModel.getMagicDb().getCommonCards().getCard(card.getAlternateState().getName()); + } + if (origPaperCard != null) { + origCard = Card.getCardForUi(origPaperCard); // if null, probably a variant card + } + origIdent = origCard != null ? getColorIdentity(CardView.get(origCard).getCurrentState()) : ""; + } catch(Exception ex) { + System.err.println("Unexpected behavior: card " + card.getName() + "[" + card.getId() + "] tripped an exception when trying to process color identity."); + } + showIdentity = !colorIdent.equals(origIdent); + } else if (colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_MULTICOLOR)) { + final int numColors = state.getColors().countColors(); + showIdentity = numColors > 1; + } else if (colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_ALWAYS)) { + showIdentity = true; + } + + if (showIdentity) { if (area.length() != 0) { area.append("\n\n"); } diff --git a/forge-gui/src/main/java/forge/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/properties/ForgeConstants.java index 02a6788a229..ccb27dc7a8c 100644 --- a/forge-gui/src/main/java/forge/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/properties/ForgeConstants.java @@ -180,7 +180,8 @@ public final class ForgeConstants { // Constants for Display Card Identity game setting public static final String DISP_COLOR_IDENT_ALWAYS = "Always"; - public static final String DISP_COLOR_IDENT_MULTICOLOR = "Only Multicolor"; + public static final String DISP_COLOR_IDENT_CHANGED = "Changed"; + public static final String DISP_COLOR_IDENT_MULTICOLOR = "Multicolor"; public static final String DISP_COLOR_IDENT_NEVER = "Never"; }