1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
12 #include "libgame/libgame.h"
22 // values for global toon animation definition
23 #define NUM_GLOBAL_TOON_ANIMS 1
24 #define NUM_GLOBAL_TOON_PARTS MAX_NUM_TOONS
26 // values for global animation definition (including toons)
27 #define NUM_GLOBAL_ANIMS_AND_TOONS (NUM_GLOBAL_ANIMS + \
28 NUM_GLOBAL_TOON_ANIMS)
29 #define NUM_GLOBAL_ANIM_PARTS_AND_TOONS MAX(NUM_GLOBAL_ANIM_PARTS_ALL, \
30 NUM_GLOBAL_TOON_PARTS)
32 #define ANIM_CLASS_BIT_TITLE_INITIAL 0
33 #define ANIM_CLASS_BIT_TITLE 1
34 #define ANIM_CLASS_BIT_MAIN 2
35 #define ANIM_CLASS_BIT_SCORES 3
36 #define ANIM_CLASS_BIT_SUBMENU 4
37 #define ANIM_CLASS_BIT_MENU 5
38 #define ANIM_CLASS_BIT_TOONS 6
39 #define ANIM_CLASS_BIT_NO_TITLE 7
41 #define NUM_ANIM_CLASSES 8
43 #define ANIM_CLASS_NONE 0
44 #define ANIM_CLASS_TITLE_INITIAL (1 << ANIM_CLASS_BIT_TITLE_INITIAL)
45 #define ANIM_CLASS_TITLE (1 << ANIM_CLASS_BIT_TITLE)
46 #define ANIM_CLASS_MAIN (1 << ANIM_CLASS_BIT_MAIN)
47 #define ANIM_CLASS_SCORES (1 << ANIM_CLASS_BIT_SCORES)
48 #define ANIM_CLASS_SUBMENU (1 << ANIM_CLASS_BIT_SUBMENU)
49 #define ANIM_CLASS_MENU (1 << ANIM_CLASS_BIT_MENU)
50 #define ANIM_CLASS_TOONS (1 << ANIM_CLASS_BIT_TOONS)
51 #define ANIM_CLASS_NO_TITLE (1 << ANIM_CLASS_BIT_NO_TITLE)
53 #define ANIM_CLASS_TOONS_SCORES (ANIM_CLASS_TOONS | \
57 #define ANIM_CLASS_TOONS_MENU_MAIN (ANIM_CLASS_TOONS | \
62 #define ANIM_CLASS_TOONS_MENU_SUBMENU (ANIM_CLASS_TOONS | \
64 ANIM_CLASS_SUBMENU | \
67 // values for global animation states
68 #define ANIM_STATE_INACTIVE 0
69 #define ANIM_STATE_RESTART (1 << 0)
70 #define ANIM_STATE_WAITING (1 << 1)
71 #define ANIM_STATE_RUNNING (1 << 2)
73 // values for global animation control
74 #define ANIM_NO_ACTION 0
76 #define ANIM_CONTINUE 2
80 struct GlobalAnimPartControlInfo
82 int old_nr; // position before mapping animation parts linearly
83 int old_anim_nr; // position before mapping animations linearly
89 boolean is_base; // animation part is base/main/default animation part
95 struct GraphicInfo graphic_info;
96 struct GraphicInfo control_info;
104 int step_xoffset, step_yoffset;
106 unsigned int initial_anim_sync_frame;
107 unsigned int step_delay, step_delay_value;
109 int init_delay_counter;
110 int anim_delay_counter;
111 int post_delay_counter;
113 boolean init_event_state;
114 boolean anim_event_state;
123 int last_anim_status;
126 struct GlobalAnimMainControlInfo
128 struct GlobalAnimPartControlInfo base;
129 struct GlobalAnimPartControlInfo part[NUM_GLOBAL_ANIM_PARTS_AND_TOONS];
134 struct GraphicInfo control_info;
136 int num_parts; // number of animation parts, but without base part
137 int num_parts_all; // number of animation parts, including base part
141 boolean has_base; // animation has base/main/default animation part
145 int init_delay_counter;
149 int last_state, last_active_part_nr;
152 struct GlobalAnimControlInfo
154 struct GlobalAnimMainControlInfo anim[NUM_GLOBAL_ANIMS_AND_TOONS];
160 struct GameModeAnimClass
164 } game_mode_anim_classes_list[] =
166 { GAME_MODE_TITLE_INITIAL_1, ANIM_CLASS_TITLE_INITIAL },
167 { GAME_MODE_TITLE_INITIAL_2, ANIM_CLASS_TITLE_INITIAL },
168 { GAME_MODE_TITLE_INITIAL_3, ANIM_CLASS_TITLE_INITIAL },
169 { GAME_MODE_TITLE_INITIAL_4, ANIM_CLASS_TITLE_INITIAL },
170 { GAME_MODE_TITLE_INITIAL_5, ANIM_CLASS_TITLE_INITIAL },
171 { GAME_MODE_TITLE_1, ANIM_CLASS_TITLE },
172 { GAME_MODE_TITLE_2, ANIM_CLASS_TITLE },
173 { GAME_MODE_TITLE_3, ANIM_CLASS_TITLE },
174 { GAME_MODE_TITLE_4, ANIM_CLASS_TITLE },
175 { GAME_MODE_TITLE_5, ANIM_CLASS_TITLE },
176 { GAME_MODE_LEVELS, ANIM_CLASS_TOONS_MENU_SUBMENU },
177 { GAME_MODE_LEVELNR, ANIM_CLASS_TOONS_MENU_SUBMENU },
178 { GAME_MODE_INFO, ANIM_CLASS_TOONS_MENU_SUBMENU },
179 { GAME_MODE_SETUP, ANIM_CLASS_TOONS_MENU_SUBMENU },
180 { GAME_MODE_PSEUDO_MAINONLY, ANIM_CLASS_TOONS_MENU_MAIN },
181 { GAME_MODE_PSEUDO_TYPENAME, ANIM_CLASS_TOONS_MENU_MAIN },
182 { GAME_MODE_PSEUDO_SCORESOLD, ANIM_CLASS_TOONS_SCORES },
183 { GAME_MODE_PSEUDO_SCORESNEW, ANIM_CLASS_TOONS_SCORES },
184 { GAME_MODE_EDITOR, ANIM_CLASS_NO_TITLE },
185 { GAME_MODE_PLAYING, ANIM_CLASS_NO_TITLE },
190 struct AnimClassGameMode
194 } anim_class_game_modes_list[] =
196 { ANIM_CLASS_BIT_TITLE_INITIAL, GAME_MODE_TITLE_INITIAL },
197 { ANIM_CLASS_BIT_TITLE, GAME_MODE_TITLE },
198 { ANIM_CLASS_BIT_MAIN, GAME_MODE_MAIN },
199 { ANIM_CLASS_BIT_SCORES, GAME_MODE_SCORES },
200 { ANIM_CLASS_BIT_SUBMENU, GAME_MODE_PSEUDO_SUBMENU },
201 { ANIM_CLASS_BIT_MENU, GAME_MODE_PSEUDO_MENU },
202 { ANIM_CLASS_BIT_TOONS, GAME_MODE_PSEUDO_TOONS },
203 { ANIM_CLASS_BIT_NO_TITLE, GAME_MODE_PSEUDO_NO_TITLE },
208 // forward declaration for internal use
209 static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *);
210 static void HandleGlobalAnim(int, int);
211 static void DoAnimationExt(void);
212 static void ResetGlobalAnim_Clickable(void);
213 static void ResetGlobalAnim_Clicked(void);
215 static struct GlobalAnimControlInfo global_anim_ctrl[NUM_GAME_MODES];
217 static unsigned int anim_sync_frame = 0;
219 static int game_mode_anim_classes[NUM_GAME_MODES];
220 static int anim_class_game_modes[NUM_ANIM_CLASSES];
222 static int anim_status_last_before_fading = GAME_MODE_DEFAULT;
223 static int anim_status_last = GAME_MODE_DEFAULT;
224 static int anim_classes_last = ANIM_CLASS_NONE;
226 static boolean drawing_to_fading_buffer = FALSE;
229 // ============================================================================
230 // generic animation frame calculation
231 // ============================================================================
233 int getAnimationFrame(int num_frames, int delay, int mode, int start_frame,
238 sync_frame += start_frame * delay;
240 if (mode & ANIM_LOOP) // looping animation
242 frame = (sync_frame % (delay * num_frames)) / delay;
244 else if (mode & ANIM_LINEAR) // linear (non-looping) animation
246 frame = sync_frame / delay;
248 if (frame > num_frames - 1)
249 frame = num_frames - 1;
251 else if (mode & ANIM_PINGPONG) // oscillate (border frames once)
253 int max_anim_frames = (num_frames > 1 ? 2 * num_frames - 2 : 1);
255 frame = (sync_frame % (delay * max_anim_frames)) / delay;
256 frame = (frame < num_frames ? frame : max_anim_frames - frame);
258 else if (mode & ANIM_PINGPONG2) // oscillate (border frames twice)
260 int max_anim_frames = 2 * num_frames;
262 frame = (sync_frame % (delay * max_anim_frames)) / delay;
263 frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
265 else if (mode & ANIM_RANDOM) // play frames in random order
267 // note: expect different frames for the same delay cycle!
269 if (gfx.anim_random_frame < 0)
270 frame = GetSimpleRandom(num_frames);
272 frame = gfx.anim_random_frame % num_frames;
274 else if (mode & (ANIM_CE_VALUE | ANIM_CE_SCORE | ANIM_CE_DELAY))
276 frame = sync_frame % num_frames;
279 if (mode & ANIM_REVERSE) // use reverse animation direction
280 frame = num_frames - frame - 1;
286 // ============================================================================
287 // global animation functions
288 // ============================================================================
290 static int getGlobalAnimationPart(struct GlobalAnimMainControlInfo *anim)
292 struct GraphicInfo *c = &anim->control_info;
293 int last_anim_random_frame = gfx.anim_random_frame;
296 gfx.anim_random_frame = -1; // (use simple, ad-hoc random numbers)
298 part_nr = getAnimationFrame(anim->num_parts, 1,
299 c->anim_mode, c->anim_start_frame,
302 gfx.anim_random_frame = last_anim_random_frame;
307 static int compareGlobalAnimPartControlInfo(const void *obj1, const void *obj2)
309 const struct GlobalAnimPartControlInfo *o1 =
310 (struct GlobalAnimPartControlInfo *)obj1;
311 const struct GlobalAnimPartControlInfo *o2 =
312 (struct GlobalAnimPartControlInfo *)obj2;
315 if (o1->control_info.draw_order != o2->control_info.draw_order)
316 compare_result = o1->control_info.draw_order - o2->control_info.draw_order;
318 compare_result = o1->nr - o2->nr;
320 return compare_result;
323 static int compareGlobalAnimMainControlInfo(const void *obj1, const void *obj2)
325 const struct GlobalAnimMainControlInfo *o1 =
326 (struct GlobalAnimMainControlInfo *)obj1;
327 const struct GlobalAnimMainControlInfo *o2 =
328 (struct GlobalAnimMainControlInfo *)obj2;
331 if (o1->control_info.draw_order != o2->control_info.draw_order)
332 compare_result = o1->control_info.draw_order - o2->control_info.draw_order;
334 compare_result = o1->nr - o2->nr;
336 return compare_result;
339 static void InitToonControls(void)
341 int mode_nr_toons = GAME_MODE_PSEUDO_TOONS;
342 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr_toons];
343 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[ctrl->num_anims];
344 int mode_nr, anim_nr, part_nr;
345 int control = IMG_INTERNAL_GLOBAL_TOON_DEFAULT;
346 int num_toons = MAX_NUM_TOONS;
349 if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
350 num_toons = global.num_toons;
352 mode_nr = mode_nr_toons;
353 anim_nr = ctrl->num_anims;
356 anim->mode_nr = mode_nr;
357 anim->control_info = graphic_info[control];
360 anim->num_parts_all = 0;
361 anim->part_counter = 0;
362 anim->active_part_nr = 0;
364 anim->has_base = FALSE;
366 anim->last_x = POS_OFFSCREEN;
367 anim->last_y = POS_OFFSCREEN;
369 anim->init_delay_counter = 0;
371 anim->state = ANIM_STATE_INACTIVE;
375 for (i = 0; i < num_toons; i++)
377 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
378 int sound = SND_UNDEFINED;
379 int music = MUS_UNDEFINED;
380 int graphic = IMG_TOON_1 + i;
381 int control = graphic;
384 part->anim_nr = anim_nr;
385 part->mode_nr = mode_nr;
387 part->is_base = FALSE;
391 part->graphic = graphic;
393 part->graphic_info = graphic_info[graphic];
394 part->control_info = graphic_info[control];
396 part->graphic_info.anim_delay *= part->graphic_info.step_delay;
398 part->control_info.init_delay_fixed = 0;
399 part->control_info.init_delay_random = 150;
401 part->control_info.x = ARG_UNDEFINED_VALUE;
402 part->control_info.y = ARG_UNDEFINED_VALUE;
404 part->initial_anim_sync_frame = 0;
406 part->step_delay = 0;
407 part->step_delay_value = graphic_info[control].step_delay;
409 part->state = ANIM_STATE_INACTIVE;
410 part->last_anim_status = -1;
413 anim->num_parts_all++;
421 static void InitGlobalAnimControls(void)
424 int mode_nr, anim_nr, part_nr;
425 int sound, music, graphic, control;
429 for (m = 0; m < NUM_GAME_MODES; m++)
433 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
440 for (a = 0; a < NUM_GLOBAL_ANIMS; a++)
442 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
443 int ctrl_id = GLOBAL_ANIM_ID_CONTROL_FIRST + a;
445 control = global_anim_info[ctrl_id].graphic[GLOBAL_ANIM_ID_PART_BASE][m];
447 // if no base animation parameters defined, use default values
448 if (control == IMG_UNDEFINED)
449 control = IMG_INTERNAL_GLOBAL_ANIM_DEFAULT;
452 anim->mode_nr = mode_nr;
453 anim->control_info = graphic_info[control];
456 anim->num_parts_all = 0;
457 anim->part_counter = 0;
458 anim->active_part_nr = 0;
460 anim->has_base = FALSE;
462 anim->last_x = POS_OFFSCREEN;
463 anim->last_y = POS_OFFSCREEN;
465 anim->init_delay_counter = 0;
467 anim->state = ANIM_STATE_INACTIVE;
471 for (p = 0; p < NUM_GLOBAL_ANIM_PARTS_ALL; p++)
473 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
475 sound = global_anim_info[a].sound[p][m];
476 music = global_anim_info[a].music[p][m];
477 graphic = global_anim_info[a].graphic[p][m];
478 control = global_anim_info[ctrl_id].graphic[p][m];
480 if (graphic == IMG_UNDEFINED || graphic_info[graphic].bitmap == NULL ||
481 control == IMG_UNDEFINED)
485 printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n",
486 m, a, p, mode_nr, anim_nr, part_nr, control);
490 printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n",
491 m, a, p, mode_nr, anim_nr, part_nr, sound);
495 part->old_anim_nr = a;
498 part->anim_nr = anim_nr;
499 part->mode_nr = mode_nr;
503 part->graphic = graphic;
505 part->graphic_info = graphic_info[graphic];
506 part->control_info = graphic_info[control];
508 part->initial_anim_sync_frame = 0;
510 part->step_delay = 0;
511 part->step_delay_value = graphic_info[control].step_delay;
513 part->state = ANIM_STATE_INACTIVE;
514 part->last_anim_status = -1;
516 anim->num_parts_all++;
518 if (p < GLOBAL_ANIM_ID_PART_BASE)
520 part->is_base = FALSE;
527 part->is_base = TRUE;
530 anim->has_base = TRUE;
534 if (anim->num_parts > 0 || anim->has_base)
544 // sort all animations according to draw_order and animation number
545 for (m = 0; m < NUM_GAME_MODES; m++)
547 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[m];
549 // sort all main animations for this game mode
550 qsort(ctrl->anim, ctrl->num_anims,
551 sizeof(struct GlobalAnimMainControlInfo),
552 compareGlobalAnimMainControlInfo);
554 for (a = 0; a < ctrl->num_anims; a++)
556 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[a];
558 // sort all animation parts for this main animation
559 qsort(anim->part, anim->num_parts,
560 sizeof(struct GlobalAnimPartControlInfo),
561 compareGlobalAnimPartControlInfo);
565 for (i = 0; i < NUM_GAME_MODES; i++)
566 game_mode_anim_classes[i] = ANIM_CLASS_NONE;
567 for (i = 0; game_mode_anim_classes_list[i].game_mode != -1; i++)
568 game_mode_anim_classes[game_mode_anim_classes_list[i].game_mode] =
569 game_mode_anim_classes_list[i].class;
571 for (i = 0; i < NUM_ANIM_CLASSES; i++)
572 anim_class_game_modes[i] = GAME_MODE_DEFAULT;
573 for (i = 0; anim_class_game_modes_list[i].game_mode != -1; i++)
574 anim_class_game_modes[anim_class_game_modes_list[i].class_bit] =
575 anim_class_game_modes_list[i].game_mode;
577 anim_status_last_before_fading = GAME_MODE_LOADING;
578 anim_status_last = GAME_MODE_LOADING;
579 anim_classes_last = ANIM_CLASS_NONE;
582 void InitGlobalAnimations(void)
584 InitGlobalAnimControls();
587 static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage)
589 Bitmap *fade_bitmap =
590 (drawing_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source :
591 drawing_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL);
592 int game_mode_anim_action[NUM_GAME_MODES];
598 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_1 &&
599 drawing_target == DRAW_TO_SCREEN)
602 // always start with reliable default values (no animation actions)
603 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
604 game_mode_anim_action[mode_nr] = ANIM_NO_ACTION;
606 if (global.anim_status != anim_status_last)
608 boolean before_fading = (global.anim_status == GAME_MODE_PSEUDO_FADING);
609 boolean after_fading = (anim_status_last == GAME_MODE_PSEUDO_FADING);
610 int anim_classes_next = game_mode_anim_classes[global.anim_status_next];
613 if (drawing_target == DRAW_TO_FADE_TARGET)
616 // special case: changing from/to this screen is done without fading
617 if (global.anim_status == GAME_MODE_PSEUDO_TYPENAME ||
618 anim_status_last == GAME_MODE_PSEUDO_TYPENAME)
621 // ---------- part 1 ------------------------------------------------------
622 // start or stop global animations by change of game mode
623 // (special handling of animations for "current screen" and "all screens")
625 if (global.anim_status_next != anim_status_last_before_fading)
627 // stop animations for last screen before fading to new screen
628 game_mode_anim_action[anim_status_last] = ANIM_STOP;
630 // start animations for current screen after fading to new screen
631 game_mode_anim_action[global.anim_status] = ANIM_START;
634 // start animations for all screens after loading new artwork set
635 if (anim_status_last == GAME_MODE_LOADING)
636 game_mode_anim_action[GAME_MODE_DEFAULT] = ANIM_START;
638 // ---------- part 2 ------------------------------------------------------
639 // start or stop global animations by change of animation class
640 // (generic handling of animations for "class of screens")
642 for (i = 0; i < NUM_ANIM_CLASSES; i++)
644 int anim_class_check = (1 << i);
645 int anim_class_game_mode = anim_class_game_modes[i];
646 int anim_class_last = anim_classes_last & anim_class_check;
647 int anim_class_next = anim_classes_next & anim_class_check;
649 // stop animations for changed screen class before fading to new screen
650 if (before_fading && anim_class_last && !anim_class_next)
651 game_mode_anim_action[anim_class_game_mode] = ANIM_STOP;
653 // start animations for changed screen class after fading to new screen
654 if (after_fading && !anim_class_last && anim_class_next)
655 game_mode_anim_action[anim_class_game_mode] = ANIM_START;
658 if (drawing_target == DRAW_TO_SCREEN)
662 anim_classes_last = anim_classes_next;
663 anim_status_last_before_fading = global.anim_status;
666 anim_status_last = global.anim_status;
668 // start or stop animations determined to be started or stopped above
669 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
670 if (game_mode_anim_action[mode_nr] != ANIM_NO_ACTION)
671 HandleGlobalAnim(game_mode_anim_action[mode_nr], mode_nr);
673 else if (drawing_target == DRAW_TO_FADE_TARGET)
675 drawing_to_fading_buffer = TRUE;
677 // start animations determined to be (temporary) started above
678 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
679 if (game_mode_anim_action[mode_nr] == ANIM_START)
680 HandleGlobalAnim(ANIM_START, mode_nr);
684 if (global.anim_status == GAME_MODE_LOADING)
687 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
689 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
692 // when preparing source fading buffer, only draw animations to be stopped
693 if (drawing_target == DRAW_TO_FADE_SOURCE &&
694 game_mode_anim_action[mode_nr] != ANIM_STOP)
697 // when preparing target fading buffer, only draw animations to be started
698 if (drawing_target == DRAW_TO_FADE_TARGET &&
699 game_mode_anim_action[mode_nr] != ANIM_START)
703 if (mode_nr != GFX_SPECIAL_ARG_DEFAULT &&
704 mode_nr != game_status)
708 for (anim_nr = 0; anim_nr < ctrl->num_anims; anim_nr++)
710 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
711 struct GraphicInfo *c = &anim->control_info;
712 int part_first, part_last;
715 if (!(anim->state & ANIM_STATE_RUNNING))
718 part_first = part_last = anim->active_part_nr;
720 if (c->anim_mode & ANIM_ALL || anim->num_parts == 0)
722 int num_parts = anim->num_parts + (anim->has_base ? 1 : 0);
725 part_last = num_parts - 1;
728 for (part_nr = part_first; part_nr <= part_last; part_nr++)
730 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
731 struct GraphicInfo *g = &part->graphic_info;
734 int width = g->width;
735 int height = g->height;
742 void (*blit_bitmap)(Bitmap *, Bitmap *, int, int, int, int, int, int) =
743 (g->draw_masked ? BlitBitmapMasked : BlitBitmap);
744 void (*blit_screen)(Bitmap *, int, int, int, int, int, int) =
745 (g->draw_masked ? BlitToScreenMasked : BlitToScreen);
747 if (!(part->state & ANIM_STATE_RUNNING))
750 if (part->drawing_stage != drawing_stage)
759 else if (part->x > part->viewport_width - g->width)
760 width -= (part->x - (part->viewport_width - g->width));
768 else if (part->y > part->viewport_height - g->height)
769 height -= (part->y - (part->viewport_height - g->height));
771 if (width <= 0 || height <= 0)
774 dst_x += part->viewport_x;
775 dst_y += part->viewport_y;
777 sync_frame = anim_sync_frame - part->initial_anim_sync_frame;
778 frame = getAnimationFrame(g->anim_frames, g->anim_delay,
779 g->anim_mode, g->anim_start_frame,
782 getFixedGraphicSource(part->graphic, frame, &src_bitmap,
788 if (drawing_target == DRAW_TO_SCREEN)
789 blit_screen(src_bitmap, src_x, src_y, width, height,
792 blit_bitmap(src_bitmap, fade_bitmap, src_x, src_y, width, height,
798 if (drawing_target == DRAW_TO_FADE_TARGET)
800 // stop animations determined to be (temporary) started above
801 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
802 if (game_mode_anim_action[mode_nr] == ANIM_START)
803 HandleGlobalAnim(ANIM_STOP, mode_nr);
805 drawing_to_fading_buffer = FALSE;
809 void DrawGlobalAnimations(int drawing_target, int drawing_stage)
811 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_1)
812 ResetGlobalAnim_Clickable();
814 DrawGlobalAnimationsExt(drawing_target, drawing_stage);
816 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_2)
817 ResetGlobalAnim_Clicked();
820 static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part)
826 boolean changed = FALSE;
828 if (part->last_anim_status == global.anim_status)
831 part->last_anim_status = global.anim_status;
833 part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_1;
835 if (part->control_info.class == get_hash_from_key("window") ||
836 part->control_info.class == get_hash_from_key("border"))
840 viewport_width = WIN_XSIZE;
841 viewport_height = WIN_YSIZE;
843 part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
845 else if (part->control_info.class == get_hash_from_key("door_1"))
849 viewport_width = DXSIZE;
850 viewport_height = DYSIZE;
852 else if (part->control_info.class == get_hash_from_key("door_2"))
856 viewport_width = VXSIZE;
857 viewport_height = VYSIZE;
859 else // default: "playfield"
861 viewport_x = REAL_SX;
862 viewport_y = REAL_SY;
863 viewport_width = FULL_SXSIZE;
864 viewport_height = FULL_SYSIZE;
867 if (viewport_x != part->viewport_x ||
868 viewport_y != part->viewport_y ||
869 viewport_width != part->viewport_width ||
870 viewport_height != part->viewport_height)
872 part->viewport_x = viewport_x;
873 part->viewport_y = viewport_y;
874 part->viewport_width = viewport_width;
875 part->viewport_height = viewport_height;
883 static void PlayGlobalAnimSound(struct GlobalAnimPartControlInfo *part)
885 int sound = part->sound;
887 if (sound == SND_UNDEFINED)
890 if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
891 (!setup.sound_loops && IS_LOOP_SOUND(sound)))
894 // !!! TODO: ADD STEREO POSITION FOR MOVING ANIMATIONS !!!
895 if (IS_LOOP_SOUND(sound))
896 PlaySoundLoop(sound);
901 printf("::: PLAY SOUND %d.%d.%d: %d\n",
902 part->anim_nr, part->nr, part->mode_nr, sound);
906 static void StopGlobalAnimSound(struct GlobalAnimPartControlInfo *part)
908 int sound = part->sound;
910 if (sound == SND_UNDEFINED)
916 printf("::: STOP SOUND %d.%d.%d: %d\n",
917 part->anim_nr, part->nr, part->mode_nr, sound);
921 static void PlayGlobalAnimMusic(struct GlobalAnimPartControlInfo *part)
923 int music = part->music;
925 if (music == MUS_UNDEFINED)
928 if (!setup.sound_music)
931 if (IS_LOOP_MUSIC(music))
932 PlayMusicLoop(music);
937 printf("::: PLAY MUSIC %d.%d.%d: %d\n",
938 part->anim_nr, part->nr, part->mode_nr, music);
942 static void StopGlobalAnimMusic(struct GlobalAnimPartControlInfo *part)
944 int music = part->music;
946 if (music == MUS_UNDEFINED)
952 printf("::: STOP MUSIC %d.%d.%d: %d\n",
953 part->anim_nr, part->nr, part->mode_nr, music);
957 static void PlayGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part)
959 // when drawing animations to fading buffer, do not play sounds or music
960 if (drawing_to_fading_buffer)
963 PlayGlobalAnimSound(part);
964 PlayGlobalAnimMusic(part);
967 static void StopGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part)
969 StopGlobalAnimSound(part);
970 StopGlobalAnimMusic(part);
973 static void PlayGlobalAnimSoundIfLoop(struct GlobalAnimPartControlInfo *part)
975 // when drawing animations to fading buffer, do not play sounds
976 if (drawing_to_fading_buffer)
979 // loop sounds only expire when playing
980 if (game_status != GAME_MODE_PLAYING)
983 // check if any sound is defined for this animation part
984 if (part->sound == SND_UNDEFINED)
987 // normal (non-loop) sounds do not expire when playing
988 if (!IS_LOOP_SOUND(part->sound))
991 // prevent expiring loop sounds when playing
992 PlayGlobalAnimSound(part);
995 static boolean checkGlobalAnimEvent(int anim_event, int mask)
997 int mask_anim_only = mask & ~ANIM_EVENT_PART_MASK;
999 if (mask & ANIM_EVENT_ANY)
1000 return (anim_event & ANIM_EVENT_ANY);
1001 else if (mask & ANIM_EVENT_SELF)
1002 return (anim_event & ANIM_EVENT_SELF);
1004 return (anim_event == mask ||
1005 anim_event == mask_anim_only);
1008 static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask)
1010 struct GraphicInfo *c = &part->control_info;
1011 int num_init_events = GetGlobalAnimEventValueCount(c->init_event);
1012 int num_anim_events = GetGlobalAnimEventValueCount(c->anim_event);
1015 for (i = 0; i < num_init_events; i++)
1017 int init_event = GetGlobalAnimEventValue(c->init_event, i);
1019 if (checkGlobalAnimEvent(init_event, mask))
1023 for (i = 0; i < num_anim_events; i++)
1025 int anim_event = GetGlobalAnimEventValue(c->anim_event, i);
1027 if (checkGlobalAnimEvent(anim_event, mask))
1034 static boolean isClickedPart(struct GlobalAnimPartControlInfo *part,
1035 int mx, int my, boolean clicked)
1037 struct GraphicInfo *g = &part->graphic_info;
1038 int part_x = part->viewport_x + part->x;
1039 int part_y = part->viewport_y + part->y;
1040 int part_width = g->width;
1041 int part_height = g->height;
1043 // check if mouse click was detected at all
1047 // check if mouse click is inside the animation part's viewport
1048 if (mx < part->viewport_x ||
1049 mx >= part->viewport_x + part->viewport_width ||
1050 my < part->viewport_y ||
1051 my >= part->viewport_y + part->viewport_height)
1054 // check if mouse click is inside the animation part's graphic
1056 mx >= part_x + part_width ||
1058 my >= part_y + part_height)
1064 static boolean clickConsumed(struct GlobalAnimPartControlInfo *part)
1066 return (part->control_info.style & STYLE_PASSTHROUGH ? FALSE : TRUE);
1069 static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part,
1070 boolean *anything_clicked,
1071 boolean *any_event_action,
1074 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[part->mode_nr];
1076 int gic_anim_nr = part->old_anim_nr + 1; // X as in "anim_X"
1077 int gic_part_nr = part->old_nr + 1; // Y as in "part_Y"
1078 int mask = event_value | (gic_anim_nr << ANIM_EVENT_ANIM_BIT);
1081 mask |= gic_part_nr << ANIM_EVENT_PART_BIT;
1085 for (anim2_nr = 0; anim2_nr < ctrl->num_anims; anim2_nr++)
1087 struct GlobalAnimMainControlInfo *anim2 = &ctrl->anim[anim2_nr];
1090 for (part2_nr = 0; part2_nr < anim2->num_parts_all; part2_nr++)
1092 struct GlobalAnimPartControlInfo *part2 = &anim2->part[part2_nr];
1094 if (part2->state != ANIM_STATE_RUNNING)
1097 if (isClickablePart(part2, mask))
1099 part2->triggered = TRUE;
1100 *anything_clicked = clickConsumed(part); // click was on "part"!
1103 printf("::: %d.%d TRIGGER CLICKED [%d]\n", anim2_nr, part2_nr,
1104 part2->control_info.anim_event_action);
1107 // after executing event action, ignore any further actions
1108 if (!*any_event_action && DoGlobalAnim_EventAction(part2))
1109 *any_event_action = TRUE;
1113 struct GraphicInfo *c = &part2->control_info;
1115 printf("::: - %d.%d: 0x%08x, 0x%08x [0x%08x]",
1116 anim2_nr, part2_nr, c->init_event, c->anim_event, mask);
1118 if (isClickablePart(part2, mask))
1119 printf(" <--- TRIGGERED BY %d.%d",
1128 static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
1131 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[part->mode_nr];
1132 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[part->anim_nr];
1133 struct GraphicInfo *g = &part->graphic_info;
1134 struct GraphicInfo *c = &part->control_info;
1135 boolean viewport_changed = SetGlobalAnimPart_Viewport(part);
1137 if (viewport_changed)
1138 state |= ANIM_STATE_RESTART;
1140 if (state & ANIM_STATE_RESTART)
1142 // when drawing animations to fading buffer, only start fixed animations
1143 if (drawing_to_fading_buffer && (c->x == ARG_UNDEFINED_VALUE ||
1144 c->y == ARG_UNDEFINED_VALUE))
1145 return ANIM_STATE_INACTIVE;
1147 ResetDelayCounterExt(&part->step_delay, anim_sync_frame);
1149 part->init_delay_counter =
1150 (c->init_delay_fixed + GetSimpleRandom(c->init_delay_random));
1152 part->anim_delay_counter =
1153 (c->anim_delay_fixed + GetSimpleRandom(c->anim_delay_random));
1155 part->init_event_state = (c->init_event != ANIM_EVENT_UNDEFINED);
1156 part->anim_event_state = (c->anim_event != ANIM_EVENT_UNDEFINED);
1158 part->initial_anim_sync_frame =
1159 (g->anim_global_sync ? 0 : anim_sync_frame + part->init_delay_counter);
1161 if (c->direction & MV_HORIZONTAL)
1163 int pos_bottom = part->viewport_height - g->height;
1165 if (c->position == POS_TOP)
1167 else if (c->position == POS_UPPER)
1168 part->y = GetSimpleRandom(pos_bottom / 2);
1169 else if (c->position == POS_MIDDLE)
1170 part->y = pos_bottom / 2;
1171 else if (c->position == POS_LOWER)
1172 part->y = pos_bottom / 2 + GetSimpleRandom(pos_bottom / 2);
1173 else if (c->position == POS_BOTTOM)
1174 part->y = pos_bottom;
1176 part->y = GetSimpleRandom(pos_bottom);
1178 if (c->direction == MV_RIGHT)
1180 part->step_xoffset = c->step_offset;
1181 part->x = -g->width + part->step_xoffset;
1185 part->step_xoffset = -c->step_offset;
1186 part->x = part->viewport_width + part->step_xoffset;
1189 part->step_yoffset = 0;
1191 else if (c->direction & MV_VERTICAL)
1193 int pos_right = part->viewport_width - g->width;
1195 if (c->position == POS_LEFT)
1197 else if (c->position == POS_RIGHT)
1198 part->x = pos_right;
1200 part->x = GetSimpleRandom(pos_right);
1202 if (c->direction == MV_DOWN)
1204 part->step_yoffset = c->step_offset;
1205 part->y = -g->height + part->step_yoffset;
1209 part->step_yoffset = -c->step_offset;
1210 part->y = part->viewport_height + part->step_yoffset;
1213 part->step_xoffset = 0;
1220 part->step_xoffset = 0;
1221 part->step_yoffset = 0;
1224 if (c->x != ARG_UNDEFINED_VALUE)
1226 if (c->y != ARG_UNDEFINED_VALUE)
1229 if (c->position == POS_LAST &&
1230 anim->last_x > -g->width && anim->last_x < part->viewport_width &&
1231 anim->last_y > -g->height && anim->last_y < part->viewport_height)
1233 part->x = anim->last_x;
1234 part->y = anim->last_y;
1237 if (c->step_xoffset != ARG_UNDEFINED_VALUE)
1238 part->step_xoffset = c->step_xoffset;
1239 if (c->step_yoffset != ARG_UNDEFINED_VALUE)
1240 part->step_yoffset = c->step_yoffset;
1242 if (part->init_delay_counter == 0 &&
1243 !part->init_event_state)
1244 PlayGlobalAnimSoundAndMusic(part);
1247 if (part->clicked &&
1248 part->init_event_state)
1250 if (part->initial_anim_sync_frame > 0)
1251 part->initial_anim_sync_frame -= part->init_delay_counter - 1;
1253 part->init_delay_counter = 1;
1254 part->init_event_state = FALSE;
1256 part->clicked = FALSE;
1259 if (part->clicked &&
1260 part->anim_event_state)
1262 part->anim_delay_counter = 1;
1263 part->anim_event_state = FALSE;
1265 part->clicked = FALSE;
1268 if (part->init_delay_counter > 0)
1270 part->init_delay_counter--;
1272 if (part->init_delay_counter == 0)
1274 part->init_event_state = FALSE;
1276 PlayGlobalAnimSoundAndMusic(part);
1279 return ANIM_STATE_WAITING;
1282 if (part->init_event_state)
1283 return ANIM_STATE_WAITING;
1285 // animation part is now running/visible and therefore clickable
1286 part->clickable = TRUE;
1288 // check if moving animation has left the visible screen area
1289 if ((part->x <= -g->width && part->step_xoffset <= 0) ||
1290 (part->x >= part->viewport_width && part->step_xoffset >= 0) ||
1291 (part->y <= -g->height && part->step_yoffset <= 0) ||
1292 (part->y >= part->viewport_height && part->step_yoffset >= 0))
1294 // do not wait for "anim" events for off-screen animations
1295 part->anim_event_state = FALSE;
1297 // do not stop animation before "anim" or "post" counter are finished
1298 if (part->anim_delay_counter == 0 &&
1299 part->post_delay_counter == 0)
1301 StopGlobalAnimSoundAndMusic(part);
1303 part->post_delay_counter =
1304 (c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
1306 if (part->post_delay_counter > 0)
1307 return ANIM_STATE_RUNNING;
1309 // drawing last frame not needed here -- animation not visible anymore
1310 return ANIM_STATE_RESTART;
1314 if (part->anim_delay_counter > 0)
1316 part->anim_delay_counter--;
1318 if (part->anim_delay_counter == 0)
1320 part->anim_event_state = FALSE;
1322 StopGlobalAnimSoundAndMusic(part);
1324 part->post_delay_counter =
1325 (c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
1327 if (part->post_delay_counter > 0)
1328 return ANIM_STATE_RUNNING;
1330 // additional state "RUNNING" required to not skip drawing last frame
1331 return ANIM_STATE_RESTART | ANIM_STATE_RUNNING;
1335 if (part->post_delay_counter > 0)
1337 part->post_delay_counter--;
1339 if (part->post_delay_counter == 0)
1340 return ANIM_STATE_RESTART;
1342 return ANIM_STATE_WAITING;
1345 // special case to prevent expiring loop sounds when playing
1346 PlayGlobalAnimSoundIfLoop(part);
1348 if (!DelayReachedExt(&part->step_delay, part->step_delay_value,
1350 return ANIM_STATE_RUNNING;
1354 static unsigned int last_counter = -1;
1355 unsigned int counter = Counter();
1357 printf("::: NEXT ANIM PART [%d, %d]\n",
1358 anim_sync_frame, counter - last_counter);
1360 last_counter = counter;
1364 part->x += part->step_xoffset;
1365 part->y += part->step_yoffset;
1367 anim->last_x = part->x;
1368 anim->last_y = part->y;
1370 return ANIM_STATE_RUNNING;
1373 static void HandleGlobalAnim_Main(struct GlobalAnimMainControlInfo *anim,
1376 struct GlobalAnimPartControlInfo *part;
1377 struct GraphicInfo *c = &anim->control_info;
1378 int num_parts = anim->num_parts + (anim->has_base ? 1 : 0);
1379 int state, active_part_nr;
1383 printf("::: HandleGlobalAnim_Main: %d, %d => %d\n",
1384 anim->mode_nr, anim->nr, anim->num_parts);
1385 printf("::: %d, %d, %d\n", global.num_toons, setup.toons, num_toons);
1389 printf("::: %s(%d): %d, %d, %d [%d]\n",
1390 (action == ANIM_START ? "ANIM_START" :
1391 action == ANIM_CONTINUE ? "ANIM_CONTINUE" :
1392 action == ANIM_STOP ? "ANIM_STOP" : "(should not happen)"),
1394 anim->state & ANIM_STATE_RESTART,
1395 anim->state & ANIM_STATE_WAITING,
1396 anim->state & ANIM_STATE_RUNNING,
1403 anim->state = anim->last_state = ANIM_STATE_RESTART;
1404 anim->active_part_nr = anim->last_active_part_nr = 0;
1405 anim->part_counter = 0;
1410 if (anim->state == ANIM_STATE_INACTIVE)
1413 anim->state = anim->last_state;
1414 anim->active_part_nr = anim->last_active_part_nr;
1419 anim->state = ANIM_STATE_INACTIVE;
1421 for (i = 0; i < num_parts; i++)
1422 StopGlobalAnimSoundAndMusic(&anim->part[i]);
1430 if (c->anim_mode & ANIM_ALL || anim->num_parts == 0)
1433 printf("::: HandleGlobalAnim_Main: %d, %d => %d\n",
1434 anim->mode_nr, anim->nr, num_parts);
1437 for (i = 0; i < num_parts; i++)
1439 part = &anim->part[i];
1444 anim->state = ANIM_STATE_RUNNING;
1445 part->state = ANIM_STATE_RESTART;
1450 if (part->state == ANIM_STATE_INACTIVE)
1456 part->state = ANIM_STATE_INACTIVE;
1464 part->state = HandleGlobalAnim_Part(part, part->state);
1466 // when animation mode is "once", stop after animation was played once
1467 if (c->anim_mode & ANIM_ONCE &&
1468 part->state & ANIM_STATE_RESTART)
1469 part->state = ANIM_STATE_INACTIVE;
1472 anim->last_state = anim->state;
1473 anim->last_active_part_nr = anim->active_part_nr;
1478 if (anim->state & ANIM_STATE_RESTART) // directly after restart
1479 anim->active_part_nr = getGlobalAnimationPart(anim);
1481 part = &anim->part[anim->active_part_nr];
1483 // first set all animation parts to "inactive", ...
1484 for (i = 0; i < num_parts; i++)
1485 anim->part[i].state = ANIM_STATE_INACTIVE;
1487 // ... then set current animation parts to "running"
1488 part->state = ANIM_STATE_RUNNING;
1490 anim->state = HandleGlobalAnim_Part(part, anim->state);
1492 if (anim->state & ANIM_STATE_RESTART)
1493 anim->part_counter++;
1495 // when animation mode is "once", stop after all animations were played once
1496 if (c->anim_mode & ANIM_ONCE &&
1497 anim->part_counter == anim->num_parts)
1498 anim->state = ANIM_STATE_INACTIVE;
1500 state = anim->state;
1501 active_part_nr = anim->active_part_nr;
1503 // while the animation parts are pausing (waiting or inactive), play the base
1504 // (main) animation; this corresponds to the "boring player animation" logic
1505 // (!!! KLUDGE WARNING: I THINK THIS IS A MESS THAT SHOULD BE CLEANED UP !!!)
1508 if (anim->state == ANIM_STATE_WAITING ||
1509 anim->state == ANIM_STATE_INACTIVE)
1511 anim->active_part_nr = anim->num_parts; // part nr of base animation
1512 part = &anim->part[anim->active_part_nr];
1514 if (anim->state != anim->last_state)
1515 part->state = ANIM_STATE_RESTART;
1517 anim->state = ANIM_STATE_RUNNING;
1518 part->state = HandleGlobalAnim_Part(part, part->state);
1522 anim->last_state = state;
1523 anim->last_active_part_nr = active_part_nr;
1526 static void HandleGlobalAnim_Mode(struct GlobalAnimControlInfo *ctrl, int action)
1531 printf("::: HandleGlobalAnim_Mode: %d => %d\n",
1532 ctrl->nr, ctrl->num_anims);
1535 for (i = 0; i < ctrl->num_anims; i++)
1536 HandleGlobalAnim_Main(&ctrl->anim[i], action);
1539 static void HandleGlobalAnim(int action, int game_mode)
1542 printf("::: HandleGlobalAnim [mode == %d]\n", game_status);
1545 HandleGlobalAnim_Mode(&global_anim_ctrl[game_mode], action);
1548 static void DoAnimationExt(void)
1553 printf("::: DoAnimation [%d, %d]\n", anim_sync_frame, Counter());
1556 // global animations now synchronized with frame delay of screen update
1559 for (i = 0; i < NUM_GAME_MODES; i++)
1560 HandleGlobalAnim(ANIM_CONTINUE, i);
1563 // force screen redraw in next frame to continue drawing global animations
1564 redraw_mask = REDRAW_ALL;
1568 static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part)
1570 int anim_event_action = part->control_info.anim_event_action;
1572 if (anim_event_action == -1)
1575 boolean action_executed = (DoGadgetAction(anim_event_action) ||
1576 DoScreenAction(anim_event_action) ||
1577 DoKeysymAction(anim_event_action));
1579 // check if further actions are allowed to be executed
1580 if (part->control_info.style & STYLE_MULTIPLE_ACTIONS)
1583 return action_executed;
1586 static void InitGlobalAnim_Clickable(void)
1590 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
1592 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
1595 for (anim_nr = 0; anim_nr < ctrl->num_anims; anim_nr++)
1597 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
1600 for (part_nr = 0; part_nr < anim->num_parts_all; part_nr++)
1602 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
1604 if (part->triggered)
1605 part->clicked = TRUE;
1607 part->triggered = FALSE;
1608 part->clickable = FALSE;
1614 static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked)
1616 boolean anything_clicked = FALSE;
1617 boolean any_part_clicked = FALSE;
1618 boolean any_event_action = FALSE;
1621 // check game modes in reverse draw order (to stop when clicked)
1622 for (mode_nr = NUM_GAME_MODES - 1; mode_nr >= 0; mode_nr--)
1624 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
1627 // check animations in reverse draw order (to stop when clicked)
1628 for (anim_nr = ctrl->num_anims - 1; anim_nr >= 0; anim_nr--)
1630 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
1633 // check animation parts in reverse draw order (to stop when clicked)
1634 for (part_nr = anim->num_parts_all - 1; part_nr >= 0; part_nr--)
1636 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
1640 part->clicked = FALSE;
1645 if (!part->clickable)
1648 if (part->state != ANIM_STATE_RUNNING)
1651 // always handle "any" click events (clicking anywhere on screen) ...
1652 if (isClickablePart(part, ANIM_EVENT_ANY))
1654 part->clicked = TRUE;
1655 anything_clicked = clickConsumed(part);
1658 // ... but only handle the first (topmost) clickable animation
1659 if (any_part_clicked)
1662 if (isClickedPart(part, mx, my, clicked))
1665 printf("::: %d.%d CLICKED [%d]\n", anim_nr, part_nr,
1666 part->control_info.anim_event_action);
1669 // after executing event action, ignore any further actions
1670 if (!any_event_action && DoGlobalAnim_EventAction(part))
1671 any_event_action = TRUE;
1673 // determine if mouse clicks should be blocked from other animations
1674 any_part_clicked = clickConsumed(part);
1676 if (isClickablePart(part, ANIM_EVENT_SELF))
1678 part->clicked = TRUE;
1679 anything_clicked = clickConsumed(part);
1682 // check if this click is defined to trigger other animations
1683 InitGlobalAnim_Triggered(part, &anything_clicked, &any_event_action,
1690 return (anything_clicked || any_event_action);
1693 static void ResetGlobalAnim_Clickable(void)
1695 InitGlobalAnim_Clickable();
1698 static void ResetGlobalAnim_Clicked(void)
1700 InitGlobalAnim_Clicked(-1, -1, FALSE);
1703 boolean HandleGlobalAnimClicks(int mx, int my, int button)
1705 static boolean click_consumed = FALSE;
1706 static int last_button = 0;
1707 boolean press_event;
1708 boolean release_event;
1709 boolean click_consumed_current = click_consumed;
1711 // check if button state has changed since last invocation
1712 press_event = (button != 0 && last_button == 0);
1713 release_event = (button == 0 && last_button != 0);
1714 last_button = button;
1718 click_consumed = InitGlobalAnim_Clicked(mx, my, TRUE);
1719 click_consumed_current = click_consumed;
1723 click_consumed = FALSE;
1725 return click_consumed_current;