stmm-games-doc  0.32.0
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
stmg::LevelAnimation Class Reference

Animation model class. More...

Inheritance diagram for stmg::LevelAnimation:
Inheritance graph
[legend]

Classes

struct  Init
 

Public Types

enum  REFSYS { REFSYS_BOARD = -3, REFSYS_SHOW = -2, REFSYS_INVALID = -1, REFSYS_SUBSHOW = 0 }
 Reference system extended enumeration. More...
 

Public Member Functions

virtual ~LevelAnimation () noexcept=default
 
int32_t getId () const noexcept
 Returns unique Id of this object. More...
 
bool isActive () const noexcept
 Whether the animation was added to the level (and not removed yet). More...
 
int32_t getViewAnimationNameIdx () const noexcept
 The optional view animation name index. More...
 
REFSYS getRefSys () noexcept
 The reference system of the animation. More...
 
FPoint getPos () const noexcept
 The current position of the animation within its reference system. More...
 
FSize getSize () const noexcept
 The size of the animation. More...
 
int32_t getZ () const noexcept
 The depth of the animation. More...
 
double gameInterval () const noexcept
 The current game interval. More...
 
double getDuration () const noexcept
 The duration in milliseconds. More...
 
void moveTo (FPoint oPos) noexcept
 Sets new position within reference system. More...
 
void moveTo (int32_t nZ) noexcept
 Sets new position within reference system. More...
 
virtual void onScrolled (Direction::VALUE eDir) noexcept
 Called by Level when the animation is scrolled by Level::boardScroll. More...
 
double getElapsed (int32_t nViewTick, int32_t nTotViewTicks) const noexcept
 The time elapsed since the animation was started in milliseconds. More...
 
bool isStarted (int32_t nViewTick, int32_t nTotViewTicks) const noexcept
 Whether the animation has already started. More...
 
bool isDone (int32_t nViewTick, int32_t nTotViewTicks) const noexcept
 Whether the animation has finished. More...
 
Levellevel () noexcept
 The level. More...
 
const Levellevel () const noexcept
 The level. More...
 
GameProxygame () noexcept
 The game. More...
 
const GameProxygame () const noexcept
 The game. More...
 

Static Public Attributes

static const double s_fDurationUndefined
 Undefined duration constant. More...
 
static const double s_fDurationInfinity
 Infinite duration constant. More...
 

Protected Member Functions

 LevelAnimation (const Init &oInit) noexcept
 Constructor. More...
 
void reInit (const Init &oInit) noexcept
 Reinitialization. More...
 

Detailed Description

Animation model class.

The animation has a position in tiles that can be changed at runtime, but it hasn't a size or a z position, which has to be defined by subclasses.

Member Enumeration Documentation

◆ REFSYS

Reference system extended enumeration.

In subshow mode animations can also be drawn in the subshow square and only seen by the respective level player.

The reference system for nLevelPlayer is REFSYS_SUBSHOW + nLevelPlayer.

Enumerator
REFSYS_BOARD 

Board.

REFSYS_SHOW 

Show.

REFSYS_INVALID 
REFSYS_SUBSHOW 

Subshow level player 0.

Constructor & Destructor Documentation

◆ ~LevelAnimation()

virtual stmg::LevelAnimation::~LevelAnimation ( )
virtualdefaultnoexcept

◆ LevelAnimation()

stmg::LevelAnimation::LevelAnimation ( const Init oInit)
explicitprotectednoexcept

Constructor.

Parameters
oInitThe parameters.

Member Function Documentation

◆ game() [1/2]

GameProxy& stmg::LevelAnimation::game ( )
inlinenoexcept

The game.

This function can only be called if the animation is active.

Returns
The level.

◆ game() [2/2]

const GameProxy& stmg::LevelAnimation::game ( ) const
inlinenoexcept

The game.

This function can only be called if the animation is active.

Returns
The level.

◆ gameInterval()

double stmg::LevelAnimation::gameInterval ( ) const
noexcept

The current game interval.

This is a shortcut to level().game().gameInterval().

Returns
The game interval in milliseconds.

◆ getDuration()

double stmg::LevelAnimation::getDuration ( ) const
inlinenoexcept

The duration in milliseconds.

Returns
The duration. -1.0 if undefined, 0.0 if infinity.

◆ getElapsed()

double stmg::LevelAnimation::getElapsed ( int32_t  nViewTick,
int32_t  nTotViewTicks 
) const
noexcept

The time elapsed since the animation was started in milliseconds.

Parameters
nViewTickThe current view tick.
nTotViewTicksThe number of view ticks in this game interval.
Returns
The elapsed time in milliseconds.

◆ getId()

int32_t stmg::LevelAnimation::getId ( ) const
inlinenoexcept

Returns unique Id of this object.

Returns
The (non negative) unique id.

◆ getPos()

FPoint stmg::LevelAnimation::getPos ( ) const
inlinenoexcept

The current position of the animation within its reference system.

Although it is usually the top-left corner of the animation rectangle, the position is implementation (subclass) specific. For some animations it might represent the center of the animation rectangle, which is defined by the view (ThemeAnimation).

If the animation is scrolled the level will automatically update the position.

Returns
The position in tiles.

◆ getRefSys()

REFSYS stmg::LevelAnimation::getRefSys ( )
inlinenoexcept

The reference system of the animation.

This value cannot change during the lifetime of the animation.

Returns
The reference system.

◆ getSize()

FSize stmg::LevelAnimation::getSize ( ) const
inlinenoexcept

The size of the animation.

Note that as for the position the view is allowed to use a bigger or smaller area.

Either width, height or both might be undefined (<= 0), in which case it must be calculated by the view.

Returns
The size in tiles.

◆ getViewAnimationNameIdx()

int32_t stmg::LevelAnimation::getViewAnimationNameIdx ( ) const
inlinenoexcept

The optional view animation name index.

This value can be used to select the view that draws this animation model. If not set only the (RTTI) type of the this animation object is taken into account.

Returns
The name index (or -1 if not set).

◆ getZ()

int32_t stmg::LevelAnimation::getZ ( ) const
inlinenoexcept

The depth of the animation.

Higher z animations are drawn on top of lower z animations.

Returns
The z of the animation.

◆ isActive()

bool stmg::LevelAnimation::isActive ( ) const
inlinenoexcept

Whether the animation was added to the level (and not removed yet).

Returns
Whether animation managed by level.

◆ isDone()

bool stmg::LevelAnimation::isDone ( int32_t  nViewTick,
int32_t  nTotViewTicks 
) const
noexcept

Whether the animation has finished.

Parameters
nViewTickThe current view tick.
nTotViewTicksThe number of view ticks in this game interval.
Returns
Whether the animation is done.

◆ isStarted()

bool stmg::LevelAnimation::isStarted ( int32_t  nViewTick,
int32_t  nTotViewTicks 
) const
noexcept

Whether the animation has already started.

Parameters
nViewTickThe current view tick.
nTotViewTicksThe number of view ticks in this game interval.
Returns
Whether the animation was started.

◆ level() [1/2]

Level& stmg::LevelAnimation::level ( )
inlinenoexcept

The level.

This function can only be called if the animation is active.

Returns
The level.

◆ level() [2/2]

const Level& stmg::LevelAnimation::level ( ) const
inlinenoexcept

The level.

This function can only be called if the animation is active.

Returns
The level.

◆ moveTo() [1/2]

void stmg::LevelAnimation::moveTo ( FPoint  oPos)
inlinenoexcept

Sets new position within reference system.

Parameters
oPosThe new position.

◆ moveTo() [2/2]

void stmg::LevelAnimation::moveTo ( int32_t  nZ)
inlinenoexcept

Sets new position within reference system.

Parameters
nZThe new z position.

◆ onScrolled()

virtual void stmg::LevelAnimation::onScrolled ( Direction::VALUE  eDir)
virtualnoexcept

Called by Level when the animation is scrolled by Level::boardScroll.

Called even if the reference system is REFSYS_SUBSHOW. The LevelAnimation implementation does nothing and therefore must not be called by subclasses.

To be scrolled the animation has to be added with Level::animationAddScrolled() rather than Level::animationAdd().

Parameters
eDirThe direction of the scroll.

◆ reInit()

void stmg::LevelAnimation::reInit ( const Init oInit)
protectednoexcept

Reinitialization.

See constructor.

Member Data Documentation

◆ s_fDurationInfinity

const double stmg::LevelAnimation::s_fDurationInfinity
static

Infinite duration constant.

◆ s_fDurationUndefined

const double stmg::LevelAnimation::s_fDurationUndefined
static

Undefined duration constant.

The duration should be determined by the theme.