Manages the user interface. More...
#include <gui_manager.hpp>
Public Member Functions | |
manager (const input::handler &mInputHandler, const std::string &sLocale, uint uiScreenWidth, uint uiScreenHeight, utils::refptr< manager_impl > pImpl) | |
Constructor. | |
~manager () | |
Destructor. | |
manager (const manager &mMgr) | |
This class is non copiable. | |
manager & | operator= (const manager &mMgr) |
This class is non copiable. | |
uint | get_screen_width () const |
Returns the "screen" width. | |
uint | get_screen_height () const |
Returns the "screen" height. | |
void | add_addon_directory (const std::string &sDirectory) |
Adds a new directory to be parsed for UI addons. | |
void | clear_addon_directory_list () |
Clears the addon directory list. | |
bool | check_uiobject_name (const std::string &sName) const |
Checks the provided string is suitable for naming a widget. | |
uiobject * | create_uiobject (const std::string &sClassName) |
Creates a new uiobject. | |
frame * | create_frame (const std::string &sClassName) |
Creates a new frame. | |
frame * | create_frame (const std::string &sClassName, const std::string &sName, frame *pParent=nullptr, const std::string &sInheritance="") |
Creates a new frame, ready for use. | |
layered_region * | create_layered_region (const std::string &sClassName) |
Creates a new layered_region. | |
utils::refptr< sprite > | create_sprite (utils::refptr< material > pMat) const |
Creates a new sprite. | |
utils::refptr< sprite > | create_sprite (utils::refptr< material > pMat, float fWidth, float fHeight) const |
Creates a new sprite. | |
utils::refptr< sprite > | create_sprite (utils::refptr< material > pMat, float fU, float fV, float fWidth, float fHeight) const |
Creates a new sprite. | |
utils::refptr< material > | create_material (const std::string &sFileName) const |
Creates a new material from a texture file. | |
utils::refptr< material > | create_material (const color &mColor) const |
Creates a new material from a plain color. | |
utils::refptr< material > | create_material (utils::refptr< render_target > pRenderTarget) const |
Creates a new material from a render target. | |
utils::refptr< render_target > | create_render_target (uint uiWidth, uint uiHeight) const |
Creates a new render target. | |
utils::refptr< font > | create_font (const std::string &sFontFile, uint uiSize) const |
Creates a new font. | |
bool | add_uiobject (uiobject *pObj) |
Adds an uiobject to be handled by this manager. | |
void | remove_uiobject (uiobject *pObj) |
Removes an uiobject from this manager. | |
void | notify_object_has_parent (uiobject *pObj) |
Tells this manager that the provided object now has a parent. | |
const uiobject * | get_uiobject (uint uiID) const |
Returns the uiobject associated with the given ID. | |
uiobject * | get_uiobject (uint uiID) |
Returns the uiobject associated with the given ID. | |
const uiobject * | get_uiobject_by_name (const std::string &sName, bool bVirtual=false) const |
Returns the uiobject associated with the given name. | |
uiobject * | get_uiobject_by_name (const std::string &sName, bool bVirtual=false) |
Returns the uiobject associated with the given name. | |
void | fire_build_strata_list () |
Tells this manager it must rebuild its strata list. | |
void | print_statistics () |
Prints in the log several performance statistics. | |
std::string | print_ui () const |
Prints debug informations in the log file. | |
addon * | get_current_addon () |
Returns the addon that is being parsed. | |
void | set_current_addon (addon *pAddOn) |
Sets the current addon. | |
std::string | parse_file_name (const std::string &sFileName) const |
Reads a file address and completes it to make a working address. | |
void | set_key_binding (uint uiKey, const std::string &sLuaString) |
Binds some Lua code to a key. | |
void | set_key_binding (uint uiKey, uint uiModifier, const std::string &sLuaString) |
Binds some Lua code to a key. | |
void | set_key_binding (uint uiKey, uint uiModifier1, uint uiModifier2, const std::string &sLuaString) |
Binds some Lua code to a key. | |
void | remove_key_binding (uint uiKey) |
Unbinds a key. | |
void | remove_key_binding (uint uiKey, uint uiModifier) |
Unbinds a key. | |
void | remove_key_binding (uint uiKey, uint uiModifier1, uint uiModifier2) |
Unbinds a key. | |
utils::wptr< lua::state > | get_lua () |
Returns the GUI Lua state. | |
void | create_lua (std::function< void()> pLuaRegs=nullptr) |
Creates the lua::State that will be used to communicate with the GUI. | |
void | read_files () |
Reads GUI files in the directory list. | |
void | load_ui () |
Loads the UI. | |
void | close_ui () |
Closes the UI, deletes widgets. | |
void | reload_ui () |
Closes the current UI and load it again. | |
void | render_ui () const |
Renders the UI into the current render target. | |
void | render_quad (const quad &mQuad) const |
Renders a quad. | |
void | render_quads (const quad &mQuad, const std::vector< std::array< vertex, 4 >> &lQuadList) const |
Renders a set of quads. | |
bool | is_loading_ui () const |
Checks if the UI is currently being loaded. | |
void | start_moving (uiobject *pObj, anchor *pAnchor=nullptr, constraint mConstraint=CONSTRAINT_NONE, std::function< void()> pApplyConstraintFunc=nullptr) |
Ask this manager for movement management. | |
void | stop_moving (uiobject *pObj) |
Stops movement for the given object. | |
bool | is_moving (uiobject *pObj) const |
Checks if the given object is allowed to move. | |
void | start_sizing (uiobject *pObj, anchor_point mPoint) |
Starts resizing a widget. | |
void | stop_sizing (uiobject *pObj) |
Stops sizing for the given object. | |
bool | is_sizing (uiobject *pObj) const |
Checks if the given object is allowed to be resized. | |
int | get_movement_x () const |
Returns the cumuled horizontal mouse movement. | |
int | get_movement_y () const |
Returns the cumuled vertical mouse movement. | |
void | notify_object_moved () |
Tells this manager an object has moved. | |
void | fire_redraw (frame_strata mStrata) const |
Tells this manager to redraw the UI. | |
void | enable_caching (bool bEnable) |
Enables/disables GUI caching. | |
void | toggle_caching () |
Toggles render caching. | |
bool | is_caching_enabled () const |
Checks if GUI caching is enabled. | |
void | enable_input (bool bEnable) |
Enables/disables input response for all widgets. | |
void | toggle_input () |
Toggles input response for all widgets. | |
bool | is_input_enabled () const |
Checks if input response is enabled for all widgets. | |
void | clear_fonts_on_close (bool bClear) |
Sets wether the Manager should clear all fonts when closed. | |
void | create_strata_render_target (frame_strata mframe_strata) |
Manually create a strata's render target. | |
const frame * | get_overed_frame () const |
Returns the frame under the mouse. | |
void | request_focus (focus_frame *pFocusFrame) |
Asks this manager for focus. | |
int | get_highest_level (frame_strata mframe_strata) const |
Returns the highest level on the provided strata. | |
void | update (float fDelta) |
updates this manager and its widgets. | |
void | on_event (const event &mEvent) |
Called whenever an Event occurs. | |
void | begin (utils::refptr< render_target > pTarget=nullptr) const |
Tells the underlying graphics engine to start rendering into a new target. | |
void | end () const |
Tells the underlying graphics engine we're done rendering. | |
template<class T > | |
void | register_frame_type (const std::string &sClassName) |
Registers a new frame type. | |
template<class T > | |
void | register_region_type (const std::string &sClassName) |
Registers a new layered_region type. | |
utils::wptr< const manager_impl > | get_impl () const |
Returns the implementation dependent manager_impl. | |
utils::wptr< manager_impl > | get_impl () |
Returns the implementation dependent manager_impl. | |
utils::wptr< event_manager > | get_event_manager () |
Returns the gui event manager. | |
utils::wptr< input::manager > | get_input_manager () |
Returns the input manager associated to this gui. | |
const std::string & | get_locale () const |
Returns the current game locale ("enGB", ...). | |
Static Public Member Functions | |
static manager * | get_manager (lua::state *pState) |
Returns the gui manager associated to the provided lua::state. |
Manages the user interface.
Definition at line 113 of file gui_manager.hpp.
gui::manager::manager | ( | const input::handler & | mInputHandler, | |
const std::string & | sLocale, | |||
uint | uiScreenWidth, | |||
uint | uiScreenHeight, | |||
utils::refptr< manager_impl > | pImpl | |||
) |
Constructor.
mInputHandler | The implementation input handler to use | |
sLocale | The name of the game locale ("enGB", ...) | |
uiScreenWidth | The width of the screen | |
uiScreenHeight | The height of the screen | |
pImpl | The implementation specific class |
Definition at line 31 of file gui_manager.cpp.
gui::manager::~manager | ( | ) |
Destructor.
Definition at line 54 of file gui_manager.cpp.
gui::manager::manager | ( | const manager & | mMgr | ) |
This class is non copiable.
void gui::manager::add_addon_directory | ( | const std::string & | sDirectory | ) |
Adds a new directory to be parsed for UI addons.
sDirectory | The new directory |
Definition at line 77 of file gui_manager.cpp.
bool gui::manager::add_uiobject | ( | uiobject * | pObj | ) |
Adds an uiobject to be handled by this manager.
pObj | The object to add |
Definition at line 293 of file gui_manager.cpp.
void gui::manager::begin | ( | utils::refptr< render_target > | pTarget = nullptr |
) | const |
Tells the underlying graphics engine to start rendering into a new target.
pTarget | The target to render to (nullptr to render to the screen) |
Definition at line 1647 of file gui_manager.cpp.
bool gui::manager::check_uiobject_name | ( | const std::string & | sName | ) | const |
Checks the provided string is suitable for naming a widget.
sName | The string to test |
Definition at line 88 of file gui_manager.cpp.
void gui::manager::clear_addon_directory_list | ( | ) |
Clears the addon directory list.
Definition at line 83 of file gui_manager.cpp.
void gui::manager::clear_fonts_on_close | ( | bool | bClear | ) |
Sets wether the Manager should clear all fonts when closed.
bClear | 'true' to clear fonts |
Definition at line 1426 of file gui_manager.cpp.
void gui::manager::close_ui | ( | ) |
Closes the UI, deletes widgets.
Definition at line 763 of file gui_manager.cpp.
utils::refptr< font > gui::manager::create_font | ( | const std::string & | sFontFile, | |
uint | uiSize | |||
) | const |
Creates a new font.
sFontFile | The file from which to read the font | |
uiSize | The requested size of the characters (in points) |
Definition at line 288 of file gui_manager.cpp.
frame * gui::manager::create_frame | ( | const std::string & | sClassName, | |
const std::string & | sName, | |||
frame * | pParent = nullptr , |
|||
const std::string & | sInheritance = "" | |||
) |
Creates a new frame, ready for use.
sClassName | The sub class of the frame (Button, ...) | |
sName | The name of this frame | |
pParent | The parent of the created frame (can be nullptr) | |
sInheritance | The name of the frame that should be inherited (empty if none) |
Definition at line 161 of file gui_manager.cpp.
frame * gui::manager::create_frame | ( | const std::string & | sClassName | ) |
layered_region * gui::manager::create_layered_region | ( | const std::string & | sClassName | ) |
Creates a new layered_region.
sClassName | The sub class of the layered_region (FontString or texture) |
Definition at line 230 of file gui_manager.cpp.
void gui::manager::create_lua | ( | std::function< void()> | pLuaRegs = nullptr |
) |
Creates the lua::State that will be used to communicate with the GUI.
pLuaRegs | Some code that will get exectued each time the lua state is created |
Definition at line 699 of file gui_manager.cpp.
utils::refptr< material > gui::manager::create_material | ( | utils::refptr< render_target > | pRenderTarget | ) | const |
Creates a new material from a render target.
pRenderTarget | The render target from which to read the pixels |
Definition at line 278 of file gui_manager.cpp.
utils::refptr< material > gui::manager::create_material | ( | const std::string & | sFileName | ) | const |
utils::refptr< render_target > gui::manager::create_render_target | ( | uint | uiWidth, | |
uint | uiHeight | |||
) | const |
Creates a new render target.
uiWidth | The width of the render target | |
uiHeight | The height of the render target |
Definition at line 283 of file gui_manager.cpp.
utils::refptr< sprite > gui::manager::create_sprite | ( | utils::refptr< material > | pMat, | |
float | fU, | |||
float | fV, | |||
float | fWidth, | |||
float | fHeight | |||
) | const |
Creates a new sprite.
pMat | The material with which to create the sprite | |
fU | The top left corner of the sprite in the material | |
fV | The top left corner of the sprite in the material | |
fWidth | The width of the sprite | |
fHeight | The height of the sprite |
Definition at line 258 of file gui_manager.cpp.
utils::refptr< sprite > gui::manager::create_sprite | ( | utils::refptr< material > | pMat, | |
float | fWidth, | |||
float | fHeight | |||
) | const |
Creates a new sprite.
pMat | The material with which to create the sprite | |
fWidth | The width of the sprite | |
fHeight | The height of the sprite |
Definition at line 249 of file gui_manager.cpp.
void gui::manager::create_strata_render_target | ( | frame_strata | mframe_strata | ) |
Manually create a strata's render target.
mframe_strata | The strata to create the render target for |
Definition at line 897 of file gui_manager.cpp.
uiobject * gui::manager::create_uiobject | ( | const std::string & | sClassName | ) |
void gui::manager::enable_caching | ( | bool | bEnable | ) |
Enables/disables GUI caching.
bEnable | 'true' to enable |
Definition at line 1384 of file gui_manager.cpp.
void gui::manager::enable_input | ( | bool | bEnable | ) |
Enables/disables input response for all widgets.
bEnable 'true' to enable input
Definition at line 1395 of file gui_manager.cpp.
void gui::manager::end | ( | ) | const |
Tells the underlying graphics engine we're done rendering.
Definition at line 1652 of file gui_manager.cpp.
void gui::manager::fire_build_strata_list | ( | ) |
Tells this manager it must rebuild its strata list.
Definition at line 977 of file gui_manager.cpp.
void gui::manager::fire_redraw | ( | frame_strata | mStrata | ) | const |
Tells this manager to redraw the UI.
Definition at line 1365 of file gui_manager.cpp.
addon * gui::manager::get_current_addon | ( | ) |
Returns the addon that is being parsed.
Definition at line 1555 of file gui_manager.cpp.
utils::wptr< event_manager > gui::manager::get_event_manager | ( | ) |
int gui::manager::get_highest_level | ( | frame_strata | mframe_strata | ) | const |
utils::wptr< manager_impl > gui::manager::get_impl | ( | ) |
Returns the implementation dependent manager_impl.
Definition at line 62 of file gui_manager.cpp.
utils::wptr<const manager_impl> gui::manager::get_impl | ( | ) | const |
Returns the implementation dependent manager_impl.
utils::wptr< input::manager > gui::manager::get_input_manager | ( | ) |
const std::string & gui::manager::get_locale | ( | ) | const |
Returns the current game locale ("enGB", ...).
Definition at line 1721 of file gui_manager.cpp.
utils::wptr< lua::state > gui::manager::get_lua | ( | ) |
Returns the GUI Lua state.
Definition at line 469 of file gui_manager.cpp.
manager * gui::manager::get_manager | ( | lua::state * | pState | ) | [static] |
Returns the gui manager associated to the provided lua::state.
pState | The lua::state |
Definition at line 49 of file gui_manager_glues.cpp.
int gui::manager::get_movement_x | ( | ) | const |
Returns the cumuled horizontal mouse movement.
Definition at line 1350 of file gui_manager.cpp.
int gui::manager::get_movement_y | ( | ) | const |
Returns the cumuled vertical mouse movement.
Definition at line 1355 of file gui_manager.cpp.
const frame * gui::manager::get_overed_frame | ( | ) | const |
Returns the frame under the mouse.
Definition at line 1431 of file gui_manager.cpp.
uint gui::manager::get_screen_height | ( | ) | const |
Returns the "screen" height.
Definition at line 72 of file gui_manager.cpp.
uint gui::manager::get_screen_width | ( | ) | const |
Returns the "screen" width.
Definition at line 67 of file gui_manager.cpp.
uiobject * gui::manager::get_uiobject | ( | uint | uiID | ) |
Returns the uiobject associated with the given ID.
uiID | The unique ID representing the widget |
Definition at line 420 of file gui_manager.cpp.
const uiobject * gui::manager::get_uiobject | ( | uint | uiID | ) | const |
Returns the uiobject associated with the given ID.
uiID | The unique ID representing the widget |
Definition at line 411 of file gui_manager.cpp.
uiobject * gui::manager::get_uiobject_by_name | ( | const std::string & | sName, | |
bool | bVirtual = false | |||
) |
Returns the uiobject associated with the given name.
sName | The name of the widget you're after | |
bVirtual | 'true' to search for a virtual frame |
Definition at line 449 of file gui_manager.cpp.
const uiobject * gui::manager::get_uiobject_by_name | ( | const std::string & | sName, | |
bool | bVirtual = false | |||
) | const |
Returns the uiobject associated with the given name.
sName | The name of the widget you're after | |
bVirtual | 'true' to search for a virtual frame |
Definition at line 429 of file gui_manager.cpp.
bool gui::manager::is_caching_enabled | ( | ) | const |
Checks if GUI caching is enabled.
Definition at line 1390 of file gui_manager.cpp.
bool gui::manager::is_input_enabled | ( | ) | const |
Checks if input response is enabled for all widgets.
Definition at line 1421 of file gui_manager.cpp.
bool gui::manager::is_loading_ui | ( | ) | const |
Checks if the UI is currently being loaded.
Definition at line 972 of file gui_manager.cpp.
bool gui::manager::is_moving | ( | uiobject * | pObj | ) | const |
Checks if the given object is allowed to move.
pObj | The object to check |
Definition at line 1255 of file gui_manager.cpp.
bool gui::manager::is_sizing | ( | uiobject * | pObj | ) | const |
Checks if the given object is allowed to be resized.
pObj | The object to check |
Definition at line 1345 of file gui_manager.cpp.
void gui::manager::load_ui | ( | ) |
Loads the UI.
Definition at line 757 of file gui_manager.cpp.
void gui::manager::notify_object_has_parent | ( | uiobject * | pObj | ) |
Tells this manager that the provided object now has a parent.
pObj | The object that has recently been given a parent |
Definition at line 406 of file gui_manager.cpp.
void gui::manager::notify_object_moved | ( | ) |
Tells this manager an object has moved.
Definition at line 1360 of file gui_manager.cpp.
void gui::manager::on_event | ( | const event & | mEvent | ) | [virtual] |
Called whenever an Event occurs.
mEvent | The Event which has occured |
Implements gui::event_receiver.
Definition at line 1578 of file gui_manager.cpp.
std::string gui::manager::parse_file_name | ( | const std::string & | sFileName | ) | const |
Reads a file address and completes it to make a working address.
sFileName | The raw file name |
Definition at line 1565 of file gui_manager.cpp.
void gui::manager::print_statistics | ( | ) |
Prints in the log several performance statistics.
Definition at line 1657 of file gui_manager.cpp.
std::string gui::manager::print_ui | ( | ) | const |
Prints debug informations in the log file.
Definition at line 1670 of file gui_manager.cpp.
void gui::manager::read_files | ( | ) |
Reads GUI files in the directory list.
Definition at line 725 of file gui_manager.cpp.
void gui::manager::register_frame_type | ( | const std::string & | sClassName | ) | [inline] |
Registers a new frame type.
sClassName | The name of the new type (as see in XML files) |
Definition at line 649 of file gui_manager.hpp.
void gui::manager::register_region_type | ( | const std::string & | sClassName | ) | [inline] |
Registers a new layered_region type.
sClassName | The name of the new type (as see in XML files) |
Definition at line 660 of file gui_manager.hpp.
void gui::manager::reload_ui | ( | ) |
Closes the current UI and load it again.
Definition at line 840 of file gui_manager.cpp.
void gui::manager::remove_key_binding | ( | uint | uiKey, | |
uint | uiModifier1, | |||
uint | uiModifier2 | |||
) |
Unbinds a key.
uiKey | The key to unbind | |
uiModifier1 | The first modifier key (shift, ctrl, ...) | |
uiModifier2 | The second modifier key (shift, ctrl, ...) |
Definition at line 1516 of file gui_manager.cpp.
void gui::manager::remove_key_binding | ( | uint | uiKey, | |
uint | uiModifier | |||
) |
Unbinds a key.
uiKey | The key to unbind | |
uiModifier | The modifier key (shift, ctrl, ...) |
Definition at line 1493 of file gui_manager.cpp.
void gui::manager::remove_key_binding | ( | uint | uiKey | ) |
void gui::manager::remove_uiobject | ( | uiobject * | pObj | ) |
Removes an uiobject from this manager.
pObj | The object to remove |
Definition at line 365 of file gui_manager.cpp.
void gui::manager::render_quad | ( | const quad & | mQuad | ) | const |
void gui::manager::render_quads | ( | const quad & | mQuad, | |
const std::vector< std::array< vertex, 4 >> & | lQuadList | |||
) | const |
Renders a set of quads.
mQuad | The base quad to use for rendering (material, blending, ...) | |
lQuadList | The list of the quads you want to render |
Definition at line 892 of file gui_manager.cpp.
void gui::manager::render_ui | ( | ) | const |
Renders the UI into the current render target.
Definition at line 849 of file gui_manager.cpp.
void gui::manager::request_focus | ( | focus_frame * | pFocusFrame | ) |
Asks this manager for focus.
pFocusFrame | The focus_frame requesting focus |
Definition at line 1436 of file gui_manager.cpp.
void gui::manager::set_current_addon | ( | addon * | pAddOn | ) |
Sets the current addon.
pAddOn | The current addon |
Definition at line 1560 of file gui_manager.cpp.
void gui::manager::set_key_binding | ( | uint | uiKey, | |
uint | uiModifier1, | |||
uint | uiModifier2, | |||
const std::string & | sLuaString | |||
) |
Binds some Lua code to a key.
uiKey | The key to bind | |
uiModifier1 | The first modifier key (shift, ctrl, ...) | |
uiModifier2 | The second modifier key (shift, ctrl, ...) | |
sLuaString | The Lua code that will be executed |
Definition at line 1465 of file gui_manager.cpp.
void gui::manager::set_key_binding | ( | uint | uiKey, | |
uint | uiModifier, | |||
const std::string & | sLuaString | |||
) |
Binds some Lua code to a key.
uiKey | The key to bind | |
uiModifier | The modifier key (shift, ctrl, ...) | |
sLuaString | The Lua code that will be executed |
Definition at line 1460 of file gui_manager.cpp.
void gui::manager::set_key_binding | ( | uint | uiKey, | |
const std::string & | sLuaString | |||
) |
Binds some Lua code to a key.
uiKey | The key to bind | |
sLuaString | The Lua code that will be executed |
Definition at line 1455 of file gui_manager.cpp.
void gui::manager::start_moving | ( | uiobject * | pObj, | |
anchor * | pAnchor = nullptr , |
|||
constraint | mConstraint = CONSTRAINT_NONE , |
|||
std::function< void()> | pApplyConstraintFunc = nullptr | |||
) |
Ask this manager for movement management.
pObj | The object to move | |
pAnchor | The reference anchor | |
mConstraint | The constraint axis if any |
Definition at line 1213 of file gui_manager.cpp.
void gui::manager::start_sizing | ( | uiobject * | pObj, | |
anchor_point | mPoint | |||
) |
Starts resizing a widget.
pObj | The object to resize | |
mPoint | The sizing point |
Definition at line 1260 of file gui_manager.cpp.
void gui::manager::stop_moving | ( | uiobject * | pObj | ) |
Stops movement for the given object.
pObj | The object to stop moving |
Definition at line 1246 of file gui_manager.cpp.
void gui::manager::stop_sizing | ( | uiobject * | pObj | ) |
Stops sizing for the given object.
pObj | The object to stop sizing |
Definition at line 1339 of file gui_manager.cpp.
void gui::manager::toggle_caching | ( | ) |
Toggles render caching.
Definition at line 1372 of file gui_manager.cpp.
void gui::manager::toggle_input | ( | ) |
Toggles input response for all widgets.
Definition at line 1401 of file gui_manager.cpp.
void gui::manager::update | ( | float | fDelta | ) |
updates this manager and its widgets.
fDelta | The time elapsed since the last call |
Definition at line 982 of file gui_manager.cpp.