mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
Fixed some NpcMenu behavior with the cancellation callback
Attempted change on cancel callback behavior -- only called when upnav Introduced some parent functions in NpcMenu to help with determining submenus Changed menus to NpcMenu (I don't imagine the need for the generalization right now)
This commit is contained in:
parent
008730d2c9
commit
c80a57ab09
@ -95,7 +95,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
||||
MapListener mapListener;
|
||||
InputProcessor inputProcessorTest;
|
||||
final Array<Actor> labels = new Array<>();
|
||||
Actor menu;
|
||||
NpcMenu menu;
|
||||
|
||||
public TextArea input;
|
||||
TextArea output;
|
||||
@ -596,14 +596,15 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
||||
}
|
||||
}
|
||||
|
||||
public Actor getMenu() {
|
||||
public NpcMenu getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
public void setMenu(Actor menu, Entity owner) {
|
||||
public void setMenu(NpcMenu menu, Entity owner) {
|
||||
if (this.menu != menu) {
|
||||
if (this.menu != null) {
|
||||
if (this.menu instanceof NpcMenu) ((NpcMenu) this.menu).cancel();
|
||||
// FIXME: Validate that cancel is only called if upnav, downnav -- looks good at a glance
|
||||
if (menu == null || menu.getParent() != this.menu) this.menu.cancel();
|
||||
stage.getRoot().removeActor(this.menu);
|
||||
}
|
||||
this.menu = menu;
|
||||
|
@ -37,6 +37,14 @@ public class NpcMenu extends Table {
|
||||
add(new Label(id, Diablo.fonts.font16, Diablo.colors.gold)).space(SPACING).row();
|
||||
}
|
||||
|
||||
public boolean hasParent() {
|
||||
return parent != null;
|
||||
}
|
||||
|
||||
public NpcMenu getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public NpcMenu addItem(int id, ClickListener clickListener) {
|
||||
LabelButton button = new LabelButton(id, Diablo.fonts.font16);
|
||||
button.addListener(clickListener);
|
||||
@ -76,7 +84,6 @@ public class NpcMenu extends Table {
|
||||
|
||||
public void cancel() {
|
||||
if (cancellationListener != null) cancellationListener.onCancelled();
|
||||
|
||||
}
|
||||
|
||||
public interface CancellationListener {
|
||||
|
Loading…
Reference in New Issue
Block a user