WASD Movement Take 2 (#7251)

* Enter now still brings up the menu, controller might need it to type. WASD typing still works.
This commit is contained in:
Drecon84
2025-03-26 08:27:16 +01:00
committed by GitHub
parent 20815552b9
commit aeb279a6f8
20 changed files with 180 additions and 177 deletions

View File

@@ -28,7 +28,7 @@ import java.time.LocalTime;
*/ */
public class UIScene extends Scene { public class UIScene extends Scene {
protected UIActor ui; protected UIActor ui;
private boolean textboxOpen;
public static class Selectable<T extends Actor> { public static class Selectable<T extends Actor> {
public T actor; public T actor;
@@ -192,6 +192,7 @@ public class UIScene extends Scene {
} }
public UIScene(String uiFilePath) { public UIScene(String uiFilePath) {
textboxOpen = false;
uiFile = uiFilePath; uiFile = uiFilePath;
stage = new Stage(new ScalingViewport(Scaling.stretch, getIntendedWidth(), getIntendedHeight())) { stage = new Stage(new ScalingViewport(Scaling.stretch, getIntendedWidth(), getIntendedHeight())) {
@Override @Override
@@ -223,7 +224,7 @@ public class UIScene extends Scene {
} }
public void removeDialog() { public void removeDialog() {
textboxOpen = false;
if (!dialogs.isEmpty()) { if (!dialogs.isEmpty()) {
dialogs.get(dialogs.size - 1).remove(); dialogs.get(dialogs.size - 1).remove();
dialogs.removeIndex(dialogs.size - 1); dialogs.removeIndex(dialogs.size - 1);
@@ -243,6 +244,7 @@ public class UIScene extends Scene {
} }
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;
if (label != null) if (label != null)
dialog.text(label); dialog.text(label);
TextraButton yes = Controls.newTextButton(stringYes, runnableYes); TextraButton yes = Controls.newTextButton(stringYes, runnableYes);
@@ -359,7 +361,6 @@ public class UIScene extends Scene {
} }
} }
if (KeyBinding.Back.isPressed(keycode) && selection != null) { if (KeyBinding.Back.isPressed(keycode) && selection != null) {
selection.onDeSelect(); selection.onDeSelect();
stage.setKeyboardFocus(null); stage.setKeyboardFocus(null);
@@ -378,15 +379,17 @@ public class UIScene extends Scene {
scroll.setScrollY(scroll.getScrollY() + 20); scroll.setScrollY(scroll.getScrollY() + 20);
} }
} }
if (KeyBinding.Down.isPressed(keycode)) if(!textboxOpen){
selectNextDown(); if (KeyBinding.Down.isPressed(keycode))
if (KeyBinding.Up.isPressed(keycode)) selectNextDown();
selectNextUp(); if (KeyBinding.Up.isPressed(keycode))
if (!(stage.getKeyboardFocus() instanceof Selector) && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)) { selectNextUp();
if (KeyBinding.Right.isPressed(keycode)) if (!(stage.getKeyboardFocus() instanceof Selector) && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)) {
selectNextRight(); if (KeyBinding.Right.isPressed(keycode))
if (KeyBinding.Left.isPressed(keycode)) selectNextRight();
selectNextLeft(); if (KeyBinding.Left.isPressed(keycode))
selectNextLeft();
}
} }
if (!dialogShowing()) { if (!dialogShowing()) {
Button pressedButton = ui.buttonPressed(keycode); Button pressedButton = ui.buttonPressed(keycode);