From 906b82f3ab967ef04fa88fe52b08e589014044c5 Mon Sep 17 00:00:00 2001 From: moomarc Date: Wed, 20 Mar 2013 09:34:48 +0000 Subject: [PATCH] - Added a user preference that allows a user to choose whether a clone or copied card should use its native artwork or the artwork of the card being cloned. By default the cloned card's image will be used. --- res/cardsfolder/i/infinite_reflection.txt | 4 ++-- .../card/ability/effects/CloneEffect.java | 12 ++++++++---- .../gui/home/settings/CSubmenuPreferences.java | 12 +++++++++++- .../gui/home/settings/VSubmenuPreferences.java | 18 +++++++++++++----- .../forge/properties/ForgePreferences.java | 3 ++- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/res/cardsfolder/i/infinite_reflection.txt b/res/cardsfolder/i/infinite_reflection.txt index b7f3daa9542..07587e1e9c1 100644 --- a/res/cardsfolder/i/infinite_reflection.txt +++ b/res/cardsfolder/i/infinite_reflection.txt @@ -7,10 +7,10 @@ T:Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self+AttachedTo SVar:RememberInitialAttach:DB$ Pump | RememberObjects$ Valid Card.AttachedBy T:Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self+AttachedTo Card | Execute$ FirstReflections | TriggerZones$ Battlefield | TriggerDescription$ When CARDNAME enters the battlefield attached to a creature, each other nontoken creature you control becomes a copy of that creature. SVar:FirstReflections:DB$ RepeatEach | RepeatCards$ Creature.nonToken+YouCtrl | UseImprinted$ True | Zone$ Battlefield | RepeatSubAbility$ Reflect | SubAbility$ DBCleanup -SVar:Reflect:DB$ Clone | Defined$ Remembered | CloneTarget$ Imprinted | ImageSource$ Remembered +SVar:Reflect:DB$ Clone | Defined$ Remembered | CloneTarget$ Imprinted SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True K:ETBReplacement:Copy:Reflections:Mandatory:Battlefield:Creature.nonToken+YouCtrl -SVar:Reflections:DB$ Clone | Defined$ Enchanted | CloneTarget$ ReplacedCard | ImageSource$ Enchanted | SpellDescription$ Nontoken creatures you control enter the battlefield as a copy of enchanted creature. +SVar:Reflections:DB$ Clone | Defined$ Enchanted | CloneTarget$ ReplacedCard | SpellDescription$ Nontoken creatures you control enter the battlefield as a copy of enchanted creature. SVar:Picture:http://www.wizards.com/global/images/magic/general/infinite_reflection.jpg Oracle:Enchant creature\nWhen Infinite Reflection enters the battlefield attached to a creature, each other nontoken creature you control becomes a copy of that creature.\nNontoken creatures you control enter the battlefield as a copy of enchanted creature. SetInfo:AVR Rare \ No newline at end of file diff --git a/src/main/java/forge/card/ability/effects/CloneEffect.java b/src/main/java/forge/card/ability/effects/CloneEffect.java index 4077402337c..7f099890a20 100644 --- a/src/main/java/forge/card/ability/effects/CloneEffect.java +++ b/src/main/java/forge/card/ability/effects/CloneEffect.java @@ -19,6 +19,7 @@ import forge.card.spellability.Target; import forge.card.trigger.Trigger; import forge.card.trigger.TriggerHandler; import forge.gui.GuiDialog; +import forge.properties.ForgePreferences.FPref; public class CloneEffect extends SpellAbilityEffect { // TODO update this method @@ -87,10 +88,13 @@ public class CloneEffect extends SpellAbilityEffect { } // determine the image to be used for the clone - String imageFileName = host.getImageKey(); - List cloneImgSources = AbilityUtils.getDefinedCards(host, sa.getParam("ImageSource"), sa); - if (!cloneImgSources.isEmpty()) { - imageFileName = cloneImgSources.get(0).getImageKey(); + String imageFileName = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE) + ? tgtCard.getImageKey() : cardToCopy.getImageKey(); + if (sa.hasParam("ImageSource")) { // Allow the image to be stipulated by using a defined card source + List cloneImgSources = AbilityUtils.getDefinedCards(host, sa.getParam("ImageSource"), sa); + if (!cloneImgSources.isEmpty()) { + imageFileName = cloneImgSources.get(0).getImageKey(); + } } boolean keepName = sa.hasParam("KeepName"); diff --git a/src/main/java/forge/gui/home/settings/CSubmenuPreferences.java b/src/main/java/forge/gui/home/settings/CSubmenuPreferences.java index 340980903a0..de8bf2422f6 100644 --- a/src/main/java/forge/gui/home/settings/CSubmenuPreferences.java +++ b/src/main/java/forge/gui/home/settings/CSubmenuPreferences.java @@ -99,6 +99,15 @@ public enum CSubmenuPreferences implements ICDoc { } }); + view.getCbCloneImgSource().addItemListener(new ItemListener() { + @Override + public void itemStateChanged(final ItemEvent arg0) { + final boolean toggle = view.getCbCloneImgSource().isSelected(); + prefs.setPref(FPref.UI_CLONE_MODE_SOURCE, String.valueOf(toggle)); + prefs.save(); + } + }); + view.getCbRemoveSmall().addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent arg0) { @@ -207,13 +216,14 @@ public enum CSubmenuPreferences implements ICDoc { view.getCbStackLand().setSelected(prefs.getPrefBoolean(FPref.UI_SMOOTH_LAND)); view.getCbDevMode().setSelected(prefs.getPrefBoolean(FPref.DEV_MODE_ENABLED)); view.getCbEnforceDeckLegality().setSelected(prefs.getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)); + view.getCbCloneImgSource().setSelected(prefs.getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE)); view.getCbRandomFoil().setSelected(prefs.getPrefBoolean(FPref.UI_RANDOM_FOIL)); view.getCbRandomizeArt().setSelected(prefs.getPrefBoolean(FPref.UI_RANDOM_CARD_ART)); view.getCbScaleLarger().setSelected(prefs.getPrefBoolean(FPref.UI_SCALE_LARGER)); view.getCbTextMana().setSelected(prefs.getPrefBoolean(FPref.UI_CARD_OVERLAY)); view.getCbEnableSounds().setSelected(prefs.getPrefBoolean(FPref.UI_ENABLE_SOUNDS)); view.reloadShortcuts(); - + SwingUtilities.invokeLater(new Runnable() { @Override public void run() { view.getCbRemoveSmall().requestFocusInWindow(); } }); diff --git a/src/main/java/forge/gui/home/settings/VSubmenuPreferences.java b/src/main/java/forge/gui/home/settings/VSubmenuPreferences.java index d8306dd4995..deeba7be321 100644 --- a/src/main/java/forge/gui/home/settings/VSubmenuPreferences.java +++ b/src/main/java/forge/gui/home/settings/VSubmenuPreferences.java @@ -74,7 +74,7 @@ public enum VSubmenuPreferences implements IVSubmenu { private final FLabel lblTitleAIProfile = new FLabel.Builder() .text("Choose AI Personality").fontStyle(Font.BOLD).fontSize(14).build(); - + private final JList lstChooseAIProfile = new FList(); private final FLabel lblChooseAIProfile = new FLabel.Builder().fontSize(12).fontStyle(Font.ITALIC) .text("AI Opponent Personality.") @@ -90,6 +90,7 @@ public enum VSubmenuPreferences implements IVSubmenu { private final JCheckBox cbManaBurn = new OptionsCheckBox("Mana Burn"); private final JCheckBox cbDevMode = new OptionsCheckBox("Developer Mode"); private final JCheckBox cbEnforceDeckLegality = new OptionsCheckBox("Deck Conformance"); + private final JCheckBox cbCloneImgSource = new OptionsCheckBox("Clones use original card art"); 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"); @@ -97,8 +98,7 @@ public enum VSubmenuPreferences implements IVSubmenu { private final JCheckBox cbEnableSounds = new OptionsCheckBox("Enable Sounds"); private final Map shortcutFields = new HashMap(); - - + /** * Constructor. */ @@ -143,6 +143,9 @@ public enum VSubmenuPreferences implements IVSubmenu { pnlPrefs.add(cbEnforceDeckLegality, regularConstraints); pnlPrefs.add(new NoteLabel("Enforces deck legality relevant to each environment (minimum deck sizes, max card count etc)"), regularConstraints); + pnlPrefs.add(cbCloneImgSource, regularConstraints); + pnlPrefs.add(new NoteLabel("When enabled clones will use their original art instead of the cloned card's art"), regularConstraints); + // AI Personality Profile Options pnlPrefs.add(new SectionLabel("AI Options"), sectionConstraints); @@ -201,7 +204,7 @@ public enum VSubmenuPreferences implements IVSubmenu { e.getValue().reload(e.getKey()); } } - + /* (non-Javadoc) * @see forge.view.home.IViewSubmenu#populate() */ @@ -320,7 +323,7 @@ public enum VSubmenuPreferences implements IVSubmenu { public void reload(FPref prefKey) { this.setCodeString(Singletons.getModel().getPreferences().getPref(prefKey)); } - + /** * Gets the code string. * @@ -451,6 +454,11 @@ public enum VSubmenuPreferences implements IVSubmenu { return cbEnforceDeckLegality; } + /** @return {@link javax.swing.JCheckBox} */ + public JCheckBox getCbCloneImgSource() { + return cbCloneImgSource; + } + /** @return {@link javax.swing.JCheckBox} */ public JCheckBox getCbEnableSounds() { return cbEnableSounds; diff --git a/src/main/java/forge/properties/ForgePreferences.java b/src/main/java/forge/properties/ForgePreferences.java index 8a951c5f44d..cdcc6d75ccd 100644 --- a/src/main/java/forge/properties/ForgePreferences.java +++ b/src/main/java/forge/properties/ForgePreferences.java @@ -51,7 +51,8 @@ public class ForgePreferences extends PreferencesStore { UI_TARGETING_OVERLAY ("false"), UI_ENABLE_SOUNDS ("true"), UI_RANDOM_CARD_ART ("false"), - UI_CURRENT_AI_PROFILE (AiProfileUtil.AI_PROFILE_RANDOM_MATCH), /** */ + UI_CURRENT_AI_PROFILE (AiProfileUtil.AI_PROFILE_RANDOM_MATCH), + UI_CLONE_MODE_SOURCE ("false"), /** */ SUBMENU_CURRENTMENU (EMenuItem.CONSTRUCTED.toString()), SUBMENU_SANCTIONED ("false"),