diff --git a/includes/font.h b/includes/font.h index 3eee73e1a..c5a9ded1c 100644 --- a/includes/font.h +++ b/includes/font.h @@ -219,9 +219,9 @@ char font_data[] = { 0x0A, 0xE0, 0x2F, 0xC0, 0x01, 0x0D, 0x06, 0x40, 0x32, 0x00, 0x30, 0x03, 0x00, 0x33, 0x00, 0x30, 0x06, 0x40, 0xC2, 0x01, 0x0D, 0xE0, 0x2F, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x23, 0x80, 0x32, 0x0A, 0x0D, 0xC3, 0xD1, 0x10, 0x1C, 0x0D, 0xC0, 0x81, 0x02, 0x0A, 0xE0, 0x2F, 0x00, 0x54, 0x00, 0x0A, 0x00, 0x00, 0x00, 0xFC, 0x03, 0xB0, 0xE0, 0x00, 0x03, 0x0C, 0x30, 0xC0, 0x00, 0x0B, 0x0E, 0xC0, 0x3F, 0x00, 0xAC, 0x03, 0xC0, 0x3A, 0x00, 0xAC, 0x03, - 0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, - 0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, - 0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, + 0x05, 0x6F, 0xBC, 0xF1, 0xC6, 0x1B, 0x6F, 0xBC, 0xF1, 0xC6, 0x1B, 0x6F, 0x00, 0x00, + 0x08, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0x00, 0x00, + 0x09, 0x00, 0xE4, 0x03, 0x90, 0x0F, 0x40, 0x3E, 0x00, 0xF9, 0x00, 0xE4, 0x03, 0x90, 0x0F, 0x40, 0x3E, 0x00, 0xF9, 0x00, 0xE4, 0x03, 0x00, 0x00, 0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, 0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07, @@ -288,11 +288,11 @@ short font_ptrs[] = { 0x0CA8, 0x0CC2, 0x0CDC, 0x0CF6, 0x0D10, 0x0D2A, 0x0D44, 0x0D5E, 0x0D78, 0x0D92, 0x0DAC, 0x0DC6, 0x0DE0, 0x0DFA, 0x0E14, 0x0E2E, 0x0E46, 0x0E60, 0x0E7A, 0x0E94, 0x0EAE, 0x0EC8, 0x0EE2, 0x0EFC, - 0x0F16, 0x0F26, 0x0F36, 0x0F46, 0x0F56, 0x0F66, 0x0F76, 0x0F86, - 0x0F96, 0x0FA6, 0x0FB6, 0x0FC6, 0x0FD6, 0x0FE6, 0x0FF6, 0x1006, - 0x1016, 0x1026, 0x1036, 0x1046, 0x1056, 0x1066, 0x1076, 0x1086, - 0x1096, 0x10A6, 0x10B6, 0x10C6, 0x10D6, 0x10E6, 0x10F6, 0x1106, - 0x1116, 0x1126, 0x1136, 0x1146, 0x1156, 0x1166, 0x1176, 0x1186, + 0x0F16, 0x0F24, 0x0F39, 0x0F51, 0x0F61, 0x0F71, 0x0F81, 0x0F91, + 0x0FA1, 0x0FB1, 0x0FC1, 0x0FD1, 0x0FE1, 0x0FF1, 0x1001, 0x1011, + 0x1021, 0x1031, 0x1041, 0x1051, 0x1061, 0x1071, 0x1081, 0x1091, + 0x10A1, 0x10B1, 0x10C1, 0x10D1, 0x10E1, 0x10F1, 0x1101, 0x1111, + 0x1121, 0x1131, 0x1141, 0x1151, 0x1161, 0x1171, 0x1181, 0x1191, }; #endif #endif diff --git a/includes/graphics.h b/includes/graphics.h index b704a5488..957c16073 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -45,7 +45,12 @@ extern int emp_decor; -extern unsigned cmode; +extern unsigned int *render_modes; +extern unsigned int render_mode; +extern unsigned int colour_mode; +extern unsigned int *display_modes; +extern unsigned int display_mode; + extern SDL_Surface *sdl_scrn; extern int sdl_scale; @@ -120,6 +125,8 @@ void draw_menu(pixel *vid_buf, int i, int hover); void drawpixel(pixel *vid, int x, int y, int r, int g, int b, int a); +int addchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a); + int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a); int drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a); diff --git a/includes/interface.h b/includes/interface.h index 64d135283..f8247d375 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -328,6 +328,8 @@ int report_ui(pixel *vid_buf, char *save_id); char *console_ui(pixel *vid_buf, char error[255],char console_more); +void render_ui(pixel *vid_buf); + void simulation_ui(pixel *vid_buf); unsigned int decorations_ui(pixel *vid_buf, int *bsx, int *bsy, unsigned int savedColor); diff --git a/includes/powdergraphics.h b/includes/powdergraphics.h index a073c7120..34b99b7bf 100644 --- a/includes/powdergraphics.h +++ b/includes/powdergraphics.h @@ -1,29 +1,50 @@ #ifndef PGRAPHICS_H #define PGRAPHICS_H -#define PMODE 0x00000FFF -#define PMODE_NONE 0x00000000 -#define PMODE_FLAT 0x00000001 -#define PMODE_BLOB 0x00000002 -#define PMODE_BLUR 0x00000004 -#define PMODE_GLOW 0x00000008 -#define PMODE_SPARK 0x00000010 -#define PMODE_FLARE 0x00000020 -#define PMODE_LFLARE 0x00000040 -#define PMODE_ADD 0x00000080 -#define PMODE_BLEND 0x00000100 - +#define PMODE 0x00000FFF +#define PMODE_NONE 0x00000000 +#define PMODE_FLAT 0x00000001 +#define PMODE_BLOB 0x00000002 +#define PMODE_BLUR 0x00000004 +#define PMODE_GLOW 0x00000008 +#define PMODE_SPARK 0x00000010 +#define PMODE_FLARE 0x00000020 +#define PMODE_LFLARE 0x00000040 +#define PMODE_ADD 0x00000080 +#define PMODE_BLEND 0x00000100 #define PSPEC_STICKMAN 0x00000200 -#define NO_DECO 0x00001000 -#define DECO_FIRE 0x00002000 +#define OPTIONS 0x0000F000 +#define NO_DECO 0x00001000 +#define DECO_FIRE 0x00002000 -#define FIREMODE 0x00FF0000 -#define FIRE_ADD 0x00010000 -#define FIRE_BLEND 0x00020000 +#define FIREMODE 0x00FF0000 +#define FIRE_ADD 0x00010000 +#define FIRE_BLEND 0x00020000 #define EFFECT 0xFF000000 #define EFFECT_GRAVIN 0x01000000 #define EFFECT_GRAVOUT 0x02000000 +#define RENDER_EFFE OPTIONS | PSPEC_STICKMAN | EFFECT +#define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND | FIREMODE +#define RENDER_GLOW OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_GLOW | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE | PMODE_ADD | PMODE_BLEND +#define RENDER_BLUR OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_BLUR | PMODE_ADD | PMODE_BLEND +#define RENDER_BASC OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND +#define RENDER_NONE OPTIONS | PSPEC_STICKMAN | PMODE_FLAT + +#define COLOUR_HEAT 0x00000001 +#define COLOUR_LIFE 0x00000002 + +#define COLOUR_DEFAULT 0x00000000 + +#define DISPLAY_AIRC 0x00000001 +#define DISPLAY_AIRP 0x00000002 +#define DISPLAY_AIRV 0x00000004 +#define DISPLAY_AIRH 0x00000008 +#define DISPLAY_AIR 0x0000000F +#define DISPLAY_WARP 0x00000010 +#define DISPLAY_PERS 0x00000020 +#define DISPLAY_EFFE 0x00000020 + #endif diff --git a/src/graphics.c b/src/graphics.c index d1d0fd721..7c4af56e9 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -28,7 +28,13 @@ #include #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>= 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 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) + if(!(display_mode & COLOUR_HEAT|COLOUR_LIFE)) { - 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; + 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->elemelem].pcolors; - else pc = PIXPACK(0x8080FF); + if (cplayer->elemelem].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>1)&1; i #include #include +#include #include #include #include @@ -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 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 diff --git a/src/misc.c b/src/misc.c index 3c8e589b0..bf2a01f87 100644 --- a/src/misc.c +++ b/src/misc.c @@ -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;