SuperTuxKart
Namespaces | Classes | Enumerations | Functions | Variables
GUIEngine Namespace Reference

Contains all GUI engine related classes and functions. More...

Namespaces

 Private
 In an attempt to make getters as fast as possible, by possibly still allowing inlining These fields should never be accessed outside of the GUI engine.
 

Classes

class  AbstractStateManager
 Abstract base class you must override from to use the GUI engine. More...
 
class  AbstractTopLevelContainer
 Represents a GUI widgets container. More...
 
class  BoxRenderParams
 class containing render params for the 'drawBoxFromStretchableTexture' function see Overview of GUI skin for more information about skinning in STK More...
 
class  BubbleWidget
 A text widget that can expand when focused. More...
 
class  ButtonWidget
 A text button widget. More...
 
class  CheckBoxWidget
 A checkbox widget. More...
 
class  CutsceneScreen
 
class  DialogQueue
 
class  DynamicRibbonHoverListener
 Even if you have a ribbon that only acts on click/enter, you may wish to know which item is currently highlighted. More...
 
struct  DynamicRibbonScrollCallback
 
class  DynamicRibbonWidget
 An extended version of RibbonWidget, with more capabilities. More...
 
class  EmojiKeyboard
 
class  EventHandler
 Class to handle irrLicht events (GUI and input as well) More...
 
class  IconButtonWidget
 A button widget with an icon and optionnaly a label beneath. More...
 
class  IListWidgetHeaderListener
 
struct  ItemDescription
 The description of an item added to a DynamicRibbonWidget. More...
 
class  ITextBoxWidgetListener
 
class  KartStatsWidget
 A progress bar widget. More...
 
class  LabelWidget
 A simple label widget. More...
 
class  LayoutManager
 
class  ListWidget
 A vertical list widget with text entries. More...
 
struct  MenuMessage
 
class  ModalDialog
 Abstract base class representing a modal dialog. More...
 
class  ModelViewWidget
 A model view widget. More...
 
class  PlayerKartWidget
 A widget representing the kart selection for a player (i.e. More...
 
class  PlayerNameSpinner
 A small extension to the spinner widget to add features like player ID management or badging. More...
 
class  ProgressBarWidget
 A progress bar widget. More...
 
class  RatingBarWidget
 A rating bar widget. More...
 
class  RibbonWidget
 A static text/icons/tabs bar widget. More...
 
class  Screen
 Represents a single GUI screen. More...
 
class  ScreenKeyboard
 Class representing a screen keyboard. More...
 
class  ScreenSingleton
 Declares a class to be a singleton. More...
 
class  SkillLevelWidget
 A skill level widget. More...
 
class  Skin
 Object used to render the GUI widgets see Overview of GUI skin for more information about skinning in STK. More...
 
class  SkinWidgetContainer
 In order to avoid calculating render information every frame, it's stored in a SkinWidgetContainer for each widget (or each widget part if it requires many) More...
 
class  SpinnerWidget
 A spinner or gauge widget (to select numbers / percentages). More...
 
class  TextBoxWidget
 A text field widget. More...
 
class  Widget
 The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for the sole goal of containing children widgets in a group) More...
 

Enumerations

enum  GameState { MENU, GAME, INGAME_MENU, CURRENT }
 
enum  EventPropagation { EVENT_BLOCK, EVENT_BLOCK_BUT_HANDLED, EVENT_LET }
 
enum  NavigationDirection { NAV_LEFT, NAV_RIGHT, NAV_UP, NAV_DOWN }
 
enum  ModalDialogLocation { MODAL_DIALOG_LOCATION_CENTER = 0, MODAL_DIALOG_LOCATION_BOTTOM = 1 }
 
enum  WidgetType {
  WTYPE_NONE = -1, WTYPE_RIBBON, WTYPE_SPINNER, WTYPE_BUTTON,
  WTYPE_ICON_BUTTON, WTYPE_CHECKBOX, WTYPE_LABEL, WTYPE_BUBBLE,
  WTYPE_SPACER, WTYPE_DIV, WTYPE_DYNAMIC_RIBBON, WTYPE_MODEL_VIEW,
  WTYPE_LIST, WTYPE_TEXTBOX, WTYPE_PROGRESS, WTYPE_RATINGBAR
}
 
enum  BadgeType {
  LOCKED_BADGE = 1, OK_BADGE = 2, BAD_BADGE = 4, TROPHY_BADGE = 8,
  GAMEPAD_BADGE = 16, KEYBOARD_BADGE = 32, LOADING_BADGE = 64, ZIPPER_BADGE = 128,
  ANCHOR_BADGE = 256
}
 
enum  Property {
  PROP_ID = 100, PROP_PROPORTION, PROP_WIDTH, PROP_HEIGHT,
  PROP_CHILD_WIDTH, PROP_CHILD_HEIGHT, PROP_WORD_WRAP, PROP_ALTERNATE_BG,
  PROP_LINE_HEIGHT, PROP_X, PROP_Y, PROP_LAYOUT,
  PROP_ALIGN, PROP_ICON, PROP_FOCUS_ICON, PROP_TEXT_ALIGN,
  PROP_TEXT_VALIGN, PROP_MIN_VALUE, PROP_MAX_VALUE, PROP_MAX_WIDTH,
  PROP_MAX_HEIGHT, PROP_SQUARE, PROP_EXTEND_LABEL, PROP_LABELS_LOCATION,
  PROP_MAX_ROWS, PROP_WRAP_AROUND, PROP_DIV_PADDING, PROP_KEEP_SELECTION,
  PROP_CUSTOM_RATIO, PROP_ICON_ALIGN
}
 
enum  RibbonType { RIBBON_COMBO, RIBBON_TOOLBAR, RIBBON_TABS, RIBBON_VERTICAL_TABS }
 Types of ribbons. More...
 
enum  RibbonFlip { FLIP_NO, FLIP_UP_LEFT, FLIP_DOWN_RIGHT }
 Filp directions of ribbons.
 
enum  TextBoxType : int {
  TBT_TEXT = 0, TBT_CAP_SENTENCES = 1, TBT_PASSWORD = 2, TBT_NUMBER = 3,
  TBT_EMAIL = 4
}
 

Functions

static DialogQueuedialog_queue_singleton (NULL)
 
float getLatestDt ()
 
void showMessage (const core::stringw &message, const float time)
 
WidgetgetFocusForPlayer (const unsigned int playerID)
 Returns the widget currently focused by given player, or NULL if none. More...
 
void focusNothingForPlayer (const unsigned int playerID)
 Focuses nothing for given player (removes any selection for this player). More...
 
bool isFocusedForPlayer (const Widget *w, const unsigned int playerID)
 Returns whether given the widget is currently focused by given player. More...
 
int getTitleFontHeight ()
 
int getFontHeight ()
 
int getSmallFontHeight ()
 
int getLargeFontHeight ()
 
void clear ()
 erases the currently displayed screen, removing all added irrLicht widgets More...
 
void update (float dt)
 Updates all widgets that need to be updated. More...
 
void cleanForGame ()
 like GUIEngine::clear, but to be called before going into game
 
void clearScreenCache ()
 
void switchToScreen (Screen *screen)
 Low-level mean to change current screen. More...
 
void addScreenToList (Screen *screen)
 Add a screen to the list of screens known by the gui engine.
 
void removeScreen (Screen *screen)
 Remove a screen from the list of screens known by the gui engine.
 
void reshowCurrentScreen ()
 to be called after e.g. More...
 
void cleanUp ()
 Clean some of the cached data, either for a shutdown or a reload. More...
 
void deallocate ()
 To be called after cleanup(). More...
 
void resetGlobalVariables ()
 
void init (IrrlichtDevice *device_a, IVideoDriver *driver_a, AbstractStateManager *state_manager, bool loading)
 
void reloadSkin ()
 call when skin in user config was updated
 
void addGUIFunctionBeforeRendering (std::function< void()> func)
 Add gui-related function before rendering GUI (from other thread)
 
void render (float elapsed_time, bool is_loading)
 called on every frame to trigger the rendering of the GUI. More...
 
void clearLoadingTips ()
 
void renderLoading (bool clearIcons=true, bool launching=false, bool update_tips=true)
 renders a "loading" screen
 
void addLoadingIcon (irr::video::ITexture *icon)
 to spice up a bit the loading icon : add icons to the loading screen
 
WidgetgetWidget (const char *name)
 Finds a widget from its name (PROP_ID) in the current screen/dialog. More...
 
WidgetgetWidget (const int id)
 Finds a widget from its irrlicht widget ID in the current screen/dialog. More...
 
void init (irr::IrrlichtDevice *device, irr::video::IVideoDriver *driver, AbstractStateManager *state_manager, bool loading=true)
 Call this method to init the GUI engine. More...
 
irr::IrrlichtDevice * getDevice ()
 
irr::gui::IGUIEnvironment * getGUIEnv ()
 
irr::video::IVideoDriver * getDriver ()
 
irr::gui::ScalableFontgetSmallFont ()
 
irr::gui::ScalableFontgetFont ()
 
irr::gui::ScalableFontgetOutlineFont ()
 
irr::gui::ScalableFontgetLargeFont ()
 
irr::gui::ScalableFontgetHighresDigitFont ()
 
irr::gui::ScalableFontgetTitleFont ()
 
ScreengetCurrentScreen ()
 
AbstractStateManagergetStateManager ()
 
SkingetSkin ()
 
void setSkin (Skin *skin)
 
ScreengetScreenNamed (const char *name)
 
void showMessage (const irr::core::stringw &message, const float time=5.0f)
 shows a message at the bottom of the screen for a while More...
 
bool isWithinATextBox ()
 
void setWithinATextBox (bool in)
 

Variables

PtrVector< Widget, REF > needsUpdate
 Widgets that need to be notified at every frame can add themselves there (FIXME: unclean)
 
PtrVector< Screen, REF > g_loaded_screens
 
float dt = 0
 
std::vector< MenuMessagegui_messages
 
std::vector< irr::video::ITexture * > g_loading_icons
 
core::stringw g_tips_string
 
static ModalDialogmodalWindow = NULL
 global instance of the current dialog if any
 
bool pointer_was_shown
 To remember and restore the previous state.
 
SkinWidgetContainerg_bg_container = NULL
 The widget used to hold the scrollbar BG.
 
SkinWidgetContainerg_thumb_container = NULL
 The widget used to hold the scrollbar thumb.
 
static bool g_is_within_a_text_box = false
 
const unsigned int FOCUSABLE_IDS_BASE = 100
 
const unsigned int UNFOCUSABLE_IDS_BASE = 1000
 
static unsigned int id_counter = FOCUSABLE_IDS_BASE
 Used to assign irrLicht IDs to widgets dynamically.
 
static unsigned int id_counter_2 = UNFOCUSABLE_IDS_BASE
 for items that can't be reached with keyboard navigation but can be clicked
 
const int BUBBLE_MARGIN_ON_RIGHT = 15
 

Detailed Description

Contains all GUI engine related classes and functions.

See GUI Module Overview for more information.

Enumeration Type Documentation

◆ BadgeType

Enumerator
LOCKED_BADGE 

display a lock on the widget, to mean a certain game feature is locked

OK_BADGE 

display a green check on a widget, useful e.g.

to display confirmation

BAD_BADGE 

display a red mark badge on the widget, useful e.g.

to warn of an invalid choice

TROPHY_BADGE 

display a trophy badge on the widget, useful e.g.

for challenges

GAMEPAD_BADGE 

A gamepad icon.

KEYBOARD_BADGE 

A keyboard icon.

LOADING_BADGE 

An hourglass badge to indicate loading.

ZIPPER_BADGE 

A zipper badge to indicate that this player receives a boost.

ANCHOR_BADGE 

A anchor badge to indicate that this player receives a handicap.

◆ RibbonType

Types of ribbons.

Enumerator
RIBBON_COMBO 

select one item out of many, like in a combo box

RIBBON_TOOLBAR 

a row of individual buttons

RIBBON_TABS 

a tab bar

RIBBON_VERTICAL_TABS 

a vertical tab bar

Function Documentation

◆ cleanUp()

void GUIEngine::cleanUp ( )

Clean some of the cached data, either for a shutdown or a reload.

If this is a shutdown then you also need to call free().

◆ clear()

void GUIEngine::clear ( )

erases the currently displayed screen, removing all added irrLicht widgets

Note
Do not use directly. Use a state manager instead to get higher-level functionnality.

◆ deallocate()

void GUIEngine::deallocate ( )

To be called after cleanup().

The difference between cleanup() and free() is that cleanUp() just removes some cached data but does not actually uninitialize the gui engine. This does.

◆ focusNothingForPlayer()

void GUIEngine::focusNothingForPlayer ( const unsigned int  playerID)

Focuses nothing for given player (removes any selection for this player).

Note
Do NOT use irrLicht's GUI focus facilities; it's too limited for our needs, so we use ours. (i.e. always call these functions, never those in IGUIEnvironment)

◆ getCurrentScreen()

Screen* GUIEngine::getCurrentScreen ( )
inline
Returns
the currently shown screen, or NULL if none

◆ getDevice()

irr::IrrlichtDevice* GUIEngine::getDevice ( )
inline
Returns
the irrlicht device object

◆ getDriver()

irr::video::IVideoDriver* GUIEngine::getDriver ( )
inline
Returns
the irrlicht video driver object

◆ getFocusForPlayer()

Widget * GUIEngine::getFocusForPlayer ( const unsigned int  playerID)

Returns the widget currently focused by given player, or NULL if none.

Note
Do NOT use irrLicht's GUI focus facilities; it's too limited for our needs, so we use ours. (i.e. always call these functions, never those in IGUIEnvironment)

◆ getFont()

irr::gui::ScalableFont* GUIEngine::getFont ( )
inline
Returns
the "normal" font (useful for text)

◆ getFontHeight()

int GUIEngine::getFontHeight ( )
Returns
the height of the font in pixels

◆ getGUIEnv()

irr::gui::IGUIEnvironment* GUIEngine::getGUIEnv ( )
inline
Returns
the irrlicht GUI environment object

◆ getHighresDigitFont()

irr::gui::ScalableFont* GUIEngine::getHighresDigitFont ( )
inline
Returns
the "high-res digits" font (useful for big numbers)

◆ getLargeFont()

irr::gui::ScalableFont* GUIEngine::getLargeFont ( )
inline
Returns
the "large" font (useful for text)

◆ getLatestDt()

float GUIEngine::getLatestDt ( )
Precondition
the value returned by this function is only valid when invoked from GUIEngine::render
Returns
the time delta between the last two frames

◆ getSkin()

Skin* GUIEngine::getSkin ( )
inline
Precondition
GUIEngine::init must have been called first
Returns
the skin object used to render widgets

◆ getSmallFont()

irr::gui::ScalableFont* GUIEngine::getSmallFont ( )
inline
Returns
the smaller font (useful for less important messages)

◆ getSmallFontHeight()

int GUIEngine::getSmallFontHeight ( )
Returns
the height of the small font in pixels

◆ getStateManager()

AbstractStateManager* GUIEngine::getStateManager ( )
inline
Returns
the state manager being used, as passed to GUIEngine::init

◆ getTitleFont()

irr::gui::ScalableFont* GUIEngine::getTitleFont ( )
inline
Returns
the "title" font (it's bigger and orange, useful for headers/captions)

◆ getTitleFontHeight()

int GUIEngine::getTitleFontHeight ( )
Returns
the height of the title font in pixels

◆ getWidget() [1/2]

Widget * GUIEngine::getWidget ( const char *  name)

Finds a widget from its name (PROP_ID) in the current screen/dialog.

Parameters
namethe name (PROP_ID) of the widget to search for
Returns
the widget that bears that name, or NULL if it was not found

◆ getWidget() [2/2]

Widget * GUIEngine::getWidget ( const int  id)

Finds a widget from its irrlicht widget ID in the current screen/dialog.

Parameters
namethe irrlicht widget ID (not to be confused with PROP_ID, which is a string) of the widget to search for
Returns
the widget that bears that irrlicht ID, or NULL if it was not found

◆ init()

void GUIEngine::init ( irr::IrrlichtDevice *  device,
irr::video::IVideoDriver *  driver,
AbstractStateManager state_manager,
bool  loading = true 
)

Call this method to init the GUI engine.

Precondition
A irrlicht device and its corresponding video drivers must have been created
Parameters
deviceAn initialized irrlicht device object
driverAn initialized irrlicht driver object
state_managerAn instance of a class derived from abstract base AbstractStateManager
loadingif it's (re-)loading the GUIEngine

◆ isFocusedForPlayer()

bool GUIEngine::isFocusedForPlayer ( const Widget w,
const unsigned int  playerID 
)

Returns whether given the widget is currently focused by given player.

Note
Do NOT use irrLicht's GUI focus facilities; it's too limited for our needs, so we use ours. (i.e. always call these functions, never those in IGUIEnvironment)

◆ render()

void GUIEngine::render ( float  elapsed_time,
bool  is_loading 
)

called on every frame to trigger the rendering of the GUI.

called on every frame to trigger the rendering of the GUI

Parameters
elapsed_timeTime since last rendering calls (in seconds).
is_loadingTrue if the rendering is called during loading of world, in which case world, physics etc must not be accessed.

◆ reshowCurrentScreen()

void GUIEngine::reshowCurrentScreen ( )

to be called after e.g.

a resolution switch

◆ showMessage()

void GUIEngine::showMessage ( const irr::core::stringw &  message,
const float  time = 5.0f 
)

shows a message at the bottom of the screen for a while

Parameters
messagethe message to display
timethe time to display the message, in seconds

◆ switchToScreen()

void GUIEngine::switchToScreen ( Screen screen)

Low-level mean to change current screen.

Note
Do not use directly. Use a state manager instead to get higher-level functionnality.

◆ update()

void GUIEngine::update ( float  dt)

Updates all widgets that need to be updated.

Parameters
dtTime step size.