mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Added keyboard shortcuts to auto yield the current ability on the stack and, if applicable, respond "Always Yes" or "Always No" at the same time.
- By default set to Y (which enables auto yield for the item on stack and sets "Always Yes" if applicable) and N (which enables auto yield for the item on stack and sets "Always No" if applicable).
This commit is contained in:
@@ -17,6 +17,7 @@ import javax.swing.KeyStroke;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
|
import forge.game.spellability.StackItemView;
|
||||||
import forge.gui.framework.EDocID;
|
import forge.gui.framework.EDocID;
|
||||||
import forge.gui.framework.SDisplayUtil;
|
import forge.gui.framework.SDisplayUtil;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
@@ -131,6 +132,43 @@ public class KeyboardShortcuts {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Auto-yield current item on stack (and respond Always Yes if applicable). */
|
||||||
|
final Action actAutoYieldAndYes = new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||||
|
if (matchUI == null) { return; }
|
||||||
|
StackItemView si = matchUI.getGameView().peekStack();
|
||||||
|
if (si != null && si.isAbility()) {
|
||||||
|
matchUI.setShouldAutoYield(si.getKey(), true);
|
||||||
|
int triggerID = Integer.valueOf(si.getSourceTrigger());
|
||||||
|
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
|
||||||
|
matchUI.setShouldAlwaysAcceptTrigger(triggerID);
|
||||||
|
}
|
||||||
|
matchUI.getGameController().passPriority();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Auto-yield current item on stack (and respond Always No if applicable). */
|
||||||
|
final Action actAutoYieldAndNo = new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
if (!Singletons.getControl().getCurrentScreen().isMatchScreen()) { return; }
|
||||||
|
if (matchUI == null) { return; }
|
||||||
|
StackItemView si = matchUI.getGameView().peekStack();
|
||||||
|
if (si != null && si.isAbility()) {
|
||||||
|
matchUI.setShouldAutoYield(si.getKey(), true);
|
||||||
|
int triggerID = Integer.valueOf(si.getSourceTrigger());
|
||||||
|
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
|
||||||
|
matchUI.setShouldAlwaysDeclineTrigger(triggerID);
|
||||||
|
}
|
||||||
|
matchUI.getGameController().passPriority();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//========== Instantiate shortcut objects and add to list.
|
//========== Instantiate shortcut objects and add to list.
|
||||||
list.add(new Shortcut(FPref.SHORTCUT_SHOWSTACK, "Match: show stack panel", actShowStack, am, im));
|
list.add(new Shortcut(FPref.SHORTCUT_SHOWSTACK, "Match: show stack panel", actShowStack, am, im));
|
||||||
list.add(new Shortcut(FPref.SHORTCUT_SHOWCOMBAT, "Match: show combat panel", actShowCombat, am, im));
|
list.add(new Shortcut(FPref.SHORTCUT_SHOWCOMBAT, "Match: show combat panel", actShowCombat, am, im));
|
||||||
@@ -140,6 +178,8 @@ public class KeyboardShortcuts {
|
|||||||
list.add(new Shortcut(FPref.SHORTCUT_ENDTURN, "Match: pass priority until EOT or next stack event", actEndTurn, am, im));
|
list.add(new Shortcut(FPref.SHORTCUT_ENDTURN, "Match: pass priority until EOT or next stack event", actEndTurn, am, im));
|
||||||
list.add(new Shortcut(FPref.SHORTCUT_ALPHASTRIKE, "Match: Alpha Strike (attack with all available)", actAllAttack, am, im));
|
list.add(new Shortcut(FPref.SHORTCUT_ALPHASTRIKE, "Match: Alpha Strike (attack with all available)", actAllAttack, am, im));
|
||||||
list.add(new Shortcut(FPref.SHORTCUT_SHOWTARGETING, "Match: toggle targeting visual overlay", actTgtOverlay, am, im));
|
list.add(new Shortcut(FPref.SHORTCUT_SHOWTARGETING, "Match: toggle targeting visual overlay", actTgtOverlay, am, im));
|
||||||
|
list.add(new Shortcut(FPref.SHORTCUT_AUTOYIELD_ALWAYS_YES, "Match: auto-yield ability on stack (Always Yes)", actAutoYieldAndYes, am, im));
|
||||||
|
list.add(new Shortcut(FPref.SHORTCUT_AUTOYIELD_ALWAYS_NO, "Match: auto-yield ability on stack (Always No)", actAutoYieldAndNo, am, im));
|
||||||
return list;
|
return list;
|
||||||
} // End initMatchShortcuts()
|
} // End initMatchShortcuts()
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,9 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
|||||||
SHORTCUT_CONCEDE ("17"),
|
SHORTCUT_CONCEDE ("17"),
|
||||||
SHORTCUT_ENDTURN ("69"),
|
SHORTCUT_ENDTURN ("69"),
|
||||||
SHORTCUT_ALPHASTRIKE ("65"),
|
SHORTCUT_ALPHASTRIKE ("65"),
|
||||||
SHORTCUT_SHOWTARGETING ("84");
|
SHORTCUT_SHOWTARGETING ("84"),
|
||||||
|
SHORTCUT_AUTOYIELD_ALWAYS_YES ("89"),
|
||||||
|
SHORTCUT_AUTOYIELD_ALWAYS_NO ("78");
|
||||||
|
|
||||||
private final String strDefaultVal;
|
private final String strDefaultVal;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user