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

Event that scrolls the board. More...

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

Classes

struct  Init
 
struct  LocalInit
 
struct  NewRowCheckRemover
 

Public Types

enum  {
  MESSAGE_PUSH_ROW = 100, MESSAGE_PAUSE_TICKS = 101, MESSAGE_PAUSE_MILLISEC = 102, MESSAGE_SET_SLICES = 110,
  MESSAGE_SET_NEW_ROW_GEN = 120, MESSAGE_NEXT_NEW_ROW_GEN = 121, MESSAGE_PREV_NEW_ROW_GEN = 122, MESSAGE_INHIBIT_START_INDEX_BASE = 200,
  MESSAGE_INHIBIT_STOP_INDEX_BASE = 300
}
 
enum  {
  LISTENER_GROUP_PUSHED = 10, LISTENER_GROUP_TOP_COLUMN = 11, LISTENER_GROUP_TOP_DESTROYED = 12, LISTENER_GROUP_TOP_NOT_EMPTY_START = 20,
  LISTENER_GROUP_TOP_NOT_EMPTY_END = 21, LISTENER_GROUP_TOP_NOT_EMPTY_TICK = 22
}
 
- Public Types inherited from stmg::Event
enum  MSG_FILTER_VALUE_OP {
  MSG_FILTER_VALUE_OP_FIRST = 0, MSG_FILTER_VALUE_OP_UNCHANGED = 0, MSG_FILTER_VALUE_OP_SET = 1, MSG_FILTER_VALUE_OP_MULT_ADD = 2,
  MSG_FILTER_VALUE_OP_DIV_ADD = 3, MSG_FILTER_VALUE_OP_PERCENT_ADD = 4, MSG_FILTER_VALUE_OP_PERMILL_ADD = 5, MSG_FILTER_VALUE_OP_MOD_ADD = 6,
  MSG_FILTER_VALUE_OP_MIN_ADD = 7, MSG_FILTER_VALUE_OP_MAX_ADD = 8, MSG_FILTER_VALUE_OP_LAST = 8
}
 Value filter. More...
 
enum  { LISTENER_GROUP_FINISHED = 0 }
 

Public Member Functions

 ScrollerEvent (Init &&oInit) noexcept
 Constructor. More...
 
void trigger (int32_t nMsg, int32_t nValue, Event *p0TriggeringEvent) noexcept override
 The trigger function. More...
 
const TileboardGetTile (int32_t nX, int32_t nY) const noexcept override
 Extended board tile getter. More...
 
const TileAnimatorboardGetTileAnimator (int32_t nX, int32_t nY, int32_t nIdxTileAni) const noexcept override
 Extended board tile animator getter. More...
 
- Public Member Functions inherited from stmg::Event
virtual ~Event () noexcept=default
 
virtual void addMsgFilter (int32_t nInFromMsg, int32_t nInToMsg, int32_t nInFromValue, int32_t nInToValue, bool bOutMsgDefined, int32_t nOutMsg, MSG_FILTER_VALUE_OP eOutValueOperator, int32_t nOutValueOperand, int32_t nOutValueAdd) noexcept
 Add a message filter. More...
 
virtual void addListener (int32_t nGroupId, Event *p0ListenerEvent, int32_t nMsg) noexcept
 Adds a listener to the event. More...
 
bool isActive () const noexcept
 Tells whether the event is active. More...
 
int32_t getTriggerTime () const noexcept
 The triggering time. More...
 
int32_t getPriority () const noexcept
 The priority. More...
 
int32_t getDebugTag () const noexcept
 The debug tag. More...
 
- Public Member Functions inherited from stmg::ExtendedBoard
virtual ~ExtendedBoard () noexcept=default
 

Protected Member Functions

void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
- Protected Member Functions inherited from stmg::Event
 Event (Init &&oInit) noexcept
 Constructor. More...
 
void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
virtual void informListeners (int32_t nGroupId, int32_t nValue) noexcept
 Calls the trigger function of a group of listeners. More...
 
const Levellevel () const noexcept
 The level this event belongs to. More...
 
Levellevel () noexcept
 The level this event belongs to. More...
 

Detailed Description

Event that scrolls the board.

The scrolling is done by moving the Show area (see Level::showGet()) fractions of a tile (see LocalInit::m_nSlices) over the board. When the next tile is reached a new row is inserted at the bottom of the board.

How a new row is generated can be controlled by input messages.

If new rows are generated randomly, it is possible to discard a row if certain tiles appear in it by setting an inhibitor, which can be activated or deactivated with input messages.

It is also possible to try to minimize free tile removals (the meaning of which is implementation specific) when new rows are added.

This class can currently only scroll down (new rows appear at the bottom of the board).

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MESSAGE_PUSH_ROW 

Beware! currently pushed rows are not counted (don't influence LocalInit::m_nRepeat).

MESSAGE_PAUSE_TICKS 

Number of game ticks to pause (passed through nValue).

MESSAGE_PAUSE_MILLISEC 

Number of milliseconds to pause (passed through nValue).

MESSAGE_SET_SLICES 

Change nr of slices (passed through nValue).

MESSAGE_SET_NEW_ROW_GEN 

nValue is index LocalInit::m_aNewRowTileGens.

If negative sets to 0. If bigger than vector size sets last.

MESSAGE_NEXT_NEW_ROW_GEN 

Switches to next row generator.

If last stays on last.

MESSAGE_PREV_NEW_ROW_GEN 

Switches to previous row generator.

If first stays on first.

MESSAGE_INHIBIT_START_INDEX_BASE 

Starts applying an inhibitor to new rows.

The inhibitor index into Init::m_aInhibitors is determined by subtracting MESSAGE_INHIBIT_START_INDEX_BASE from the message number. There can be at most 100 inhibitors.

MESSAGE_INHIBIT_STOP_INDEX_BASE 

Stops applying an ibhibitor to new rows.

Like MESSAGE_INHIBIT_START_INDEX_BASE.

◆ anonymous enum

anonymous enum
Enumerator
LISTENER_GROUP_PUSHED 

Sent if a row was pushed with nValue containing the row generator.

LISTENER_GROUP_TOP_COLUMN 

Sent for each column (nValue) with non empty tile in the to be destroyed top row.

LISTENER_GROUP_TOP_DESTROYED 

Sent when the top line is destroyed (after the LISTENER_GROUP_TOP_COLUMNs).

LISTENER_GROUP_TOP_NOT_EMPTY_START 

Sent when the top line not empty wait starts.

nValue contains the initial number of wait game ticks.

LISTENER_GROUP_TOP_NOT_EMPTY_END 

Sent when the top line was cleared or destroyed (before LISTENER_GROUP_TOP_COLUMN).

nValue is always 0.

LISTENER_GROUP_TOP_NOT_EMPTY_TICK 

Sent when the top line not empty wait changes.

nValue contains the number of wait game ticks.

Constructor & Destructor Documentation

◆ ScrollerEvent()

stmg::ScrollerEvent::ScrollerEvent ( Init &&  oInit)
explicitnoexcept

Constructor.

Parameters
oInitThe initialization data.

Member Function Documentation

◆ boardGetTile()

const Tile& stmg::ScrollerEvent::boardGetTile ( int32_t  nX,
int32_t  nY 
) const
overridevirtualnoexcept

Extended board tile getter.

Parameters
nXThe x. Can e outside the level's board.
nYThe y. Can e outside the level's board.
Returns
The tile.

Implements stmg::ExtendedBoard.

◆ boardGetTileAnimator()

const TileAnimator* stmg::ScrollerEvent::boardGetTileAnimator ( int32_t  nX,
int32_t  nY,
int32_t  nIdxTileAni 
) const
overridevirtualnoexcept

Extended board tile animator getter.

Parameters
nXThe x. Can e outside the level's board.
nYThe y. Can e outside the level's board.
nIdxTileAniThe tile animation. Must be >= 0 and < Level::getNrTileAniAttrs().
Returns
The tile animator.

Implements stmg::ExtendedBoard.

◆ reInit()

void stmg::ScrollerEvent::reInit ( Init &&  oInit)
protectednoexcept

Reinitialization.

Parameters
oInitThe initialization data.

◆ trigger()

void stmg::ScrollerEvent::trigger ( int32_t  nMsg,
int32_t  nValue,
Event p0TriggeringEvent 
)
overridevirtualnoexcept

The trigger function.

This function provides the functionality of the event and can be called in two ways.

It can be called by an event through informListeners() this event was listening to. Note: events can listen to themselves.

It can also be called by the timer if the event was active.

When this function is called the event has already been deactivated by the level (if it was active in the first place).

When this function is called the filters of this event have already been applied.

Parameters
nMsgThe message received.
nValueThe value received.
p0TriggeringEventThe triggering event or null if triggered by timer.

Implements stmg::Event.