Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
GUIEngine Class Reference

implementation of main menu based uppon formspecs More...

#include <guiEngine.h>

+ Collaboration diagram for GUIEngine:

Public Member Functions

 GUIEngine (JoystickController *joystick, gui::IGUIElement *parent, RenderingEngine *rendering_engine, IMenuManager *menumgr, MainMenuData *data, bool &kill)
 default constructor
 
virtual ~GUIEngine ()
 default destructor
 
MainMenuScriptinggetScriptIface ()
 return MainMenuScripting interface
 
std::string getScriptDir ()
 return dir of current menuscript
 
TranslationsgetContentTranslations (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.
 
RenderingEnginem_rendering_engine = nullptr
 
gui::IGUIElement * m_parent = nullptr
 parent gui element
 
IMenuManagerm_menumanager = nullptr
 manager to add menus to
 
scene::ISceneManager * m_smgr = nullptr
 scene manager to add scene elements to
 
MainMenuDatam_data = nullptr
 pointer to data beeing transfered back to main game handling
 
std::unique_ptr< ISimpleTextureSourcem_texture_source
 texture source
 
std::unique_ptr< ISoundManagerm_sound_manager
 sound manager
 
FormspecFormSourcem_formspecgui = nullptr
 representation of form source to be used in mainmenu formspec
 
TextDestGuiEnginem_buttonhandler = nullptr
 formspec input receiver
 
irr_ptr< GUIFormSpecMenum_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< MainMenuScriptingm_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
 

Detailed Description

implementation of main menu based uppon formspecs

Constructor & Destructor Documentation

◆ GUIEngine()

GUIEngine::GUIEngine ( JoystickController * joystick,
gui::IGUIElement * parent,
RenderingEngine * rendering_engine,
IMenuManager * menumgr,
MainMenuData * data,
bool & kill )

◆ ~GUIEngine()

GUIEngine::~GUIEngine ( )
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.

+ Here is the call graph for this function:

Member Function Documentation

◆ downloadFile()

bool GUIEngine::downloadFile ( const std::string & url,
const std::string & target )
staticprivate

download a file using curl

Parameters
urlurl to download
targetfile 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drawBackground()

void GUIEngine::drawBackground ( video::IVideoDriver * driver)
private

draw background layer

Parameters
driverto use for drawing

References draw2DImageFilterScaled(), m_textures, image_definition::minsize, MYMAX, TEX_LAYER_BACKGROUND, and image_definition::texture.

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drawClouds()

void GUIEngine::drawClouds ( float dtime)
private

do preprocessing for cloud subsystem

References g_menuclouds, g_menucloudsmgr, and Clouds::step().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drawFooter()

void GUIEngine::drawFooter ( video::IVideoDriver * driver)
private

draw footer layer

Parameters
driverto use for drawing

References draw2DImageFilterScaled(), m_textures, TEX_LAYER_FOOTER, and image_definition::texture.

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drawHeader()

void GUIEngine::drawHeader ( video::IVideoDriver * driver)
private

draw header layer

Parameters
driverto use for drawing

References draw2DImageFilterScaled(), m_menu, m_textures, TEX_LAYER_HEADER, and image_definition::texture.

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drawOverlay()

void GUIEngine::drawOverlay ( video::IVideoDriver * driver)
private

draw overlay layer

Parameters
driverto use for drawing

References draw2DImageFilterScaled(), m_textures, TEX_LAYER_OVERLAY, and image_definition::texture.

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fullscreenChangedCallback()

void GUIEngine::fullscreenChangedCallback ( const std::string & name,
void * data )
staticprivate

References getScriptIface(), and ScriptApiMainMenu::handleMainMenuEvent().

Referenced by GUIEngine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContentTranslations()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScriptDir()

std::string GUIEngine::getScriptDir ( )
inline

return dir of current menuscript

References m_scriptdir.

Referenced by ModApiMainMenu::l_get_mainmenu_path().

+ Here is the caller graph for this function:

◆ getScriptIface()

MainMenuScripting * GUIEngine::getScriptIface ( )
inline

return MainMenuScripting interface

References m_script.

Referenced by fullscreenChangedCallback(), TextDestGuiEngine::gotText(), and TextDestGuiEngine::gotText().

+ Here is the caller graph for this function:

◆ loadMainMenuScript()

bool GUIEngine::loadMainMenuScript ( )
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void GUIEngine::run ( )
private

◆ setFormspecPrepend()

void GUIEngine::setFormspecPrepend ( const std::string & fs)
private

References m_menu.

Referenced by ModApiMainMenu::l_set_formspec_prepend().

+ Here is the caller graph for this function:

◆ setTexture()

bool GUIEngine::setTexture ( texture_layer layer,
const std::string & texturepath,
bool tile_image,
unsigned int minsize )
private

load a texture for a specified layer

Parameters
layerdraw layer to specify texture
texturepathfull 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTopleftText()

void GUIEngine::setTopleftText ( const std::string & text)
private

specify text to appear as top left string

Parameters
textto set

References m_toplefttext, translate_string(), updateTopLeftTextSize(), and utf8_to_wide().

Referenced by ModApiMainMenu::l_set_topleft_text().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTopLeftTextSize()

void GUIEngine::updateTopLeftTextSize ( )
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ MainMenuSoundHandle

friend class MainMenuSoundHandle
friend

◆ ModApiMainMenu

friend class ModApiMainMenu
friend

grant ModApiMainMenu access to private members

◆ ModApiMainMenuSound

friend class ModApiMainMenuSound
friend

Member Data Documentation

◆ m_buttonhandler

TextDestGuiEngine* GUIEngine::m_buttonhandler = nullptr
private

formspec input receiver

Referenced by GUIEngine(), and ModApiMainMenu::l_show_path_select_dialog().

◆ m_clouds_enabled

bool GUIEngine::m_clouds_enabled = true
private

is drawing of clouds enabled atm

Referenced by ModApiMainMenu::l_set_clouds(), and run().

◆ m_data

MainMenuData* GUIEngine::m_data = nullptr
private

pointer to data beeing transfered back to main game handling

Referenced by GUIEngine(), and ModApiMainMenu::l_start().

◆ m_formspecgui

FormspecFormSource* GUIEngine::m_formspecgui = nullptr
private

representation of form source to be used in mainmenu formspec

Referenced by GUIEngine(), and ModApiMainMenu::l_update_formspec().

◆ m_irr_toplefttext

irr::gui::IGUIStaticText* GUIEngine::m_irr_toplefttext = nullptr
private

pointer to gui element shown at topleft corner

Referenced by GUIEngine(), ~GUIEngine(), and updateTopLeftTextSize().

◆ m_kill

bool& GUIEngine::m_kill
private

reference to kill variable managed by SIGINT handler

Referenced by ModApiMainMenu::l_close(), and run().

◆ m_last_translations

Translations GUIEngine::m_last_translations
private

Only the most recently used translation set is kept loaded.

Referenced by getContentTranslations().

◆ m_last_translations_key

std::string GUIEngine::m_last_translations_key
private

Referenced by getContentTranslations().

◆ m_menu

irr_ptr<GUIFormSpecMenu> GUIEngine::m_menu
private

◆ m_menumanager

◆ m_parent

◆ m_rendering_engine

◆ m_script

std::unique_ptr<MainMenuScripting> GUIEngine::m_script
private

scripting interface

Referenced by GUIEngine(), ~GUIEngine(), getScriptIface(), loadMainMenuScript(), and run().

◆ m_scriptdir

std::string GUIEngine::m_scriptdir = ""
private

script basefolder

Referenced by getScriptDir(), and loadMainMenuScript().

◆ m_smgr

scene::ISceneManager* GUIEngine::m_smgr = nullptr
private

scene manager to add scene elements to

◆ m_sound_manager

std::unique_ptr<ISoundManager> GUIEngine::m_sound_manager
private

sound manager

Referenced by GUIEngine(), ~GUIEngine(), and run().

◆ m_startgame

bool GUIEngine::m_startgame = false
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().

◆ m_texture_source

std::unique_ptr<ISimpleTextureSource> GUIEngine::m_texture_source
private

◆ m_textures

image_definition GUIEngine::m_textures[TEX_LAYER_MAX]
private

array containing pointers to current specified texture layers

Referenced by GUIEngine(), ~GUIEngine(), drawBackground(), drawFooter(), drawHeader(), drawOverlay(), and setTexture().

◆ m_toplefttext

EnrichedString GUIEngine::m_toplefttext
private

and text that is in it

Referenced by GUIEngine(), setTopleftText(), and updateTopLeftTextSize().


The documentation for this class was generated from the following files: