diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-19 16:20:13 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-19 16:20:13 -0500 |
commit | 59edd60ebec61bf24dd27063f85bcd049fd0af13 (patch) | |
tree | 902bb77c940134d20e35dfcb556b8e755bc373ef /include/ui_menu.hpp | |
parent | 36ed75a7749b81fab69f66b9ef8bbf0d18489f73 (diff) |
killed common, more inventory, other random stuff
Diffstat (limited to 'include/ui_menu.hpp')
-rw-r--r-- | include/ui_menu.hpp | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/include/ui_menu.hpp b/include/ui_menu.hpp index b45a76d..5288161 100644 --- a/include/ui_menu.hpp +++ b/include/ui_menu.hpp @@ -1,56 +1,53 @@ #ifndef UI_MENU_H_ #define UI_MENU_H_ -#include <common.hpp> +#include <string> +#include <vector> + +#include <color.hpp> #include <config.hpp> #include <ui.hpp> +#include <vector2.hpp> -typedef void (*menuFunc)(void); +using MenuAction = std::function<void(void)>; class Menu; class menuItem { public: int member; - Menu *child; + Menu* child; vec2 loc; dim2 dim; Color color; std::string text; - //union { - struct { - menuFunc func; - } button; - - struct { - float minValue; - float maxValue; - float sliderLoc; - float *var; - } slider; - //}; - - menuItem(){} - ~menuItem(){ - //button.text = NULL; - //slider.text = NULL; - - //delete[] button.text; - //delete[] slider.text; - //delete slider.var; - } + + struct { + MenuAction func; + } button; + + struct { + float minValue; + float maxValue; + float sliderLoc; + float* var; + } slider; + + menuItem(void) {} + + menuItem(vec2 l, dim2 d, Color c, std::string t, Menu* ch = nullptr) + : child(ch), loc(l), dim(d), color(c), text(t) {} }; class Menu { public: std::vector<menuItem> items; - Menu *parent; + Menu* parent; - ~Menu() - { + ~Menu(void) { items.clear(); - parent = NULL; + parent = nullptr; } void gotoParent(void); @@ -58,7 +55,7 @@ public: namespace ui { namespace menu { - menuItem createButton(vec2 l, dim2 d, Color c, const char* t, menuFunc f); + menuItem createButton(vec2 l, dim2 d, Color c, const char* t, MenuAction f); menuItem createChildButton(vec2 l, dim2 d, Color c, const char* ti, Menu *_child); menuItem createParentButton(vec2 l, dim2 d, Color c, const char* t); menuItem createSlider(vec2 l, dim2 d, Color c, float min, float max, const char* t, float* v); |