19#ifndef HEADER_SCREEN_HPP
20#define HEADER_SCREEN_HPP
25#include "utils/cpp2011.hpp"
28#include <IXMLReader.h>
32 namespace gui {
class IGUIElement; }
36#include "config/stk_config.hpp"
37#include "guiengine/abstract_top_level_container.hpp"
38#include "guiengine/engine.hpp"
39#include "guiengine/event_handler.hpp"
40#include "guiengine/widget.hpp"
41#include "input/input.hpp"
42#include "utils/leak_check.hpp"
43#include "utils/ptr_vector.hpp"
57 template<
typename SCREEN>
61 static SCREEN* singleton;
69 static SCREEN* getInstance()
71 if (singleton == NULL)
73 singleton =
new SCREEN();
74 std::function<SCREEN*()> new_screen_function = []()
75 {
return ScreenSingleton::getInstance(); };
76 singleton->setScreenPointerFunction(new_screen_function);
83 template <
typename SCREEN> SCREEN*
123 unsigned m_width, m_height;
127 std::string m_filename;
144 irr::gui::IGUIElement* parent = NULL);
153 Screen(
bool pause_race=
true);
155 Screen(
const char* filename,
bool pause_race=
true);
159 bool operator ==(
const char* filename)
const {
return m_filename == filename; }
181 const std::string&
getName()
const {
return m_filename; }
302 virtual int getWidth() {
return m_width; }
304 virtual int getHeight() {
return m_height; }
306 virtual bool isResizable()
const {
return m_resizable; }
313 const unsigned int value,
314 Input::InputType type,
316 {
return EVENT_LET; }
351 virtual void onCutsceneEnd() = 0;
Represents a GUI widgets container.
Definition: abstract_top_level_container.hpp:43
Definition: screen.hpp:344
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:97
virtual void onDialogClose()
Callback that gets called when a dialog is closed.
Definition: screen.hpp:337
bool m_pause_race
True if the race (if it is running) should be paused when this screen is shown.
Definition: screen.hpp:106
virtual void eventCallback(Widget *widget, const std::string &name, const int playerID)=0
will be called everytime something happens.
unsigned int m_magic_number
to catch errors as early as possible, for debugging purposes only
Definition: screen.hpp:121
bool m_update_in_background
When set to true it updates the screen even if modal dialog is opened.
Definition: screen.hpp:118
virtual void filterInput(Input::InputType type, int deviceID, int btnID, int axisDir, int value)
Override this if you need to be notified of raw input in subclasses.
Definition: screen.hpp:328
virtual void onDisabledItemClicked(const std::string &item)
Callback you can use if you want to know when the user pressed on a disabled ribbon item.
Definition: screen.hpp:322
void manualAddWidget(Widget *w)
Can be used for custom purposes for which the load-screen-from-XML code won't make it.
Definition: screen.cpp:209
virtual MusicInformation * getInGameMenuMusic() const
Definition: screen.hpp:300
bool isLoaded() const
Definition: screen.hpp:164
virtual void beforeAddingWidget()
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: screen.hpp:236
virtual void init()
Callback invoked when entering this menu (after the widgets have been added).
Definition: screen.cpp:94
bool m_resizable
True if this screen is resizable.
Definition: screen.hpp:101
virtual void onFocusChanged(Widget *previous, Widget *focus, int playerID)
Callback called when focus changes.
Definition: screen.hpp:340
virtual void loadedFromFile()=0
Callback invoked when loading this menu.
virtual void onUpdate(float dt)
optional callback you can override to be notified at every frame.
Definition: screen.hpp:285
void addWidgets()
Adds the IrrLicht widgets corresponding to this screen to the IGUIEnvironment.
Definition: screen.cpp:189
std::function< Screen *()> getNewScreenPointer() const
Save the function before GUIEngine::clearScreenCache, call it after to get the new screen instance po...
Definition: screen.hpp:149
std::function< Screen *()> m_screen_func
For runtime screen reloading without template.
Definition: screen.hpp:129
void manualRemoveWidget(Widget *w)
Can be used for custom purposes for which the load-screen-from-XML code won't make it.
Definition: screen.cpp:218
virtual bool onEscapePressed()
Called when escape is pressed.
Definition: screen.hpp:268
virtual MusicInformation * getMusic() const
Definition: screen.hpp:295
void setNeeds3D(bool needs3D)
Invoke this method for screens that use a 3D scene as background.
Definition: screen.hpp:200
void setUpdateInBackground(bool value)
When set to true it updates the screen even if modal dialog is opened.
Definition: screen.hpp:177
virtual void tearDown()
Callback invoked before leaving this menu.
Definition: screen.cpp:116
virtual void unloaded()
Callback invoked when this screen is being unloaded.
Definition: screen.hpp:229
bool needs3D()
Will be called to determine if the 3D scene must be rendered when at this screen.
Definition: screen.hpp:188
void push()
Displays this screen bu pushing it onto the stack of screen in the state manager.
Definition: screen.cpp:105
const std::string & getName() const
Definition: screen.hpp:181
virtual void onDraw(float dt)
optional callback you can override to be notified at every frame.
Definition: screen.hpp:290
void loadFromFile()
loads this Screen from the file passed to the constructor
Definition: screen.cpp:131
virtual EventPropagation filterActions(PlayerAction action, int deviceID, const unsigned int value, Input::InputType type, int playerId)
Override this if you need to be notified of player actions in subclasses.
Definition: screen.hpp:311
bool m_render_3d
Will be called to determine if the 3D scene must be rendered when at this screen.
Definition: screen.hpp:113
void calculateLayout()
Called after all widgets have been added.
Definition: screen.cpp:173
virtual void unload()
Next time this menu needs to be shown, don't use cached values, re-calculate everything.
Definition: screen.cpp:153
Object used to render the GUI widgets see Overview of GUI skin for more information about skinning in...
Definition: skin.hpp:269
Definition: ptr_vector.hpp:44
MusicInformation * m_title_music
Filename of the title music to play.
Definition: stk_config.hpp:170
static void parseScreenFileDiv(irr::io::IXMLReader *xml, PtrVector< Widget > &append_to, irr::gui::IGUIElement *parent=NULL)
Loads a GUI screen from its XML file.
Definition: screen_loader.cpp:38
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
void addScreenToList(Screen *cutscene)
Add a screen to the list of screens known by the gui engine.
Definition: engine.cpp:962