diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-02-02 08:46:58 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-02-02 08:46:58 -0500 |
commit | 783143974e36856e92be3fe1b13cc6a0d0b1faeb (patch) | |
tree | 4a6e0b56120874845027e96901c0eb89c106a64d /include | |
parent | ed970399ee3865ac7c5682d8a81a6a8a2282dd4a (diff) |
Better menus and config writing
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 4 | ||||
-rw-r--r-- | include/config.h | 12 | ||||
-rw-r--r-- | include/ui.h | 21 |
3 files changed, 29 insertions, 8 deletions
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 <iostream> +#include <SDL2/SDL_mixer.h> +#include <tinyxml2.h> + +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 <common.h> #include <cstdarg> +#include <config.h> #include <world.h> #include <ft2build.h> #include <SDL2/SDL_opengl.h> @@ -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::vector<menuItem>items; + 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::vector<menuItem>mi); + void drawMenu(Menu* menu); /* |