anim_classes_last = ANIM_CLASS_NONE;
}
+static void SetGlobalAnimEventsForCustomElements(int list_pos)
+{
+ int num_events = GetGlobalAnimEventValueCount(list_pos);
+ int i;
+
+ for (i = 0; i < num_events; i++)
+ {
+ int event = GetGlobalAnimEventValue(list_pos, i);
+
+ if (event & ANIM_EVENT_CE_CHANGE)
+ {
+ int nr = (event >> ANIM_EVENT_CE_BIT) & 0xff;
+
+ if (nr >= 0 && nr < NUM_CUSTOM_ELEMENTS)
+ element_info[EL_CUSTOM_START + nr].has_anim_event = TRUE;
+ }
+ }
+}
+
+void InitGlobalAnimEventsForCustomElements(void)
+{
+ int m, a, p;
+ int control;
+
+ // custom element events for global animations only relevant while playing
+ m = GAME_MODE_PLAYING;
+
+ for (a = 0; a < NUM_GLOBAL_ANIMS; a++)
+ {
+ int ctrl_id = GLOBAL_ANIM_ID_CONTROL_FIRST + a;
+
+ control = global_anim_info[ctrl_id].graphic[GLOBAL_ANIM_ID_PART_BASE][m];
+
+ // if no base animation parameters defined, use default values
+ if (control == IMG_UNDEFINED)
+ control = IMG_INTERNAL_GLOBAL_ANIM_DEFAULT;
+
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].init_event);
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].anim_event);
+
+ for (p = 0; p < NUM_GLOBAL_ANIM_PARTS_ALL; p++)
+ {
+ control = global_anim_info[ctrl_id].graphic[p][m];
+
+ if (control == IMG_UNDEFINED)
+ continue;
+
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].init_event);
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].anim_event);
+ }
+ }
+}
+
void InitGlobalAnimations(void)
{
InitGlobalAnimControls();
viewport_width = part->graphic_info.width;
viewport_height = part->graphic_info.height;
- part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
+ part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_3;
// do not use global animation mouse pointer when reloading artwork
if (global.anim_status != GAME_MODE_LOADING)
if (music == MUS_UNDEFINED)
return;
+ char *anim_music = getMusicInfoEntryFilename(music);
+ char *curr_music = getCurrentlyPlayingMusicFilename();
+
+ // do not stop music if global anim music differs from current music
+ if (!strEqual(curr_music, anim_music))
+ return;
+
StopMusic();
#if 0
static boolean checkGlobalAnimEvent(int anim_event, int mask)
{
int mask_anim_only = mask & ~ANIM_EVENT_PART_MASK;
+ int mask_ce_only = mask & ~ANIM_EVENT_PAGE_MASK;
if (mask & ANIM_EVENT_ANY)
return (anim_event & ANIM_EVENT_ANY);
return (anim_event & ANIM_EVENT_SELF);
else if (mask & ANIM_EVENT_UNCLICK_ANY)
return (anim_event & ANIM_EVENT_UNCLICK_ANY);
+ else if (mask & ANIM_EVENT_CE_CHANGE)
+ return (anim_event == mask ||
+ anim_event == mask_ce_only);
else
return (anim_event == mask ||
anim_event == mask_anim_only);
return FALSE;
}
-static boolean isClickedPart(struct GlobalAnimPartControlInfo *part,
- int mx, int my, boolean clicked)
+static boolean isInsidePartStacked(struct GlobalAnimPartControlInfo *part,
+ int mx, int my)
{
struct GraphicInfo *g = &part->graphic_info;
+ struct GraphicInfo *c = &part->control_info;
int part_x = part->viewport_x + part->x;
int part_y = part->viewport_y + part->y;
int part_width = g->width;
int part_height = g->height;
+ int x, y;
+
+ for (y = 0; y < c->stacked_yfactor; y++)
+ {
+ for (x = 0; x < c->stacked_xfactor; x++)
+ {
+ int part_stacked_x = part_x + x * (part_width + c->stacked_xoffset);
+ int part_stacked_y = part_y + y * (part_height + c->stacked_yoffset);
+
+ if (mx >= part_stacked_x &&
+ mx < part_stacked_x + part_width &&
+ my >= part_stacked_y &&
+ my < part_stacked_y + part_height)
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+static boolean isClickedPart(struct GlobalAnimPartControlInfo *part,
+ int mx, int my, boolean clicked)
+{
// check if mouse click was detected at all
if (!clicked)
return FALSE;
- // check if mouse click is inside the animation part's viewport
+ // check if mouse click is outside the animation part's viewport
if (mx < part->viewport_x ||
mx >= part->viewport_x + part->viewport_width ||
my < part->viewport_y ||
my >= part->viewport_y + part->viewport_height)
return FALSE;
- // check if mouse click is inside the animation part's graphic
- if (mx < part_x ||
- mx >= part_x + part_width ||
- my < part_y ||
- my >= part_y + part_height)
- return FALSE;
+ // check if mouse click is inside the animation part's (stacked) graphic
+ if (isInsidePartStacked(part, mx, my))
+ return TRUE;
- return TRUE;
+ return FALSE;
}
static boolean clickBlocked(struct GlobalAnimPartControlInfo *part)
}
}
+static void InitGlobalAnim_Triggered_ByCustomElement(int nr, int page)
+{
+ struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[GAME_MODE_PLAYING];
+
+ int event_value = ANIM_EVENT_CE_CHANGE;
+ int event_bits = (nr << ANIM_EVENT_CE_BIT) | (page << ANIM_EVENT_PAGE_BIT);
+ int mask = event_value | event_bits;
+ int anim2_nr;
+
+ for (anim2_nr = 0; anim2_nr < ctrl->num_anims; anim2_nr++)
+ {
+ struct GlobalAnimMainControlInfo *anim2 = &ctrl->anim[anim2_nr];
+ int part2_nr;
+
+ for (part2_nr = 0; part2_nr < anim2->num_parts_all; part2_nr++)
+ {
+ struct GlobalAnimPartControlInfo *part2 = &anim2->part[part2_nr];
+
+ if (!(part2->state & ANIM_STATE_RUNNING))
+ continue;
+
+ if (isClickablePart(part2, mask))
+ {
+ part2->triggered = TRUE;
+
+#if 0
+ Debug("anim:InitGlobalAnim_Triggered_ByCustomElement",
+ "%d.%d TRIGGERED BY CE %d", anim2_nr, part2_nr, nr + 1);
+#endif
+ }
+ }
+ }
+}
+
static void HandleGlobalAnimDelay(struct GlobalAnimPartControlInfo *part,
int delay_type, char *info_text)
{
part->init_event_state)
{
if (part->initial_anim_sync_frame > 0)
- part->initial_anim_sync_frame -= part->init_delay_counter - 1;
+ {
+ if (part->init_delay_counter > 0)
+ part->initial_anim_sync_frame -= part->init_delay_counter - 1;
+ else
+ part->initial_anim_sync_frame = anim_sync_frame;
+ }
part->init_delay_counter = 1;
part->init_event_state = FALSE;
InitGlobalAnim_Clicked(-1, -1, ANIM_CLICKED_RESET);
}
+void RestartGlobalAnimsByStatus(int status)
+{
+ int anim_status_last = global.anim_status;
+
+ global.anim_status = status;
+
+ // force restarting global animations by changed global animation status
+ SDLRedrawWindow();
+
+ global.anim_status = anim_status_last;
+}
+
boolean HandleGlobalAnimClicks(int mx, int my, int button, boolean force_click)
{
static boolean click_consumed = FALSE;
{
return anim_sync_frame;
}
+
+void HandleGlobalAnimEventByElementChange(int element, int page)
+{
+ if (!IS_CUSTOM_ELEMENT(element))
+ return;
+
+ // custom element stored as 0 to 255, change page stored as 1 to 32
+ InitGlobalAnim_Triggered_ByCustomElement(element - EL_CUSTOM_START, page + 1);
+}