Merge pull request #2729 from kevlahnota/newmaster2

update dialog buttons
This commit is contained in:
Anthony Calosa
2023-03-22 16:25:49 +08:00
committed by GitHub
2 changed files with 242 additions and 285 deletions

View File

@@ -19,6 +19,8 @@ import com.github.tommyettinger.textra.TextraLabel;
import forge.Forge; import forge.Forge;
import forge.adventure.stage.GameHUD; import forge.adventure.stage.GameHUD;
import forge.adventure.util.*; import forge.adventure.util.*;
import forge.sound.SoundEffectType;
import forge.sound.SoundSystem;
/** /**
* Base class for an GUI scene where the elements are loaded from a json file * Base class for an GUI scene where the elements are loaded from a json file
@@ -27,26 +29,23 @@ public class UIScene extends Scene {
protected UIActor ui; protected UIActor ui;
public static class Selectable<T extends Actor> public static class Selectable<T extends Actor> {
{
public T actor; public T actor;
public float getY()
{ public float getY() {
Actor act = actor; Actor act = actor;
float y = 0; float y = 0;
while (act!=null) while (act != null) {
{
y += act.getY(); y += act.getY();
act = act.getParent(); act = act.getParent();
} }
return y; return y;
} }
public float getX()
{ public float getX() {
Actor act = actor; Actor act = actor;
float x = 0; float x = 0;
while (act!=null) while (act != null) {
{
x += act.getX(); x += act.getX();
act = act.getParent(); act = act.getParent();
} }
@@ -57,43 +56,43 @@ public class UIScene extends Scene {
actor = newActor; actor = newActor;
} }
public void onSelect(UIScene scene) public void onSelect(UIScene scene) {
{
} }
public void onDeSelect()
{ public void onDeSelect() {
//actor.fire(UIScene.eventExit()); //actor.fire(UIScene.eventExit());
} }
public void onPressDown(UIScene scene)
{ public void onPressDown(UIScene scene) {
if(actor instanceof TextField) if (actor instanceof TextField) {
{
scene.requestTextInput(((TextField) actor).getText(), text -> ((TextField) actor).setText(text)); scene.requestTextInput(((TextField) actor).getText(), text -> ((TextField) actor).setText(text));
} }
actor.fire(UIScene.eventTouchDown()); actor.fire(UIScene.eventTouchDown());
} }
public void onPressUp()
{ public void onPressUp() {
actor.fire(UIScene.eventTouchUp()); actor.fire(UIScene.eventTouchUp());
} }
public float yDiff(Selectable finalOne) { public float yDiff(Selectable finalOne) {
return Math.abs(finalOne.getY() - getY()); return Math.abs(finalOne.getY() - getY());
} }
public float xDiff(Selectable finalOne) { public float xDiff(Selectable finalOne) {
return Math.abs(finalOne.getX() - getX()); return Math.abs(finalOne.getX() - getX());
} }
} }
static final public int ButtonYes = 0x1; static final public int ButtonYes = 0x1;
static final public int ButtonNo = 0x2; static final public int ButtonNo = 0x2;
static final public int ButtonOk = 0x4; static final public int ButtonOk = 0x4;
static final public int ButtonAbort = 0x8; static final public int ButtonAbort = 0x8;
public Dialog prepareDialog(String header, int buttons, Runnable onOkOrYes) { public Dialog prepareDialog(String header, int buttons, Runnable onOkOrYes) {
Dialog dialog =new Dialog(header, Controls.getSkin()) Dialog dialog = new Dialog(header, Controls.getSkin()) {
{ protected void result(Object object) {
protected void result(Object object) SoundSystem.instance.play(SoundEffectType.ButtonPress, false);
{
if (onOkOrYes != null && object != null && object.equals(true)) if (onOkOrYes != null && object != null && object.equals(true))
onOkOrYes.run(); onOkOrYes.run();
this.hide(); this.hide();
@@ -114,8 +113,8 @@ public class UIScene extends Scene {
dialog.setResizable(false); dialog.setResizable(false);
return dialog; return dialog;
} }
public void showDialog(Dialog dialog)
{ public void showDialog(Dialog dialog) {
stage.addActor(dialog); stage.addActor(dialog);
possibleSelectionStack.add(new Array<>()); possibleSelectionStack.add(new Array<>());
addToSelectable(dialog.getContentTable()); addToSelectable(dialog.getContentTable());
@@ -147,39 +146,40 @@ public class UIScene extends Scene {
public Array<Array<Selectable>> possibleSelectionStack = new Array<>(); public Array<Array<Selectable>> possibleSelectionStack = new Array<>();
public Array<Dialog> dialogs = new Array<>(); public Array<Dialog> dialogs = new Array<>();
public Array<Selectable> getPossibleSelection()
{ public Array<Selectable> getPossibleSelection() {
if (possibleSelectionStack.isEmpty()) if (possibleSelectionStack.isEmpty())
possibleSelectionStack.add(ui.selectActors); possibleSelectionStack.add(ui.selectActors);
return possibleSelectionStack.get(possibleSelectionStack.size - 1); return possibleSelectionStack.get(possibleSelectionStack.size - 1);
} }
protected Stage stage; protected Stage stage;
String uiFile; String uiFile;
public static InputEvent eventTouchUp()
{ public static InputEvent eventTouchUp() {
InputEvent event = new InputEvent(); InputEvent event = new InputEvent();
event.setPointer(-1); event.setPointer(-1);
event.setType(InputEvent.Type.touchUp); event.setType(InputEvent.Type.touchUp);
return event; return event;
} }
public static InputEvent eventTouchDown()
{ public static InputEvent eventTouchDown() {
InputEvent event = new InputEvent(); InputEvent event = new InputEvent();
event.setPointer(-1); event.setPointer(-1);
event.setType(InputEvent.Type.touchDown); event.setType(InputEvent.Type.touchDown);
return event; return event;
} }
public static InputEvent eventExit()
{ public static InputEvent eventExit() {
InputEvent event = new InputEvent(); InputEvent event = new InputEvent();
event.setPointer(-1); event.setPointer(-1);
event.setType(InputEvent.Type.exit); event.setType(InputEvent.Type.exit);
return event; return event;
} }
public static InputEvent eventEnter()
{ public static InputEvent eventEnter() {
InputEvent event = new InputEvent(); InputEvent event = new InputEvent();
event.setPointer(-1); event.setPointer(-1);
event.setType(InputEvent.Type.enter); event.setType(InputEvent.Type.enter);
@@ -190,24 +190,28 @@ public class UIScene extends Scene {
public boolean buttonUp(Controller controller, int keycode) { public boolean buttonUp(Controller controller, int keycode) {
return stage.keyUp(KeyBinding.controllerButtonToKey(controller, keycode)); return stage.keyUp(KeyBinding.controllerButtonToKey(controller, keycode));
} }
@Override @Override
public boolean buttonDown(Controller controller, int keycode) { public boolean buttonDown(Controller controller, int keycode) {
return stage.keyDown(KeyBinding.controllerButtonToKey(controller, keycode)); return stage.keyDown(KeyBinding.controllerButtonToKey(controller, keycode));
} }
protected void addToSelectable(Table table) { protected void addToSelectable(Table table) {
for(Cell cell:table.getCells()) for (Cell cell : table.getCells()) {
{
if (cell.getActor() != null && cell.getActor().getClass() != Actor.class && !(cell.getActor() instanceof Label) && !(cell.getActor() instanceof TextraLabel)) if (cell.getActor() != null && cell.getActor().getClass() != Actor.class && !(cell.getActor() instanceof Label) && !(cell.getActor() instanceof TextraLabel))
getPossibleSelection().add(new Selectable(cell.getActor())); getPossibleSelection().add(new Selectable(cell.getActor()));
} }
} }
protected void addToSelectable(Button button)//prevent to addToSelectable(Table) fallback protected void addToSelectable(Button button)//prevent to addToSelectable(Table) fallback
{ {
getPossibleSelection().add(new Selectable(button)); getPossibleSelection().add(new Selectable(button));
} }
protected void addToSelectable(Actor button) { protected void addToSelectable(Actor button) {
getPossibleSelection().add(new Selectable(button)); getPossibleSelection().add(new Selectable(button));
} }
protected void addToSelectable(Selectable selectable) { protected void addToSelectable(Selectable selectable) {
getPossibleSelection().add(selectable); getPossibleSelection().add(selectable);
} }
@@ -225,11 +229,13 @@ public class UIScene extends Scene {
keyReleased(keycode); keyReleased(keycode);
return super.keyUp(keycode); return super.keyUp(keycode);
} }
@Override @Override
public boolean keyDown(int keyCode) { public boolean keyDown(int keyCode) {
keyPressed(keyCode); keyPressed(keyCode);
return super.keyDown(keyCode); return super.keyDown(keyCode);
} }
@Override @Override
public boolean mouseMoved(int screenX, int screenY) { public boolean mouseMoved(int screenX, int screenY) {
pointerMoved(screenX, screenY); pointerMoved(screenX, screenY);
@@ -237,8 +243,7 @@ public class UIScene extends Scene {
} }
}; };
ui = new UIActor(Config.instance().getFile(uiFile)); ui = new UIActor(Config.instance().getFile(uiFile));
for(Actor actor:ui.getChildren()) for (Actor actor : ui.getChildren()) {
{
if (actor instanceof ScrollPane) if (actor instanceof ScrollPane)
stage.setScrollFocus(actor); stage.setScrollFocus(actor);
} }
@@ -249,20 +254,16 @@ public class UIScene extends Scene {
private void removeDialog() { private void removeDialog() {
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);
if (!dialogs.isEmpty()) if (!dialogs.isEmpty())
dialogs.get(dialogs.size - 1).show(stage); dialogs.get(dialogs.size - 1).show(stage);
} }
if(possibleSelectionStack.isEmpty()) if (possibleSelectionStack.isEmpty()) {
{
getPossibleSelection(); getPossibleSelection();
} } else {
else
{
possibleSelectionStack.removeIndex(possibleSelectionStack.size - 1); possibleSelectionStack.removeIndex(possibleSelectionStack.size - 1);
} }
} }
@@ -295,24 +296,21 @@ public class UIScene extends Scene {
Forge.switchToLast(); Forge.switchToLast();
return true; return true;
} }
public Selectable getSelected()
{ public Selectable getSelected() {
for(Selectable selectable: getPossibleSelection()) for (Selectable selectable : getPossibleSelection()) {
{
if (stage.getKeyboardFocus() == selectable.actor) if (stage.getKeyboardFocus() == selectable.actor)
return selectable; return selectable;
} }
return null; return null;
} }
public boolean keyReleased(int keycode)
{ public boolean keyReleased(int keycode) {
ui.pressUp(keycode); ui.pressUp(keycode);
if(!dialogShowing()) if (!dialogShowing()) {
{
Button pressedButton = ui.buttonPressed(keycode); Button pressedButton = ui.buttonPressed(keycode);
if(pressedButton!=null) if (pressedButton != null) {
{
if (pressedButton.isVisible()) if (pressedButton.isVisible())
pressedButton.fire(eventTouchUp()); pressedButton.fire(eventTouchUp());
} }
@@ -325,16 +323,14 @@ public class UIScene extends Scene {
return true; return true;
} }
public boolean keyPressed(int keycode) { public boolean keyPressed(int keycode) {
Selectable selection = getSelected(); Selectable selection = getSelected();
ui.pressDown(keycode); ui.pressDown(keycode);
if(stage.getKeyboardFocus() instanceof SelectBox) if (stage.getKeyboardFocus() instanceof SelectBox) {
{
SelectBox box = (SelectBox) stage.getKeyboardFocus(); SelectBox box = (SelectBox) stage.getKeyboardFocus();
if(box.getScrollPane().hasParent()) if (box.getScrollPane().hasParent()) {
{ if (KeyBinding.Use.isPressed(keycode)) {
if(KeyBinding.Use.isPressed(keycode))
{
box.getSelection().choose(box.getList().getSelected()); box.getSelection().choose(box.getList().getSelected());
box.getScrollPane().hide(); box.getScrollPane().hide();
} }
@@ -346,20 +342,16 @@ public class UIScene extends Scene {
selection.onPressDown(this); selection.onPressDown(this);
} }
if(KeyBinding.ScrollUp.isPressed(keycode)) if (KeyBinding.ScrollUp.isPressed(keycode)) {
{
Actor focus = stage.getScrollFocus(); Actor focus = stage.getScrollFocus();
if(focus!=null&&focus instanceof ScrollPane) if (focus != null && focus instanceof ScrollPane) {
{
ScrollPane scroll = ((ScrollPane) focus); ScrollPane scroll = ((ScrollPane) focus);
scroll.setScrollY(scroll.getScrollY() - 20); scroll.setScrollY(scroll.getScrollY() - 20);
} }
} }
if(KeyBinding.ScrollDown.isPressed(keycode)) if (KeyBinding.ScrollDown.isPressed(keycode)) {
{
Actor focus = stage.getScrollFocus(); Actor focus = stage.getScrollFocus();
if(focus!=null&&focus instanceof ScrollPane) if (focus != null && focus instanceof ScrollPane) {
{
ScrollPane scroll = ((ScrollPane) focus); ScrollPane scroll = ((ScrollPane) focus);
scroll.setScrollY(scroll.getScrollY() + 20); scroll.setScrollY(scroll.getScrollY() + 20);
} }
@@ -368,18 +360,15 @@ public class UIScene extends Scene {
selectNextDown(); selectNextDown();
if (KeyBinding.Up.isPressed(keycode)) if (KeyBinding.Up.isPressed(keycode))
selectNextUp(); selectNextUp();
if(!(stage.getKeyboardFocus() instanceof Selector)&&!(stage.getKeyboardFocus() instanceof TextField)&&!(stage.getKeyboardFocus() instanceof Slider)) if (!(stage.getKeyboardFocus() instanceof Selector) && !(stage.getKeyboardFocus() instanceof TextField) && !(stage.getKeyboardFocus() instanceof Slider)) {
{
if (KeyBinding.Right.isPressed(keycode)) if (KeyBinding.Right.isPressed(keycode))
selectNextRight(); selectNextRight();
if (KeyBinding.Left.isPressed(keycode)) if (KeyBinding.Left.isPressed(keycode))
selectNextLeft(); selectNextLeft();
} }
if(!dialogShowing()) if (!dialogShowing()) {
{
Button pressedButton = ui.buttonPressed(keycode); Button pressedButton = ui.buttonPressed(keycode);
if(pressedButton!=null) if (pressedButton != null) {
{
if (pressedButton.isVisible()) if (pressedButton.isVisible())
pressedButton.fire(eventTouchDown()); pressedButton.fire(eventTouchDown());
} }
@@ -396,11 +385,13 @@ public class UIScene extends Scene {
public void disconnected(final Controller controller) { public void disconnected(final Controller controller) {
ui.controllerDisconnected(); ui.controllerDisconnected();
} }
@Override @Override
public void connected(final Controller controller) { public void connected(final Controller controller) {
selectFirst(); selectFirst();
ui.controllerConnected(); ui.controllerConnected();
} }
public boolean pointerMoved(int screenX, int screenY) { public boolean pointerMoved(int screenX, int screenY) {
unselectActors(); unselectActors();
return false; return false;
@@ -417,41 +408,35 @@ public class UIScene extends Scene {
} }
}, 0.10f); }, 0.10f);
} }
public void unselectActors() { public void unselectActors() {
for (Selectable selectable : getPossibleSelection()) { for (Selectable selectable : getPossibleSelection()) {
selectable.onDeSelect(); selectable.onDeSelect();
} }
} }
Array<Selectable> visibleSelection()
{ Array<Selectable> visibleSelection() {
Array<Selectable> selectables = new Array<>(); Array<Selectable> selectables = new Array<>();
for (Selectable selectable : getPossibleSelection()) { for (Selectable selectable : getPossibleSelection()) {
if(selectable.actor.isVisible()) if (selectable.actor.isVisible()) {
{ if (selectable.actor instanceof Button) {
if(selectable.actor instanceof Button)
{
if (!((Button) selectable.actor).isDisabled()) if (!((Button) selectable.actor).isDisabled())
selectables.add(selectable); selectables.add(selectable);
} } else {
else
{
selectables.add(selectable); selectables.add(selectable);
} }
} }
} }
return selectables; return selectables;
} }
public void selectNextDown() { public void selectNextDown() {
if(getSelected()==null) if (getSelected() == null) {
{
selectFirst(); selectFirst();
} } else {
else
{
Selectable current = getSelected(); Selectable current = getSelected();
Array<Selectable> candidates = new Array<>(); Array<Selectable> candidates = new Array<>();
for(Selectable selectable:visibleSelection()) for (Selectable selectable : visibleSelection()) {
{
if (selectable.xDiff(current) < 0.1 && selectable != current) if (selectable.xDiff(current) < 0.1 && selectable != current)
candidates.add(selectable); candidates.add(selectable);
} }
@@ -459,20 +444,16 @@ public class UIScene extends Scene {
candidates.addAll(visibleSelection()); candidates.addAll(visibleSelection());
Selectable finalOne = null; Selectable finalOne = null;
Selectable fallback = null; Selectable fallback = null;
for(Selectable candidate:candidates) for (Selectable candidate : candidates) {
{
if (fallback == null || candidate.getY() > fallback.getY()) if (fallback == null || candidate.getY() > fallback.getY())
fallback = candidate; fallback = candidate;
if(candidate.getY()<current.getY()&&(finalOne==null||current.yDiff(candidate)<current.yDiff(finalOne))) if (candidate.getY() < current.getY() && (finalOne == null || current.yDiff(candidate) < current.yDiff(finalOne))) {
{
finalOne = candidate; finalOne = candidate;
} }
} }
if (finalOne == null) if (finalOne == null)
for(Selectable candidate:visibleSelection()) for (Selectable candidate : visibleSelection()) {
{ if (candidate.getY() < current.getY() && (finalOne == null || current.yDiff(candidate) < current.yDiff(finalOne))) {
if(candidate.getY()<current.getY()&&(finalOne==null||current.yDiff(candidate)<current.yDiff(finalOne)))
{
finalOne = candidate; finalOne = candidate;
} }
} }
@@ -483,17 +464,14 @@ public class UIScene extends Scene {
} }
} }
private void selectNextLeft() { private void selectNextLeft() {
if(getSelected()==null) if (getSelected() == null) {
{
selectFirst(); selectFirst();
} } else {
else
{
Selectable current = getSelected(); Selectable current = getSelected();
Array<Selectable> candidates = new Array<>(); Array<Selectable> candidates = new Array<>();
for(Selectable selectable:visibleSelection()) for (Selectable selectable : visibleSelection()) {
{
if (selectable.yDiff(current) < 0.1 && selectable != current) if (selectable.yDiff(current) < 0.1 && selectable != current)
candidates.add(selectable); candidates.add(selectable);
} }
@@ -501,20 +479,16 @@ public class UIScene extends Scene {
candidates.addAll(visibleSelection()); candidates.addAll(visibleSelection());
Selectable finalOne = null; Selectable finalOne = null;
Selectable fallback = null; Selectable fallback = null;
for(Selectable candidate:candidates) for (Selectable candidate : candidates) {
{
if (fallback == null || candidate.getX() > fallback.getX()) if (fallback == null || candidate.getX() > fallback.getX())
fallback = candidate; fallback = candidate;
if(candidate.getX()<current.getX()&&(finalOne==null||current.xDiff(candidate)<current.xDiff(finalOne))) if (candidate.getX() < current.getX() && (finalOne == null || current.xDiff(candidate) < current.xDiff(finalOne))) {
{
finalOne = candidate; finalOne = candidate;
} }
} }
if (finalOne == null) if (finalOne == null)
for(Selectable candidate:visibleSelection()) for (Selectable candidate : visibleSelection()) {
{ if (candidate.getX() < current.getX() && (finalOne == null || current.xDiff(candidate) < current.xDiff(finalOne))) {
if(candidate.getX()<current.getX()&&(finalOne==null||current.xDiff(candidate)<current.xDiff(finalOne)))
{
finalOne = candidate; finalOne = candidate;
} }
} }
@@ -525,17 +499,14 @@ public class UIScene extends Scene {
} }
} }
private void selectNextRight() { private void selectNextRight() {
if(getSelected()==null) if (getSelected() == null) {
{
selectFirst(); selectFirst();
} } else {
else
{
Selectable current = getSelected(); Selectable current = getSelected();
Array<Selectable> candidates = new Array<>(); Array<Selectable> candidates = new Array<>();
for(Selectable selectable:visibleSelection()) for (Selectable selectable : visibleSelection()) {
{
if (selectable.yDiff(current) < 0.1 && selectable != current) if (selectable.yDiff(current) < 0.1 && selectable != current)
candidates.add(selectable); candidates.add(selectable);
} }
@@ -543,20 +514,16 @@ public class UIScene extends Scene {
candidates.addAll(visibleSelection()); candidates.addAll(visibleSelection());
Selectable finalOne = null; Selectable finalOne = null;
Selectable fallback = null; Selectable fallback = null;
for(Selectable candidate:candidates) for (Selectable candidate : candidates) {
{
if (fallback == null || candidate.getX() < fallback.getX()) if (fallback == null || candidate.getX() < fallback.getX())
fallback = candidate; fallback = candidate;
if(candidate.getX()>current.getX()&&(finalOne==null||current.xDiff(candidate)<current.xDiff(finalOne))) if (candidate.getX() > current.getX() && (finalOne == null || current.xDiff(candidate) < current.xDiff(finalOne))) {
{
finalOne = candidate; finalOne = candidate;
} }
} }
if (finalOne == null) if (finalOne == null)
for(Selectable candidate:visibleSelection()) for (Selectable candidate : visibleSelection()) {
{ if (candidate.getX() > current.getX() && (finalOne == null || current.xDiff(candidate) < current.xDiff(finalOne))) {
if(candidate.getX()>current.getX()&&(finalOne==null||current.xDiff(candidate)<current.xDiff(finalOne)))
{
finalOne = candidate; finalOne = candidate;
} }
} }
@@ -571,16 +538,12 @@ public class UIScene extends Scene {
public void selectNextUp() { public void selectNextUp() {
if(getSelected()==null) if (getSelected() == null) {
{
selectFirst(); selectFirst();
} } else {
else
{
Selectable current = getSelected(); Selectable current = getSelected();
Array<Selectable> candidates = new Array<>(); Array<Selectable> candidates = new Array<>();
for(Selectable selectable:visibleSelection()) for (Selectable selectable : visibleSelection()) {
{
if (selectable.xDiff(current) < 0.1 && selectable != current) if (selectable.xDiff(current) < 0.1 && selectable != current)
candidates.add(selectable); candidates.add(selectable);
} }
@@ -588,20 +551,16 @@ public class UIScene extends Scene {
candidates.addAll(visibleSelection()); candidates.addAll(visibleSelection());
Selectable finalOne = null; Selectable finalOne = null;
Selectable fallback = null; Selectable fallback = null;
for(Selectable candidate:candidates) for (Selectable candidate : candidates) {
{
if (fallback == null || candidate.getY() < fallback.getY()) if (fallback == null || candidate.getY() < fallback.getY())
fallback = candidate; fallback = candidate;
if(candidate.getY()>current.getY()&&(finalOne==null||current.yDiff(candidate)<current.yDiff(finalOne))) if (candidate.getY() > current.getY() && (finalOne == null || current.yDiff(candidate) < current.yDiff(finalOne))) {
{
finalOne = candidate; finalOne = candidate;
} }
} }
if (finalOne == null)//allowAllNow if (finalOne == null)//allowAllNow
for(Selectable candidate:visibleSelection()) for (Selectable candidate : visibleSelection()) {
{ if (candidate.getY() > current.getY() && (finalOne == null || current.yDiff(candidate) < current.yDiff(finalOne))) {
if(candidate.getY()>current.getY()&&(finalOne==null||current.yDiff(candidate)<current.yDiff(finalOne)))
{
finalOne = candidate; finalOne = candidate;
} }
} }
@@ -616,21 +575,17 @@ public class UIScene extends Scene {
private void selectFirst() { private void selectFirst() {
Selectable result = null; Selectable result = null;
for(Selectable candidate: getPossibleSelection()) for (Selectable candidate : getPossibleSelection()) {
{ if (result == null || candidate.getY() > result.getY()) {
if(result==null|| candidate.getY()>result.getY())
{
result = candidate; result = candidate;
} }
} }
selectActor(result); selectActor(result);
} }
ScrollPane scrollPaneOfActor(Actor actor)
{ ScrollPane scrollPaneOfActor(Actor actor) {
while (actor!=null) while (actor != null) {
{ if (actor.getParent() instanceof ScrollPane) {
if(actor.getParent() instanceof ScrollPane)
{
return (ScrollPane) actor.getParent(); return (ScrollPane) actor.getParent();
} }
actor = actor.getParent(); actor = actor.getParent();
@@ -645,12 +600,12 @@ public class UIScene extends Scene {
if (actor == null) return; if (actor == null) return;
stage.setKeyboardFocus(actor.actor); stage.setKeyboardFocus(actor.actor);
ScrollPane scrollPane = scrollPaneOfActor(actor.actor); ScrollPane scrollPane = scrollPaneOfActor(actor.actor);
if(scrollPane!=null) if (scrollPane != null) {
{
scrollPane.scrollTo(actor.actor.getX(), actor.actor.getY(), actor.actor.getWidth(), actor.actor.getHeight(), false, false); scrollPane.scrollTo(actor.actor.getX(), actor.actor.getY(), actor.actor.getWidth(), actor.actor.getHeight(), false, false);
} }
actor.onSelect(this); actor.onSelect(this);
} }
Image screenImage; Image screenImage;
TextureRegion backgroundTexture; TextureRegion backgroundTexture;
@@ -659,6 +614,7 @@ public class UIScene extends Scene {
stage.cancelTouchFocus(); stage.cancelTouchFocus();
return super.leave(); return super.leave();
} }
@Override @Override
public void enter() { public void enter() {
if (screenImage != null) { if (screenImage != null) {
@@ -674,6 +630,7 @@ public class UIScene extends Scene {
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
super.enter(); super.enter();
} }
public TextureRegion getUIBackground() { public TextureRegion getUIBackground() {
try { try {
Actor a = ui.getChild(0); Actor a = ui.getChild(0);

Binary file not shown.