Massive cleanup of sdl_scale, and fix moving a sign in the zoom window
This commit is contained in:
parent
74979102b3
commit
8872e33b44
@ -340,5 +340,10 @@ void render_ui(pixel *vid_buf, int xcoord, int ycoord, int orientation);
|
||||
void simulation_ui(pixel *vid_buf);
|
||||
|
||||
unsigned int decorations_ui(pixel *vid_buf, int *bsx, int *bsy, unsigned int savedColor);
|
||||
|
||||
Uint8 mouse_get_state(int *x, int *y);
|
||||
|
||||
void mouse_coords_window_to_sim(int *sim_x, int *sim_y, int window_x, int window_y);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -3181,9 +3181,8 @@ void render_signs(pixel *vid_buf)
|
||||
if (MSIGN==i)
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
mouse_get_state(&mx, &my);
|
||||
mouse_coords_window_to_sim(&mx, &my, mx, my);
|
||||
signs[i].x = mx;
|
||||
signs[i].y = my;
|
||||
}
|
||||
|
196
src/interface.c
196
src/interface.c
@ -184,7 +184,7 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -205,9 +205,7 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
drawrect(vid_buf, x0, y0, 192, 80, 192, 192, 192, 255);
|
||||
clearrect(vid_buf, x0, y0, 192, 80);
|
||||
@ -490,16 +488,14 @@ void ui_list_process(pixel * vid_buf, int mx, int my, int mb, ui_list *ed)
|
||||
ystart = 5;
|
||||
while (!sdl_poll())
|
||||
{
|
||||
mb = SDL_GetMouseState(&mx, &my);
|
||||
mb = mouse_get_state(&mx, &my);
|
||||
if (!mb)
|
||||
break;
|
||||
}
|
||||
|
||||
while (!sdl_poll() && !selected)
|
||||
{
|
||||
mb = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
mb = mouse_get_state(&mx, &my);
|
||||
for(i = 0; i < ed->count; i++)
|
||||
{
|
||||
if(mx > ed->x && mx < ed->x+ed->w && my > (ystart + i*16) && my < (ystart + i * 16) + 16)
|
||||
@ -525,7 +521,7 @@ void ui_list_process(pixel * vid_buf, int mx, int my, int mb, ui_list *ed)
|
||||
}
|
||||
while (!sdl_poll())
|
||||
{
|
||||
mb = SDL_GetMouseState(&mx, &my);
|
||||
mb = mouse_get_state(&mx, &my);
|
||||
if (!mb)
|
||||
break;
|
||||
}
|
||||
@ -923,7 +919,7 @@ void error_ui(pixel *vid_buf, int err, char *txt)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -931,9 +927,7 @@ void error_ui(pixel *vid_buf, int err, char *txt)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, 244, 52+textheight);
|
||||
drawrect(vid_buf, x0, y0, 240, 48+textheight, 192, 192, 192, 255);
|
||||
@ -959,7 +953,7 @@ void error_ui(pixel *vid_buf, int err, char *txt)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -990,7 +984,7 @@ char *input_ui(pixel *vid_buf, char *title, char *prompt, char *text, char *shad
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -998,9 +992,7 @@ char *input_ui(pixel *vid_buf, char *title, char *prompt, char *text, char *shad
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, xsize+4, ysize+4);
|
||||
drawrect(vid_buf, x0, y0, xsize, ysize, 192, 192, 192, 255);
|
||||
@ -1028,7 +1020,7 @@ char *input_ui(pixel *vid_buf, char *title, char *prompt, char *text, char *shad
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1081,7 +1073,7 @@ void prop_edit_ui(pixel *vid_buf, int x, int y)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1089,9 +1081,7 @@ void prop_edit_ui(pixel *vid_buf, int x, int y)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, xsize+4, ysize+4);
|
||||
drawrect(vid_buf, x0, y0, xsize, ysize, 192, 192, 192, 255);
|
||||
@ -1223,7 +1213,7 @@ void prop_edit_ui(pixel *vid_buf, int x, int y)
|
||||
exit:
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1235,7 +1225,7 @@ void info_ui(pixel *vid_buf, char *top, char *txt)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1243,9 +1233,7 @@ void info_ui(pixel *vid_buf, char *top, char *txt)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, 244, 64);
|
||||
drawrect(vid_buf, x0, y0, 240, 60, 192, 192, 192, 255);
|
||||
@ -1266,7 +1254,7 @@ void info_ui(pixel *vid_buf, char *top, char *txt)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1314,7 +1302,7 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1322,9 +1310,7 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, xsize+4, ysize+4);
|
||||
drawrect(vid_buf, x0, y0, xsize, ysize, 192, 192, 192, 255);
|
||||
@ -1350,7 +1336,7 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1369,7 +1355,7 @@ int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1377,9 +1363,7 @@ int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, 244, 52+textheight);
|
||||
drawrect(vid_buf, x0, y0, 240, 48+textheight, 192, 192, 192, 255);
|
||||
@ -1412,7 +1396,7 @@ int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1428,7 +1412,7 @@ void login_ui(pixel *vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1458,9 +1442,7 @@ void login_ui(pixel *vid_buf)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
drawrect(vid_buf, x0, y0, 192, 80, 192, 192, 192, 255);
|
||||
clearrect(vid_buf, x0, y0, 192, 80);
|
||||
@ -1598,7 +1580,7 @@ int stamp_ui(pixel *vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1606,9 +1588,7 @@ int stamp_ui(pixel *vid_buf)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, -1, -1, XRES+BARSIZE+1, YRES+MENUSIZE+1);
|
||||
k = stamp_page*per_page;//0;
|
||||
@ -1723,7 +1703,7 @@ int stamp_ui(pixel *vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1754,9 +1734,7 @@ void tag_list_ui(pixel *vid_buf)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
op = tag = NULL;
|
||||
|
||||
@ -1868,7 +1846,7 @@ void tag_list_ui(pixel *vid_buf)
|
||||
}
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1892,7 +1870,7 @@ int save_name_ui(pixel *vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -1942,9 +1920,7 @@ int save_name_ui(pixel *vid_buf)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
drawrect(vid_buf, x0, y0, 420, 90+YRES/4, 192, 192, 192, 255);
|
||||
clearrect(vid_buf, x0, y0, 420, 90+YRES/4);
|
||||
@ -2035,16 +2011,14 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
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);
|
||||
@ -2213,7 +2187,7 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -2225,8 +2199,6 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *su, int *dae, int
|
||||
{
|
||||
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);
|
||||
@ -2594,8 +2566,6 @@ int quickoptions_tooltip_y = 0;
|
||||
void quickoptions_menu(pixel *vid_buf, int b, int bq, int x, int y)
|
||||
{
|
||||
int i = 0;
|
||||
x /= sdl_scale;
|
||||
y /= sdl_scale;
|
||||
if(quickoptions_tooltip_fade && quickoptions_tooltip)
|
||||
{
|
||||
drawtext_outline(vid_buf, (XRES - 5) - textwidth(quickoptions_tooltip), quickoptions_tooltip_y, quickoptions_tooltip, 255, 255, 255, quickoptions_tooltip_fade*20, 0, 0, 0, quickoptions_tooltip_fade*15);
|
||||
@ -3088,7 +3058,7 @@ int search_ui(pixel *vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -3116,9 +3086,7 @@ int search_ui(pixel *vid_buf)
|
||||
bq = b;
|
||||
mxq = mx;
|
||||
myq = my;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
if (mx!=mxq || my!=myq || sdl_wheel || b)
|
||||
mmt = 0;
|
||||
@ -3800,7 +3768,7 @@ int report_ui(pixel* vid_buf, char *save_id)
|
||||
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -3811,9 +3779,7 @@ int report_ui(pixel* vid_buf, char *save_id)
|
||||
drawrect(vid_buf, 205, 155, (XRES+BARSIZE-400)-10, (YRES+MENUSIZE-300)-28, 255, 255, 255, 170);
|
||||
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
|
||||
drawrect(vid_buf, 200, (YRES+MENUSIZE-150)-18, 50, 18, 255, 255, 255, 255);
|
||||
@ -3899,7 +3865,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -3993,9 +3959,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
if (active && http_async_req_status(http))
|
||||
{
|
||||
@ -4367,7 +4331,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
||||
//Prevent those mouse clicks being passed down.
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -5200,9 +5164,7 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
|
||||
}
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
ed.focus = 1;
|
||||
|
||||
memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE);
|
||||
@ -5403,9 +5365,7 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE);
|
||||
render_parts(vid_buf);
|
||||
@ -5431,13 +5391,7 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
|
||||
box_G.x = XRES - 254 + 40;
|
||||
box_B.x = XRES - 254 + 75;
|
||||
}
|
||||
if (zoom_en && mx>=zoom_wx && my>=zoom_wy //change mouse position while it is in a zoom window
|
||||
&& mx<(zoom_wx+ZFACTOR*ZSIZE)
|
||||
&& my<(zoom_wy+ZFACTOR*ZSIZE))
|
||||
{
|
||||
mx = (((mx-zoom_wx)/ZFACTOR)+zoom_x);
|
||||
my = (((my-zoom_wy)/ZFACTOR)+zoom_y);
|
||||
}
|
||||
mouse_coords_window_to_sim(&mx, &my, mx, my);//change mouse position while it is in a zoom window
|
||||
|
||||
drawrect(vid_buf, -1, -1, XRES+1, YRES+1, 220, 220, 220, 255);
|
||||
drawrect(vid_buf, -1, -1, XRES+2, YRES+2, 70, 70, 70, 255);
|
||||
@ -6020,7 +5974,7 @@ int save_filename_ui(pixel *vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -6033,9 +5987,7 @@ int save_filename_ui(pixel *vid_buf)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, xsize+4, ysize+4);
|
||||
drawrect(vid_buf, x0, y0, xsize, ysize, 192, 192, 192, 255);
|
||||
@ -6120,7 +6072,7 @@ int save_filename_ui(pixel *vid_buf)
|
||||
savefin:
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -6165,7 +6117,7 @@ void catalogue_ui(pixel * vid_buf)
|
||||
cssave = csave = saves;
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -6173,9 +6125,7 @@ void catalogue_ui(pixel * vid_buf)
|
||||
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
sprintf(savetext, "Found %d save%s", rescount, rescount==1?"":"s");
|
||||
clearrect(vid_buf, x0-2, y0-2, xsize+4, ysize+4);
|
||||
clearrect(vid_buf2, x0-2, y0-2, xsize+4, ysize+4);
|
||||
@ -6352,7 +6302,7 @@ void catalogue_ui(pixel * vid_buf)
|
||||
openfin:
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -6511,7 +6461,7 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -6519,9 +6469,7 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
memcpy(vid_buf, o_vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE);
|
||||
render_parts(vid_buf);
|
||||
@ -6676,7 +6624,7 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -6753,7 +6701,7 @@ void simulation_ui(pixel * vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
@ -6761,9 +6709,7 @@ void simulation_ui(pixel * vid_buf)
|
||||
while (!sdl_poll())
|
||||
{
|
||||
bq = b;
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
mx /= sdl_scale;
|
||||
my /= sdl_scale;
|
||||
b = mouse_get_state(&mx, &my);
|
||||
|
||||
clearrect(vid_buf, x0-2, y0-2, xsize+4, ysize+4);
|
||||
drawrect(vid_buf, x0, y0, xsize, ysize, 192, 192, 192, 255);
|
||||
@ -6856,8 +6802,36 @@ void simulation_ui(pixel * vid_buf)
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
b = mouse_get_state(&mx, &my);
|
||||
if (!b)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Uint8 mouse_get_state(int *x, int *y)
|
||||
{
|
||||
//Wrapper around SDL_GetMouseState to divide by sdl_scale
|
||||
Uint8 sdl_b;
|
||||
int sdl_x, sdl_y;
|
||||
sdl_b = SDL_GetMouseState(&sdl_x, &sdl_y);
|
||||
*x = sdl_x/sdl_scale;
|
||||
*y = sdl_y/sdl_scale;
|
||||
return sdl_b;
|
||||
}
|
||||
|
||||
void mouse_coords_window_to_sim(int *sim_x, int *sim_y, int window_x, int window_y)
|
||||
{
|
||||
//Change mouse coords to take zoom window into account
|
||||
if (zoom_en && window_x>=zoom_wx && window_y>=zoom_wy
|
||||
&& window_x<(zoom_wx+ZFACTOR*ZSIZE)
|
||||
&& window_y<(zoom_wy+ZFACTOR*ZSIZE))
|
||||
{
|
||||
*sim_x = (((window_x-zoom_wx)/ZFACTOR)+zoom_x);
|
||||
*sim_y = (((window_y-zoom_wy)/ZFACTOR)+zoom_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
*sim_x = window_x;
|
||||
*sim_y = window_y;
|
||||
}
|
||||
}
|
||||
|
100
src/main.c
100
src/main.c
@ -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();
|
||||
|
Reference in New Issue
Block a user