SuperTuxKart
Loading...
Searching...
No Matches
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.
 
void popMenu ()
 removes the menu at the top of the screens stack If the stack becomes empty after performing the pop (i.e.
 
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.
 
void onResize ()
 Called when resizing of stk window.
 
void enterMenuState ()
 Used in no graphics STK to enter menu screen (when server is idle state)
 
void enterGameState ()
 call to make the state manager enter game mode.
 
GameState getGameState ()
 
void reshowTopMostMenu ()
 to be called after e.g.
 
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.
 
virtual void onStackEmptied ()=0
 callback invoked when the stack is emptied (all menus are popped out).
 
virtual void onTopMostScreenChanged ()=0
 
unsigned int getMenuStackSize () const
 Returns the number of screens on the stack.
 

Protected Member Functions

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

Protected Attributes

std::atomic< GameStatem_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.
 

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

◆ escapePressed()

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

callback invoked whenever escape was pressed (or any similar cancel operation)

Implemented in StateManager.

◆ 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.

◆ onTopMostScreenChanged()

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

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: