implementation of main menu based uppon formspecs More...
#include <guiEngine.h>
Public Member Functions | |
GUIEngine (JoystickController *joystick, gui::IGUIElement *parent, RenderingEngine *rendering_engine, IMenuManager *menumgr, MainMenuData *data, bool &kill) | |
default constructor | |
virtual | ~GUIEngine () |
default destructor | |
MainMenuScripting * | getScriptIface () |
return MainMenuScripting interface | |
std::string | getScriptDir () |
return dir of current menuscript | |
Translations * | getContentTranslations (const std::string &path, const std::string &domain, const std::string &lang_code) |
Get translations for content. | |
Private Member Functions | |
bool | loadMainMenuScript () |
find and run the main menu script | |
void | run () |
run main menu loop | |
void | updateTopLeftTextSize () |
update size of topleftext element | |
void | setFormspecPrepend (const std::string &fs) |
void | drawBackground (video::IVideoDriver *driver) |
draw background layer | |
void | drawOverlay (video::IVideoDriver *driver) |
draw overlay layer | |
void | drawHeader (video::IVideoDriver *driver) |
draw header layer | |
void | drawFooter (video::IVideoDriver *driver) |
draw footer layer | |
bool | setTexture (texture_layer layer, const std::string &texturepath, bool tile_image, unsigned int minsize) |
load a texture for a specified layer | |
void | setTopleftText (const std::string &text) |
specify text to appear as top left string | |
void | drawClouds (float dtime) |
do preprocessing for cloud subsystem | |
Static Private Member Functions | |
static bool | downloadFile (const std::string &url, const std::string &target) |
download a file using curl | |
static void | fullscreenChangedCallback (const std::string &name, void *data) |
Private Attributes | |
std::string | m_last_translations_key |
Translations | m_last_translations |
Only the most recently used translation set is kept loaded. | |
RenderingEngine * | m_rendering_engine = nullptr |
gui::IGUIElement * | m_parent = nullptr |
parent gui element | |
IMenuManager * | m_menumanager = nullptr |
manager to add menus to | |
scene::ISceneManager * | m_smgr = nullptr |
scene manager to add scene elements to | |
MainMenuData * | m_data = nullptr |
pointer to data beeing transfered back to main game handling | |
std::unique_ptr< ISimpleTextureSource > | m_texture_source |
texture source | |
std::unique_ptr< ISoundManager > | m_sound_manager |
sound manager | |
FormspecFormSource * | m_formspecgui = nullptr |
representation of form source to be used in mainmenu formspec | |
TextDestGuiEngine * | m_buttonhandler = nullptr |
formspec input receiver | |
irr_ptr< GUIFormSpecMenu > | m_menu |
the formspec menu | |
bool & | m_kill |
reference to kill variable managed by SIGINT handler | |
bool | m_startgame = false |
variable used to abort menu and return back to main game handling | |
std::unique_ptr< MainMenuScripting > | m_script |
scripting interface | |
std::string | m_scriptdir = "" |
script basefolder | |
image_definition | m_textures [TEX_LAYER_MAX] |
array containing pointers to current specified texture layers | |
irr::gui::IGUIStaticText * | m_irr_toplefttext = nullptr |
pointer to gui element shown at topleft corner | |
EnrichedString | m_toplefttext |
and text that is in it | |
bool | m_clouds_enabled = true |
is drawing of clouds enabled atm | |
Friends | |
class | ModApiMainMenu |
grant ModApiMainMenu access to private members | |
class | ModApiMainMenuSound |
class | MainMenuSoundHandle |
implementation of main menu based uppon formspecs
GUIEngine::GUIEngine | ( | JoystickController * | joystick, |
gui::IGUIElement * | parent, | ||
RenderingEngine * | rendering_engine, | ||
IMenuManager * | menumgr, | ||
MainMenuData * | data, | ||
bool & | kill ) |
default constructor
dev | device to draw at |
parent | parent gui element |
menumgr | manager to add menus to |
smgr | scene manager to add scene elements to |
data | struct to transfer data to main game handling |
References irr::gui::StaticText::add(), EnrichedString::c_str(), createOpenALSoundManager(), MainMenuDataForScript::errormessage, errorstream, fullscreenChangedCallback(), g_fontengine, g_settings, g_sound_manager_singleton, RenderingEngine::get_gui_env(), RenderingEngine::get_video_driver(), Settings::getBool(), FontEngine::getTextHeight(), FontEngine::getTextWidth(), infostream, loadMainMenuScript(), m_buttonhandler, m_data, m_formspecgui, m_irr_toplefttext, m_menu, m_menumanager, m_parent, m_rendering_engine, m_script, m_sound_manager, m_texture_source, m_textures, m_toplefttext, Settings::registerChangedCallback(), run(), MainMenuData::script_data, ScriptApiMainMenu::setMainMenuData(), and BaseException::what().
|
virtual |
default destructor
References Settings::deregisterAllChangedCallbacks(), g_settings, RenderingEngine::get_video_driver(), infostream, m_irr_toplefttext, m_rendering_engine, m_script, m_sound_manager, and m_textures.
|
staticprivate |
download a file using curl
url | url to download |
target | file to store to |
References HTTPFetchRequest::caller, HTTPFetchResult::data, fs::DeleteSingleFileOrEmptyDirectory(), g_settings, Settings::getS32(), HTTPFETCH_SYNC, httpfetch_sync_interruptible(), open_ofstream(), HTTPFetchResult::succeeded, HTTPFetchRequest::timeout, and HTTPFetchRequest::url.
Referenced by ModApiMainMenu::l_download_file().
|
private |
draw background layer
driver | to use for drawing |
References draw2DImageFilterScaled(), m_textures, image_definition::minsize, MYMAX, TEX_LAYER_BACKGROUND, and image_definition::texture.
Referenced by run().
|
private |
do preprocessing for cloud subsystem
References g_menuclouds, g_menucloudsmgr, and Clouds::step().
Referenced by run().
|
private |
draw footer layer
driver | to use for drawing |
References draw2DImageFilterScaled(), m_textures, TEX_LAYER_FOOTER, and image_definition::texture.
Referenced by run().
|
private |
draw header layer
driver | to use for drawing |
References draw2DImageFilterScaled(), m_menu, m_textures, TEX_LAYER_HEADER, and image_definition::texture.
Referenced by run().
|
private |
draw overlay layer
driver | to use for drawing |
References draw2DImageFilterScaled(), m_textures, TEX_LAYER_OVERLAY, and image_definition::texture.
Referenced by run().
|
staticprivate |
References getScriptIface(), and ScriptApiMainMenu::handleMainMenuEvent().
Referenced by GUIEngine().
Translations * GUIEngine::getContentTranslations | ( | const std::string & | path, |
const std::string & | domain, | ||
const std::string & | lang_code ) |
Get translations for content.
Only loads a single textdomain from the path, as specified by domain
, for performance reasons.
WARNING: Do not store the returned pointer for long as the contents may change with the next call to getContentTranslations
.
References DIR_DELIM, findLocaleFileInMods(), findLocaleFileWithExtension(), GAME, getContentType(), fs::GetFilenameFromPath(), Translations::loadTranslation(), m_last_translations, m_last_translations_key, MODPACK, and fs::ReadFile().
Referenced by ModApiMainMenu::l_get_content_translation().
|
inline |
return dir of current menuscript
References m_scriptdir.
Referenced by ModApiMainMenu::l_get_mainmenu_path().
|
inline |
return MainMenuScripting interface
References m_script.
Referenced by fullscreenChangedCallback(), TextDestGuiEngine::gotText(), and TextDestGuiEngine::gotText().
|
private |
find and run the main menu script
References ScriptApiBase::checkSetByBuiltin(), DIR_DELIM, errorstream, g_settings, Settings::get(), ScriptApiBase::loadScript(), m_script, m_scriptdir, porting::path_share, and BaseException::what().
Referenced by GUIEngine().
|
private |
run main menu loop
References RenderingEngine::autosaveScreensizeAndCo(), MainMenuScripting::beforeClose(), drawBackground(), drawClouds(), drawFooter(), drawHeader(), drawOverlay(), FrameMarker::end(), g_fontengine, g_settings, RenderingEngine::get_gui_env(), RenderingEngine::get_raw_device(), Settings::getBool(), FontEngine::getTextHeight(), Settings::getU16(), ScriptApiMainMenu::handleMainMenuEvent(), FpsControl::limit(), m_clouds_enabled, m_kill, m_menu, m_rendering_engine, m_script, m_sound_manager, m_startgame, RenderingEngine::MENU_SKY_COLOR, FpsControl::reset(), RenderingEngine::run(), sound_volume_control(), FrameMarker::started(), ISoundManager::step(), MainMenuScripting::step(), and updateTopLeftTextSize().
Referenced by GUIEngine().
|
private |
References m_menu.
Referenced by ModApiMainMenu::l_set_formspec_prepend().
|
private |
load a texture for a specified layer
layer | draw layer to specify texture |
texturepath | full path of texture to load |
References RenderingEngine::get_video_driver(), m_rendering_engine, m_textures, image_definition::minsize, minsize(), fs::PathExists(), image_definition::texture, and image_definition::tile.
Referenced by ModApiMainMenu::l_set_background().
|
private |
specify text to appear as top left string
text | to set |
References m_toplefttext, translate_string(), updateTopLeftTextSize(), and utf8_to_wide().
Referenced by ModApiMainMenu::l_set_topleft_text().
|
private |
update size of topleftext element
References irr::gui::StaticText::add(), EnrichedString::c_str(), g_fontengine, RenderingEngine::get_gui_env(), FontEngine::getTextHeight(), FontEngine::getTextWidth(), m_irr_toplefttext, m_rendering_engine, and m_toplefttext.
Referenced by run(), and setTopleftText().
|
friend |
|
friend |
grant ModApiMainMenu access to private members
|
friend |
|
private |
formspec input receiver
Referenced by GUIEngine(), and ModApiMainMenu::l_show_path_select_dialog().
|
private |
is drawing of clouds enabled atm
Referenced by ModApiMainMenu::l_set_clouds(), and run().
|
private |
pointer to data beeing transfered back to main game handling
Referenced by GUIEngine(), and ModApiMainMenu::l_start().
|
private |
representation of form source to be used in mainmenu formspec
Referenced by GUIEngine(), and ModApiMainMenu::l_update_formspec().
|
private |
pointer to gui element shown at topleft corner
Referenced by GUIEngine(), ~GUIEngine(), and updateTopLeftTextSize().
|
private |
reference to kill variable managed by SIGINT handler
Referenced by ModApiMainMenu::l_close(), and run().
|
private |
Only the most recently used translation set is kept loaded.
Referenced by getContentTranslations().
|
private |
Referenced by getContentTranslations().
|
private |
the formspec menu
Referenced by GUIEngine(), drawHeader(), ModApiMainMenu::l_get_table_index(), run(), and setFormspecPrepend().
|
private |
manager to add menus to
Referenced by GUIEngine(), ModApiMainMenu::l_open_url_dialog(), ModApiMainMenu::l_show_keys_menu(), ModApiMainMenu::l_show_path_select_dialog(), and ModApiMainMenu::l_show_touchscreen_layout().
|
private |
parent gui element
Referenced by GUIEngine(), ModApiMainMenu::l_open_url_dialog(), ModApiMainMenu::l_show_keys_menu(), ModApiMainMenu::l_show_path_select_dialog(), and ModApiMainMenu::l_show_touchscreen_layout().
|
private |
|
private |
scripting interface
Referenced by GUIEngine(), ~GUIEngine(), getScriptIface(), loadMainMenuScript(), and run().
|
private |
script basefolder
Referenced by getScriptDir(), and loadMainMenuScript().
|
private |
scene manager to add scene elements to
|
private |
sound manager
Referenced by GUIEngine(), ~GUIEngine(), and run().
|
private |
variable used to abort menu and return back to main game handling
Referenced by ModApiMainMenu::l_set_formspec_prepend(), ModApiMainMenu::l_start(), ModApiMainMenu::l_update_formspec(), and run().
|
private |
texture source
Referenced by GUIEngine(), ModApiMainMenu::l_open_url_dialog(), ModApiMainMenu::l_show_keys_menu(), and ModApiMainMenu::l_show_touchscreen_layout().
|
private |
array containing pointers to current specified texture layers
Referenced by GUIEngine(), ~GUIEngine(), drawBackground(), drawFooter(), drawHeader(), drawOverlay(), and setTexture().
|
private |
and text that is in it
Referenced by GUIEngine(), setTopleftText(), and updateTopLeftTextSize().