diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-04-29 23:34:07 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-04-29 23:39:12 (GMT) |
| commit | 8872e33b44ddc766e2c92fc843e2ee883247f473 (patch) | |
| tree | f520b81af863eeb1bedbab36568604791ddd84b6 /src/main.c | |
| parent | 74979102b34980ce2a815ebf15985d356a73de3c (diff) | |
| download | powder-8872e33b44ddc766e2c92fc843e2ee883247f473.zip powder-8872e33b44ddc766e2c92fc843e2ee883247f473.tar.gz | |
Massive cleanup of sdl_scale, and fix moving a sign in the zoom window
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 100 |
1 files changed, 44 insertions, 56 deletions
@@ -1763,25 +1763,25 @@ int main(int argc, char *argv[]) } bq = bc; // bq is previous mouse state - bc = b = SDL_GetMouseState(&x, &y); // b is current mouse state + bc = b = mouse_get_state(&x, &y); // b is current mouse state #ifdef LUACONSOLE if(bc && bq){ - if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bc, LUACON_MPRESS)){ + if(!luacon_mouseevent(x, y, bc, LUACON_MPRESS)){ b = 0; } } else if(bc && !bq){ - if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bc, LUACON_MDOWN)){ + if(!luacon_mouseevent(x, y, bc, LUACON_MDOWN)){ b = 0; } } else if(!bc && bq){ - if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bq, LUACON_MUP)){ + if(!luacon_mouseevent(x, y, bq, LUACON_MUP)){ b = 0; } } - luacon_step(x/sdl_scale, y/sdl_scale,sl,sr); + luacon_step(x, y,sl,sr); #endif quickoptions_menu(vid_buf, b, bq, x, y); @@ -1793,27 +1793,21 @@ int main(int argc, char *argv[]) for (i=0; i<SC_TOTAL; i++)//check mouse position to see if it is on a menu section { - if (!b&&x>=sdl_scale*(XRES-2) && x<sdl_scale*(XRES+BARSIZE-1) &&y>= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y<sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)+15)) + if (!b&&x>=(XRES-2) && x<(XRES+BARSIZE-1) &&y>= ((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y<((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)+15)) { active_menu = i; } } menu_ui_v3(vid_buf, active_menu, &sl, &sr, &su, &dae, b, bq, x, y); //draw the elements in the current menu - if (zoom_en && x>=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy //change mouse position while it is in a zoom window - && x<sdl_scale*(zoom_wx+ZFACTOR*ZSIZE) - && y<sdl_scale*(zoom_wy+ZFACTOR*ZSIZE)) - { - x = (((x/sdl_scale-zoom_wx)/ZFACTOR)+zoom_x)*sdl_scale; - y = (((y/sdl_scale-zoom_wy)/ZFACTOR)+zoom_y)*sdl_scale; - } - if (y>0 && y<sdl_scale*YRES && x>0 && x<sdl_scale*XRES) + mouse_coords_window_to_sim(&x, &y, x, y);//change mouse position while it is in a zoom window + if (y>=0 && y<YRES && x>=0 && x<XRES) { int cr; //cr is particle under mouse, for drawing HUD information char nametext[50]; - if (photons[y/sdl_scale][x/sdl_scale]) { - cr = photons[y/sdl_scale][x/sdl_scale]; + if (photons[y][x]) { + cr = photons[y][x]; } else { - cr = pmap[y/sdl_scale][x/sdl_scale]; + cr = pmap[y][x]; } if (cr) { @@ -1858,28 +1852,28 @@ int main(int argc, char *argv[]) } if (DEBUG_MODE) { - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp); - sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale); + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[y/CELL][x/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp); + sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x, y); } else { #ifdef BETA - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp); + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[y/CELL][x/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp); #else - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", nametext, pv[y/CELL][x/CELL], parts[cr>>8].temp-273.15f); #endif } if ((cr&0xFF)==PT_PHOT) wavelength_gfx = parts[cr>>8].ctype; } else { - sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); + sprintf(heattext, "Empty, Pressure: %3.2f", pv[y/CELL][x/CELL]); if (DEBUG_MODE) { if (ngrav_enable) - sprintf(coordtext, "X:%d Y:%d. GX: %.2f GY: %.2f", x/sdl_scale, y/sdl_scale, gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)], gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]); + sprintf(coordtext, "X:%d Y:%d. GX: %.2f GY: %.2f", x, y, gravx[((y/CELL)*(XRES/CELL))+(x/CELL)], gravy[((y/CELL)*(XRES/CELL))+(x/CELL)]); else - sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); + sprintf(coordtext, "X:%d Y:%d", x, y); } } } @@ -1887,8 +1881,8 @@ int main(int argc, char *argv[]) mx = x; my = y; - if (b && !bq && x>=(XRES-19-new_message_len)*sdl_scale && - x<=(XRES-14)*sdl_scale && y>=(YRES-37)*sdl_scale && y<=(YRES-24)*sdl_scale && svf_messages) + if (b && !bq && x>=(XRES-19-new_message_len) && + x<=(XRES-14) && y>=(YRES-37) && y<=(YRES-24) && svf_messages) { open_link("http://" SERVER "/Conversations.html"); } @@ -1910,8 +1904,8 @@ int main(int argc, char *argv[]) update_flag = 0; } - if (b && !bq && x>=(XRES-19-old_ver_len)*sdl_scale && - x<=(XRES-14)*sdl_scale && y>=(YRES-22)*sdl_scale && y<=(YRES-9)*sdl_scale && old_version) + if (b && !bq && x>=(XRES-19-old_ver_len) && + x<=(XRES-14) && y>=(YRES-22) && y<=(YRES-9) && old_version) { tmp = malloc(128); #ifdef BETA @@ -1956,9 +1950,9 @@ int main(int argc, char *argv[]) old_version = 0; } } - if (y>=sdl_scale*(YRES+(MENUSIZE-20))) //mouse checks for buttons at the bottom, to draw mouseover texts + if (y>=(YRES+(MENUSIZE-20))) //mouse checks for buttons at the bottom, to draw mouseover texts { - if (x>=189*sdl_scale && x<=202*sdl_scale && svf_login && svf_open && svf_myvote==0) + if (x>=189 && x<=202 && svf_login && svf_open && svf_myvote==0) { db = svf_own ? 275 : 272; if (da < 51) @@ -1976,25 +1970,25 @@ int main(int argc, char *argv[]) if (da < 51) da ++; } - else if (x>=219*sdl_scale && x<=((XRES+BARSIZE-(510-349))*sdl_scale) && svf_login && svf_open) + else if (x>=219 && x<=((XRES+BARSIZE-(510-349))) && svf_login && svf_open) { db = svf_own ? 257 : 256; if (da < 51) da ++; } - else if (x>=((XRES+BARSIZE-(510-351))*sdl_scale) && x<((XRES+BARSIZE-(510-366))*sdl_scale)) + else if (x>=((XRES+BARSIZE-(510-351))) && x<((XRES+BARSIZE-(510-366)))) { db = 270; if (da < 51) da ++; } - else if (x>=((XRES+BARSIZE-(510-367))*sdl_scale) && x<((XRES+BARSIZE-(510-383))*sdl_scale)) + else if (x>=((XRES+BARSIZE-(510-367))) && x<((XRES+BARSIZE-(510-383)))) { db = 266; if (da < 51) da ++; } - else if (x>=37*sdl_scale && x<=187*sdl_scale) + else if (x>=37 && x<=187) { if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) { @@ -2005,13 +1999,13 @@ int main(int argc, char *argv[]) else if(svf_login) { db = 259; - if (svf_open && svf_own && x<=55*sdl_scale) + if (svf_open && svf_own && x<=55) db = 258; if (da < 51) da ++; } } - else if (x>=((XRES+BARSIZE-(510-385))*sdl_scale) && x<=((XRES+BARSIZE-(510-476))*sdl_scale)) + else if (x>=((XRES+BARSIZE-(510-385))) && x<=((XRES+BARSIZE-(510-476)))) { db = svf_login ? 261 : 260; if (svf_admin) @@ -2025,7 +2019,7 @@ int main(int argc, char *argv[]) if (da < 51) da ++; } - else if (x>=sdl_scale && x<=17*sdl_scale) + else if (x>=1 && x<=17) { if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) db = 276; @@ -2034,19 +2028,19 @@ int main(int argc, char *argv[]) if (da < 51) da ++; } - else if (x>=((XRES+BARSIZE-(510-494))*sdl_scale) && x<=((XRES+BARSIZE-(510-509))*sdl_scale)) + else if (x>=((XRES+BARSIZE-(510-494))) && x<=((XRES+BARSIZE-(510-509)))) { db = sys_pause ? 264 : 263; if (da < 51) da ++; } - else if (x>=((XRES+BARSIZE-(510-476))*sdl_scale) && x<=((XRES+BARSIZE-(510-491))*sdl_scale)) + else if (x>=((XRES+BARSIZE-(510-476))) && x<=((XRES+BARSIZE-(510-491)))) { db = 267; if (da < 51) da ++; } - else if (x>=19*sdl_scale && x<=35*sdl_scale && svf_open) + else if (x>=19 && x<=35 && svf_open) { db = 265; if (da < 51) @@ -2069,8 +2063,8 @@ int main(int argc, char *argv[]) if (load_mode) { - load_x = CELL*((mx/sdl_scale-load_w/2+CELL/2)/CELL); - load_y = CELL*((my/sdl_scale-load_h/2+CELL/2)/CELL); + load_x = CELL*((mx-load_w/2+CELL/2)/CELL); + load_y = CELL*((my-load_h/2+CELL/2)/CELL); if (load_x+load_w>XRES) load_x=XRES-load_w; if (load_y+load_h>YRES) load_y=YRES-load_h; if (load_x<0) load_x=0; @@ -2091,8 +2085,8 @@ int main(int argc, char *argv[]) } else if (save_mode==1)//getting the area you are selecting { - save_x = mx/sdl_scale; - save_y = my/sdl_scale; + save_x = mx; + save_y = my; if (save_x >= XRES) save_x = XRES-1; if (save_y >= YRES) save_y = YRES-1; save_w = 1; @@ -2109,8 +2103,8 @@ int main(int argc, char *argv[]) } else if (save_mode==2) { - save_w = mx/sdl_scale + 1 - save_x; - save_h = my/sdl_scale + 1 - save_y; + save_w = mx + 1 - save_x; + save_h = my + 1 - save_y; if (save_w+save_x>XRES) save_w = XRES-save_x; if (save_h+save_y>YRES) save_h = YRES-save_y; if (save_w<1) save_w = 1; @@ -2141,8 +2135,6 @@ int main(int argc, char *argv[]) } else if (sdl_zoom_trig && zoom_en<2) { - x /= sdl_scale; - y /= sdl_scale; x -= ZSIZE/2; y -= ZSIZE/2; if (x<0) x=0; @@ -2164,8 +2156,6 @@ int main(int argc, char *argv[]) { if (it > 50) it = 50; - x /= sdl_scale; - y /= sdl_scale; if (y>=YRES+(MENUSIZE-20))//check if mouse is on menu buttons { if (!lb)//mouse is NOT held down, so it is a first click @@ -2247,7 +2237,7 @@ int main(int argc, char *argv[]) else execute_save(vid_buf); while (!sdl_poll()) - if (!SDL_GetMouseState(&x, &y)) + if (!mouse_get_state(&x, &y)) break; b = bq = 0; } @@ -2477,8 +2467,6 @@ int main(int argc, char *argv[]) { if (lb && lm) //lm is box/line tool { - x /= sdl_scale; - y /= sdl_scale; c = (lb&1) ? sl : sr; su = c; if (lm == 1)//line @@ -2508,9 +2496,9 @@ int main(int argc, char *argv[]) if (zoom_en!=1 && !load_mode && !save_mode)//draw normal cursor { - render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bsx, bsy); - mousex = mx/sdl_scale; - mousey = my/sdl_scale; + render_cursor(vid_buf, mx, my, su, bsx, bsy); + mousex = mx; + mousey = my; } #ifdef OGLR draw_parts_fbo(); |
