From: Holger Schemel Date: Tue, 16 Feb 2021 22:14:07 +0000 (+0100) Subject: added support for left, middle or right mouse button for CE change events X-Git-Tag: 4.2.3.0~9 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=19b66a27a5959f35c14f5c28b9b4645e89888159;p=rocksndiamonds.git added support for left, middle or right mouse button for CE change events --- diff --git a/src/game.c b/src/game.c index b1498dc8..48f5e7f1 100644 --- a/src/game.c +++ b/src/game.c @@ -1075,6 +1075,8 @@ static boolean CheckTriggeredElementChangeExt(int, int, int, int, int,int,int); CheckTriggeredElementChangeExt(x, y, e, ev, CH_PLAYER_ANY, s, -1) #define CheckTriggeredElementChangeByPage(x, y, e, ev, p) \ CheckTriggeredElementChangeExt(x,y,e,ev, CH_PLAYER_ANY, CH_SIDE_ANY, p) +#define CheckTriggeredElementChangeByMouse(x, y, e, ev, s) \ + CheckTriggeredElementChangeExt(x, y, e, ev, CH_PLAYER_ANY, s, -1) static boolean CheckElementChangeExt(int, int, int, int, int, int, int); #define CheckElementChange(x, y, e, te, ev) \ @@ -1083,6 +1085,8 @@ static boolean CheckElementChangeExt(int, int, int, int, int, int, int); CheckElementChangeExt(x, y, e, EL_EMPTY, ev, p, s) #define CheckElementChangeBySide(x, y, e, te, ev, s) \ CheckElementChangeExt(x, y, e, te, ev, CH_PLAYER_ANY, s) +#define CheckElementChangeByMouse(x, y, e, ev, s) \ + CheckElementChangeExt(x, y, e, EL_UNDEFINED, ev, CH_PLAYER_ANY, s) static void PlayLevelSound(int, int, int); static void PlayLevelSoundNearest(int, int, int); @@ -12141,6 +12145,7 @@ void GameActions_RND(void) if (mouse_action.button) { int new_button = (mouse_action.button && mouse_action_last.button == 0); + int ch_button = CH_SIDE_FROM_BUTTON(mouse_action.button); x = mouse_action.lx; y = mouse_action.ly; @@ -12148,12 +12153,14 @@ void GameActions_RND(void) if (new_button) { - CheckElementChange(x, y, element, EL_UNDEFINED, CE_CLICKED_BY_MOUSE); - CheckTriggeredElementChange(x, y, element, CE_MOUSE_CLICKED_ON_X); + CheckElementChangeByMouse(x, y, element, CE_CLICKED_BY_MOUSE, ch_button); + CheckTriggeredElementChangeByMouse(x, y, element, CE_MOUSE_CLICKED_ON_X, + ch_button); } - CheckElementChange(x, y, element, EL_UNDEFINED, CE_PRESSED_BY_MOUSE); - CheckTriggeredElementChange(x, y, element, CE_MOUSE_PRESSED_ON_X); + CheckElementChangeByMouse(x, y, element, CE_PRESSED_BY_MOUSE, ch_button); + CheckTriggeredElementChangeByMouse(x, y, element, CE_MOUSE_PRESSED_ON_X, + ch_button); } SCAN_PLAYFIELD(x, y) diff --git a/src/main.h b/src/main.h index 9c669ca6..72283693 100644 --- a/src/main.h +++ b/src/main.h @@ -331,6 +331,11 @@ #define CH_SIDE_TOP_BOTTOM MV_VERTICAL #define CH_SIDE_ANY MV_ANY_DIRECTION +#define CH_SIDE_FROM_BUTTON(b) ((b) == MB_LEFTBUTTON ? CH_SIDE_LEFT : \ + (b) == MB_RIGHTBUTTON ? CH_SIDE_RIGHT : \ + (b) == MB_MIDDLEBUTTON ? CH_SIDE_TOP_BOTTOM : \ + CH_SIDE_NONE) + // values for change player for custom elements #define CH_PLAYER_NONE PLAYER_BITS_NONE #define CH_PLAYER_1 PLAYER_BITS_1