summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-21 18:41:12 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-21 18:41:12 (GMT)
commit9cf65de1c369e91ba9de1a9cbceab7ba9131c89d (patch)
tree224cdf096c61c39c7b3283ae055e8e6b6a6b9c68
parent08009ebbaac9abd7941f5057a2289cbbbde4c5ee (diff)
downloadpowder-9cf65de1c369e91ba9de1a9cbceab7ba9131c89d.zip
powder-9cf65de1c369e91ba9de1a9cbceab7ba9131c89d.tar.gz
Quick options menu
-rw-r--r--includes/defines.h1
-rw-r--r--includes/interface.h22
-rw-r--r--src/interface.c45
-rw-r--r--src/main.c2
4 files changed, 68 insertions, 2 deletions
diff --git a/includes/defines.h b/includes/defines.h
index 9aeed25..0f016f9 100644
--- a/includes/defines.h
+++ b/includes/defines.h
@@ -163,6 +163,7 @@ extern int aheat_enable;
extern int decorations_enable;
extern int hud_enable;
extern int pretty_powder;
+extern int drawgrav_enable;
int limitFPS;
int water_equal_test;
diff --git a/includes/interface.h b/includes/interface.h
index 5d59dcf..a8a511e 100644
--- a/includes/interface.h
+++ b/includes/interface.h
@@ -15,6 +15,17 @@ struct menu_section
};
typedef struct menu_section menu_section;
+#define QM_TOGGLE 1
+
+struct quick_option
+{
+ char *icon;
+ const char *name;
+ int type;
+ int *variable;
+};
+typedef struct quick_option quick_option;
+
struct menu_wall
{
pixel colour;
@@ -58,6 +69,13 @@ static menu_section msections[] = //doshow does not do anything currently.
{"\xC8", "Cracker!", 0, 0},
};
+static quick_option quickmenu[] = //doshow does not do anything currently.
+{
+ {"P", "Sand effect", QM_TOGGLE, &pretty_powder},
+ {"G", "Draw gravity grid", QM_TOGGLE, &drawgrav_enable},
+ {NULL}
+};
+
static menu_section colorsections[] = //doshow does not do anything currently.
{
{"\xC4", "Colors", 7, 1},
@@ -201,10 +219,10 @@ extern int zoom_en;
extern int zoom_x, zoom_y;
extern int zoom_wx, zoom_wy;
-extern int drawgrav_enable;
-
void menu_count(void);
+void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y);
+
void prop_edit_ui(pixel *vid_buf, int x, int y);
void get_sign_pos(int i, int *x0, int *y0, int *w, int *h);
diff --git a/src/interface.c b/src/interface.c
index 1afe53a..75e22ec 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -2416,6 +2416,51 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b
return 0;
}
+int quickoptions_tooltip_fade = 0;
+char * quickoptions_tooltip;
+int quickoptions_tooltip_y = 0;
+void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y)
+{
+ int i = 0;
+ if(quickoptions_tooltip_fade && quickoptions_tooltip)
+ {
+ drawtext_outline(vid_buf, (XRES - 5) - textwidth(quickoptions_tooltip), quickoptions_tooltip_y, quickoptions_tooltip, 255, 255, 255, quickoptions_tooltip_fade*20, 0, 0, 0, quickoptions_tooltip_fade*15);
+ quickoptions_tooltip_fade--;
+ }
+ while(quickmenu[i].icon!=NULL)
+ {
+ if(quickmenu[i].type == QM_TOGGLE)
+ {
+ drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+1, 14, 14, 255, 255, 255, 255);
+ if(*(quickmenu[i].variable))
+ {
+ fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+1, 14, 14, 255, 255, 255, 255);
+ drawtext(vid_buf, (XRES+BARSIZE)-11, (i*16)+5, quickmenu[i].icon, 0, 0, 0, 255);
+ }
+ else
+ {
+ fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+1, 14, 14, 0, 0, 0, 255);
+ drawtext(vid_buf, (XRES+BARSIZE)-11, (i*16)+5, quickmenu[i].icon, 255, 255, 255, 255);
+ }
+ if(x >= (XRES+BARSIZE)-16 && x <= (XRES+BARSIZE)-2 && y >= (i*16)+1 && y <= (i*16)+15)
+ {
+ quickoptions_tooltip_fade+=2;
+ quickoptions_tooltip = quickmenu[i].name;
+ quickoptions_tooltip_y = (i*16)+5;
+ if(b && !bq)
+ {
+ *(quickmenu[i].variable) = !(*(quickmenu[i].variable));
+ }
+ }
+ }
+ i++;
+ }
+ if(quickoptions_tooltip_fade > 12)
+ quickoptions_tooltip_fade = 12;
+ if(quickoptions_tooltip_fade < 0)
+ quickoptions_tooltip_fade = 0;
+}
+
int sdl_poll(void)
{
SDL_Event event;
diff --git a/src/main.c b/src/main.c
index 9ac79cd..9052730 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2613,6 +2613,8 @@ int main(int argc, char *argv[])
luacon_step(x/sdl_scale, y/sdl_scale,sl,sr);
#endif
+ quickoptions_menu(vid_buf, b, bq, x, y);
+
for (i=0; i<SC_TOTAL; i++)//draw all the menu sections
{
draw_menu(vid_buf, i, active_menu);