From: Holger Schemel Date: Sun, 23 Apr 2017 17:55:42 +0000 (+0200) Subject: added animation event by 'any' input (click anywhere, space, enter, escape) X-Git-Tag: 4.0.1.0~47 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=a00af4d54f7f23fe9ed4ae7e3244895c4acc0158 added animation event by 'any' input (click anywhere, space, enter, escape) --- diff --git a/src/anim.c b/src/anim.c index b566bddc..4a6d2db0 100644 --- a/src/anim.c +++ b/src/anim.c @@ -936,9 +936,14 @@ static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask) { struct GraphicInfo *c = &part->control_info; + boolean clickable_any = FALSE; boolean clickable_self = FALSE; boolean clickable_triggered = FALSE; + if (mask & ANIM_EVENT_CLICK_ANY) + clickable_any = (c->init_event & ANIM_EVENT_CLICK_ANY || + c->anim_event & ANIM_EVENT_CLICK_ANY); + if (mask & ANIM_EVENT_CLICK_SELF) clickable_self = (c->init_event & ANIM_EVENT_CLICK_SELF || c->anim_event & ANIM_EVENT_CLICK_SELF); @@ -946,7 +951,7 @@ static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask) clickable_triggered = (matchesAnimEventMask(c->init_event, mask) || matchesAnimEventMask(c->anim_event, mask)); - return (clickable_self || clickable_triggered); + return (clickable_any || clickable_self || clickable_triggered); } static boolean isClickedPart(struct GlobalAnimPartControlInfo *part, @@ -1452,8 +1457,13 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked) continue; } - if (part->clickable && - isClickedPart(part, mx, my, clicked)) + if (!part->clickable) + continue; + + if (isClickablePart(part, ANIM_EVENT_CLICK_ANY)) + any_part_clicked = part->clicked = TRUE; + + if (isClickedPart(part, mx, my, clicked)) { #if 0 printf("::: %d.%d CLICKED\n", anim_nr, part_nr); diff --git a/src/events.c b/src/events.c index 93b13550..6dbb1e71 100644 --- a/src/events.c +++ b/src/events.c @@ -1703,6 +1703,15 @@ void HandleKey(Key key, int key_status) return; } + if (HandleGlobalAnimClicks(-1, -1, (key == KSYM_space || + key == KSYM_Return || + key == KSYM_Escape))) + { + /* do not handle this key event anymore */ + if (key != KSYM_Escape) /* always allow ESC key to be handled */ + return; + } + if (game_status == GAME_MODE_PLAYING && AllPlayersGone && (key == KSYM_Return || key == setup.shortcut.toggle_pause)) { @@ -1957,6 +1966,12 @@ void HandleJoystick() int dx = (left ? -1 : right ? 1 : 0); int dy = (up ? -1 : down ? 1 : 0); + if (HandleGlobalAnimClicks(-1, -1, newbutton)) + { + /* do not handle this button event anymore */ + return; + } + switch (game_status) { case GAME_MODE_TITLE: diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 4c1f5683..470fc057 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -2859,6 +2859,9 @@ int get_parameter_value(char *value_raw, char *suffix, int type) { result = ANIM_EVENT_DEFAULT; + if (string_has_parameter(value, "any")) + result |= ANIM_EVENT_CLICK_ANY; + if (string_has_parameter(value, "click")) result |= ANIM_EVENT_CLICK_SELF; diff --git a/src/libgame/system.h b/src/libgame/system.h index 406a6f36..b214ba75 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -342,6 +342,7 @@ #define ANIM_EVENT_CLICK_PART_7 (1 << 14) #define ANIM_EVENT_CLICK_PART_8 (1 << 15) #define ANIM_EVENT_CLICK_SELF (1 << 16) +#define ANIM_EVENT_CLICK_ANY (1 << 17) #define ANIM_EVENT_CLICK_ANIM_ALL (ANIM_EVENT_CLICK_ANIM_1 | \ ANIM_EVENT_CLICK_ANIM_2 | \