From c6e2d17ffee43b1c91ec72164d818a570dce952d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 19 Feb 2011 18:36:08 +0000 Subject: [PATCH 01/10] Minor version --- includes/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/defines.h b/includes/defines.h index 3b765aabc..90f50da13 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -8,7 +8,7 @@ #endif #define SAVE_VERSION 46 -#define MINOR_VERSION 1 +#define MINOR_VERSION 2 #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. #define BETA From 1307af5c5787cecfffac7e383e23b88a92d694d7 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 19 Feb 2011 18:59:07 +0000 Subject: [PATCH 02/10] Fix saving of display mode from keys and fix persistent display --- includes/graphics.h | 1 + src/graphics.c | 1 + src/interface.c | 2 ++ src/main.c | 5 +++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/graphics.h b/includes/graphics.h index a5de71a25..4d4d438fb 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -46,6 +46,7 @@ extern unsigned char fire_b[YRES/CELL][XRES/CELL]; extern unsigned int fire_alpha[CELL*3][CELL*3]; extern pixel *fire_bg; +extern pixel *pers_bg; pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f); diff --git a/src/graphics.c b/src/graphics.c index 78f1867fb..a3cbf8774 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -31,6 +31,7 @@ unsigned char fire_b[YRES/CELL][XRES/CELL]; unsigned int fire_alpha[CELL*3][CELL*3]; pixel *fire_bg; +pixel *pers_bg; pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f) { diff --git a/src/interface.c b/src/interface.c index d3057d8e0..703ac068b 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1892,6 +1892,7 @@ void set_cmode(int cm) else if (cmode==CM_PERS) { memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); strcpy(itc_msg, "Persistent Display"); } else if (cmode==CM_PRESS) @@ -1925,6 +1926,7 @@ void set_cmode(int cm) { strcpy(itc_msg, "Velocity Display"); } + save_presets(0); } char *download_ui(pixel *vid_buf, char *uri, int *len) diff --git a/src/main.c b/src/main.c index 16f309253..2f3a6414f 100644 --- a/src/main.c +++ b/src/main.c @@ -1188,7 +1188,6 @@ int main(int argc, char *argv[]) int pastFPS = 0; int past = 0; pixel *vid_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); - pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE); void *http_ver_check; void *http_session_check = NULL; char *ver_data=NULL, *check_data=NULL, *tmp; @@ -1248,6 +1247,7 @@ int main(int argc, char *argv[]) parts[NPART-1].life = -1; pfree = 0; fire_bg=calloc(XRES*YRES, PIXELSIZE); + pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE); memset(signs, 0, sizeof(signs)); //fbi_img = render_packed_rgb(fbi, FBI_W, FBI_H, FBI_CMP); @@ -2291,6 +2291,7 @@ int main(int argc, char *argv[]) ISSPAWN2 = 0; memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); memset(fire_b, 0, sizeof(fire_b)); @@ -2319,6 +2320,7 @@ int main(int argc, char *argv[]) { search_ui(vid_buf); memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); memset(fire_r, 0, sizeof(fire_r)); memset(fire_g, 0, sizeof(fire_g)); memset(fire_b, 0, sizeof(fire_b)); @@ -2340,7 +2342,6 @@ int main(int argc, char *argv[]) set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); } } - save_presets(0); } if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) sys_pause = !sys_pause; From 9002a87d6128927e14f88cb09ff241b004cb0bf8 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 19 Feb 2011 19:28:39 +0000 Subject: [PATCH 03/10] Notication of authentication improvement --- src/main.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 2f3a6414f..dfcc1d906 100644 --- a/src/main.c +++ b/src/main.c @@ -1204,6 +1204,7 @@ int main(int argc, char *argv[]) pixel *load_img=NULL;//, *fbi_img=NULL; int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0; SDL_AudioSpec fmt; + int username_flash = 0, username_flash_t = 1; GSPEED = 1; /* Set 16-bit stereo audio at 22Khz */ @@ -1272,7 +1273,7 @@ int main(int argc, char *argv[]) else if (!strncmp(argv[i], "kiosk", 5)) { kiosk_enable = 1; - sdl_scale = 2; + //sdl_scale = 2; //Removed because some displays cannot handle the resolution hud_enable = 0; } } @@ -1391,7 +1392,6 @@ int main(int argc, char *argv[]) check_data = http_async_req_stop(http_session_check, &http_s_ret, NULL); if(http_ret==200 && check_data) { - printf("{%s}\n", check_data); if(!strncmp(check_data, "EXPIRED", 7)) { //Session expired @@ -1415,6 +1415,7 @@ int main(int argc, char *argv[]) svf_own = 0; svf_admin = 0; svf_mod = 0; + error_ui(vid_buf, "Unable to log in", "Your account has been suspended, consider reading the rules."); } else if(!strncmp(check_data, "OK", 2)) { @@ -1432,7 +1433,6 @@ int main(int argc, char *argv[]) svf_mod = 1; } } - save_presets(0); } else { @@ -1446,9 +1446,26 @@ int main(int argc, char *argv[]) svf_admin = 0; svf_mod = 0; } + save_presets(0); free(check_data); } http_session_check = NULL; + } else { + clearrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14); + drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255); + drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255); + if(username_flash>30){ + username_flash_t = -1; + username_flash = 30; + } else if(username_flash<0) { + username_flash_t = 1; + username_flash = 0; + } + username_flash += username_flash_t; + if (svf_login) + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 175-(username_flash*5)); + else + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[checking]", 255, 255, 255, 255); } do_s_check = (do_s_check+1) & 15; } @@ -2299,8 +2316,10 @@ int main(int argc, char *argv[]) if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) { login_ui(vid_buf); - if (svf_login) + if (svf_login){ save_presets(0); + http_session_check = NULL; + } } if (x>=37 && x<=187 && svf_login) { From dc35feeac9e692191b99ba44122dbab203d1cd6c Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Mon, 21 Feb 2011 03:08:50 +0800 Subject: [PATCH 04/10] Fix console preventing window from closing --- src/interface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/interface.c b/src/interface.c index 703ac068b..0efc7809b 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3953,6 +3953,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show } } } + console_mode = 0; return NULL; } From 1419337374ad254eddab69fa1bff11204abca69d Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Mon, 21 Feb 2011 04:55:47 +0800 Subject: [PATCH 05/10] Reduce overlap of HUD text when in debug/beta mode Also reduce duplication of some HUD code --- src/main.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main.c b/src/main.c index 2f3a6414f..6667f7710 100644 --- a/src/main.c +++ b/src/main.c @@ -1935,35 +1935,29 @@ int main(int argc, char *argv[]) } if (!((cr>>8)>=NPART || !cr)) { -#ifdef BETA if (DEBUG_MODE) { int tctype = parts[cr>>8].ctype; if (tctype>=PT_NUM) tctype = 0; - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, cr>>8); - //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - } else + sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale); + } else { +#ifdef BETA sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); #else - if (DEBUG_MODE) - { - int tctype = parts[cr>>8].ctype; - if (tctype>=PT_NUM) - tctype = 0; - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life ,cr>>8); - //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - } else { sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); - } #endif + } } else { sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); + if (DEBUG_MODE) + { + sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); + } } - if (DEBUG_MODE) - sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); } mx = x; my = y; From 6f2965d0d069e8586d9ca32d042ee6dd094cb0f0 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Mon, 21 Feb 2011 06:38:19 +0800 Subject: [PATCH 06/10] Zoom key conflict with international keyboards Change zoom key to only use keysym.sym, like all the other keyboard controls. This may mean it is no longer the 'z' key on all systems, but will prevent it conflicting with the other keyboard controls. --- includes/interface.h | 2 -- src/interface.c | 7 ++----- src/main.c | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/includes/interface.h b/includes/interface.h index e1d7e6f22..a49f75f9e 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -154,8 +154,6 @@ extern char search_expr[256]; extern char *tag_names[TAG_MAX]; extern int tag_votes[TAG_MAX]; -extern int Z_keysym; - extern int zoom_en; extern int zoom_x, zoom_y; extern int zoom_wx, zoom_wy; diff --git a/src/interface.c b/src/interface.c index 0efc7809b..2aef3632b 100644 --- a/src/interface.c +++ b/src/interface.c @@ -60,8 +60,6 @@ char search_expr[256] = ""; char *tag_names[TAG_MAX]; int tag_votes[TAG_MAX]; -int Z_keysym = 'z'; - int zoom_en = 0; int zoom_x=(XRES-ZSIZE_D)/2, zoom_y=(YRES-ZSIZE_D)/2; int zoom_wx=0, zoom_wy=0; @@ -1763,10 +1761,9 @@ int sdl_poll(void) sdl_ascii=event.key.keysym.unicode; if (event.key.keysym.sym == SDLK_CAPSLOCK) sdl_caps = 1; - if (event.key.keysym.unicode=='z' || event.key.keysym.unicode=='Z') + if (event.key.keysym.sym=='z') { sdl_zoom_trig = 1; - Z_keysym = event.key.keysym.sym; } if ( event.key.keysym.sym == SDLK_PLUS) { @@ -1816,7 +1813,7 @@ int sdl_poll(void) case SDL_KEYUP: if (event.key.keysym.sym == SDLK_CAPSLOCK) sdl_caps = 0; - if (event.key.keysym.sym == Z_keysym) + if (event.key.keysym.sym == 'z') sdl_zoom_trig = 0; if (event.key.keysym.sym == SDLK_RIGHT || event.key.keysym.sym == SDLK_LEFT) { diff --git a/src/main.c b/src/main.c index 6667f7710..84e440ca6 100644 --- a/src/main.c +++ b/src/main.c @@ -2108,7 +2108,7 @@ int main(int argc, char *argv[]) if (!sdl_zoom_trig && zoom_en==1) zoom_en = 0; - if (sdl_key==Z_keysym && zoom_en==2) + if (sdl_key=='z' && zoom_en==2) zoom_en = 1; if (load_mode) From 383eaff5b221c5e1d899e256783c4c20805c8c84 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 21 Feb 2011 16:24:03 +0000 Subject: [PATCH 07/10] Sound and scripts are opt-in, to speed up loading and closing --- src/main.c | 179 +++++++++++++++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 80 deletions(-) diff --git a/src/main.c b/src/main.c index d0147956c..3fa2828f9 100644 --- a/src/main.c +++ b/src/main.c @@ -169,7 +169,8 @@ int FPSB = 0; int MSIGN =-1; //int CGOL = 0; //int GSPEED = 1;//causes my .exe to crash.. -int sound_enable; +int sound_enable = 0; +int file_script = 0; sign signs[MAXSIGNS]; @@ -1214,16 +1215,7 @@ int main(int argc, char *argv[]) fmt.samples = 512; fmt.callback = mixaudio; fmt.userdata = NULL; - /* Open the audio device and start playing sound! */ - if ( SDL_OpenAudio(&fmt, NULL) < 0 ) - { - fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); - } - else - { - sound_enable = 1; - SDL_PauseAudio(0); - } + #ifdef MT numCores = core_count(); #endif @@ -1276,6 +1268,24 @@ int main(int argc, char *argv[]) //sdl_scale = 2; //Removed because some displays cannot handle the resolution hud_enable = 0; } + else if (!strncmp(argv[i], "sound", 5)) + { + /* Open the audio device and start playing sound! */ + if ( SDL_OpenAudio(&fmt, NULL) < 0 ) + { + fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); + } + else + { + sound_enable = 1; + SDL_PauseAudio(0); + } + } + else if (!strncmp(argv[i], "scripts", 5)) + { + file_script = 1; + } + } save_presets(0); @@ -2767,84 +2777,93 @@ int process_command(pixel *vid_buf,char *console,char *console_error) { } else if(strcmp(console2, "file")==0 && console3) { - FILE *f=fopen(console3, "r"); - if(f) - { - char fileread[5000];//TODO: make this change with file size - char pch[5000]; - char tokens[10]; - int tokensize; - nx = 0; - ny = 0; - j = 0; - m = 0; - if(console4) - console_parse_coords(console4, &nx , &ny, console_error); - memset(pch,0,sizeof(pch)); - memset(fileread,0,sizeof(fileread)); - fread(fileread,1,5000,f); - for(i=0; i Date: Mon, 21 Feb 2011 17:57:17 +0000 Subject: [PATCH 08/10] UI improvements for elements menu --- includes/interface.h | 3 +-- includes/powder.h | 10 +++++----- src/graphics.c | 2 ++ src/interface.c | 40 ++++++++++++++++++++-------------------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/includes/interface.h b/includes/interface.h index a49f75f9e..ea1f9a5be 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -52,10 +52,9 @@ static menu_wall mwalls[] = #define SC_LIQUID 4 #define SC_NUCLEAR 7 #define SC_LIFE 9 -#define SC_LIFE2 10 #define SC_CRACKER 12 #define SC_CRACKER2 13 -#define SC_TOTAL 11 +#define SC_TOTAL 10 static menu_section msections[] = { diff --git a/includes/powder.h b/includes/powder.h index f5fa948d5..9964abadd 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -511,11 +511,11 @@ static const part_type ptypes[PT_NUM] = {"REPL", PIXPACK(0x259588), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B1357/S1357", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"MYST", PIXPACK(0x0C3C00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B3458/S05678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL}, - {"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; diff --git a/src/graphics.c b/src/graphics.c index a3cbf8774..ea8d0d545 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -448,6 +448,8 @@ void draw_tool(pixel *vid_buf, int b, int sl, int sr, unsigned pc, unsigned iswa int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc) { int i, j, c; + if (x > XRES-26 || x < 0) + return 26; if (b>=UI_WALLSTART) { b = b-100; diff --git a/src/interface.c b/src/interface.c index 2aef3632b..e43bd9ae9 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1531,13 +1531,14 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr) void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, int my) { - int h,x,y,n=0,height,width,sy,rows=0; + int h,x,y,n=0,height,width,sy,rows=0,xoff=0,fwidth; SEC = SEC2; mx /= sdl_scale; my /= sdl_scale; rows = ceil((float)msections[i].itemcount/16.0f); height = (ceil((float)msections[i].itemcount/16.0f)*18); width = restrict_flt(msections[i].itemcount*31, 0, 16*31); + fwidth = msections[i].itemcount*31; h = -1; x = XRES-BARSIZE-18; y = YRES+1; @@ -1548,11 +1549,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if (n!=SPC_AIR&&n!=SPC_HEAT&&n!=SPC_COOL&&n!=SPC_VACUUM) { - if (x-18<=2) + /*if (x-18<=2) { x = XRES-BARSIZE-18; y += 19; - } + }*/ x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { @@ -1585,11 +1586,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if (n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM) { - if (x-18<=0) + /*if (x-18<=0) { x = XRES-BARSIZE-18; y += 19; - } + }*/ x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { @@ -1619,11 +1620,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, { if (ptypes[n].menusection==i&&ptypes[n].menu==1) { - if (x-18<=0) + /*if (x-18<=0) { x = XRES-BARSIZE-18; y += 19; - } + }*/ x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5; if (!bq && mx>=x+32 && mx=y && my< y+15) { @@ -1652,37 +1653,36 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, } else { + if (fwidth > XRES){ + float overflow = fwidth-XRES+BARSIZE, location = ((float)XRES+BARSIZE)/((float)(mx-XRES+BARSIZE)); + xoff = (int)(overflow / location); + } for (n = 0; n=x+32-xoff && mx=y && my< y+15) { - x = XRES-BARSIZE-18; - y += 19; - } - x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5; - if (!bq && mx>=x+32 && mx=y && my< y+15) - { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 0, 0, 255); h = n; } - if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + if (!bq && mx>=x+32-xoff && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); h = n; } else if (n==SLALT) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); } else if (n==*sl) { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 0, 0, 255); } else if (n==*sr) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 0, 255, 255); } } } From ff1aca9524b74985f1cce2da0ac96cf088fd5d52 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 22 Feb 2011 00:15:48 +0000 Subject: [PATCH 09/10] Update version --- includes/defines.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index 90f50da13..01c281216 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -8,9 +8,9 @@ #endif #define SAVE_VERSION 46 -#define MINOR_VERSION 2 +#define MINOR_VERSION 3 #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. -#define BETA +//#define BETA #define SERVER "powdertoy.co.uk" From a84234dcd4e5a3dfb4a62d73ff07df1e01bed086 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 22 Feb 2011 00:51:01 +0000 Subject: [PATCH 10/10] Improvement to scrolling menu --- src/interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interface.c b/src/interface.c index e43bd9ae9..a762b39d7 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1653,8 +1653,8 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, } else { - if (fwidth > XRES){ - float overflow = fwidth-XRES+BARSIZE, location = ((float)XRES+BARSIZE)/((float)(mx-XRES+BARSIZE)); + if (fwidth > XRES-BARSIZE){ + float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE))); xoff = (int)(overflow / location); } for (n = 0; n