[Lua] Replace gui.show_inspector's undocumented config parameter with a string parameter that does the same thing.

It's still supported to pass a config, just in case anything relied on that.

This also updates the LuaDoc documentation at the same time.
This commit is contained in:
Celtic Minstrel 2024-02-10 21:09:42 -05:00 committed by Celtic Minstrel
parent 69789b7757
commit 7aa5450a41
5 changed files with 17 additions and 6 deletions

View file

@ -751,7 +751,7 @@ function wml_actions.remove_event(cfg)
end
function wml_actions.inspect(cfg)
gui.show_inspector(cfg)
gui.show_inspector(cfg.name)
end
function wml_actions.label( cfg )

View file

@ -417,7 +417,15 @@ int game_lua_kernel::intf_create_animator(lua_State* L)
int game_lua_kernel::intf_gamestate_inspector(lua_State *L)
{
if (game_display_) {
return lua_gui2::show_gamestate_inspector(luaW_checkvconfig(L, 1), gamedata(), game_state_);
vconfig cfg = vconfig::unconstructed_vconfig();
std::string name;
if(luaW_tovconfig(L, 1, cfg)) {
name = cfg["name"].str();
deprecated_message("gui.show_inspector(cfg)", DEP_LEVEL::INDEFINITE, {1, 19, 0}, "Instead of {name = 'title' }, pass just 'title'.");
} else {
name = luaL_optstring(L, 1, "");
}
return lua_gui2::show_gamestate_inspector(name, gamedata(), game_state_);
}
return 0;
}

View file

@ -238,9 +238,9 @@ int show_lua_console(lua_State* /*L*/, lua_kernel_base* lk)
return 0;
}
int show_gamestate_inspector(const vconfig& cfg, const game_data& data, const game_state& state)
int show_gamestate_inspector(const std::string& name, const game_data& data, const game_state& state)
{
gui2::dialogs::gamestate_inspector::display(data.get_variables(), *state.events_manager_, state.board_, cfg["name"]);
gui2::dialogs::gamestate_inspector::display(data.get_variables(), *state.events_manager_, state.board_, name);
return 0;
}

View file

@ -15,6 +15,8 @@
#pragma once
#include <string>
struct lua_State;
class lua_kernel_base;
class vconfig;
@ -30,7 +32,7 @@ int show_menu(lua_State* L);
int show_story(lua_State* L);
int show_message_box(lua_State* L);
int show_lua_console(lua_State*L, lua_kernel_base * lk);
int show_gamestate_inspector(const vconfig& cfg, const game_data& data, const game_state& state);
int show_gamestate_inspector(const std::string& name, const game_data& data, const game_state& state);
int luaW_open(lua_State *L);
} // end namespace lua_gui2

View file

@ -75,7 +75,8 @@ function gui.show_story(story, title) end
function gui.show_help(topic) end
---Open the gamestate inspector
function gui.show_inspector() end
---@param title? string A title to be displayed in the inspector. Can be used to disambiguate where it was called from.
function gui.show_inspector(title) end
---Open the in-game Lua console
function gui.show_lua_console() end