#include "files.h"
#include "events.h"
#include "screens.h"
+#include "tape.h"
#define DEBUG_ANIM_DELAY 0
struct GraphicInfo graphic_info;
struct GraphicInfo control_info;
+ boolean class_playfield;
+
int viewport_x;
int viewport_y;
int viewport_width;
else
frame = gfx.anim_random_frame % num_frames;
}
+ else if (mode & ANIM_LEVEL_NR) // play frames by level number
+ {
+ int level_pos = level_nr - leveldir_current->first_level;
+
+ frame = level_pos % num_frames;
+ }
else if (mode & (ANIM_CE_VALUE | ANIM_CE_SCORE | ANIM_CE_DELAY))
{
frame = sync_frame % num_frames;
return compare_result;
}
+static boolean isPausedOnPlayfield(struct GlobalAnimPartControlInfo *part)
+{
+ // only pause playfield animations when playing
+ if (game_status != GAME_MODE_PLAYING)
+ return FALSE;
+
+ // do not pause animations when game ended (and engine is running)
+ if (checkGameEnded())
+ return FALSE;
+
+ // only pause animations on playfield
+ if (!part->class_playfield)
+ return FALSE;
+
+ // only pause animations when engine is paused or request dialog is open(ing)
+ if (!tape.pausing && !game.request_active_or_moving)
+ return FALSE;
+
+ return TRUE;
+}
+
static void InitToonControls(void)
{
int mode_nr_toons = GAME_MODE_PSEUDO_TOONS;
if (part->drawing_stage != drawing_stage)
continue;
+ // if game is paused, also pause playfield animations
+ if (isPausedOnPlayfield(part))
+ part->initial_anim_sync_frame++;
+
sync_frame = anim_sync_frame - part->initial_anim_sync_frame;
// re-initialize random animation frame after animation delay
part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_1;
+ part->class_playfield = FALSE;
+
if (part->control_info.class == get_hash_from_key("window") ||
part->control_info.class == get_hash_from_key("border"))
{
viewport_y = REAL_SY;
viewport_width = FULL_SXSIZE;
viewport_height = FULL_SYSIZE;
+
+ part->class_playfield = TRUE;
}
if (viewport_x != part->viewport_x ||
return ((part->control_info.style & STYLE_PASSTHROUGH) ? FALSE : TRUE);
}
+static void SetGlobalAnimPartTileXY(struct GlobalAnimPartControlInfo *part)
+{
+ // calculate playfield position (with scrolling) for related CE tile
+ // (do not use FX/FY, which are incorrect during envelope requests)
+ int FX0 = 2 * TILEX_VAR; // same as FX during DRAW_TO_FIELDBUFFER
+ int FY0 = 2 * TILEY_VAR; // same as FY during DRAW_TO_FIELDBUFFER
+ int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos);
+ int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos);
+ int sx = FX0 + SCREENX(part->tile_x) * TILEX_VAR;
+ int sy = FY0 + SCREENY(part->tile_y) * TILEY_VAR;
+ int cx = SX - REAL_SX;
+ int cy = SY - REAL_SY;
+ int x = sx - fx + cx;
+ int y = sy - fy + cy;
+
+ part->tile_xoffset += part->step_xoffset;
+ part->tile_yoffset += part->step_yoffset;
+
+ part->x = x + part->tile_xoffset;
+ part->y = y + part->tile_yoffset;
+}
+
static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part,
boolean *click_consumed,
boolean *any_event_action,
part2->tile_xoffset = c->x;
part2->tile_yoffset = c->y;
+ // set resulting animation position relative to CE tile position
+ // (but only for ".init_event", not ".anim_event" type events)
+ if (part2->init_event_state)
+ SetGlobalAnimPartTileXY(part2);
+
// restart animation (by using current sync frame)
part2->initial_anim_sync_frame = anim_sync_frame;
}
struct GraphicInfo *c = &part->control_info;
boolean viewport_changed = SetGlobalAnimPart_Viewport(part);
+ // if game is paused, also pause playfield animations
+ if (isPausedOnPlayfield(part))
+ return state;
+
if (viewport_changed)
state |= ANIM_STATE_RESTART;
if (c->position == POS_CE)
{
- // calculate playfield position (with scrolling) for related CE tile
- // (do not use FX/FY, which are incorrect during envelope requests)
- int FX0 = 2 * TILEX_VAR; // same as FX during DRAW_TO_FIELDBUFFER
- int FY0 = 2 * TILEY_VAR; // same as FY during DRAW_TO_FIELDBUFFER
- int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos);
- int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos);
- int sx = FX0 + SCREENX(part->tile_x) * TILEX_VAR;
- int sy = FY0 + SCREENY(part->tile_y) * TILEY_VAR;
- int cx = SX - REAL_SX;
- int cy = SY - REAL_SY;
- int x = sx - fx + cx;
- int y = sy - fy + cy;
-
- part->tile_xoffset += part->step_xoffset;
- part->tile_yoffset += part->step_yoffset;
-
- part->x = x + part->tile_xoffset;
- part->y = y + part->tile_yoffset;
+ SetGlobalAnimPartTileXY(part);
}
else
{