Add lua function gui.switch_theme() to allow add-ons to switch themes in the middle of a scenario
This commit is contained in:
parent
59911072aa
commit
60640dc8bd
3 changed files with 17 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "scripting/lua_gui2.hpp"
|
||||
|
||||
#include "gui/gui.hpp"
|
||||
#include "gui/core/gui_definition.hpp"
|
||||
#include "gui/dialogs/drop_down_menu.hpp"
|
||||
#include "gui/dialogs/gamestate_inspector.hpp"
|
||||
|
@ -168,6 +169,16 @@ int show_story(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the current ui(gui2) theme
|
||||
* - Arg 1: The id of the theme to switch to
|
||||
*/
|
||||
int switch_theme(lua_State* L) {
|
||||
std::string theme_id = luaL_checkstring(L, 1);
|
||||
gui2::switch_theme(theme_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a popup menu at the current mouse position
|
||||
* Best used from a [set_menu_item], to show a submenu
|
||||
|
@ -281,6 +292,7 @@ int luaW_open(lua_State* L)
|
|||
{ "show_story", &show_story },
|
||||
{ "show_prompt", &show_message_box },
|
||||
{ "show_help", &show_help },
|
||||
{ "switch_theme", &switch_theme },
|
||||
{ "add_widget_definition", &intf_add_widget_definition },
|
||||
{ "show_dialog", &intf_show_dialog },
|
||||
{ nullptr, nullptr },
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace lua_gui2 {
|
|||
int intf_add_widget_definition(lua_State *L);
|
||||
int show_message_dialog(lua_State *L);
|
||||
int show_popup_dialog(lua_State *L);
|
||||
int switch_theme(lua_State* L);
|
||||
int show_menu(lua_State* L);
|
||||
int show_story(lua_State* L);
|
||||
int show_message_box(lua_State* L);
|
||||
|
|
|
@ -88,6 +88,10 @@ function gui.show_lua_console() end
|
|||
---@return integer
|
||||
function gui.show_dialog(cfg, preshow, postshow) end
|
||||
|
||||
---Changes the current ui (gui2) theme
|
||||
---@param theme_id string The id of the gui2 theme to switch to
|
||||
function gui.switch_theme(theme_id) end
|
||||
|
||||
-- Add a custom widget definition, for use in a custom dialog
|
||||
---@param type string The type of widget the definition applies to
|
||||
---@param id string An ID for the definition, to be referenced from WML
|
||||
|
|
Loading…
Add table
Reference in a new issue