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

Action widget. More...

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

Classes

struct  Init
 
struct  LocalInit
 

Public Types

enum  ACTION_TYPE { ACTION_KEY_ACTION = 1, ACTION_INTERRUPT = 2, ACTION_EVENT_MSG = 3 }
 What happens when the widget is pressed. More...
 

Public Member Functions

int32_t getImageId () const noexcept
 The shown image. More...
 
const std::string & getText () const noexcept
 The shown text. More...
 
double getTextSize () const noexcept
 The text height in tiles. More...
 
void handleXYInput (const shared_ptr< stmi::Event > &refXYEvent, int32_t nTeam, int32_t nMate) noexcept
 Execute action out of a stmi::XYEvent for a player. More...
 
 ActionWidget (Init &&oInit) noexcept
 Constructor. More...
 
void dump (int32_t nIndentSpaces, bool bHeader) const noexcept override
 Writes object contents to std::cout. More...
 
- Public Member Functions inherited from stmg::RelSizedGameWidget
double getReferenceWFactor () const noexcept
 The width size factor to the reference widget. More...
 
double getReferenceHFactor () const noexcept
 The height size factor to the reference widget. More...
 
double getWHRatio () const noexcept
 The width to height ratio. More...
 
- Public Member Functions inherited from stmg::GameWidget
virtual ~GameWidget () noexcept=default
 
int32_t getViewWidgetNameIdx () const noexcept
 The type (name) that might be used to choose a ThemeWidget. More...
 
const std::string & getName () const noexcept
 The name of the widget. More...
 
int32_t getTeam () const noexcept
 The team the widget is assigned to. More...
 
int32_t getMate () const noexcept
 The mate the widget is assigned to. More...
 
WidgetAxisFit getWidgetHorizAxisFit (int32_t nLayoutConfig) const noexcept
 Widget alignment and expansion for the x axis. More...
 
WidgetAxisFit getWidgetVertAxisFit (int32_t nLayoutConfig) const noexcept
 Widget alignment and expansion for the y axis. More...
 
bool isAssignedToHuman () const noexcept
 Tells whether the widget is assigned to a human. More...
 
ContainerWidgetgetContainer () const noexcept
 The container to which this widget was added to. More...
 
void dump (int32_t nIndentSpaces) const noexcept
 Writes object contents to std::cout (header included). More...
 
void dump () const noexcept
 Writes object contents to std::cout (header included). More...
 

Protected Member Functions

void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
- Protected Member Functions inherited from stmg::RelSizedGameWidget
 RelSizedGameWidget (Init &&oInit) noexcept
 Constructor. More...
 
void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
- Protected Member Functions inherited from stmg::GameWidget
 GameWidget (Init &&oData) noexcept
 Constructor. More...
 
void reInit (Init &&oData) noexcept
 Reinitialization. More...
 
Layoutlayout () noexcept
 The layout the widget belongs to. More...
 
const Layoutlayout () const noexcept
 The layout the widget belongs to. More...
 
GameProxygame () noexcept
 The game the widget belongs to. More...
 
const GameProxygame () const noexcept
 The game the widget belongs to. More...
 
virtual void onAddedToLayout () noexcept
 Signals widget was added to layout. More...
 
virtual void onAddedToGame () noexcept
 Signals widget was added to game. More...
 

Detailed Description

Action widget.

When its view is pressed by mouse or touched either sends a KeyActionEvent to the game, sends a message to an event or interrupts the game.

Member Enumeration Documentation

◆ ACTION_TYPE

What happens when the widget is pressed.

Enumerator
ACTION_KEY_ACTION 

Execute a key action.

ACTION_INTERRUPT 

Execute an interrupt.

Ex: PAUSE.

ACTION_EVENT_MSG 

Trigger an event with a message.

Constructor & Destructor Documentation

◆ ActionWidget()

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

Constructor.

Parameters
oInitThe initialization data.

Member Function Documentation

◆ dump()

void stmg::ActionWidget::dump ( int32_t  nIndentSpaces,
bool  bHeader 
) const
overridevirtualnoexcept

Writes object contents to std::cout.

Should only do it in debug mode. The function is also exposed in release mode because it is virtual.

If bHeader is true this function should also output the type of the object and its address.

Parameters
nIndentSpacesNumber of spaces put in front of each output line.
bHeaderWhether the header of the object should be displayed.

Reimplemented from stmg::RelSizedGameWidget.

◆ getImageId()

int32_t stmg::ActionWidget::getImageId ( ) const
inlinenoexcept

The shown image.

Returns
The image id of the widget or -1 if not defined.

◆ getText()

const std::string& stmg::ActionWidget::getText ( ) const
inlinenoexcept

The shown text.

Returns
The text of the widget. Can be empty.

◆ getTextSize()

double stmg::ActionWidget::getTextSize ( ) const
inlinenoexcept

The text height in tiles.

Returns
The text size. Is positive.

◆ handleXYInput()

void stmg::ActionWidget::handleXYInput ( const shared_ptr< stmi::Event > &  refXYEvent,
int32_t  nTeam,
int32_t  nMate 
)
noexcept

Execute action out of a stmi::XYEvent for a player.

Parameters
refXYEventThe event generated in the view. Cannot be null.
nTeamThe team of the player. Must be >=-1.
nMateThe mate number of the player. Must be >=-1. If team is -1 must be -1 too.

◆ reInit()

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

Reinitialization.

Parameters
oInitThe initialization data.