Luanti 5.16.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, volatile std::sig_atomic_t &kill)
 default constructor
virtual ~GUIEngine ()
 default destructor
MainMenuScriptinggetScriptIface ()
 return MainMenuScripting interface
std::string getScriptDir ()
 return dir of current menuscript
void requestScreenshot ()
 Request taking a screenshot on the next frame.
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
void setMenuCloudsColor (video::SColor color)
void setMenuSkyColor (video::SColor color)

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
volatile std::sig_atomic_t & 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
bool m_take_screenshot = false
 flag to take a screenshot on next frame
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
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,
volatile std::sig_atomic_t & kill )

default constructor

GUIEngine.

Parameters
devdevice to draw at
parentparent gui element
menumgrmanager to add menus to
smgrscene manager to add scene elements to
datastruct to transfer data to main game handling

References gui::StaticText::add(), createOpenALSoundManager(), errorstream, fullscreenChangedCallback(), g_fontengine, g_settings, g_sound_manager_singleton, RenderingEngine::get_gui_env(), RenderingEngine::get_video_driver(), infostream, loadMainMenuScript(), m_buttonhandler, m_data, m_formspecgui, m_irr_toplefttext, m_kill, m_menu, m_menumanager, m_parent, m_rendering_engine, m_script, m_smgr, m_sound_manager, m_texture_source, m_textures, m_toplefttext, run(), RenderingEngine::showErrorMessageBox(), strgettext(), and BaseException::what().

Referenced by fullscreenChangedCallback().

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

◆ ~GUIEngine()

GUIEngine::~GUIEngine ( )
virtual

default destructor

References g_settings, infostream, m_irr_toplefttext, m_menu, m_script, and m_sound_manager.

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, 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, MYMAX, TEX_LAYER_BACKGROUND, x, and y.

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 m_rendering_engine.

Referenced by run().

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, and TEX_LAYER_FOOTER.

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, and TEX_LAYER_HEADER.

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, and TEX_LAYER_OVERLAY.

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

Here is the caller graph for this function:

◆ loadMainMenuScript()

bool GUIEngine::loadMainMenuScript ( )
private

find and run the main menu script

References DIR_DELIM, errorstream, g_settings, 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:

◆ requestScreenshot()

void GUIEngine::requestScreenshot ( )
inline

Request taking a screenshot on the next frame.

References m_take_screenshot.

◆ run()

void GUIEngine::run ( )
private

run main menu loop

References RenderingEngine::autosaveScreensizeAndCo(), drawBackground(), drawClouds(), drawFooter(), drawHeader(), drawOverlay(), FrameMarker::end(), g_fontengine, g_settings, FpsControl::limit(), m_clouds_enabled, m_kill, m_menu, m_rendering_engine, m_script, m_sound_manager, m_startgame, m_take_screenshot, FpsControl::reset(), sound_volume_control(), FrameMarker::started(), takeScreenshot(), and updateTopLeftTextSize().

Referenced by GUIEngine().

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

◆ 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:

◆ setMenuCloudsColor()

void GUIEngine::setMenuCloudsColor ( video::SColor color)
private

References m_rendering_engine.

Referenced by ModApiMainMenu::l_set_clouds_color().

Here is the caller graph for this function:

◆ setMenuSkyColor()

void GUIEngine::setMenuSkyColor ( video::SColor color)
private

References m_rendering_engine.

Referenced by ModApiMainMenu::l_set_sky_color().

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 m_texture_source, m_textures, and fs::PathExists().

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 gui::StaticText::add(), g_fontengine, 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:

◆ MainMenuSoundHandle

friend class MainMenuSoundHandle
friend

References MainMenuSoundHandle.

Referenced by MainMenuSoundHandle.

◆ ModApiMainMenu

friend class ModApiMainMenu
friend

grant ModApiMainMenu access to private members

References ModApiMainMenu.

Referenced by ModApiMainMenu.

◆ ModApiMainMenuSound

friend class ModApiMainMenuSound
friend

References ModApiMainMenuSound.

Referenced by ModApiMainMenuSound.

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

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

pointer to gui element shown at topleft corner

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

◆ m_kill

volatile std::sig_atomic_t& GUIEngine::m_kill
private

reference to kill variable managed by SIGINT handler

Referenced by GUIEngine(), 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

IMenuManager* GUIEngine::m_menumanager = nullptr
private

◆ m_parent

gui::IGUIElement* GUIEngine::m_parent = nullptr
private

◆ 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

Referenced by GUIEngine().

◆ 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_take_screenshot

bool GUIEngine::m_take_screenshot = false
private

flag to take a screenshot on next frame

Referenced by requestScreenshot(), 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(), 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: