diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-08 06:15:31 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-08 06:15:31 +0100 |
commit | 7648047a45a4df146094540709daa46fff90d29d (patch) | |
tree | 69f016384db342b469e6b7b1dd920596ec0fcee8 /core/src/ch/asynk/rustanddust/menu | |
parent | 021fa2ace9b61af6c962f3911991c893ea554e8e (diff) | |
download | RustAndDust-7648047a45a4df146094540709daa46fff90d29d.zip RustAndDust-7648047a45a4df146094540709daa46fff90d29d.tar.gz |
ui/Menu: improve enum API, so that it can write Labels itself
Diffstat (limited to 'core/src/ch/asynk/rustanddust/menu')
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/MainMenu.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/core/src/ch/asynk/rustanddust/menu/MainMenu.java b/core/src/ch/asynk/rustanddust/menu/MainMenu.java index 620205a..e69329f 100644 --- a/core/src/ch/asynk/rustanddust/menu/MainMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/MainMenu.java @@ -9,29 +9,34 @@ public class MainMenu extends Menu { public enum Items implements Menu.MenuItem { - EXIT(0), - OPTIONS(1), - TUTORIALS(2), - PLAY(3), - NONE(4); + EXIT(0, "Exit"), + OPTIONS(1, "Options"), + TUTORIALS(2, "Tutorials"), + PLAY(3, "Play"), + NONE(5, null); public int i; - Items(int i) + public String s; + Items(int i, String s) { this.i = i; + this.s = s; } + public String s() { return s; } public int i() { return i; } public int last() { return NONE.i; } + public Menu.MenuItem get(int i) + { + if (i == EXIT.i) return EXIT; + else if (i == OPTIONS.i) return OPTIONS; + else if (i == TUTORIALS.i) return TUTORIALS; + else if (i == PLAY.i) return PLAY; + else return NONE; + } }; public MainMenu(RustAndDust game) { super(Items.NONE, game.font, game.ninePatch); - - label(Items.PLAY).write("Play"); - label(Items.TUTORIALS).write("Tutorials"); - label(Items.OPTIONS).write("Options"); - label(Items.EXIT).write("Exit"); - this.visible = true; } |