Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
guiEngine.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 sapier
4
5#pragma once
6
7/******************************************************************************/
8/* Includes */
9/******************************************************************************/
10#include "irrlichttypes.h"
11#include "guiFormSpecMenu.h"
12#include "client/clouds.h"
13#include "client/sound.h"
15#include "translation.h"
16
17/******************************************************************************/
18/* Structs and macros */
19/******************************************************************************/
28
30 video::ITexture *texture = nullptr;
31 bool tile;
32 unsigned int minsize;
33};
34
35/******************************************************************************/
36/* forward declarations */
37/******************************************************************************/
38class GUIEngine;
39class RenderingEngine;
42struct MainMenuData;
43
44/******************************************************************************/
45/* declarations */
46/******************************************************************************/
47
50{
51public:
56 TextDestGuiEngine(GUIEngine* engine) : m_engine(engine) {};
57
62 void gotText(const StringMap &fields);
63
68 void gotText(const std::wstring &text);
69
70private:
72 GUIEngine *m_engine = nullptr;
73};
74
77{
78public:
83 MenuTextureSource(video::IVideoDriver *driver) : m_driver(driver) {};
84
88 virtual ~MenuTextureSource();
89
95 video::ITexture *getTexture(const std::string &name, u32 *id = NULL);
96
97private:
99 video::IVideoDriver *m_driver = nullptr;
101 std::vector<video::ITexture*> m_to_delete;
102};
103
106{
107protected:
108 void addThePaths(const std::string &name,
109 std::vector<std::string> &paths) override;
110};
111
115 friend class ModApiMainMenu;
118
119public:
129 gui::IGUIElement *parent,
130 RenderingEngine *rendering_engine,
131 IMenuManager *menumgr,
132 MainMenuData *data,
133 bool &kill);
134
136 virtual ~GUIEngine();
137
142 {
143 return m_script.get();
144 }
145
149 std::string getScriptDir()
150 {
151 return m_scriptdir;
152 }
153
163 Translations *getContentTranslations(const std::string &path,
164 const std::string &domain, const std::string &lang_code);
165
166private:
170
172 bool loadMainMenuScript();
173
175 void run();
176
179
182 gui::IGUIElement *m_parent = nullptr;
186 scene::ISceneManager *m_smgr = nullptr;
190 std::unique_ptr<ISimpleTextureSource> m_texture_source;
192 std::unique_ptr<ISoundManager> m_sound_manager;
193
199 irr_ptr<GUIFormSpecMenu> m_menu;
200
202 bool &m_kill;
203
205 bool m_startgame = false;
206
208 std::unique_ptr<MainMenuScripting> m_script;
209
211 std::string m_scriptdir = "";
212
213 void setFormspecPrepend(const std::string &fs);
214
219 void drawBackground(video::IVideoDriver *driver);
224 void drawOverlay(video::IVideoDriver *driver);
229 void drawHeader(video::IVideoDriver *driver);
234 void drawFooter(video::IVideoDriver *driver);
235
241 bool setTexture(texture_layer layer, const std::string &texturepath,
242 bool tile_image, unsigned int minsize);
243
249 static bool downloadFile(const std::string &url, const std::string &target);
250
253
258 void setTopleftText(const std::string &text);
259
261 irr::gui::IGUIStaticText *m_irr_toplefttext = nullptr;
264
266 void drawClouds(float dtime);
267
269 bool m_clouds_enabled = true;
270
271 static void fullscreenChangedCallback(const std::string &name, void *data);
272};
Definition enriched_string.h:29
Definition guiFormSpecMenu.h:513
implementation of main menu based uppon formspecs
Definition guiEngine.h:113
bool m_startgame
variable used to abort menu and return back to main game handling
Definition guiEngine.h:205
scene::ISceneManager * m_smgr
scene manager to add scene elements to
Definition guiEngine.h:186
bool m_clouds_enabled
is drawing of clouds enabled atm
Definition guiEngine.h:269
void run()
run main menu loop
Definition guiEngine.cpp:296
Translations m_last_translations
Only the most recently used translation set is kept loaded.
Definition guiEngine.h:169
FormspecFormSource * m_formspecgui
representation of form source to be used in mainmenu formspec
Definition guiEngine.h:195
virtual ~GUIEngine()
default destructor
Definition guiEngine.cpp:390
void drawOverlay(video::IVideoDriver *driver)
draw overlay layer
Definition guiEngine.cpp:481
void drawBackground(video::IVideoDriver *driver)
draw background layer
Definition guiEngine.cpp:426
void updateTopLeftTextSize()
update size of topleftext element
Definition guiEngine.cpp:656
image_definition m_textures[TEX_LAYER_MAX]
array containing pointers to current specified texture layers
Definition guiEngine.h:252
bool setTexture(texture_layer layer, const std::string &texturepath, bool tile_image, unsigned int minsize)
load a texture for a specified layer
Definition guiEngine.cpp:591
void setTopleftText(const std::string &text)
specify text to appear as top left string
Definition guiEngine.cpp:648
std::unique_ptr< ISoundManager > m_sound_manager
sound manager
Definition guiEngine.h:192
MainMenuData * m_data
pointer to data beeing transfered back to main game handling
Definition guiEngine.h:188
RenderingEngine * m_rendering_engine
Definition guiEngine.h:180
std::unique_ptr< MainMenuScripting > m_script
scripting interface
Definition guiEngine.h:208
void drawHeader(video::IVideoDriver *driver)
draw header layer
Definition guiEngine.cpp:500
std::unique_ptr< ISimpleTextureSource > m_texture_source
texture source
Definition guiEngine.h:190
EnrichedString m_toplefttext
and text that is in it
Definition guiEngine.h:263
bool loadMainMenuScript()
find and run the main menu script
Definition guiEngine.cpp:272
MainMenuScripting * getScriptIface()
return MainMenuScripting interface
Definition guiEngine.h:141
std::string m_last_translations_key
Definition guiEngine.h:167
void drawClouds(float dtime)
do preprocessing for cloud subsystem
Definition guiEngine.cpp:410
void drawFooter(video::IVideoDriver *driver)
draw footer layer
Definition guiEngine.cpp:559
static void fullscreenChangedCallback(const std::string &name, void *data)
Definition guiEngine.cpp:668
Translations * getContentTranslations(const std::string &path, const std::string &domain, const std::string &lang_code)
Get translations for content.
Definition guiEngine.cpp:230
static bool downloadFile(const std::string &url, const std::string &target)
download a file using curl
Definition guiEngine.cpp:617
irr::gui::IGUIStaticText * m_irr_toplefttext
pointer to gui element shown at topleft corner
Definition guiEngine.h:261
IMenuManager * m_menumanager
manager to add menus to
Definition guiEngine.h:184
TextDestGuiEngine * m_buttonhandler
formspec input receiver
Definition guiEngine.h:197
void setFormspecPrepend(const std::string &fs)
Definition guiEngine.cpp:417
gui::IGUIElement * m_parent
parent gui element
Definition guiEngine.h:182
GUIEngine(JoystickController *joystick, gui::IGUIElement *parent, RenderingEngine *rendering_engine, IMenuManager *menumgr, MainMenuData *data, bool &kill)
default constructor
Definition guiEngine.cpp:107
std::string getScriptDir()
return dir of current menuscript
Definition guiEngine.h:149
bool & m_kill
reference to kill variable managed by SIGINT handler
Definition guiEngine.h:202
irr_ptr< GUIFormSpecMenu > m_menu
the formspec menu
Definition guiEngine.h:199
std::string m_scriptdir
script basefolder
Definition guiEngine.h:211
Definition modalMenu.h:25
Definition texturesource.h:25
Definition shader.h:213
Definition joystick_controller.h:87
Definition scripting_mainmenu.h:20
Definition l_mainmenu_sound.h:25
GUIEngine specific implementation of SoundFallbackPathProvider.
Definition guiEngine.h:106
void addThePaths(const std::string &name, std::vector< std::string > &paths) override
MenuMusicFetcher
Definition guiEngine.cpp:92
GUIEngine specific implementation of ISimpleTextureSource.
Definition guiEngine.h:77
MenuTextureSource(video::IVideoDriver *driver)
default constructor
Definition guiEngine.h:83
virtual ~MenuTextureSource()
destructor, removes all loaded textures
Definition guiEngine.cpp:49
video::IVideoDriver * m_driver
driver to get textures from
Definition guiEngine.h:99
std::vector< video::ITexture * > m_to_delete
set of textures to delete
Definition guiEngine.h:101
video::ITexture * getTexture(const std::string &name, u32 *id=NULL)
get a texture, loading it if required
Definition guiEngine.cpp:63
Definition l_mainmenu_sound.h:15
Implementation of lua api support for mainmenu.
Definition l_mainmenu.h:13
Definition renderingengine.h:68
Definition sound.h:22
GUIEngine specific implementation of TextDest used within guiFormSpecMenu.
Definition guiEngine.h:50
TextDestGuiEngine(GUIEngine *engine)
default constructor
Definition guiEngine.h:56
GUIEngine * m_engine
target to transmit data to
Definition guiEngine.h:72
void gotText(const StringMap &fields)
receive fields transmitted by guiFormSpecMenu
Definition guiEngine.cpp:37
Definition translation.h:19
static size_t minsize(const GettextPluralForm::Ptr &form)
Definition gettext_plural_form.cpp:7
texture_layer
texture layer ids
Definition guiEngine.h:21
@ TEX_LAYER_BACKGROUND
Definition guiEngine.h:22
@ TEX_LAYER_OVERLAY
Definition guiEngine.h:23
@ TEX_LAYER_HEADER
Definition guiEngine.h:24
@ TEX_LAYER_MAX
Definition guiEngine.h:26
@ TEX_LAYER_FOOTER
Definition guiEngine.h:25
Definition filesys.cpp:53
std::unordered_map< std::string, std::string > StringMap
Definition string.h:65
Definition guiMainMenu.h:21
Definition guiFormSpecMenu.h:67
Definition guiEngine.h:29
bool tile
Definition guiEngine.h:31
unsigned int minsize
Definition guiEngine.h:32
video::ITexture * texture
Definition guiEngine.h:30