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

The widget base class. More...

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

Classes

struct  Init
 Instance initialization data. More...
 

Public Member Functions

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...
 
virtual void dump (int32_t nIndentSpaces, bool bHeader) const noexcept
 Writes object contents to std::cout. 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

 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

The widget base class.

Widgets can be assigned to:

A game widget can potentially have two configurations. The normal one and the switched one. This allows the view (ThemeWidget) of the widget and its layout to adapt to a portrait (height bigger than width) or landscape (width bigger than height) window or screen size.

Constructor & Destructor Documentation

◆ ~GameWidget()

virtual stmg::GameWidget::~GameWidget ( )
virtualdefaultnoexcept

◆ GameWidget()

stmg::GameWidget::GameWidget ( Init &&  oData)
explicitprotectednoexcept

Constructor.

Parameters
oDataThe initialization data.

Member Function Documentation

◆ dump() [1/3]

virtual void stmg::GameWidget::dump ( int32_t  nIndentSpaces,
bool  bHeader 
) const
virtualnoexcept

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 in stmg::ActionsBoxWidget, stmg::VarWidget, stmg::ProgressWidget, stmg::BoxWidget, stmg::LevelShowWidget, stmg::VolatileWidget, stmg::PreviewWidget, stmg::ActionWidget, stmg::BackgroundWidget, stmg::RelSizedGameWidget, stmg::InputBoxWidget, stmg::ContainerWidget, and stmg::TransparentWidget.

◆ dump() [2/3]

void stmg::GameWidget::dump ( int32_t  nIndentSpaces) const
noexcept

Writes object contents to std::cout (header included).

Parameters
nIndentSpacesNumber of spaces put in front of each output line.

◆ dump() [3/3]

void stmg::GameWidget::dump ( ) const
noexcept

Writes object contents to std::cout (header included).

◆ game() [1/2]

GameProxy& stmg::GameWidget::game ( )
protectednoexcept

The game the widget belongs to.

Returns
The game. Undefined if the widget wasn't added to the game yet.

◆ game() [2/2]

const GameProxy& stmg::GameWidget::game ( ) const
protectednoexcept

The game the widget belongs to.

Returns
The game. Undefined if the widget wasn't added to the game yet.

◆ getContainer()

ContainerWidget* stmg::GameWidget::getContainer ( ) const
inlinenoexcept

The container to which this widget was added to.

Returns
The parent or null.

◆ getMate()

int32_t stmg::GameWidget::getMate ( ) const
inlinenoexcept

The mate the widget is assigned to.

Returns
The mate or -1 if global or team widget.

◆ getName()

const std::string& stmg::GameWidget::getName ( ) const
inlinenoexcept

The name of the widget.

Returns
The name. Can be empty.

◆ getTeam()

int32_t stmg::GameWidget::getTeam ( ) const
inlinenoexcept

The team the widget is assigned to.

Returns
The team or -1 if global widget.

◆ getViewWidgetNameIdx()

int32_t stmg::GameWidget::getViewWidgetNameIdx ( ) const
inlinenoexcept

The type (name) that might be used to choose a ThemeWidget.

It should be used by Theme to choose the ThemeWidget object (view) drawing this object (model)

Returns
The index in Named.widgets(), if -1 not defined.

◆ getWidgetHorizAxisFit()

WidgetAxisFit stmg::GameWidget::getWidgetHorizAxisFit ( int32_t  nLayoutConfig) const
noexcept

Widget alignment and expansion for the x axis.

Parameters
nLayoutConfigThe layout config.
Returns
The horizontal axis fit.

◆ getWidgetVertAxisFit()

WidgetAxisFit stmg::GameWidget::getWidgetVertAxisFit ( int32_t  nLayoutConfig) const
noexcept

Widget alignment and expansion for the y axis.

Parameters
nLayoutConfigThe layout config.
Returns
The vertical axis fit.

◆ isAssignedToHuman()

bool stmg::GameWidget::isAssignedToHuman ( ) const
inlinenoexcept

Tells whether the widget is assigned to a human.

The owner can be determined by getTeam() and getMate(). If the owner type is a player tells whether it is human. If the owner type is team tells whether at least one mate in the team is human. If the owner type is game tells whether there is at least one human player playing.

Returns
Whether assigned to human.

◆ layout() [1/2]

Layout& stmg::GameWidget::layout ( )
protectednoexcept

The layout the widget belongs to.

Returns
The layout. Undefined if the widget wasn't added to the layout yet.

◆ layout() [2/2]

const Layout& stmg::GameWidget::layout ( ) const
protectednoexcept

The layout the widget belongs to.

Returns
The layout. Undefined if the widget wasn't added to the layout yet.

◆ onAddedToGame()

virtual void stmg::GameWidget::onAddedToGame ( )
inlineprotectedvirtualnoexcept

Signals widget was added to game.

This happens after onAddedToLayout().

Reimplemented in stmg::LevelShowWidget, stmg::VolatileWidget, and stmg::PreviewWidget.

◆ onAddedToLayout()

virtual void stmg::GameWidget::onAddedToLayout ( )
inlineprotectedvirtualnoexcept

Signals widget was added to layout.

Reimplemented in stmg::InputBoxWidget.

◆ reInit()

void stmg::GameWidget::reInit ( Init &&  oData)
protectednoexcept

Reinitialization.

Parameters
oDataThe initialization data.