mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 11:19:51 +02:00
Line snapping (hold down Alt when drawing a line)
Specific element select changed to Ctrl+Alt
This commit is contained in:
committed by
Simon Robertshaw
parent
726acc96a0
commit
1be79e581d
2
README
2
README
@@ -70,7 +70,7 @@ Ctrl + Mouse scroll Change vertical brush size
|
||||
Shift + Mouse scroll Change horizontal brush size
|
||||
Shift + Ctrl + R Horizontal mirror for selected area
|
||||
Ctrl + R Rotate selected area counterclockwise
|
||||
Shift + Left Alt Select subject for Specific Element erase
|
||||
Ctrl + Left Alt Select subject for Specific Element erase
|
||||
Ctrl + = Reset Electricity
|
||||
|
||||
|
||||
|
@@ -1923,7 +1923,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255);
|
||||
h = n;
|
||||
}
|
||||
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
|
||||
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
|
||||
h = n;
|
||||
@@ -1960,7 +1960,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255);
|
||||
h = n;
|
||||
}
|
||||
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
|
||||
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
|
||||
h = n;
|
||||
@@ -1994,7 +1994,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255);
|
||||
h = n;
|
||||
}
|
||||
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
|
||||
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
|
||||
h = n;
|
||||
@@ -2065,7 +2065,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 55, 55, 255);
|
||||
h = n;
|
||||
}
|
||||
if (!bq && mx>=x+32-xoff && mx<x+58-xoff && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
|
||||
if (!bq && mx>=x+32-xoff && mx<x+58-xoff && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255);
|
||||
h = n;
|
||||
@@ -2086,7 +2086,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
}
|
||||
}
|
||||
if (!bq && mx>=((XRES+BARSIZE)-16) ) //highlight menu section
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))
|
||||
if (i>=0&&i<SC_TOTAL)
|
||||
SEC = i;
|
||||
|
||||
@@ -2110,7 +2110,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
//h has the value of the element it is over, and -1 if not over an element
|
||||
if (b==1&&h==-1)
|
||||
{
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0)
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL) && SEC>=0)
|
||||
{
|
||||
SLALT = -1;
|
||||
SEC2 = SEC;
|
||||
@@ -2118,7 +2118,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
}
|
||||
if (b==1&&h!=-1)
|
||||
{
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))
|
||||
{
|
||||
SLALT = h;
|
||||
SEC2 = -1;
|
||||
@@ -2130,7 +2130,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
}
|
||||
if (b==4&&h==-1)
|
||||
{
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT) && SEC>=0)
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL) && SEC>=0)
|
||||
{
|
||||
SLALT = -1;
|
||||
SEC2 = SEC;
|
||||
@@ -2138,7 +2138,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
|
||||
}
|
||||
if (b==4&&h!=-1)
|
||||
{
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))
|
||||
if (sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))
|
||||
{
|
||||
SLALT = h;
|
||||
SEC2 = -1;
|
||||
@@ -5010,7 +5010,7 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
|
||||
}
|
||||
else //first click
|
||||
{
|
||||
if ((sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL|KMOD_LALT)))
|
||||
if ((sdl_mod & (KMOD_SHIFT)) && !(sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
lx = mx;
|
||||
ly = my;
|
||||
@@ -5018,7 +5018,7 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
|
||||
lm = 1;//line
|
||||
}
|
||||
//start box tool
|
||||
else if ((sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) && !(sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)))
|
||||
else if ((sdl_mod & (KMOD_CTRL)) && !(sdl_mod & (KMOD_SHIFT|KMOD_ALT)))
|
||||
{
|
||||
lx = mx;
|
||||
ly = my;
|
||||
@@ -5026,7 +5026,7 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
|
||||
lm = 2;//box
|
||||
}
|
||||
//sample tool
|
||||
else if (((sdl_mod & (KMOD_LALT|KMOD_RALT)) && !(sdl_mod & (KMOD_SHIFT))) || b==SDL_BUTTON_MIDDLE)
|
||||
else if (((sdl_mod & (KMOD_ALT)) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) || b==SDL_BUTTON_MIDDLE)
|
||||
{
|
||||
if (my>=0 && my<YRES && mx>=0 && mx<XRES)
|
||||
{
|
||||
|
36
src/main.c
36
src/main.c
@@ -1561,7 +1561,7 @@ int main(int argc, char *argv[])
|
||||
int vs = 0;
|
||||
#endif
|
||||
int wavelength_gfx = 0;
|
||||
int x, y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty;
|
||||
int x, y, line_x, line_y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty;
|
||||
int da = 0, dae = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2;
|
||||
float nfvx, nfvy;
|
||||
int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0;
|
||||
@@ -3024,11 +3024,23 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (lm == 1)//line tool
|
||||
{
|
||||
xor_line(lx, ly, x, y, vid_buf);
|
||||
if (sdl_mod & KMOD_ALT)
|
||||
{
|
||||
float snap_angle = floor(atan2(y-ly, x-lx)/(M_PI*0.25)+0.5)*M_PI*0.25;
|
||||
float line_mag = sqrtf(pow(x-lx,2)+pow(y-ly,2));
|
||||
line_x = (int)(line_mag*cos(snap_angle)+lx+0.5f);
|
||||
line_y = (int)(line_mag*sin(snap_angle)+ly+0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
line_x = x;
|
||||
line_y = y;
|
||||
}
|
||||
xor_line(lx, ly, line_x, line_y, vid_buf);
|
||||
if (c==WL_FAN+100 && lx>=0 && ly>=0 && lx<XRES && ly<YRES && bmap[ly/CELL][lx/CELL]==WL_FAN)
|
||||
{
|
||||
nfvx = (x-lx)*0.005f;
|
||||
nfvy = (y-ly)*0.005f;
|
||||
nfvx = (line_x-lx)*0.005f;
|
||||
nfvy = (line_y-ly)*0.005f;
|
||||
flood_parts(lx, ly, WL_FANHELPER, -1, WL_FAN);
|
||||
for (j=0; j<YRES/CELL; j++)
|
||||
for (i=0; i<XRES/CELL; i++)
|
||||
@@ -3045,8 +3057,8 @@ int main(int argc, char *argv[])
|
||||
for (i=-bsx; i<=bsx; i++)
|
||||
if (lx+i>=0 && ly+j>=0 && lx+i<XRES && ly+j<YRES && ((CURRENT_BRUSH==CIRCLE_BRUSH && pow(i,2)*pow(bsy,2)+pow(j,2)*pow(bsx,2)<=pow(bsx,2)*pow(bsy,2))||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=bsy*bsx)))
|
||||
{
|
||||
vx[(ly+j)/CELL][(lx+i)/CELL] += (x-lx)*0.002f;
|
||||
vy[(ly+j)/CELL][(lx+i)/CELL] += (y-ly)*0.002f;
|
||||
vx[(ly+j)/CELL][(lx+i)/CELL] += (line_x-lx)*0.002f;
|
||||
vy[(ly+j)/CELL][(lx+i)/CELL] += (line_y-ly)*0.002f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3080,7 +3092,7 @@ int main(int argc, char *argv[])
|
||||
else //it is the first click
|
||||
{
|
||||
//start line tool
|
||||
if ((sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL|KMOD_LALT)))
|
||||
if ((sdl_mod & (KMOD_SHIFT)) && !(sdl_mod & (KMOD_CTRL)))
|
||||
{
|
||||
lx = x;
|
||||
ly = y;
|
||||
@@ -3088,7 +3100,7 @@ int main(int argc, char *argv[])
|
||||
lm = 1;//line
|
||||
}
|
||||
//start box tool
|
||||
else if ((sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) && !(sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)))
|
||||
else if ((sdl_mod & (KMOD_CTRL)) && !(sdl_mod & (KMOD_SHIFT|KMOD_ALT)))
|
||||
{
|
||||
lx = x;
|
||||
ly = y;
|
||||
@@ -3096,7 +3108,7 @@ int main(int argc, char *argv[])
|
||||
lm = 2;//box
|
||||
}
|
||||
//flood fill
|
||||
else if ((sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)) && (sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LALT)))
|
||||
else if ((sdl_mod & (KMOD_CTRL)) && (sdl_mod & (KMOD_SHIFT)) && !(sdl_mod & (KMOD_ALT)))
|
||||
{
|
||||
if (sdl_mod & (KMOD_CAPS))
|
||||
c = 0;
|
||||
@@ -3110,7 +3122,7 @@ int main(int argc, char *argv[])
|
||||
lm = 0;
|
||||
}
|
||||
//sample
|
||||
else if (((sdl_mod & (KMOD_LALT|KMOD_RALT)) && !(sdl_mod & (KMOD_SHIFT))) || b==SDL_BUTTON_MIDDLE)
|
||||
else if (((sdl_mod & (KMOD_ALT)) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) || b==SDL_BUTTON_MIDDLE)
|
||||
{
|
||||
if (y>=0 && y<YRES && x>=0 && x<XRES)
|
||||
{
|
||||
@@ -3169,12 +3181,14 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
x /= sdl_scale;
|
||||
y /= sdl_scale;
|
||||
line_x /= sdl_scale;
|
||||
line_y /= sdl_scale;
|
||||
c = (lb&1) ? sl : sr;
|
||||
su = c;
|
||||
if (lm == 1)//line
|
||||
{
|
||||
if (c!=WL_FAN+100 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN)
|
||||
create_line(lx, ly, x, y, bsx, bsy, c);
|
||||
create_line(lx, ly, line_x, line_y, bsx, bsy, c);
|
||||
}
|
||||
else//box
|
||||
create_box(lx, ly, x, y, c);
|
||||
|
@@ -2641,7 +2641,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
||||
{
|
||||
i = ox;
|
||||
j = oy;
|
||||
if (((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| ((sdl_mod & (KMOD_CAPS)) && b!=WL_FANHELPER) ))
|
||||
if (((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))|| ((sdl_mod & (KMOD_CAPS)) && b!=WL_FANHELPER) ))
|
||||
{
|
||||
if (bmap[j][i]==SLALT-100)
|
||||
b = 0;
|
||||
@@ -2673,8 +2673,8 @@ int create_parts(int x, int y, int rx, int ry, int c)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//if SHIFT+ALT or CAPSLOCK is on, specific delete
|
||||
if (((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE)
|
||||
//if CTRL+ALT or CAPSLOCK is on, specific delete
|
||||
if (((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE)
|
||||
{
|
||||
if (rx==0&&ry==0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user