From: Holger Schemel Date: Mon, 2 Oct 2023 22:09:03 +0000 (+0200) Subject: added pausing global animations on playfield if game engine is paused X-Git-Tag: 4.3.7.0~14 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fd4817380a5fba31a5745366b2f223f98ac4c169;p=rocksndiamonds.git added pausing global animations on playfield if game engine is paused --- diff --git a/src/anim.c b/src/anim.c index 5e3a896e..060bb60e 100644 --- a/src/anim.c +++ b/src/anim.c @@ -17,6 +17,7 @@ #include "files.h" #include "events.h" #include "screens.h" +#include "tape.h" #define DEBUG_ANIM_DELAY 0 @@ -114,6 +115,8 @@ struct GlobalAnimPartControlInfo struct GraphicInfo graphic_info; struct GraphicInfo control_info; + boolean class_playfield; + int viewport_x; int viewport_y; int viewport_width; @@ -372,6 +375,27 @@ static int compareGlobalAnimMainControlInfo(const void *obj1, const void *obj2) return compare_result; } +static boolean isPausedOnPlayfield(struct GlobalAnimPartControlInfo *part) +{ + // only pause playfield animations when playing + if (game_status != GAME_MODE_PLAYING) + return FALSE; + + // do not pause animations when game ended (and engine is running) + if (checkGameEnded()) + return FALSE; + + // only pause animations on playfield + if (!part->class_playfield) + return FALSE; + + // only pause animations when engine is paused or request dialog is open(ing) + if (!tape.pausing && !game.request_active_or_moving) + return FALSE; + + return TRUE; +} + static void InitToonControls(void) { int mode_nr_toons = GAME_MODE_PSEUDO_TOONS; @@ -921,6 +945,10 @@ static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage) if (part->drawing_stage != drawing_stage) continue; + // if game is paused, also pause playfield animations + if (isPausedOnPlayfield(part)) + part->initial_anim_sync_frame++; + sync_frame = anim_sync_frame - part->initial_anim_sync_frame; // re-initialize random animation frame after animation delay @@ -994,6 +1022,8 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_1; + part->class_playfield = FALSE; + if (part->control_info.class == get_hash_from_key("window") || part->control_info.class == get_hash_from_key("border")) { @@ -1055,6 +1085,8 @@ static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part viewport_y = REAL_SY; viewport_width = FULL_SXSIZE; viewport_height = FULL_SYSIZE; + + part->class_playfield = TRUE; } if (viewport_x != part->viewport_x || @@ -1465,6 +1497,10 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, struct GraphicInfo *c = &part->control_info; boolean viewport_changed = SetGlobalAnimPart_Viewport(part); + // if game is paused, also pause playfield animations + if (isPausedOnPlayfield(part)) + return state; + if (viewport_changed) state |= ANIM_STATE_RESTART;