mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Merge branch 'master' into 'master'
Basic support for auto-yield keyboard shortcuts on mobile Forge (Y / N) See merge request core-developers/forge!5477
This commit is contained in:
@@ -9,6 +9,9 @@ import java.util.Set;
|
||||
|
||||
import forge.animation.ForgeAnimation;
|
||||
import forge.assets.FImage;
|
||||
import forge.game.spellability.StackItemView;
|
||||
import forge.gui.interfaces.IGuiGame;
|
||||
import forge.util.collect.FCollectionView;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
@@ -440,6 +443,7 @@ public class MatchScreen extends FScreen {
|
||||
|
||||
@Override
|
||||
public boolean keyDown(int keyCode) {
|
||||
// TODO: make the keyboard shortcuts configurable on Mobile
|
||||
switch (keyCode) {
|
||||
case Keys.ENTER:
|
||||
case Keys.SPACE:
|
||||
@@ -480,6 +484,68 @@ public class MatchScreen extends FScreen {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case Keys.Y: //auto-yield, always yes, Ctrl+Y on Android, Y when running on desktop
|
||||
if (KeyInputAdapter.isCtrlKeyDown() || GuiBase.getInterface().isRunningOnDesktop()) {
|
||||
final IGuiGame gui = MatchController.instance;
|
||||
final IGameController controller = MatchController.instance.getGameController();
|
||||
final GameView gameView = MatchController.instance.getGameView();
|
||||
final FCollectionView<StackItemView> stack = MatchController.instance.getGameView().getStack();
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
StackItemView stackInstance = stack.getLast();
|
||||
final int triggerID = stackInstance.getSourceTrigger();
|
||||
|
||||
if (gui.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
gui.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
gui.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
//auto-yes if ability is on top of stack
|
||||
controller.selectButtonOk();
|
||||
}
|
||||
}
|
||||
|
||||
final String key = stackInstance.getKey();
|
||||
gui.setShouldAutoYield(key, true);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
//auto-pass priority if ability is on top of stack
|
||||
controller.passPriority();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Keys.N: //auto-yield, always no, Ctrl+N on Android, N when running on desktop
|
||||
if (KeyInputAdapter.isCtrlKeyDown() || GuiBase.getInterface().isRunningOnDesktop()) {
|
||||
final IGuiGame gui = MatchController.instance;
|
||||
final IGameController controller = MatchController.instance.getGameController();
|
||||
final GameView gameView = MatchController.instance.getGameView();
|
||||
final FCollectionView<StackItemView> stack = MatchController.instance.getGameView().getStack();
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
StackItemView stackInstance = stack.getLast();
|
||||
final int triggerID = stackInstance.getSourceTrigger();
|
||||
|
||||
if (gui.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
gui.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
gui.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
//auto-no if ability is on top of stack
|
||||
controller.selectButtonCancel();
|
||||
}
|
||||
}
|
||||
|
||||
final String key = stackInstance.getKey();
|
||||
gui.setShouldAutoYield(key, true);
|
||||
if (stackInstance.equals(gameView.peekStack())) {
|
||||
//auto-pass priority if ability is on top of stack
|
||||
controller.passPriority();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return super.keyDown(keyCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user