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

Blocks preview widget. More...

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

Classes

struct  Init
 
struct  LocalInit
 

Public Member Functions

void set (const std::string &sText, std::vector< Block > &oBlocks) noexcept
 Sets blocks and text of the preview widget. More...
 
int32_t getPainterIdx () const noexcept
 The painter that should draw the tiles. More...
 
int32_t getMinTilesW () const noexcept
 The minimum number of horizontal tiles. More...
 
int32_t getMinTilesH () const noexcept
 The minimum number of vertical tiles. More...
 
const std::string & getText () const noexcept
 The text shown along with the blocks. More...
 
const std::vector< Block > & getBlocks () const noexcept
 The shown blocks. More...
 
bool isChanged () const noexcept
 Whether set was called since the last game tick. More...
 
GameProxygame () noexcept
 
const GameProxygame () const noexcept
 
 PreviewWidget (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...
 
void onAddedToGame () noexcept override
 Signals widget was added to game. 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...
 

Detailed Description

Blocks preview widget.

Constructor & Destructor Documentation

◆ PreviewWidget()

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

Constructor.

Parameters
oInitThe initialization data.

Member Function Documentation

◆ dump()

void stmg::PreviewWidget::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.

◆ game() [1/2]

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

◆ game() [2/2]

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

◆ getBlocks()

const std::vector<Block>& stmg::PreviewWidget::getBlocks ( ) const
inlinenoexcept

The shown blocks.

Returns
The blocks. Can be empty vector.

◆ getMinTilesH()

int32_t stmg::PreviewWidget::getMinTilesH ( ) const
inlinenoexcept

The minimum number of vertical tiles.

◆ getMinTilesW()

int32_t stmg::PreviewWidget::getMinTilesW ( ) const
inlinenoexcept

The minimum number of horizontal tiles.

◆ getPainterIdx()

int32_t stmg::PreviewWidget::getPainterIdx ( ) const
inlinenoexcept

The painter that should draw the tiles.

You can assume that this value doesn't change after initialization.

Returns
the index into Named::painters().

◆ getText()

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

The text shown along with the blocks.

Returns
The string. Can be empty.

◆ isChanged()

bool stmg::PreviewWidget::isChanged ( ) const
noexcept

Whether set was called since the last game tick.

◆ onAddedToGame()

void stmg::PreviewWidget::onAddedToGame ( )
overrideprotectedvirtualnoexcept

Signals widget was added to game.

This happens after onAddedToLayout().

Reimplemented from stmg::GameWidget.

◆ reInit()

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

Reinitialization.

Parameters
oInitThe initialization data.

◆ set()

void stmg::PreviewWidget::set ( const std::string &  sText,
std::vector< Block > &  oBlocks 
)
noexcept

Sets blocks and text of the preview widget.

Parameters
sTextSingle line short text. Can be empty.
oBlocksThe blocks to show. Can be empty.