60 animated(
const std::chrono::milliseconds& start_time = std::chrono::milliseconds{0});
67 const std::chrono::milliseconds& start_time = std::chrono::milliseconds{0},
void update_animation_timers(double acceleration=1.0)
Updates both animation timelines.
std::chrono::steady_clock::time_point get_current_animation_tick(bool uses_acceleration)
Gets the current time point for animations.
bool is_static() const
True when the single-unchanging-frame optimization is enabled: need_update() will always report false...
std::chrono::milliseconds get_time_in_current_frame() const
How far into its own duration the current frame is, clamped to [0, duration].
const T & get_first_frame() const
const T & get_frame(std::size_t n) const
animated(const anim_description &cfg, const std::chrono::milliseconds &start_time=std::chrono::milliseconds{0}, bool force_change=false)
Creates an animation with its frame list already built from cfg.
std::vector< frame > frames_
bool uses_acceleration() const
Which timeline this animation currently reads; see set_uses_acceleration().
void resume_animation()
Shifts the timeline forward by the time spent paused, then continues playback.
std::chrono::milliseconds get_begin_time() const
Animation-time offset of the first frame's start.
std::chrono::milliseconds get_current_frame_begin_time() const
Animation-time offset where the current frame starts.
virtual ~animated()=default
std::chrono::milliseconds max_animation_time_
std::pair< std::chrono::milliseconds, T > frame_description
void set_uses_acceleration(bool uses_accel)
Selects which of the two global timelines get_current_animation_tick() reads for this animation: acce...
std::chrono::steady_clock::time_point next_frame_tick_
void add_frame(const std::chrono::milliseconds &duration, const T &value, bool force_change=false)
Appends a frame, starting where the previous one ends (or at start_time, if first).
std::size_t current_frame_index_
void apply_time_offset(const std::chrono::milliseconds &time)
Shifts the timeline so the current tick corresponds to the given animation time, then restarts frame ...
void pause_animation()
Freezes the timeline in place.
std::vector< frame_description > anim_description
void start_animation(const std::chrono::milliseconds &start_time_offset, bool cycles=false)
Anchors the timeline to the current tick, then begins playback.
std::chrono::steady_clock::time_point get_playback_tick() const
The tick get_elapsed_time() and get_time_in_current_frame() treat as "now": frozen at pause_tick_ whi...
void set_end_time(const std::chrono::milliseconds &ending_time)
Reduces or extends the frame list so get_end_time() becomes ending_time: drops frames after the cut a...
const T & get_last_frame() const
void force_change()
Clears the flag returned by is_static().
std::chrono::steady_clock::time_point pause_tick_
bool need_update() const
True once the current tick has reached the current frame's end, meaning advance_to_current_frame() ha...
bool animation_finished() const
True if playback has run past the last frame, is not yet started, or has no frames.
std::chrono::milliseconds get_elapsed_time() const
Time since playback began, per get_playback_tick().
std::chrono::milliseconds starting_frame_time_
void remove_frames_until(const std::chrono::milliseconds &starting_time)
Drops whole frames from the front while their end time is still before starting_time,...
const T & get_current_frame() const
std::size_t get_frames_count() const
void set_begin_time(const std::chrono::milliseconds &new_begin_time)
Rebases the timeline onto a new begin time, offsetting every frame's start_time_ by the difference so...
std::chrono::steady_clock::time_point animation_start_tick_
std::chrono::milliseconds get_animation_duration() const
get_end_time() minus get_begin_time(): how long one pass through all frames takes.
void set_duration_limit(const std::chrono::milliseconds &time)
static const T void_value_
std::chrono::milliseconds get_end_time() const
Animation-time offset where the last frame ends.
std::chrono::milliseconds get_current_frame_end_time() const
Animation-time offset where the current frame ends.
animated(const std::chrono::milliseconds &start_time=std::chrono::milliseconds{0})
Creates an animation with no frames; add_frame() populates it afterward.
bool cycles() const
True if the animation loops back to the first frame instead of stopping at the last.
void advance_to_current_frame()
Moves current_frame_index_ forward to match the current tick, one frame at a time (or in whole cycles...
std::chrono::milliseconds duration_
std::chrono::milliseconds start_time_
static map_location::direction n