Merge branch 'master' into FixEncodingAndroidCompatible

This commit is contained in:
Eradev
2025-07-07 00:14:02 -04:00
committed by GitHub
2 changed files with 26 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
package forge.adventure.scene; package forge.adventure.scene;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.controllers.Controller; import com.badlogic.gdx.controllers.Controller;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.TextureRegion; 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) { public Dialog createGenericDialog(String title, String label, String stringYes, String stringNo, Runnable runnableYes, Runnable runnableNo) {
return createGenericDialog(title, label, stringYes, stringNo, runnableYes, runnableNo, false, ""); 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) { 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()); Dialog dialog = new Dialog(title == null ? "" : title, Controls.getSkin());
textboxOpen = true; textboxOpen = true;
@@ -378,18 +380,23 @@ public class UIScene extends Scene {
scroll.setScrollY(scroll.getScrollY() + 20); scroll.setScrollY(scroll.getScrollY() + 20);
} }
} }
if(!textboxOpen){ if (!textboxOpen) {
if (KeyBinding.Down.isPressed(keycode)) //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(); 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(); selectNextUp();
if (!(stage.getKeyboardFocus() instanceof Selector) && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)) { // Allow Right & Left keybinds if not Selector, Slider or Textfield
if (KeyBinding.Right.isPressed(keycode)) if (KeyBinding.Right.isPressed(keycode, !(stage.getKeyboardFocus() instanceof Selector)
&& !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)))
selectNextRight(); selectNextRight();
if (KeyBinding.Left.isPressed(keycode)) if (KeyBinding.Left.isPressed(keycode, !(stage.getKeyboardFocus() instanceof Selector)
&& !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)))
selectNextLeft(); selectNextLeft();
} }
}
if (!dialogShowing()) { if (!dialogShowing()) {
Button pressedButton = ui.buttonPressed(keycode); Button pressedButton = ui.buttonPressed(keycode);
if (pressedButton != null) { if (pressedButton != null) {

View File

@@ -34,11 +34,17 @@ public enum KeyBinding {
} }
public boolean isPressed(int key) { public boolean isPressed(int key) {
return isPressed(key, null);
}
public boolean isPressed(int key, Boolean requiredCondition) {
if (requiredCondition == null || requiredCondition) {
for (int i = 0; i < bindings.length; i++) { for (int i = 0; i < bindings.length; i++) {
if (key == bindings[i]) { if (key == bindings[i]) {
return true; return true;
} }
} }
}
return false; return false;
} }