From 4be294f9d518dcacd0a54dc718e35c15c7c75c33 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 22 Apr 2019 10:41:25 +0200 Subject: [PATCH] fixed handling global animation click events When handling global animation click events, it may happen that more than one click event occurs within the same game frame (especially when doing a click by tapping on a touch pad or screen, which may lead to a "press" and "release" event within the same game frame). Before, only the first click event was correctly handled (as the event was not directly handled, but stored and processed later in the screen redraw phase, when global animations are handled), while all following events (that occurred within the same game frame) are usually lost if they should be processed for the next part of the animation (which is not active before the first event was processed). Example: Global animation for a button that will be shown as "pressed" after handling a "click" event and that will be shown as "unpressed" again after handling a "release" event. If the "click" and "release" events occur within the same game frame, the global animation still is in the "unpressed" animation part when the "release" event is handled, so it will be ignored and the button will stay in the "pressed" state. To fix this buggy behavior, click (and release) events are now handled immediately after they occur (instead of processing them in the screen redraw phase), which results in changing the animation's active part directly after the event occured, so the next event can be processed by the next part of the animation. --- src/anim.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/anim.c b/src/anim.c index be6c98f6..d226d5cd 100644 --- a/src/anim.c +++ b/src/anim.c @@ -230,6 +230,8 @@ static int anim_classes_last = ANIM_CLASS_NONE; static boolean drawing_to_fading_buffer = FALSE; +static boolean handle_click = FALSE; + // ============================================================================ // generic animation frame calculation @@ -1198,6 +1200,9 @@ static void HandleGlobalAnimEvent(struct GlobalAnimPartControlInfo *part, static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, int state) { + if (handle_click && !part->clicked) + return state; + struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[part->mode_nr]; struct GlobalAnimMainControlInfo *anim = &ctrl->anim[part->anim_nr]; struct GraphicInfo *g = &part->graphic_info; @@ -1828,6 +1833,15 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event) } } + if (anything_clicked) + { + handle_click = TRUE; + + HandleGlobalAnim(ANIM_CONTINUE, game_status); + + handle_click = FALSE; + } + return (anything_clicked || any_event_action); } -- 2.34.1