diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-11-12 20:44:15 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-11-12 20:44:15 (GMT) |
| commit | 0f4c0915d9bdfbd9e865200941083bd463d03d69 (patch) | |
| tree | eb01e996656c59b303d74bfd79f9a947fa32f277 /src | |
| parent | 1b984200f3059680f6ad3cfe9805bff234d00737 (diff) | |
| download | powder-0f4c0915d9bdfbd9e865200941083bd463d03d69.zip powder-0f4c0915d9bdfbd9e865200941083bd463d03d69.tar.gz | |
Replace cmode with more flexible render options, TODO: Saving and render options UI
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 260 | ||||
| -rw-r--r-- | src/interface.c | 121 | ||||
| -rw-r--r-- | src/luaconsole.c | 5 | ||||
| -rw-r--r-- | src/main.c | 41 | ||||
| -rw-r--r-- | src/misc.c | 8 |
5 files changed, 172 insertions, 263 deletions
diff --git a/src/graphics.c b/src/graphics.c index d1d0fd7..7c4af56 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -28,7 +28,13 @@ #include <misc.h> #include "hmap.h" -unsigned cmode = CM_FIRE; +//unsigned cmode = CM_FIRE; +unsigned int *render_modes; +unsigned int render_mode; +unsigned int colour_mode; +unsigned int *display_modes; +unsigned int display_mode; + SDL_Surface *sdl_scrn; int sdl_scale = 1; @@ -60,6 +66,32 @@ int plasma_data_points = 5; pixel plasma_data_colours[] = {PIXPACK(0xAFFFFF), PIXPACK(0xAFFFFF), PIXPACK(0x301060), PIXPACK(0x301040), PIXPACK(0x000000)}; 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[0] = 0; + render_modes[0] = RENDER_FIRE; + render_modes[1] = 0; + + display_mode = 0; + i = 0; + while(display_modes[i]) + { + display_mode |= display_modes[i]; + i++; + } + render_mode = 0; + i = 0; + while(render_modes[i]) + { + render_mode |= render_modes[i]; + i++; + } +} + char * generate_gradient(pixel * colours, float * points, int pointcount, int size) { int cp, i, j; @@ -848,6 +880,32 @@ inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a) return x + w; } +#if defined(WIN32) && !defined(__GNUC__) +_inline int addchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a) +#else +inline int addchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a) +#endif +{ + int i, j, w, bn = 0, ba = 0; + char *rp = font_data + font_ptrs[c]; + w = *(rp++); + for (j=0; j<FONT_H; j++) + for (i=0; i<w; i++) + { + if (!bn) + { + ba = *(rp++); + bn = 8; + } + { + addpixel(vid, x+i, y+j, r, g, b, ((ba&3)*a)/3); + } + ba >>= 2; + bn -= 2; + } + return x + w; +} + int drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a) { int sx = x; @@ -1237,25 +1295,23 @@ void draw_air(pixel *vid) #ifndef OGLR int x, y, i, j; pixel c; - if (cmode == CM_PERS)//this should never happen anyway - return; for (y=0; y<YRES/CELL; y++) for (x=0; x<XRES/CELL; x++) { - if (cmode == CM_PRESS) + if (display_mode & DISPLAY_AIRP) { if (pv[y][x] > 0.0f) c = PIXRGB(clamp_flt(pv[y][x], 0.0f, 8.0f), 0, 0);//positive pressure is red! else c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f));//negative pressure is blue! } - else if (cmode == CM_VEL) + else if (display_mode & DISPLAY_AIRV) { c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red clamp_flt(pv[y][x], 0.0f, 8.0f),//pressure adds green clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue } - else if (cmode == CM_HEAT && aheat_enable) + else if (display_mode & DISPLAY_AIRH) { float ttemp = hv[y][x]+(-MIN_TEMP); int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3); @@ -1264,7 +1320,7 @@ void draw_air(pixel *vid) // clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green // clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue } - else if (cmode == CM_CRACK) + else if (display_mode & DISPLAY_AIRC) { int r; int g; @@ -1302,15 +1358,15 @@ void draw_air(pixel *vid) } #else GLuint airProg; - if(cmode == CM_CRACK) + if(display_mode & DISPLAY_AIRC) { airProg = airProg_Cracker; } - else if(cmode == CM_VEL) + else if(display_mode & DISPLAY_AIRV) { airProg = airProg_Velocity; } - else if(cmode == CM_PRESS) + else if(display_mode & DISPLAY_AIRP) { airProg = airProg_Pressure; } @@ -1447,7 +1503,7 @@ void draw_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b, void addpixel(pixel *vid, int x, int y, int r, int g, int b, int a) { pixel t; - if (x<0 || y<0 || x>=XRES || y>=YRES) + if (x<0 || y<0 || x>=XRES+BARSIZE || y>=YRES+MENUSIZE) return; t = vid[y*(XRES+BARSIZE)+x]; r = (a*r + 255*PIXR(t)) >> 8; @@ -1592,7 +1648,7 @@ void draw_other(pixel *vid) // EMP effect if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/25+2; if (emp_decor>40) emp_decor=40; if (emp_decor<0) emp_decor = 0; - if (cmode==CM_NOTHING) // no in nothing mode + if (!(display_mode & display_mode == DISPLAY_EFFE)) // no in nothing mode return; if (emp_decor>0) { @@ -1653,7 +1709,6 @@ GLfloat lineC[(((YRES*XRES)*2)*6)]; #endif void render_parts(pixel *vid) { - //TODO: Replace cmode with a set of flags int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y, caddress; float gradv, flicker, fnx, fny; #ifdef OGLR @@ -1709,7 +1764,7 @@ void render_parts(pixel *vid) decg = (parts[i].dcolour>>8)&0xFF; decb = (parts[i].dcolour)&0xFF; - if(cmode == CM_NOTHING) + /*if(display_mode == RENDER_NONE) { if(decorations_enable) { @@ -1729,7 +1784,7 @@ void render_parts(pixel *vid) vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(colr,colg,colb); #endif } - else + else*/ { if (graphicscache[t].isready) { @@ -1786,18 +1841,39 @@ void render_parts(pixel *vid) colg += sin(gradv*caddress*4.55 +3.14) * 34; colb += sin(gradv*caddress*2.22 +3.14) * 64; } + + if(pixel_mode & FIRE_ADD && !(render_mode & FIRE_ADD)) + pixel_mode |= PMODE_GLOW; + if(pixel_mode & FIRE_BLEND && !(render_mode & FIRE_BLEND)) + pixel_mode |= PMODE_BLUR; + + pixel_mode &= render_mode; + //Alter colour based on display mode - switch(cmode) + if(display_mode & COLOUR_HEAT) { - case CM_HEAT: caddress = restrict_flt((int)( restrict_flt((float)(parts[i].temp+(-MIN_TEMP)), 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3); firea = 255; firer = colr = (unsigned char)color_data[caddress]; fireg = colg = (unsigned char)color_data[caddress+1]; fireb = colb = (unsigned char)color_data[caddress+2]; cola = 255; - if(pixel_mode & (FIRE_ADD | FIRE_BLEND | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIRE_ADD|FIRE_BLEND|PMODE_GLOW)) | PMODE_BLUR | PMODE_FLAT; - break; + if(pixel_mode & (FIREMODE | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR; + } + else if(display_mode & COLOUR_LIFE) + { + gradv = 0.4f; + if (!(parts[i].life<5)) + q = sqrt(parts[i].life); + else + q = parts[i].life; + colr = colg = colb = sin(gradv*q) * 100 + 128; + cola = 255; + if(pixel_mode & (FIREMODE | PMODE_GLOW)) pixel_mode = (pixel_mode & ~(FIREMODE|PMODE_GLOW)) | PMODE_BLUR; + } + + /*switch(cmode) + { case CM_LIFE: gradv = 0.4f; if (!(parts[i].life<5)) @@ -1826,21 +1902,24 @@ void render_parts(pixel *vid) break; default: break; - } + }*/ //Apply decoration colour - if(!(pixel_mode & NO_DECO) && cmode != CM_HEAT && decorations_enable) - { - colr = (deca*decr + (255-deca)*colr) >> 8; - colg = (deca*decg + (255-deca)*colg) >> 8; - colb = (deca*decb + (255-deca)*colb) >> 8; - } - - if(pixel_mode & DECO_FIRE && decorations_enable) + if(!(display_mode & COLOUR_HEAT|COLOUR_LIFE)) { - firer = (deca*decr + (255-deca)*firer) >> 8; - fireg = (deca*decg + (255-deca)*fireg) >> 8; - fireb = (deca*decb + (255-deca)*fireb) >> 8; + if(!(pixel_mode & NO_DECO) && decorations_enable) + { + colr = (deca*decr + (255-deca)*colr) >> 8; + colg = (deca*decg + (255-deca)*colg) >> 8; + colb = (deca*decb + (255-deca)*colb) >> 8; + } + + if(pixel_mode & DECO_FIRE && decorations_enable) + { + firer = (deca*decr + (255-deca)*firer) >> 8; + fireg = (deca*decg + (255-deca)*fireg) >> 8; + fireb = (deca*decb + (255-deca)*fireb) >> 8; + } } #ifndef OGLR @@ -1861,7 +1940,6 @@ void render_parts(pixel *vid) char buff[20]; //Buffer for HP int s; int legr, legg, legb; - pixel pc; playerst *cplayer; if(t==PT_STKM) cplayer = &player; @@ -1914,8 +1992,18 @@ void render_parts(pixel *vid) drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); } - if (cplayer->elem<PT_NUM) pc = ptypes[cplayer->elem].pcolors; - else pc = PIXPACK(0x8080FF); + if (cplayer->elem<PT_NUM) + { + colr = PIXR(ptypes[cplayer->elem].pcolors); + colg = PIXG(ptypes[cplayer->elem].pcolors); + colb = PIXB(ptypes[cplayer->elem].pcolors); + } + else + { + colr = 0x80; + colg = 0x80; + colb = 0xFF; + } s = XRES+BARSIZE; if (t==PT_STKM2) @@ -1931,10 +2019,8 @@ void render_parts(pixel *vid) legb = 255; } - if (cmode == CM_HEAT) + if (colour_mode) { - pc = PIXRGB(colr, colg, colb); - legr = colr; legg = colg; legb = colb; @@ -1943,17 +2029,17 @@ void render_parts(pixel *vid) //head if(t==PT_FIGH) { - draw_line(vid , nx, ny+2, nx+2, ny, PIXR(pc), PIXG(pc), PIXB(pc), s); - draw_line(vid , nx+2, ny, nx, ny-2, PIXR(pc), PIXG(pc), PIXB(pc), s); - draw_line(vid , nx, ny-2, nx-2, ny, PIXR(pc), PIXG(pc), PIXB(pc), s); - draw_line(vid , nx-2, ny, nx, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s); + draw_line(vid , nx, ny+2, nx+2, ny, colr, colg, colb, s); + draw_line(vid , nx+2, ny, nx, ny-2, colr, colg, colb, s); + draw_line(vid , nx, ny-2, nx-2, ny, colr, colg, colb, s); + draw_line(vid , nx-2, ny, nx, ny+2, colr, colg, colb, s); } else { - draw_line(vid , nx-2, ny+2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s); - draw_line(vid , nx-2, ny-2, nx+2, ny-2, PIXR(pc), PIXG(pc), PIXB(pc), s); - draw_line(vid , nx-2, ny-2, nx-2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s); - draw_line(vid , nx+2, ny-2, nx+2, ny+2, PIXR(pc), PIXG(pc), PIXB(pc), s); + draw_line(vid , nx-2, ny+2, nx+2, ny+2, colr, colg, colb, s); + draw_line(vid , nx-2, ny-2, nx+2, ny-2, colr, colg, colb, s); + draw_line(vid , nx-2, ny-2, nx-2, ny+2, colr, colg, colb, s); + draw_line(vid , nx+2, ny-2, nx+2, ny+2, colr, colg, colb, s); } //legs draw_line(vid , nx, ny+3, cplayer->legs[0], cplayer->legs[1], legr, legg, legb, s); @@ -2532,7 +2618,7 @@ void render_parts(pixel *vid) void draw_parts_fbo() { glEnable( GL_TEXTURE_2D ); - if(cmode==CM_FANCY) + if(display_mode & DISPLAY_WARP) { float xres = XRES, yres = YRES; glUseProgram(lensProg); @@ -2569,7 +2655,7 @@ void draw_parts_fbo() glVertex3f(XRES*sdl_scale, MENUSIZE*sdl_scale, 1.0); glEnd(); - if(cmode==CM_FANCY) + if(display_mode & DISPLAY_WARP) { glUseProgram(0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -2672,86 +2758,6 @@ void draw_walls(pixel *vid) vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x242424); } } - - if (cmode==CM_BLOB) - { - // when in blob view, draw some blobs... - if (wtypes[wt].drawstyle==1) - { - for (j=0; j<CELL; j+=2) - for (i=(j>>1)&1; i<CELL; i+=2) - drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc)); - } - else if (wtypes[wt].drawstyle==2) - { - for (j=0; j<CELL; j+=2) - for (i=0; i<CELL; i+=2) - drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc)); - } - else if (wtypes[wt].drawstyle==3) - { - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc)); - } - else if (wtypes[wt].drawstyle==4) - { - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if(i == j) - drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc)); - else if (i == j+1 || (i == 0 && j == CELL-1)) - drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(gc), PIXG(gc), PIXB(gc)); - else - drawblob(vid, (x*CELL+i), (y*CELL+j), 0x20, 0x20, 0x20); - } - if (bmap[y][x]==WL_EWALL) - { - if (emap[y][x]) - { - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (i&j&1) - drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80); - } - else - { - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - if (!(i&j&1)) - drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80); - } - } - else if (bmap[y][x]==WL_WALLELEC) - { - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - { - if (!((y*CELL+j)%2) && !((x*CELL+i)%2)) - drawblob(vid, (x*CELL+i), (y*CELL+j), PIXR(pc), PIXG(pc), PIXB(pc)); - else - drawblob(vid, (x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80); - } - } - else if (bmap[y][x]==WL_EHOLE) - { - if (emap[y][x]) - { - for (j=0; j<CELL; j++) - for (i=0; i<CELL; i++) - drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24); - for (j=0; j<CELL; j+=2) - for (i=0; i<CELL; i+=2) - vid[(y*CELL+j)*(XRES+BARSIZE)+(x*CELL+i)] = PIXPACK(0x000000); - } - else - { - for (j=0; j<CELL; j+=2) - for (i=0; i<CELL; i+=2) - drawblob(vid, (x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24); - } - } - } if (wtypes[wt].eglow && emap[y][x]) { diff --git a/src/interface.c b/src/interface.c index 47b3be2..8b0d0c9 100644 --- a/src/interface.c +++ b/src/interface.c @@ -804,58 +804,15 @@ void draw_svf_ui(pixel *vid_buf, int alternate)// all the buttons at the bottom } //The simulation options button, used to be the heat sim button - /*if (!legacy_enable) - { - fillrect(vid_buf, XRES-160+BARSIZE, YRES+(MENUSIZE-17), 16, 16, 255, 255, 255, 255); - drawtext(vid_buf, XRES-154+BARSIZE, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255); - drawtext(vid_buf, XRES-154+BARSIZE, YRES+(MENUSIZE-13), "\xBD", 0, 0, 0, 255); - } - else*/ { drawtext(vid_buf, XRES-156+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xCF", 255, 255, 255, 255); drawrect(vid_buf, XRES-159+BARSIZE/*494*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); } //the view mode button - switch (cmode) - { - case CM_VEL: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x98", 128, 160, 255, 255); - break; - case CM_PRESS: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x99", 255, 212, 32, 255); - break; - case CM_PERS: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9A", 212, 212, 212, 255); - break; - case CM_FIRE: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9B", 255, 0, 0, 255); - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x9C", 255, 255, 64, 255); - break; - case CM_BLOB: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBF", 55, 255, 55, 255); - break; - case CM_HEAT: - drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBE", 255, 0, 0, 255); - drawtext(vid_buf, XRES-27+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xBD", 255, 255, 255, 255); - break; - case CM_FANCY: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xC4", 100, 150, 255, 255); - break; - case CM_NOTHING: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 100, 150, 255, 255); - break; - case CM_CRACK: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD4", 255, 55, 55, 255); - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD5", 55, 255, 55, 255); - break; - case CM_GRAD: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD3", 255, 50, 255, 255); - break; - case CM_LIFE: - drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 255, 50, 255, 255); - break; - } + addchar(vid_buf, XRES-29+BARSIZE, YRES+(MENUSIZE-13), 0xD8, 255, 0, 0, 255); + addchar(vid_buf, XRES-29+BARSIZE, YRES+(MENUSIZE-13), 0xD9, 0, 255, 0, 255); + addchar(vid_buf, XRES-29+BARSIZE, YRES+(MENUSIZE-13), 0xDA, 0, 0, 255, 255); drawrect(vid_buf, XRES-32+BARSIZE/*478*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); // special icons for admin/mods @@ -2705,74 +2662,6 @@ int sdl_poll(void) return 0; } -void set_cmode(int cm) // sets to given view mode -{ - cmode = cm; - itc = 51; - if (cmode==CM_BLOB) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Blob Display"); - } - else if (cmode==CM_HEAT) - { - strcpy(itc_msg, "Heat Display"); - } - else if (cmode==CM_FANCY) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Fancy Display"); - } - else if (cmode==CM_FIRE) - { - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); - strcpy(itc_msg, "Fire Display"); - } - else if (cmode==CM_PERS) - { - memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - strcpy(itc_msg, "Persistent Display"); - } - else if (cmode==CM_PRESS) - { - strcpy(itc_msg, "Pressure Display"); - } - else if (cmode==CM_NOTHING) - { - strcpy(itc_msg, "Nothing Display"); - } - else if (cmode==CM_CRACK) - { - strcpy(itc_msg, "Alternate Velocity Display"); - } - else if (cmode==CM_GRAD) - { - strcpy(itc_msg, "Heat Gradient Display"); - } - else if (cmode==CM_LIFE) - { - if (DEBUG_MODE) //can only get to Life view in debug mode - { - strcpy(itc_msg, "Life Display"); - } - else - { - set_cmode(CM_CRACK); - } - } - else //if no special text given, it will display this. - { - strcpy(itc_msg, "Velocity Display"); - } - save_presets(0); -} - char *download_ui(pixel *vid_buf, char *uri, int *len) { int dstate = 0; @@ -6154,6 +6043,10 @@ openfin: return; } +void render_ui(pixel * vid_buf) +{ +} + void simulation_ui(pixel * vid_buf) { int xsize = 300; diff --git a/src/luaconsole.c b/src/luaconsole.c index c74155b..b0b8a53 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -1104,10 +1104,7 @@ int luatpt_heat(lua_State* l) } int luatpt_cmode_set(lua_State* l) { - int aheatstate; - aheatstate = luaL_optint(l, 1, CM_FIRE); - cmode = aheatstate; - return 0; + return luaL_error(l, "Not implemented"); } int luatpt_setfire(lua_State* l) { @@ -47,6 +47,7 @@ #include <font.h> #include <powder.h> #include <graphics.h> +#include <powdergraphics.h> #include <version.h> #include <http.h> #include <md5.h> @@ -1521,7 +1522,9 @@ int main(int argc, char *argv[]) char ppmfilename[256], ptifilename[256], ptismallfilename[256]; FILE *f; - cmode = CM_FIRE; + colour_mode = COLOUR_DEFAULT; + init_display_modes(); + sys_pause = 1; parts = calloc(sizeof(particle), NPART); for (i=0; i<NPART-1; i++) @@ -1669,6 +1672,9 @@ int main(int argc, char *argv[]) cb_parts = calloc(sizeof(particle), NPART); init_can_move(); clear_sim(); + + colour_mode = COLOUR_DEFAULT; + init_display_modes(); //fbi_img = render_packed_rgb(fbi, FBI_W, FBI_H, FBI_CMP); @@ -1803,7 +1809,7 @@ int main(int argc, char *argv[]) #ifdef OGLR part_vbuf = vid_buf; #else - if(ngrav_enable && cmode==CM_FANCY) + if(ngrav_enable && display_mode & DISPLAY_WARP) { part_vbuf = part_vbuf_store; memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); @@ -1819,7 +1825,7 @@ int main(int argc, char *argv[]) gravwl_timeout--; } #ifdef OGLR - if (cmode==CM_PERS)//save background for persistent, then clear + if (display_mode & DISPLAY_PERS)//save background for persistent, then clear { clearScreen(0.01f); memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); @@ -1828,17 +1834,17 @@ int main(int argc, char *argv[]) { clearScreen(1.0f); memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - if (cmode==CM_VEL || cmode==CM_PRESS || cmode==CM_CRACK || (cmode==CM_HEAT && aheat_enable))//air only gets drawn in these modes + if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes { draw_air(part_vbuf); } } #else - if (cmode==CM_VEL || cmode==CM_PRESS || cmode==CM_CRACK || (cmode==CM_HEAT && aheat_enable))//air only gets drawn in these modes + if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes { draw_air(part_vbuf); } - else if (cmode==CM_PERS)//save background for persistent, then clear + else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear { memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE); memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE)); @@ -1962,7 +1968,7 @@ int main(int argc, char *argv[]) sys_pause = 1; } - if (cmode==CM_PERS) + if (display_mode & DISPLAY_PERS) { if (!fire_fc)//fire_fc has nothing to do with fire... it is a counter for diminishing persistent view every 3 frames { @@ -1976,14 +1982,14 @@ int main(int argc, char *argv[]) } #ifndef OGLR - if (cmode==CM_FIRE||cmode==CM_BLOB||cmode==CM_FANCY) + if (render_mode & FIREMODE) render_fire(part_vbuf); #endif render_signs(part_vbuf); #ifndef OGLR - if(ngrav_enable && cmode==CM_FANCY) + if(ngrav_enable && display_mode & DISPLAY_WARP) render_gravlensing(part_vbuf, vid_buf); #endif @@ -2202,7 +2208,8 @@ int main(int argc, char *argv[]) it = 50; save_mode = 1; } - if (sdl_key=='1') + //TODO: Superseded by new display mode switching, need some keyboard shortcuts + /*if (sdl_key=='1') { set_cmode(CM_VEL); } @@ -2245,7 +2252,7 @@ int main(int argc, char *argv[]) if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE) { set_cmode(CM_LIFE); - } + }*/ if (sdl_key==SDLK_TAB) { CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ; @@ -2550,12 +2557,13 @@ int main(int argc, char *argv[]) save_mode = 1; copy_mode = 1; } - else if (sdl_key=='c') + //TODO: Superseded by new display mode switching, need some keyboard shortcuts + /*else if (sdl_key=='c') { set_cmode((cmode+1) % CM_COUNT); if (it > 50) it = 50; - } + }*/ if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo { int cbx, cby, cbi; @@ -3154,7 +3162,8 @@ int main(int argc, char *argv[]) } if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) { - if (b & SDL_BUTTON_LMASK) { + render_ui(vid_buf); + /*if (b & SDL_BUTTON_LMASK) { set_cmode((cmode+1) % CM_COUNT); } if (b & SDL_BUTTON_RMASK) { @@ -3163,7 +3172,7 @@ int main(int argc, char *argv[]) } else { set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); } - } + }*/ } if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) sys_pause = !sys_pause; @@ -3668,6 +3677,8 @@ int main(int argc, char *argv[]) player2.elem = PT_DUST; } } + save_presets(0); + SDL_CloseAudio(); http_done(); #ifdef GRAVFFT @@ -159,7 +159,7 @@ void save_presets(int do_update) //General settings cJSON_AddStringToObject(root, "proxy", http_proxy_string); - cJSON_AddNumberToObject(root, "cmode", cmode); + cJSON_AddNumberToObject(root, "colour_mode", colour_mode); cJSON_AddNumberToObject(root, "scale", sdl_scale); outputdata = cJSON_Print(root); @@ -265,7 +265,8 @@ void load_presets(void) //Read general settings if((tmpobj = cJSON_GetObjectItem(root, "proxy")) && tmpobj->type == cJSON_String) strncpy(http_proxy_string, tmpobj->valuestring, 255); else http_proxy_string[0] = 0; - if(tmpobj = cJSON_GetObjectItem(root, "cmode")) cmode = tmpobj->valueint; + //TODO: Translate old cmode value into new *_mode values + if(tmpobj = cJSON_GetObjectItem(root, "colour_mode")) colour_mode = tmpobj->valueint; if(tmpobj = cJSON_GetObjectItem(root, "scale")) sdl_scale = tmpobj->valueint; cJSON_Delete(root); @@ -317,7 +318,8 @@ void load_presets(void) sdl_scale = (tmp == 2) ? 2 : 1; if (fread(&tmp, 1, 1, f) != 1) goto fail; - cmode = tmp%CM_COUNT; + //TODO: Translate old cmode value into new *_mode values + //cmode = tmp%CM_COUNT; if (fread(&tmp, 1, 1, f) != 1) goto fail; svf_admin = tmp; |
