From 783143974e36856e92be3fe1b13cc6a0d0b1faeb Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Tue, 2 Feb 2016 08:46:58 -0500 Subject: Better menus and config writing --- include/common.h | 4 +++- include/config.h | 12 ++++++++++++ include/ui.h | 21 ++++++++++++++------- 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 include/config.h (limited to 'include') diff --git a/include/common.h b/include/common.h index d0f539b..9f19134 100644 --- a/include/common.h +++ b/include/common.h @@ -80,7 +80,7 @@ struct col{ red-=a; green-=a; blue-=a; - return *this; + return{red+a,green+a,blue+a}; } col operator+=(float a){ return{red+a,green+a,blue+a}; @@ -130,6 +130,8 @@ extern bool FULLSCREEN; //#define HLINE 3 extern unsigned int HLINE; +extern float VOLUME_MASTER; +extern float VOLUME_MUSIC; /** * A 'wrapper' for libc's srand(), as we hope to eventually have our own random number * generator. diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..af9d72e --- /dev/null +++ b/include/config.h @@ -0,0 +1,12 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include +#include +#include + +void readConfig(); + +void updateConfig(); + +#endif //CONFIG_H \ No newline at end of file diff --git a/include/ui.h b/include/ui.h index bf9c0ae..ade5850 100644 --- a/include/ui.h +++ b/include/ui.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -17,7 +18,6 @@ typedef void(*menuFunc)(); - struct menuItem{ int member; union{ @@ -41,13 +41,23 @@ struct menuItem{ float sliderLoc; }slider; - }; }; -namespace ui { +class Menu{ +public: + std::vectoritems; + Menu *child; + Menu *parent; + void gotoChild(); + void gotoParent(); +}; + +namespace ui { menuItem createButton(vec2 l, dim2 d, Color c, const char* t, menuFunc f); + menuItem createChildButton(vec2 l, dim2 d, Color c, const char* t); + 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); /** * Contains the coordinates of the mouse inside the window. @@ -59,9 +69,6 @@ namespace ui { * These flags are used elsewhere. */ - extern bool oMenu; - extern bool pMenu; - extern bool menu; extern bool debug; extern bool posFlag; extern unsigned int fontSize; @@ -126,7 +133,7 @@ namespace ui { void quitGame(); void quitMenu(); void optionsMenuF(); - void drawMenu(std::vectormi); + void drawMenu(Menu* menu); /* -- cgit v1.2.3