re-added file "RocksBusy.ilbm" (that was accidentally deleted)
[rocksndiamonds.git] / src / anim.c
index d81a0746edde6052861a2dfa1145b3a7c3c9f6ce..fbc88c351e5e33ca498db163bb57dde6117794a2 100644 (file)
@@ -14,6 +14,7 @@
 #include "anim.h"
 #include "main.h"
 #include "tools.h"
+#include "events.h"
 #include "screens.h"
 
 
@@ -916,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",
@@ -955,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;
@@ -1225,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 +1481,8 @@ static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part)
     return FALSE;
 
   boolean action_executed = (DoGadgetAction(anim_event_action) ||
-                            DoScreenAction(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)