From a787d5faf435eddf20270d7368c45d0f540e962e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 21 Feb 2016 23:13:41 +0100 Subject: Menu: prepare can jump to another menu --- core/src/ch/asynk/rustanddust/menu/MainMenu.java | 2 +- core/src/ch/asynk/rustanddust/menu/MenuCtrl.java | 6 ++++-- core/src/ch/asynk/rustanddust/menu/OptionsMenu.java | 2 +- core/src/ch/asynk/rustanddust/menu/PlayMenu.java | 2 +- core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/menu/MainMenu.java b/core/src/ch/asynk/rustanddust/menu/MainMenu.java index 335e527..19567ce 100644 --- a/core/src/ch/asynk/rustanddust/menu/MainMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/MainMenu.java @@ -83,7 +83,7 @@ public class MainMenu extends Patch implements MenuCtrl.Panel } @Override - public boolean prepare() { return true; } + public MenuCtrl.MenuType prepare() { return MenuCtrl.MenuType.MAIN; } @Override public MenuCtrl.MenuType touch(float x, float y) diff --git a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java index 6b7bfa8..56015fd 100644 --- a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java +++ b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java @@ -25,7 +25,7 @@ public class MenuCtrl implements Disposable, Drawable interface Panel extends Disposable, Drawable { - public boolean prepare(); + public MenuType prepare(); public void computePosition(); public MenuType touch(float x, float y); } @@ -60,8 +60,10 @@ public class MenuCtrl implements Disposable, Drawable } if (next != MenuType.NONE) { - if (panels[next.i].prepare()) + while(current != next) { current = next; + next = panels[next.i].prepare(); + } } return false; diff --git a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java index e5401ff..04796a2 100644 --- a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java @@ -149,7 +149,7 @@ public class OptionsMenu extends Patch implements MenuCtrl.Panel } @Override - public boolean prepare() { return true; } + public MenuCtrl.MenuType prepare() { return MenuCtrl.MenuType.OPTIONS; } @Override public MenuCtrl.MenuType touch(float x, float y) diff --git a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java index 805efa0..0ed7f95 100644 --- a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java @@ -172,7 +172,7 @@ public class PlayMenu extends Patch implements MenuCtrl.Panel } @Override - public boolean prepare() { return true; } + public MenuCtrl.MenuType prepare() { return MenuCtrl.MenuType.PLAY; } @Override public void dispose() diff --git a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java index cae9b6c..5a8d03f 100644 --- a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java @@ -25,7 +25,7 @@ public class TutorialsMenu extends Patch implements MenuCtrl.Panel } @Override - public boolean prepare() { return true; } + public MenuCtrl.MenuType prepare() { return MenuCtrl.MenuType.TUTORIALS; } @Override public void computePosition() -- cgit v1.1-2-g2b99