mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge branch 'master' into FixEncodingAndroidCompatible
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.controllers.Controller;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
@@ -242,6 +243,7 @@ public class UIScene extends Scene {
|
||||
public Dialog createGenericDialog(String title, String label, String stringYes, String stringNo, Runnable runnableYes, Runnable runnableNo) {
|
||||
return createGenericDialog(title, label, stringYes, stringNo, runnableYes, runnableNo, false, "");
|
||||
}
|
||||
|
||||
public Dialog createGenericDialog(String title, String label, String stringYes, String stringNo, Runnable runnableYes, Runnable runnableNo, boolean cancelButton, String stringCancel) {
|
||||
Dialog dialog = new Dialog(title == null ? "" : title, Controls.getSkin());
|
||||
textboxOpen = true;
|
||||
@@ -341,7 +343,7 @@ public class UIScene extends Scene {
|
||||
|
||||
public boolean keyPressed(int keycode) {
|
||||
ui.pressDown(keycode);
|
||||
|
||||
|
||||
Selectable selection = getSelected();
|
||||
if (KeyBinding.Use.isPressed(keycode)) {
|
||||
if (selection != null) {
|
||||
@@ -378,17 +380,22 @@ public class UIScene extends Scene {
|
||||
scroll.setScrollY(scroll.getScrollY() + 20);
|
||||
}
|
||||
}
|
||||
if(!textboxOpen){
|
||||
if (KeyBinding.Down.isPressed(keycode))
|
||||
if (!textboxOpen) {
|
||||
//Allow letter S for TextField since this is binded on down keys
|
||||
if (KeyBinding.Down.isPressed(keycode, !(stage.getKeyboardFocus() instanceof TextField))
|
||||
|| KeyBinding.Down.isPressed(keycode, Input.Keys.S != keycode))
|
||||
selectNextDown();
|
||||
if (KeyBinding.Up.isPressed(keycode))
|
||||
//Allow letter W for TextField since this is binded on up keys
|
||||
if (KeyBinding.Up.isPressed(keycode, !(stage.getKeyboardFocus() instanceof TextField))
|
||||
|| KeyBinding.Up.isPressed(keycode, Input.Keys.W != keycode))
|
||||
selectNextUp();
|
||||
if (!(stage.getKeyboardFocus() instanceof Selector) && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)) {
|
||||
if (KeyBinding.Right.isPressed(keycode))
|
||||
selectNextRight();
|
||||
if (KeyBinding.Left.isPressed(keycode))
|
||||
selectNextLeft();
|
||||
}
|
||||
// Allow Right & Left keybinds if not Selector, Slider or Textfield
|
||||
if (KeyBinding.Right.isPressed(keycode, !(stage.getKeyboardFocus() instanceof Selector)
|
||||
&& !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)))
|
||||
selectNextRight();
|
||||
if (KeyBinding.Left.isPressed(keycode, !(stage.getKeyboardFocus() instanceof Selector)
|
||||
&& !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)))
|
||||
selectNextLeft();
|
||||
}
|
||||
if (!dialogShowing()) {
|
||||
Button pressedButton = ui.buttonPressed(keycode);
|
||||
|
||||
@@ -34,9 +34,15 @@ public enum KeyBinding {
|
||||
}
|
||||
|
||||
public boolean isPressed(int key) {
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
if (key == bindings[i]) {
|
||||
return true;
|
||||
return isPressed(key, null);
|
||||
}
|
||||
|
||||
public boolean isPressed(int key, Boolean requiredCondition) {
|
||||
if (requiredCondition == null || requiredCondition) {
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
if (key == bindings[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user