summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-11-13 21:02:46 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-11-13 21:02:46 (GMT)
commitc63dff45e4e59ac14c0a087388b89e0d08fa5a62 (patch)
tree50f2791205200202f1d2a991cd530e207b572180 /src
parent0f4c0915d9bdfbd9e865200941083bd463d03d69 (diff)
downloadpowder-c63dff45e4e59ac14c0a087388b89e0d08fa5a62.zip
powder-c63dff45e4e59ac14c0a087388b89e0d08fa5a62.tar.gz
Basic render modes for Render_ui
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c8
-rw-r--r--src/interface.c104
-rw-r--r--src/main.c12
3 files changed, 110 insertions, 14 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 7c4af56..3e889ad 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -69,8 +69,8 @@ float plasma_data_pos[] = {1.0f, 0.9f, 0.5f, 0.25, 0.0f};
void init_display_modes()
{
int i;
- display_modes = calloc(sizeof(unsigned int), 1);
- render_modes = calloc(sizeof(unsigned int), 2);
+ display_modes = calloc(1, sizeof(unsigned int));
+ render_modes = calloc(2, sizeof(unsigned int));
display_modes[0] = 0;
render_modes[0] = RENDER_FIRE;
@@ -1846,6 +1846,10 @@ void render_parts(pixel *vid)
pixel_mode |= PMODE_GLOW;
if(pixel_mode & FIRE_BLEND && !(render_mode & FIRE_BLEND))
pixel_mode |= PMODE_BLUR;
+ if(pixel_mode & PMODE_BLUR && !(render_mode & PMODE_BLUR))
+ pixel_mode |= PMODE_FLAT;
+ if(pixel_mode & PMODE_GLOW && !(render_mode & PMODE_GLOW))
+ pixel_mode |= PMODE_FLAT;
pixel_mode &= render_mode;
diff --git a/src/interface.c b/src/interface.c
index 8b0d0c9..15b4e8c 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -24,6 +24,7 @@
#ifdef PYCONSOLE
#include <pythonconsole.h>
#endif
+#include <powdergraphics.h>
SDLMod sdl_mod;
int sdl_key, sdl_rkey, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
@@ -6043,8 +6044,109 @@ openfin:
return;
}
-void render_ui(pixel * vid_buf)
+void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
{
+ int i, j, count;
+ int xsize;
+ int ysize;
+ int yoffset;
+ int xoffset;
+ int b, bq, mx, my;
+ ui_checkbox *cb;
+ int optioncount = 5;
+ int options[] = {RENDER_EFFE, RENDER_GLOW, RENDER_FIRE, RENDER_BLUR, RENDER_BASC};
+ int optionicons[] = {0xCC, 0xC3, 0x9B, 0xC4, 0xD1};
+
+ yoffset = 16;
+ xoffset = 0;
+
+ xsize = 35;
+ ysize = optioncount * yoffset + 6;
+
+ ycoord -= ysize;
+ xcoord -= xsize;
+
+ cb = calloc(optioncount, sizeof(ui_checkbox));
+ for(i = 0; i < optioncount; i++)
+ {
+ cb[i].x = xcoord + (i * xoffset) + 5;
+ cb[i].y = ycoord + (i * yoffset) + 5;
+ cb[i].focus = 0;
+ cb[i].checked = 0;
+ j = 0;
+ while(render_modes[j])
+ {
+ if(render_modes[j] == options[i])
+ {
+ cb[i].checked = 1;
+ break;
+ }
+ j++;
+ }
+ }
+
+ while (!sdl_poll())
+ {
+ b = SDL_GetMouseState(&mx, &my);
+ if (!b)
+ break;
+ }
+
+ while (!sdl_poll())
+ {
+ bq = b;
+ b = SDL_GetMouseState(&mx, &my);
+ mx /= sdl_scale;
+ my /= sdl_scale;
+
+ clearrect(vid_buf, xcoord-2, ycoord-2, xsize+4, ysize+4);
+ drawrect(vid_buf, xcoord, ycoord, xsize, ysize, 192, 192, 192, 255);
+
+ for(i = 0; i < optioncount; i++)
+ {
+ drawchar(vid_buf, cb[i].x + 16, cb[i].y+2, optionicons[i], 255, 255, 255, 255);
+ ui_checkbox_draw(vid_buf, &(cb[i]));
+ ui_checkbox_process(mx, my, b, bq, &(cb[i]));
+ }
+
+ sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
+
+ if (sdl_key==SDLK_RETURN)
+ break;
+ if (sdl_key==SDLK_ESCAPE)
+ break;
+ if (b && !bq && (mx < xcoord || mx > xcoord+xsize || my < ycoord || my > ycoord+ysize))
+ break;
+ }
+
+ count = 1;
+ for(i = 0; i < optioncount; i++)
+ {
+ if(cb[i].checked)
+ count++;
+ }
+ free(render_modes);
+ render_mode = 0;
+ render_modes = calloc(count, sizeof(unsigned int));
+ count = 0;
+ for(i = 0; i < optioncount; i++)
+ {
+ if(cb[i].checked)
+ {
+ render_modes[count] = options[i];
+ render_mode |= options[i];
+ count++;
+ }
+ }
+
+ free(cb);
+
+ while (!sdl_poll())
+ {
+ b = SDL_GetMouseState(&mx, &my);
+ if (!b)
+ break;
+ }
}
void simulation_ui(pixel * vid_buf)
diff --git a/src/main.c b/src/main.c
index c2451af..565e27a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3162,17 +3162,7 @@ int main(int argc, char *argv[])
}
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
{
- render_ui(vid_buf);
- /*if (b & SDL_BUTTON_LMASK) {
- set_cmode((cmode+1) % CM_COUNT);
- }
- if (b & SDL_BUTTON_RMASK) {
- if ((cmode+(CM_COUNT-1)) % CM_COUNT == CM_LIFE) {
- set_cmode(CM_GRAD);
- } else {
- set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT);
- }
- }*/
+ render_ui(vid_buf, XRES+BARSIZE-(510-491), YRES+(MENUSIZE-19), 3);
}
if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq)
sys_pause = !sys_pause;