SuperTuxKart
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GUIEngine::AbstractStateManager Class Referenceabstract

Abstract base class you must override from to use the GUI engine. More...

#include <abstract_state_manager.hpp>

Inheritance diagram for GUIEngine::AbstractStateManager:
Inheritance graph
[legend]

Public Member Functions

 AbstractStateManager ()
 inits an AbstractStateManager is MENU state
 
void pushScreen (Screen *screen)
 adds a menu at the top of the screens stack
 
void replaceTopMostScreen (Screen *screen, GUIEngine::GameState gameState=GUIEngine::CURRENT)
 replaces the menu at the top of the screens stack (i.e. More...
 
void popMenu ()
 removes the menu at the top of the screens stack If the stack becomes empty after performing the pop (i.e. More...
 
void resetAndGoToScreen (Screen *screen)
 clears the menu stack and starts afresh with a new stack containing only the given screen
 
void resetAndSetStack (Screen *screens[])
 Sets the whole menu stack. More...
 
void enterGameState ()
 call to make the state manager enter game mode. More...
 
GameState getGameState ()
 
void reshowTopMostMenu ()
 to be called after e.g. More...
 
template<typename T >
void hardResetAndGoToScreen ()
 
virtual void escapePressed ()=0
 callback invoked whenever escape was pressed (or any similar cancel operation)
 
virtual void onGameStateChange (GameState new_state)=0
 callback invoked when game mode changes (e.g. More...
 
virtual void onStackEmptied ()=0
 callback invoked when the stack is emptied (all menus are popped out). More...
 
virtual void onTopMostScreenChanged ()=0
 
unsigned int getMenuStackSize () const
 Returns the number of screens on the stack. More...
 

Protected Member Functions

void pushMenu (Screen *screen)
 
void setGameState (GameState state)
 

Protected Attributes

GameState m_game_mode
 Whether we are in game mode.
 
std::vector< std::pair< std::string, Screen * > > m_menu_stack
 This stack will contain menu names (e.g. More...
 

Detailed Description

Abstract base class you must override from to use the GUI engine.

Member Function Documentation

◆ enterGameState()

void AbstractStateManager::enterGameState ( )

call to make the state manager enter game mode.

Causes the menu stack to be cleared; all widgets shown on screen are removed

◆ getGameState()

GameState AbstractStateManager::getGameState ( )
Returns
the current state of the game

◆ getMenuStackSize()

unsigned int GUIEngine::AbstractStateManager::getMenuStackSize ( ) const
inline

Returns the number of screens on the stack.

Is used to decide if exiting a screen would cause STK to end or not.

◆ onGameStateChange()

virtual void GUIEngine::AbstractStateManager::onGameStateChange ( GameState  new_state)
pure virtual

callback invoked when game mode changes (e.g.

goes from "menu" to "in-game")

Implemented in StateManager.

◆ onStackEmptied()

virtual void GUIEngine::AbstractStateManager::onStackEmptied ( )
pure virtual

callback invoked when the stack is emptied (all menus are popped out).

This is essentially a request to close the application (since a game can't run without a state)

Implemented in StateManager.

◆ popMenu()

void AbstractStateManager::popMenu ( )

removes the menu at the top of the screens stack If the stack becomes empty after performing the pop (i.e.

if it contained only one item prior to the call), the game is aborted. In other cases, the second-topmost screen is displayed.

◆ replaceTopMostScreen()

void AbstractStateManager::replaceTopMostScreen ( Screen screen,
GUIEngine::GameState  gameState = GUIEngine::CURRENT 
)

replaces the menu at the top of the screens stack (i.e.

pops the topmost screen and adds this one instead, but without displaying the second-topmost menu of the stack in-between)

◆ resetAndSetStack()

void AbstractStateManager::resetAndSetStack ( Screen screens[])

Sets the whole menu stack.

Only the topmost screen will be inited/shown, but others remain under for cases where the user wants to go back.

Parameters
screensan array containing the menus that should go into stack. The first item will be the bottom item in the stack, the last item will be the stack top. Array must be NULL-terminated.

◆ reshowTopMostMenu()

void AbstractStateManager::reshowTopMostMenu ( )

to be called after e.g.

a resolution switch

Member Data Documentation

◆ m_menu_stack

std::vector<std::pair<std::string, Screen*> > GUIEngine::AbstractStateManager::m_menu_stack
protected

This stack will contain menu names (e.g.

main.stkgui), and/or 'race' with screen instance pointer.


The documentation for this class was generated from the following files: