53 #define ERR_LUA LOG_STREAM(err, log_scripting_lua) 72 input.
caption = txt_cfg[
"label"].str();
73 input.
text = txt_cfg[
"text"].str();
81 for(std::size_t
i = 1;
i <=
n;
i++) {
86 opt[
"description"] = short_opt;
88 std::ostringstream
error;
89 error <<
"expected array of config and/or translatable strings, but index ";
94 if(opt[
"default"].to_bool(
false)) {
103 if(i < 1 || std::size_t(i) > n) {
104 std::ostringstream
error;
105 error <<
"default= key in options list is not a valid option index (1-" << n <<
")";
114 const std::string& title = def_cfg[
"title"];
115 const std::string& message = def_cfg[
"message"];
118 std::unique_ptr<portrait>
left;
119 std::unique_ptr<portrait>
right;
120 const bool is_double = def_cfg.
has_attribute(
"second_portrait");
121 const bool left_side = def_cfg[
"left_side"].to_bool(
true);
122 if(is_double || left_side) {
123 left.reset(
new portrait {def_cfg[
"portrait"], def_cfg[
"mirror"].to_bool(
false)});
126 right.reset(
new portrait {def_cfg[
"portrait"], def_cfg[
"mirror"].to_bool(
false)});
129 right.reset(
new portrait {def_cfg[
"second_portrait"], def_cfg[
"second_mirror"].to_bool(
false)});
183 std::vector<config>
items = lua_check<std::vector<config>>(L, 1);
184 SDL_Rect pos {1,1,1,1};
185 SDL_GetMouseState(&pos.x, &pos.y);
211 std::transform(button.begin(), button.end(), std::inserter(btn_style, btn_style.begin()), [](
char c) {
return std::tolower(c); });
214 std::optional<button_style>
style;
215 if(btn_style.empty()) {
216 style = button_style::auto_close;
217 }
else if(btn_style ==
"ok") {
218 style = button_style::ok_button;
219 }
else if(btn_style ==
"close") {
220 style = button_style::close_button;
221 }
else if(btn_style ==
"ok_cancel") {
222 style = button_style::ok_cancel_buttons;
223 }
else if(btn_style ==
"cancel") {
224 style = button_style::cancel_button;
225 }
else if(btn_style ==
"yes_no") {
226 style = button_style::yes_no_buttons;
230 if(style == button_style::ok_cancel_buttons || style == button_style::yes_no_buttons) {
265 lua_kernel_base::get_lua_kernel<lua_kernel_base>(L).add_widget_definition(type,
id);
267 }
catch(
const std::invalid_argument&
e) {
275 auto& lk = lua_kernel_base::get_lua_kernel<lua_kernel_base>(L);
276 lk.add_log(
"Adding gui module...\n");
277 static luaL_Reg const gui_callbacks[] = {
285 {
nullptr,
nullptr },
287 std::vector<lua_cpp::Reg>
const cpp_gui_callbacks {
#define lua_isnoneornil(L, n)
Parameter pack for message portrait.
void show_message(const std::string &title, const std::string &msg, const std::string &button_caption, const bool auto_close, const bool message_use_markup, const bool title_use_markup)
Shows a message to the user.
int show_lua_console(lua_State *, lua_kernel_base *lk)
static void display(const std::string &scenario_name, const config &story)
int chosen_option
The initially chosen option.
int show_story(lua_State *L)
Displays a story screen.
LUA_API int lua_type(lua_State *L, int idx)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API int lua_rawgeti(lua_State *L, int idx, lua_Integer n)
static l_noret error(LoadState *S, const char *why)
bool has_attribute(config_key_type key) const
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
button_style
Selects the style of the buttons to be shown.
#define lua_tointeger(L, i)
Parameter pack for message list input options.
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
const std::vector< std::string > items
const config & get_variables() const
int show_message_dialog(lua_State *L)
Displays a message window.
bool show(const unsigned auto_close_time=0)
Shows the window.
Definitions for the interface to Wesnoth Markup Language (WML).
int luaW_open(lua_State *L)
int intf_add_widget_definition(lua_State *L)
const std::unique_ptr< game_events::manager > events_manager_
static void display(lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
int show_gamestate_inspector(const vconfig &cfg, const game_data &data, const game_state &state)
LUALIB_API int luaL_argerror(lua_State *L, int arg, const char *extramsg)
bool luaW_toboolean(lua_State *L, int n)
int intf_show_lua_console(lua_State *L)
t_string luaW_checktstring(lua_State *L, int index)
Converts a scalar to a translatable string.
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
int show_menu(lua_State *L)
Displays a popup menu at the current mouse position Best used from a [set_menu_item], to show a submenu.
LUA_API void lua_pushnil(lua_State *L)
LUALIB_API void luaL_checktype(lua_State *L, int arg, int t)
#define lua_isboolean(L, n)
static lg::log_domain log_scripting_lua("scripting/lua")
bool luaW_toconfig(lua_State *L, int index, config &cfg)
Converts an optional table or vconfig to a config object.
int show_popup_dialog(lua_State *L)
Displays a popup message.
bool luaW_totstring(lua_State *L, int index, t_string &str)
Converts a scalar to a translatable string.
int show_wml_message(const std::string &title, const std::string &message, const wml_message_portrait *left, const wml_message_portrait *right, const wml_message_options &options, const wml_message_input &input)
Helper function to show a portrait.
LUA_API void lua_rawset(lua_State *L, int idx)
config luaW_checkconfig(lua_State *L, int index)
Converts an optional table or vconfig to a config object.
Helper class for message options.
LUA_API int lua_isnumber(lua_State *L, int idx)
LUA_API size_t lua_rawlen(lua_State *L, int idx)
std::vector< wml_message_option > option_list
A list of options to select in the dialog.
A variable-expanding proxy for the config class.
Functions to load and save images from/to disk.
Standard logging facilities (interface).
bool add_single_widget_definition(const std::string &widget_type, const std::string &definition_id, const config &cfg)
Adds a widget definition to the default GUI.
Dialog was closed with the OK button.
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
int show_message_box(lua_State *L)
Displays a simple message box.
A config object defines a single node in a WML file, with access to child nodes.
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
static map_location::DIRECTION n
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
#define luaL_optstring(L, n, d)
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUA_API const char * lua_typename(lua_State *L, int t)
void set_functions(lua_State *L, const std::vector< lua_cpp::Reg > &functions)
Analogous to lua_setfuncs, it registers a collection of function wrapper objects into a table...
#define luaL_checkstring(L, n)