Minetest  5.4.0
GUIEngine Class Reference

implementation of main menu based uppon formspecs More...

#include <guiEngine.h>

+ Collaboration diagram for GUIEngine:

Classes

struct  clouddata
 internam data required for drawing clouds More...
 

Public Member Functions

 GUIEngine (JoystickController *joystick, gui::IGUIElement *parent, IMenuManager *menumgr, MainMenuData *data, bool &kill)
 default constructor More...
 
virtual ~GUIEngine ()
 default destructor More...
 
MainMenuScriptinggetScriptIface ()
 return MainMenuScripting interface More...
 
std::string getScriptDir ()
 return dir of current menuscript More...
 
unsigned int queueAsync (const std::string &serialized_fct, const std::string &serialized_params)
 pass async callback to scriptengine More...
 

Private Member Functions

bool loadMainMenuScript ()
 find and run the main menu script More...
 
void run ()
 run main menu loop More...
 
void updateTopLeftTextSize ()
 update size of topleftext element More...
 
void setFormspecPrepend (const std::string &fs)
 
void drawBackground (video::IVideoDriver *driver)
 draw background layer More...
 
void drawOverlay (video::IVideoDriver *driver)
 draw overlay layer More...
 
void drawHeader (video::IVideoDriver *driver)
 draw header layer More...
 
void drawFooter (video::IVideoDriver *driver)
 draw footer layer More...
 
bool setTexture (texture_layer layer, const std::string &texturepath, bool tile_image, unsigned int minsize)
 load a texture for a specified layer More...
 
void setTopleftText (const std::string &text)
 specify text to appear as top left string More...
 
void cloudInit ()
 initialize cloud subsystem More...
 
void cloudPreProcess ()
 do preprocessing for cloud subsystem More...
 
void cloudPostProcess (u32 frametime_min, IrrlichtDevice *device)
 do postprocessing for cloud subsystem More...
 
s32 playSound (const SimpleSoundSpec &spec, bool looped)
 start playing a sound and return handle More...
 
void stopSound (s32 handle)
 stop playing a sound started with playSound() More...
 

Static Private Member Functions

static bool downloadFile (const std::string &url, const std::string &target)
 download a file using curl More...
 

Private Attributes

gui::IGUIElement * m_parent = nullptr
 parent gui element More...
 
IMenuManagerm_menumanager = nullptr
 manager to add menus to More...
 
scene::ISceneManager * m_smgr = nullptr
 scene manager to add scene elements to More...
 
MainMenuDatam_data = nullptr
 pointer to data beeing transfered back to main game handling More...
 
ISimpleTextureSourcem_texture_source = nullptr
 pointer to texture source More...
 
ISoundManagerm_sound_manager = nullptr
 pointer to soundmanager More...
 
FormspecFormSourcem_formspecgui = nullptr
 representation of form source to be used in mainmenu formspec More...
 
TextDestGuiEnginem_buttonhandler = nullptr
 formspec input receiver More...
 
GUIFormSpecMenum_menu = nullptr
 the formspec menu More...
 
bool & m_kill
 reference to kill variable managed by SIGINT handler More...
 
bool m_startgame = false
 variable used to abort menu and return back to main game handling More...
 
MainMenuScriptingm_script = nullptr
 scripting interface More...
 
std::string m_scriptdir = ""
 script basefolder More...
 
image_definition m_textures [TEX_LAYER_MAX]
 array containing pointers to current specified texture layers More...
 
irr::gui::IGUIStaticText * m_irr_toplefttext = nullptr
 pointer to gui element shown at topleft corner More...
 
EnrichedString m_toplefttext
 and text that is in it More...
 
bool m_clouds_enabled = true
 is drawing of clouds enabled atm More...
 
clouddata m_cloud
 data used to draw clouds More...
 

Friends

class ModApiMainMenu
 grant ModApiMainMenu access to private members More...
 
class ModApiSound
 

Detailed Description

implementation of main menu based uppon formspecs

Constructor & Destructor Documentation

◆ GUIEngine()

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

◆ ~GUIEngine()

GUIEngine::~GUIEngine ( )
virtual

default destructor

References GUIEngine::clouddata::clouds, dummySoundManager, RenderingEngine::get_video_driver(), infostream, m_cloud, m_irr_toplefttext, m_script, m_sound_manager, m_texture_source, and m_textures.

+ Here is the call graph for this function:

Member Function Documentation

◆ cloudInit()

void GUIEngine::cloudInit ( )
private

initialize cloud subsystem

References GUIEngine::clouddata::camera, GUIEngine::clouddata::clouds, RenderingEngine::get_timer_time(), GUIEngine::clouddata::lasttime, m_cloud, m_smgr, Clouds::setHeight(), and Clouds::update().

Referenced by run().

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

◆ cloudPostProcess()

void GUIEngine::cloudPostProcess ( u32  frametime_min,
IrrlichtDevice *  device 
)
private

do postprocessing for cloud subsystem

References RenderingEngine::get_timer_time(), GUIEngine::clouddata::lasttime, and m_cloud.

Referenced by run().

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

◆ cloudPreProcess()

void GUIEngine::cloudPreProcess ( )
private

do preprocessing for cloud subsystem

References GUIEngine::clouddata::clouds, GUIEngine::clouddata::dtime, RenderingEngine::get_timer_time(), GUIEngine::clouddata::lasttime, m_cloud, m_smgr, Clouds::render(), and Clouds::step().

Referenced by run().

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

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

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

◆ 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 TextDestGuiEngine::gotText().

+ 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, 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:

◆ playSound()

s32 GUIEngine::playSound ( const SimpleSoundSpec spec,
bool  looped 
)
private

start playing a sound and return handle

References m_sound_manager, and ISoundManager::playSound().

Referenced by ModApiSound::l_sound_play().

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

◆ queueAsync()

unsigned int GUIEngine::queueAsync ( const std::string &  serialized_fct,
const std::string &  serialized_params 
)

pass async callback to scriptengine

References m_script, and MainMenuScripting::queueAsync().

Referenced by ModApiMainMenu::l_do_async_callback().

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

◆ run()

void GUIEngine::run ( )
private

run main menu loop

References cloudInit(), cloudPostProcess(), cloudPreProcess(), drawBackground(), drawFooter(), drawHeader(), drawOverlay(), g_fontengine, g_settings, RenderingEngine::get_gui_env(), RenderingEngine::get_raw_device(), RenderingEngine::get_video_driver(), Settings::getBool(), Settings::getFloat(), FontEngine::getTextHeight(), Settings::getU16(), m_clouds_enabled, m_kill, m_menu, m_script, m_startgame, RenderingEngine::run(), Settings::setU16(), sleep_ms, MainMenuScripting::step(), 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, and GUIFormSpecMenu::setFormspecPrepend().

Referenced by ModApiMainMenu::l_set_formspec_prepend().

+ Here is the call graph for this function:
+ 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_textures, image_definition::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:

◆ stopSound()

void GUIEngine::stopSound ( s32  handle)
private

stop playing a sound started with playSound()

References m_sound_manager, and ISoundManager::stopSound().

Referenced by ModApiSound::l_sound_stop().

+ 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 EnrichedString::c_str(), g_fontengine, RenderingEngine::get_gui_env(), FontEngine::getTextHeight(), FontEngine::getTextWidth(), m_irr_toplefttext, 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 Function Documentation

◆ ModApiMainMenu

friend class ModApiMainMenu
friend

grant ModApiMainMenu access to private members

◆ ModApiSound

friend class ModApiSound
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_cloud

clouddata GUIEngine::m_cloud
private

data used to draw clouds

Referenced by ~GUIEngine(), cloudInit(), cloudPostProcess(), and cloudPreProcess().

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

GUIFormSpecMenu* GUIEngine::m_menu = nullptr
private

◆ m_menumanager

IMenuManager* GUIEngine::m_menumanager = nullptr
private

◆ m_parent

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

◆ m_script

MainMenuScripting* GUIEngine::m_script = nullptr
private

scripting interface

Referenced by GUIEngine(), ~GUIEngine(), getScriptIface(), loadMainMenuScript(), queueAsync(), 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 cloudInit(), and cloudPreProcess().

◆ m_sound_manager

ISoundManager* GUIEngine::m_sound_manager = nullptr
private

pointer to soundmanager

Referenced by GUIEngine(), ~GUIEngine(), playSound(), and stopSound().

◆ 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

ISimpleTextureSource* GUIEngine::m_texture_source = nullptr
private

pointer to texture source

Referenced by GUIEngine(), ~GUIEngine(), and ModApiMainMenu::l_show_keys_menu().

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