X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fanim.c;h=fbc88c351e5e33ca498db163bb57dde6117794a2;hp=de1c40bff53c07c41cd9f4119c4cedfdcb1aef01;hb=6cf34a189f4a3707c9131652621dd67731f14f6b;hpb=70fe541d68f18a22eb3bd134f128c0d56b885701 diff --git a/src/anim.c b/src/anim.c index de1c40bf..fbc88c35 100644 --- a/src/anim.c +++ b/src/anim.c @@ -14,6 +14,8 @@ #include "anim.h" #include "main.h" #include "tools.h" +#include "events.h" +#include "screens.h" /* values for global toon animation definition */ @@ -915,7 +917,10 @@ static void PlayGlobalAnimMusic(struct GlobalAnimPartControlInfo *part) if (!setup.sound_music) return; - PlayMusic(music); + if (IS_LOOP_MUSIC(music)) + PlayMusicLoop(music); + else + PlayMusic(music); #if 0 printf("::: PLAY MUSIC %d.%d.%d: %d\n", @@ -954,6 +959,28 @@ static void StopGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part) StopGlobalAnimMusic(part); } +static void PlayGlobalAnimSoundIfLoop(struct GlobalAnimPartControlInfo *part) +{ + // when drawing animations to fading buffer, do not play sounds + if (drawing_to_fading_buffer) + return; + + // loop sounds only expire when playing + if (game_status != GAME_MODE_PLAYING) + return; + + // check if any sound is defined for this animation part + if (part->sound == SND_UNDEFINED) + return; + + // normal (non-loop) sounds do not expire when playing + if (!IS_LOOP_SOUND(part->sound)) + return; + + // prevent expiring loop sounds when playing + PlayGlobalAnimSound(part); +} + static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask) { struct GraphicInfo *c = &part->control_info; @@ -1003,10 +1030,8 @@ static boolean isClickedPart(struct GlobalAnimPartControlInfo *part, return TRUE; } -static boolean setPartClicked(struct GlobalAnimPartControlInfo *part) +static boolean clickConsumed(struct GlobalAnimPartControlInfo *part) { - part->clicked = TRUE; - return (part->control_info.style & STYLE_PASSTHROUGH ? FALSE : TRUE); } @@ -1226,6 +1251,9 @@ int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, int state) return ANIM_STATE_WAITING; } + // special case to prevent expiring loop sounds when playing + PlayGlobalAnimSoundIfLoop(part); + if (!DelayReachedExt(&part->step_delay, part->step_delay_value, anim_sync_frame)) return ANIM_STATE_RUNNING; @@ -1452,7 +1480,15 @@ static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part) if (anim_event_action == -1) return FALSE; - return DoGadgetAction(anim_event_action); + boolean action_executed = (DoGadgetAction(anim_event_action) || + DoScreenAction(anim_event_action) || + DoKeysymAction(anim_event_action)); + + // check if further actions are allowed to be executed + if (part->control_info.style & STYLE_MULTIPLE_ACTIONS) + return FALSE; + + return action_executed; } static void InitGlobalAnim_Clickable() @@ -1518,7 +1554,10 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked) // always handle "any" click events (clicking anywhere on screen) ... if (isClickablePart(part, ANIM_EVENT_ANY)) - anything_clicked = setPartClicked(part); + { + part->clicked = TRUE; + anything_clicked = clickConsumed(part); + } // ... but only handle the first (topmost) clickable animation if (any_part_clicked) @@ -1535,10 +1574,14 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked) if (!any_event_action && DoGlobalAnim_EventAction(part)) any_event_action = TRUE; - any_part_clicked = TRUE; + // determine if mouse clicks should be blocked from other animations + any_part_clicked = clickConsumed(part); if (isClickablePart(part, ANIM_EVENT_SELF)) - anything_clicked = setPartClicked(part); + { + part->clicked = TRUE; + anything_clicked = clickConsumed(part); + } // check if this click is defined to trigger other animations int gic_anim_nr = part->old_anim_nr + 1; // X as in "anim_X" @@ -1564,7 +1607,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked) if (isClickablePart(part2, mask)) { - setPartClicked(part2); + part2->clicked = TRUE; + anything_clicked = clickConsumed(part); // click was on "part"! #if 0 printf("::: %d.%d TRIGGER CLICKED [%d]\n", anim2_nr, part2_nr, @@ -1595,7 +1639,7 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked) } } - return anything_clicked; + return (anything_clicked || any_event_action); } static void ResetGlobalAnim_Clickable()