diff options
author | rubenwardy <rw@rubenwardy.com> | 2019-08-12 18:16:35 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2019-08-12 19:16:35 +0200 |
commit | 91114b562fb2c65467485008b810836f951274ea (patch) | |
tree | c87cd43af2bf9b3a76a30257f914626729c302be | |
parent | a067d404542704c3bcc284262f588fba398b3102 (diff) | |
download | minetest-91114b562fb2c65467485008b810836f951274ea.tar.gz minetest-91114b562fb2c65467485008b810836f951274ea.tar.bz2 minetest-91114b562fb2c65467485008b810836f951274ea.zip |
Add support for set_formspec_prepend in main menu (#8611)
-rw-r--r-- | doc/menu_lua_api.txt | 2 | ||||
-rw-r--r-- | src/gui/guiEngine.cpp | 10 | ||||
-rw-r--r-- | src/gui/guiEngine.h | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 16 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.h | 2 |
5 files changed, 31 insertions, 1 deletions
diff --git a/doc/menu_lua_api.txt b/doc/menu_lua_api.txt index f6b2ffbd2..a2f9c3f5b 100644 --- a/doc/menu_lua_api.txt +++ b/doc/menu_lua_api.txt @@ -79,6 +79,8 @@ core.explode_table_event(string) -> table core.explode_textlist_event(string) -> table ^ returns e.g. {type="CHG", index=1} ^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click) +core.set_formspec_prepend(formspec) +^ string to be added to every mainmenu formspec, to be used for theming. GUI: core.set_background(type, texturepath,[tile],[minsize]) diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp index 241144a2a..3107d64cd 100644 --- a/src/gui/guiEngine.cpp +++ b/src/gui/guiEngine.cpp @@ -390,6 +390,15 @@ void GUIEngine::cloudPostProcess() } /******************************************************************************/ +void GUIEngine::setFormspecPrepend(const std::string &fs) +{ + if (m_menu) { + m_menu->setFormspecPrepend(fs); + } +} + + +/******************************************************************************/ void GUIEngine::drawBackground(video::IVideoDriver *driver) { v2u32 screensize = driver->getScreenSize(); @@ -610,4 +619,3 @@ unsigned int GUIEngine::queueAsync(const std::string &serialized_func, { return m_script->queueAsync(serialized_func, serialized_params); } - diff --git a/src/gui/guiEngine.h b/src/gui/guiEngine.h index 0ff5030c0..e55531bbc 100644 --- a/src/gui/guiEngine.h +++ b/src/gui/guiEngine.h @@ -221,6 +221,8 @@ private: /** script basefolder */ std::string m_scriptdir = ""; + void setFormspecPrepend(const std::string &fs); + /** * draw background layer * @param driver to use for drawing diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 2094da241..76db7ed13 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -107,6 +107,21 @@ int ModApiMainMenu::l_update_formspec(lua_State *L) } /******************************************************************************/ +int ModApiMainMenu::l_set_formspec_prepend(lua_State *L) +{ + GUIEngine *engine = getGuiEngine(L); + sanity_check(engine != NULL); + + if (engine->m_startgame) + return 0; + + std::string formspec(luaL_checkstring(L, 1)); + engine->setFormspecPrepend(formspec); + + return 0; +} + +/******************************************************************************/ int ModApiMainMenu::l_start(lua_State *L) { GUIEngine* engine = getGuiEngine(L); @@ -1041,6 +1056,7 @@ int ModApiMainMenu::l_do_async_callback(lua_State *L) void ModApiMainMenu::Initialize(lua_State *L, int top) { API_FCT(update_formspec); + API_FCT(set_formspec_prepend); API_FCT(set_clouds); API_FCT(get_textlist_index); API_FCT(get_table_index); diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 9ff822960..b2ca49320 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -104,6 +104,8 @@ private: static int l_update_formspec(lua_State *L); + static int l_set_formspec_prepend(lua_State *L); + static int l_get_screen_info(lua_State *L); //filesystem |