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);
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);
+ return (anim_event == mask ||
+ anim_event == mask_ce_only);
else
return (anim_event == mask ||
anim_event == mask_anim_only);
}
}
-static void InitGlobalAnim_Triggered_ByCustomElement(int nr)
+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 mask = event_value | (nr << ANIM_EVENT_CE_BIT);
+ 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++)
return anim_sync_frame;
}
-void HandleGlobalAnimEventByElementChange(int element)
+void HandleGlobalAnimEventByElementChange(int element, int page)
{
if (!IS_CUSTOM_ELEMENT(element))
return;
- InitGlobalAnim_Triggered_ByCustomElement(element - EL_CUSTOM_START);
+ // custom element stored as 0 to 255, change page stored as 1 to 32
+ InitGlobalAnim_Triggered_ByCustomElement(element - EL_CUSTOM_START, page + 1);
}
void RestartGlobalAnimsByStatus(int);
boolean HandleGlobalAnimClicks(int, int, int, boolean);
-void HandleGlobalAnimEventByElementChange(int);
+void HandleGlobalAnimEventByElementChange(int, int);
int getGlobalAnimSyncFrame(void);
static int get_anim_parameter_value_ce(char *s)
{
char *s_ptr = s;
- char *pattern = "ce_change:custom_";
- int pattern_len = strlen(pattern);
- char *matching_char = strstr(s_ptr, pattern);
+ char *pattern_1 = "ce_change:custom_";
+ char *pattern_2 = ".page_";
+ int pattern_1_len = strlen(pattern_1);
+ char *matching_char = strstr(s_ptr, pattern_1);
int result = ANIM_EVENT_NONE;
if (matching_char == NULL)
result = ANIM_EVENT_CE_CHANGE;
- s_ptr = matching_char + pattern_len;
+ s_ptr = matching_char + pattern_1_len;
- // check for custom element number ("custom_X" or "custom_XX" or "custom_XXX")
+ // check for custom element number ("custom_X", "custom_XX" or "custom_XXX")
if (*s_ptr >= '0' && *s_ptr <= '9')
{
int gic_ce_nr = (*s_ptr++ - '0');
if (gic_ce_nr < 1 || gic_ce_nr > NUM_CUSTOM_ELEMENTS)
return ANIM_EVENT_NONE;
- // store internal CE number (0 to 255, not "custom_1" to "custom_256")
+ // custom element stored as 0 to 255
gic_ce_nr--;
result |= gic_ce_nr << ANIM_EVENT_CE_BIT;
return ANIM_EVENT_NONE;
}
+ // check for change page number ("page_X" or "page_XX") (optional)
+ if (strPrefix(s_ptr, pattern_2))
+ {
+ s_ptr += strlen(pattern_2);
+
+ if (*s_ptr >= '0' && *s_ptr <= '9')
+ {
+ int gic_page_nr = (*s_ptr++ - '0');
+
+ if (*s_ptr >= '0' && *s_ptr <= '9')
+ gic_page_nr = 10 * gic_page_nr + (*s_ptr++ - '0');
+
+ if (gic_page_nr < 1 || gic_page_nr > MAX_CHANGE_PAGES)
+ return ANIM_EVENT_NONE;
+
+ // change page stored as 1 to 32 (0 means "all change pages")
+
+ result |= gic_page_nr << ANIM_EVENT_PAGE_BIT;
+ }
+ else
+ {
+ // invalid animation part number specified
+
+ return ANIM_EVENT_NONE;
+ }
+ }
+
// discard result if next character is neither delimiter nor whitespace
if (!(*s_ptr == ',' || *s_ptr == '\0' ||
*s_ptr == ' ' || *s_ptr == '\t'))
ChangeCount[x][y]++; // count number of changes in the same frame
if (ei->has_anim_event)
- HandleGlobalAnimEventByElementChange(element);
+ HandleGlobalAnimEventByElementChange(element, page);
if (change->explode)
{
// event mask: bits 0-15
// CE number: bits 16-23
// anim number: bits 16-23
+// page number: bits 24-31
// part number: bits 24-31
#define ANIM_EVENT_CE_BIT 16
#define ANIM_EVENT_ANIM_BIT 16
+#define ANIM_EVENT_PAGE_BIT 24
#define ANIM_EVENT_PART_BIT 24
#define ANIM_EVENT_CE_MASK (0xff << ANIM_EVENT_CE_BIT)
#define ANIM_EVENT_ANIM_MASK (0xff << ANIM_EVENT_ANIM_BIT)
+#define ANIM_EVENT_PAGE_MASK (0xff << ANIM_EVENT_PAGE_BIT)
#define ANIM_EVENT_PART_MASK (0xff << ANIM_EVENT_PART_BIT)
#define ANIM_EVENT_DEFAULT ANIM_EVENT_NONE