diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 20 | ||||
-rw-r--r-- | include/ui.h | 41 |
2 files changed, 59 insertions, 2 deletions
diff --git a/include/common.h b/include/common.h index 8e08d1d..d0f539b 100644 --- a/include/common.h +++ b/include/common.h @@ -61,6 +61,8 @@ typedef struct { float z; } vec3; +typedef vec2 dim2; + /** * This structure contains two sets of coordinates for ray drawing. */ @@ -70,11 +72,25 @@ typedef struct { vec2 end; } Ray; -typedef struct{ +struct col{ float red; float green; float blue; -} Color; + col operator-=(float a){ + red-=a; + green-=a; + blue-=a; + return *this; + } + col operator+=(float a){ + return{red+a,green+a,blue+a}; + } + col operator=(float a){ + return{red=a,green=a,blue=a}; + } +}; + +typedef col Color; #include <Texture.h> diff --git a/include/ui.h b/include/ui.h index c018008..030c73d 100644 --- a/include/ui.h +++ b/include/ui.h @@ -10,12 +10,42 @@ #include <world.h> #include <ft2build.h> +#include <SDL2/SDL_opengl.h> #include FT_FREETYPE_H #define DEBUG +typedef void(*menuFunc)(); + + +struct menuItem{ + int member; + union{ + + struct{ + vec2 loc; + dim2 dim; + Color color; + const char* text; + menuFunc func; + }button; + + struct{ + vec2 loc; + dim2 dim; + Color color; + float minValue; + float maxValue; + const char* text; + void* var; + }slider; + + }; +}; + namespace ui { + menuItem createButton(vec2 l, dim2 d, Color c, const char* t, menuFunc f); /** * Contains the coordinates of the mouse inside the window. */ @@ -26,6 +56,8 @@ namespace ui { * These flags are used elsewhere. */ + extern bool pMenu; + extern bool menu; extern bool debug; extern bool posFlag; extern unsigned int fontSize; @@ -83,6 +115,15 @@ namespace ui { void draw(void); + + /* + * Draw various menu items + */ + void quitGame(); + void quitMenu(); + void drawMenu(std::vector<menuItem>mi); + + /* * Handle keyboard/mouse events. */ |