From 1be79e581d31f1c40051f916128ecbce64f80022 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Tue, 12 Jul 2011 16:35:55 +0800 Subject: [PATCH] Line snapping (hold down Alt when drawing a line) Specific element select changed to Ctrl+Alt --- README | 2 +- src/interface.c | 24 ++++++++++++------------ src/main.c | 36 +++++++++++++++++++++++++----------- src/powder.c | 6 +++--- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/README b/README index c9174be44..27a6f7ab6 100644 --- a/README +++ b/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 diff --git a/src/interface.c b/src/interface.c index 64a899163..3f14e7f7c 100644 --- a/src/interface.c +++ b/src/interface.c @@ -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=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + if (!bq && mx>=x+32 && mx=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=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + if (!bq && mx>=x+32 && mx=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=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))) + if (!bq && mx>=x+32 && mx=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=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_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=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=0 && mx=0 && ly>=0 && lx=0 && ly+j>=0 && lx+i=0 && y=0 && x=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); diff --git a/src/powder.c b/src/powder.c index e1457c770..2a72fee64 100644 --- a/src/powder.c +++ b/src/powder.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) {