stmm-games-doc  0.32.0
Public Member Functions | Protected Member Functions | List of all members
stmg::ThemeWidgetInteractive Class Referenceabstract

Optional interface for ThemeWidget. More...

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

Public Member Functions

virtual ~ThemeWidgetInteractive () noexcept=default
 
virtual bool handleXYInput (const shared_ptr< stmi::Event > &refXYEvent, int32_t nTeam, int32_t nMate) noexcept=0
 Handles the XYEvent input. More...
 
bool isInteractive () const noexcept
 Tells whether the widget should really be interactive. More...
 
ThemeWidgetgetThemeWidget () noexcept
 The pointer to the interface's theme widget. More...
 
void dump (int32_t nIndentSpaces) const noexcept
 

Protected Member Functions

 ThemeWidgetInteractive (ThemeWidget *p0TW, bool bInteractive) noexcept
 Constructor. More...
 
void reInit (ThemeWidget *p0TW, bool bInteractive) noexcept
 Reinitialization. More...
 

Detailed Description

Optional interface for ThemeWidget.

This interface can only be acquired from a ThemeWidget instance (usually by the theme layout) through dynamic_cast or std::dynamic_pointer_cast.

Constructor & Destructor Documentation

◆ ~ThemeWidgetInteractive()

virtual stmg::ThemeWidgetInteractive::~ThemeWidgetInteractive ( )
virtualdefaultnoexcept

◆ ThemeWidgetInteractive()

stmg::ThemeWidgetInteractive::ThemeWidgetInteractive ( ThemeWidget p0TW,
bool  bInteractive 
)
protectednoexcept

Constructor.

Parameters
p0TWPointer to the theme widget implementing this interface. Cannot be null.
bInteractiveWhether the widget is really interactive.

Member Function Documentation

◆ dump()

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

◆ getThemeWidget()

ThemeWidget* stmg::ThemeWidgetInteractive::getThemeWidget ( )
inlinenoexcept

The pointer to the interface's theme widget.

Returns
The widget implementing this interface. Can't be null.

◆ handleXYInput()

virtual bool stmg::ThemeWidgetInteractive::handleXYInput ( const shared_ptr< stmi::Event > &  refXYEvent,
int32_t  nTeam,
int32_t  nMate 
)
pure virtualnoexcept

Handles the XYEvent input.

It's safe to statically cast refXYEvent->get() to stmi::XYEvent*.

The team and mate parameters are not necessarily those of the widget but can also be determined by the stmi::Capability of the stmi::XYEvent, which is done by the caller of this function.

The interactive widget might not handle an event. For example when a new grab (see stmi::XYEvent::XY_GRAB) is initiated, the widget might return false because it already has an open grab. Another example: a key action widget needs the player to be defined (nMate >= 0).

Parameters
refXYEventReference to a stmi::XYEvent object. Cannot be null.
nTeamThe team or -1 if not set.
nMateThe mate of -1 if not set.
Returns
Whether the widget has handled the event.

Implemented in stmg::InputBoxThWidget, and stmg::ActionsBoxThWidget.

◆ isInteractive()

bool stmg::ThemeWidgetInteractive::isInteractive ( ) const
inlinenoexcept

Tells whether the widget should really be interactive.

When the widget's model refers to an AI player or a team, level, game that doesn't contain human players this may return false. Even widgets assigned to a human player might want to disable interactivity because the game only uses the keyboard as input.

Returns
Whether the widget is really interactive.

◆ reInit()

void stmg::ThemeWidgetInteractive::reInit ( ThemeWidget p0TW,
bool  bInteractive 
)
protectednoexcept

Reinitialization.

Parameters
p0TWPointer to the theme widget implementing this interface. Cannot be null.
bInteractiveWhether the widget is really interactive.