From 10f76eae8249177d94e1edd3151290039a7b610b Mon Sep 17 00:00:00 2001 From: Agetian Date: Wed, 1 Feb 2017 17:32:02 +0000 Subject: [PATCH] - Implemented a toggleable option to auto-yield either per ability or per card ("Auto-Yield Mode" under Gameplay). - Restored the historical Forge default of auto-yielding per ability. --- .../home/settings/CSubmenuPreferences.java | 11 ++++++++++- .../home/settings/VSubmenuPreferences.java | 10 +++++++++- .../src/forge/screens/settings/SettingsPage.java | 5 +++++ forge-gui/CHANGES.txt | 3 +++ .../main/java/forge/match/AbstractGuiGame.java | 15 ++++++++++++--- .../java/forge/properties/ForgeConstants.java | 3 +++ .../java/forge/properties/ForgePreferences.java | 3 ++- 7 files changed, 44 insertions(+), 6 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 a58711498fb..9f23081db88 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 @@ -117,7 +117,7 @@ public enum CSubmenuPreferences implements ICDoc { lstControls.add(Pair.of(view.getCbManaLostPrompt(), FPref.UI_MANA_LOST_PROMPT)); lstControls.add(Pair.of(view.getCbEscapeEndsTurn(), FPref.UI_ALLOW_ESC_TO_END_TURN)); lstControls.add(Pair.of(view.getCbDetailedPaymentDesc(), FPref.UI_DETAILED_SPELLDESC_IN_PROMPT)); - lstControls.add(Pair.of(view.getcbPreselectPrevAbOrder(), FPref.UI_PRESELECT_PREVIOUS_ABILITY_ORDER)); + lstControls.add(Pair.of(view.getCbPreselectPrevAbOrder(), FPref.UI_PRESELECT_PREVIOUS_ABILITY_ORDER)); lstControls.add(Pair.of(view.getCbFilterLandsByColorId(), FPref.UI_FILTER_LANDS_BY_COLOR_IDENTITY)); @@ -181,6 +181,7 @@ public enum CSubmenuPreferences implements ICDoc { initializeCloseActionComboBox(); initializeAiProfilesComboBox(); initializeColorIdentityCombobox(); + initializeAutoYieldModeComboBox(); initializePlayerNameButton(); } @@ -318,6 +319,14 @@ public enum CSubmenuPreferences implements ICDoc { panel.setComboBox(comboBox, selectedItem); } + private void initializeAutoYieldModeComboBox() { + final String[] elems = {ForgeConstants.AUTO_YIELD_PER_ABILITY, ForgeConstants.AUTO_YIELD_PER_CARD}; + final FPref userSetting = FPref.UI_AUTO_YIELD_MODE; + final FComboBoxPanel panel = this.view.getAutoYieldModeComboBoxPanel(); + 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 ed6e6e6409f..54c9f5710e9 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 @@ -97,6 +97,7 @@ public enum VSubmenuPreferences implements IVSubmenu { private final FComboBoxPanel cbpCloseAction = new FComboBoxPanel<>("Close Action:"); private final FComboBoxPanel cbpAiProfiles = new FComboBoxPanel<>("AI Personality:"); private final FComboBoxPanel cbpDisplayCurrentCardColors = new FComboBoxPanel<>("Show Detailed Card Color:"); + private final FComboBoxPanel cbpAutoYieldMode = new FComboBoxPanel<>("Auto-Yield Mode:"); /** * Constructor. @@ -175,6 +176,9 @@ public enum VSubmenuPreferences implements IVSubmenu { pnlPrefs.add(cbPreselectPrevAbOrder, regularConstraints); pnlPrefs.add(new NoteLabel("When enabled, preselects the last defined simultaneous ability order in the ordering dialog."), regularConstraints); + pnlPrefs.add(cbpAutoYieldMode, regularConstraints); + pnlPrefs.add(new NoteLabel("Defines the granularity level of auto-yields (yield to each unique ability or to each unique card)."), regularConstraints); + // Deck building options pnlPrefs.add(new SectionLabel("Random Deck Generation"), sectionConstraints); @@ -552,6 +556,10 @@ public enum VSubmenuPreferences implements IVSubmenu { return cbpCloseAction; } + public FComboBoxPanel getAutoYieldModeComboBoxPanel() { + return cbpAutoYieldMode; + } + /** @return {@link javax.swing.JCheckBox} */ public JCheckBox getCbEnforceDeckLegality() { return cbEnforceDeckLegality; @@ -627,7 +635,7 @@ public enum VSubmenuPreferences implements IVSubmenu { return cbDetailedPaymentDesc; } - public final JCheckBox getcbPreselectPrevAbOrder() { + public final JCheckBox getCbPreselectPrevAbOrder() { return cbPreselectPrevAbOrder; } diff --git a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java index 795509d03d3..f6cab580529 100644 --- a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java +++ b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java @@ -126,6 +126,11 @@ public class SettingsPage extends TabPage { "Preselect Last Order of Abilities", "When enabled, preselects the last defined simultaneous ability order in the ordering dialog."), 1); + lstSettings.addItem(new CustomSelectSetting(FPref.UI_AUTO_YIELD_MODE, + "Auto-Yield Mode", + "Defines the granularity level of auto-yields (yield to each unique ability or to each unique card).", + new String[]{ForgeConstants.AUTO_YIELD_PER_ABILITY, ForgeConstants.AUTO_YIELD_PER_CARD}), + 1); //Random Deck Generation lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_NOSMALL, diff --git a/forge-gui/CHANGES.txt b/forge-gui/CHANGES.txt index fde64eb1d8f..c9a4ca9edcc 100644 --- a/forge-gui/CHANGES.txt +++ b/forge-gui/CHANGES.txt @@ -14,6 +14,9 @@ This release features all Aether Revolt cards that you can play with in all game - Commander 2016 - This release features most Commander 2016 cards scripted and ready to play. The few remaining cards that are not currently supported may be scripted in the upcoming versions of Forge. +- Auto-Yielding Granularity - +It is now possible to specify the granularity level for auto-yields: it is possible to choose between yielding to each unique ability or to each unique card. The difference is that, for example, when yielding per ability if you auto-yield to Hellrider's triggered ability once, all triggers from other Hellrider cards will be automatically auto-yielded to as well. When yielding per card, you will need to auto-yield to each Hellrider separately. The historical Forge default of auto-yielding per ability has been restored, and the option can now be toggled in Forge Preferences (check out "Auto-Yield Mode" under Gameplay) in both Desktop and Mobile Forge. + - User interface updates and changes - Some notable modifications were made to the Forge UI for desktop computers. First of all, many pop-up prompts have been replaced with prompt window queries - for example, Scry 1 now shows the request to put the card on the top or bottom of the library in the prompt window instead of a pop-up dialog window, and allows to view the card in question by moving the mouse over the prompt window, which is more convenient. Second of all, in both desktop and mobile Forge, there is now an option in Forge Preferences called "Preselect Last Order of Abilities" that preselects the last known order of simultaneous abilities, thus making it possible to just use "Space" once to confirm the previous order instead of having to press Space for each ability or clicking the ">>" button to add the previous order once more. This option is currently disabled by default to avoid being confusing to users who are used to doing it the way it used to be before. Also, there is now an option to view detailed spell ability descriptions in the prompt window during mana payment and targeting, which is enabled by default but can be enabled/disabled in Forge preferences ("Spell Description in Payment Prompt" under the "Gameplay" preference group). diff --git a/forge-gui/src/main/java/forge/match/AbstractGuiGame.java b/forge-gui/src/main/java/forge/match/AbstractGuiGame.java index 3e8c8df6f02..90f2a700a0f 100644 --- a/forge-gui/src/main/java/forge/match/AbstractGuiGame.java +++ b/forge-gui/src/main/java/forge/match/AbstractGuiGame.java @@ -27,6 +27,9 @@ import forge.game.player.PlayerView; import forge.interfaces.IGameController; import forge.interfaces.IGuiGame; import forge.interfaces.IMayViewCards; +import forge.model.FModel; +import forge.properties.ForgeConstants; +import forge.properties.ForgePreferences; import forge.trackable.TrackableTypes; public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards { @@ -355,15 +358,21 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards { } @Override public final boolean shouldAutoYield(final String key) { - return !getDisableAutoYields() && autoYields.contains(key); + String abilityKey = key.indexOf("): ") != -1 ? key.substring(key.indexOf("): ") + 3) : key; + boolean yieldPerAbility = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_AUTO_YIELD_MODE).equals(ForgeConstants.AUTO_YIELD_PER_ABILITY); + + return !getDisableAutoYields() && autoYields.contains(yieldPerAbility ? abilityKey : key); } @Override public final void setShouldAutoYield(final String key, final boolean autoYield) { + String abilityKey = key.indexOf("): ") != -1 ? key.substring(key.indexOf("): ") + 3) : key; + boolean yieldPerAbility = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_AUTO_YIELD_MODE).equals(ForgeConstants.AUTO_YIELD_PER_ABILITY); + if (autoYield) { - autoYields.add(key); + autoYields.add(yieldPerAbility ? abilityKey : key); } else { - autoYields.remove(key); + autoYields.remove(yieldPerAbility ? abilityKey : key); } } diff --git a/forge-gui/src/main/java/forge/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/properties/ForgeConstants.java index 93b58312a56..df3a653b216 100644 --- a/forge-gui/src/main/java/forge/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/properties/ForgeConstants.java @@ -194,4 +194,7 @@ public final class ForgeConstants { public static final String DISP_CURRENT_COLORS_MULTI_OR_CHANGED = "Multi+Changed"; public static final String DISP_CURRENT_COLORS_NEVER = "Never"; + // Constants for Auto-Yield Mode + public static final String AUTO_YIELD_PER_CARD = "Per Card"; + public static final String AUTO_YIELD_PER_ABILITY = "Per Ability"; } diff --git a/forge-gui/src/main/java/forge/properties/ForgePreferences.java b/forge-gui/src/main/java/forge/properties/ForgePreferences.java index a02e0a4e691..b6416eb6113 100644 --- a/forge-gui/src/main/java/forge/properties/ForgePreferences.java +++ b/forge-gui/src/main/java/forge/properties/ForgePreferences.java @@ -82,10 +82,11 @@ 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_CURRENT_COLORS("Never"), + UI_DISPLAY_CURRENT_COLORS(ForgeConstants.DISP_CURRENT_COLORS_NEVER), UI_FILTER_LANDS_BY_COLOR_IDENTITY("true"), UI_ALLOW_ESC_TO_END_TURN ("false"), UI_PRESELECT_PREVIOUS_ABILITY_ORDER ("false"), + UI_AUTO_YIELD_MODE (ForgeConstants.AUTO_YIELD_PER_ABILITY), UI_FOR_TOUCHSCREN("false"),