From: Holger Schemel Date: Mon, 7 Mar 2016 22:27:38 +0000 (+0100) Subject: fixed screen specific global animations to stop when fading screens X-Git-Tag: 4.0.0.0-rc1~58 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ea925ed1065e3211c36c9bb2a56a5dbe760c208d;p=rocksndiamonds.git fixed screen specific global animations to stop when fading screens --- diff --git a/src/cartoons.c b/src/cartoons.c index 0352e4f8..4797420c 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -405,14 +405,19 @@ void InitGlobalAnimations() void DrawGlobalAnimExt(int drawing_stage) { - int anim_classes = game_mode_anim_classes[global.anim_status_next]; int mode_nr; - int i; - // start or stop global animations by change of game mode - // (special handling of animations for "current screen" and "all screens") if (global.anim_status != anim_status_last) { + boolean before_fading = (global.anim_status == GAME_MODE_PSEUDO_FADING); + boolean after_fading = (anim_status_last == GAME_MODE_PSEUDO_FADING); + int anim_classes_next = game_mode_anim_classes[global.anim_status_next]; + int i; + + // ---------- part 1 ------------------------------------------------------ + // start or stop global animations by change of game mode + // (special handling of animations for "current screen" and "all screens") + // stop animations for last screen HandleGlobalAnim(ANIM_STOP, anim_status_last); @@ -423,27 +428,30 @@ void DrawGlobalAnimExt(int drawing_stage) if (anim_status_last == GAME_MODE_LOADING) HandleGlobalAnim(ANIM_START, GAME_MODE_DEFAULT); - anim_status_last = global.anim_status; - } + // ---------- part 2 ------------------------------------------------------ + // start or stop global animations by change of animation class + // (generic handling of animations for "class of screens") - // start or stop global animations by change of animation class - // (generic handling of animations for "class of screens") - if (anim_classes != anim_classes_last) - { for (i = 0; i < NUM_ANIM_CLASSES; i++) { int anim_class_check = (1 << i); int anim_class_game_mode = anim_class_game_modes[i]; int anim_class_last = anim_classes_last & anim_class_check; - int anim_class = anim_classes & anim_class_check; + int anim_class_next = anim_classes_next & anim_class_check; - if (anim_class_last && !anim_class) + // stop animations for changed screen class before fading to new screen + if (before_fading && anim_class_last && !anim_class_next) HandleGlobalAnim(ANIM_STOP, anim_class_game_mode); - else if (!anim_class_last && anim_class) + + // start animations for changed screen class after fading to new screen + if (after_fading && !anim_class_last && anim_class_next) HandleGlobalAnim(ANIM_START, anim_class_game_mode); } - anim_classes_last = anim_classes; + if (after_fading) + anim_classes_last = anim_classes_next; + + anim_status_last = global.anim_status; } if (!setup.toons || global.anim_status == GAME_MODE_LOADING) diff --git a/src/tools.c b/src/tools.c index 4a524360..5bd15699 100644 --- a/src/tools.c +++ b/src/tools.c @@ -628,6 +628,20 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type) redraw_mask &= ~fade_mask; } +static void SetAnimStatus_BeforeFadingOut() +{ + global.anim_status = GAME_MODE_PSEUDO_FADING; +} + +static void SetAnimStatus_AfterFadingIn() +{ + global.anim_status = global.anim_status_next; + + // force update of global animation status in case of rapid screen changes + redraw_mask = REDRAW_ALL; + BackToFront(); +} + void FadeIn(int fade_mask) { #if 1 @@ -644,12 +658,12 @@ void FadeIn(int fade_mask) FADE_SXSIZE = FULL_SXSIZE; FADE_SYSIZE = FULL_SYSIZE; - global.anim_status = global.anim_status_next; + SetAnimStatus_AfterFadingIn(); } void FadeOut(int fade_mask) { - global.anim_status = GAME_MODE_PSEUDO_FADING; + SetAnimStatus_BeforeFadingOut(); #if 0 DrawMaskedBorder(REDRAW_ALL);