Lua: Flip functions moved to the gui module
This means that they are now added to the gui module by default in C++, and only duplicated to the Wesnoth module in Lua.
This commit is contained in:
parent
0ee05637d9
commit
498a3e98c4
3 changed files with 27 additions and 29 deletions
|
@ -1,19 +1,19 @@
|
|||
-- Note: This file is loaded automatically by the engine.
|
||||
|
||||
function wesnoth.alert(title, msg)
|
||||
function gui.alert(title, msg)
|
||||
if not msg then
|
||||
msg = title;
|
||||
title = "";
|
||||
end
|
||||
wesnoth.show_message_box(title, msg, "ok", true)
|
||||
gui.show_prompt(title, msg, "ok", true)
|
||||
end
|
||||
|
||||
function wesnoth.confirm(title, msg)
|
||||
function gui.confirm(title, msg)
|
||||
if not msg then
|
||||
msg = title;
|
||||
title = "";
|
||||
end
|
||||
return wesnoth.show_message_box(title, msg, "yes_no", true)
|
||||
return gui.show_prompt(title, msg, "yes_no", true)
|
||||
end
|
||||
|
||||
|
||||
|
@ -519,21 +519,6 @@ end
|
|||
|
||||
--[========[GUI2 Dialog Manipulations]========]
|
||||
|
||||
gui = {}
|
||||
|
||||
gui.show_menu = wesnoth.show_menu
|
||||
gui.show_narration = wesnoth.show_message_dialog
|
||||
gui.show_popup = wesnoth.show_popup_dialog
|
||||
gui.show_story = wesnoth.show_story
|
||||
gui.show_prompt = wesnoth.show_message_box
|
||||
gui.alert = wesnoth.alert
|
||||
gui.confirm = wesnoth.confirm
|
||||
gui.show_lua_console = wesnoth.show_lua_console
|
||||
if wesnoth.kernel_type() == "Game Lua Kernel" then
|
||||
gui.show_inspector = wesnoth.gamestate_inspector
|
||||
end
|
||||
gui.add_widget_definition = wesnoth.add_widget_definition
|
||||
|
||||
--! Displays a WML message box with attributes from table @attr and options
|
||||
--! from table @options.
|
||||
--! @return the index of the selected option.
|
||||
|
@ -621,7 +606,7 @@ wesnoth.show_menu = wesnoth.deprecate_api('wesnoth.show_menu', 'gui.show_menu',
|
|||
wesnoth.show_message_dialog = wesnoth.deprecate_api('wesnoth.show_message_dialog', 'gui.show_narration', 1, nil, gui.show_narration)
|
||||
wesnoth.show_popup_dialog = wesnoth.deprecate_api('wesnoth.show_popup_dialog', 'gui.show_popup', 1, nil, gui.show_popup)
|
||||
wesnoth.show_story = wesnoth.deprecate_api('wesnoth.show_story', 'gui.show_story', 1, nil, gui.show_story)
|
||||
wesnoth.show_prompt = wesnoth.deprecate_api('wesnoth.show_message_box', 'gui.show_prompt', 1, nil, gui.show_prompt)
|
||||
wesnoth.show_message_box = wesnoth.deprecate_api('wesnoth.show_message_box', 'gui.show_prompt', 1, nil, gui.show_prompt)
|
||||
wesnoth.alert = wesnoth.deprecate_api('wesnoth.alert', 'gui.alert', 1, nil, gui.alert)
|
||||
wesnoth.confirm = wesnoth.deprecate_api('wesnoth.confirm', 'gui.confirm', 1, nil, gui.confirm)
|
||||
wesnoth.show_lua_console = wesnoth.deprecate_api('wesnoth.show_lua_console', 'gui.show_lua_console', 1, nil, gui.show_lua_console)
|
||||
|
|
|
@ -4181,7 +4181,6 @@ game_lua_kernel::game_lua_kernel(game_state & gs, play_controller & pc, reports
|
|||
{ "find_vacant_tile", &dispatch<&game_lua_kernel::intf_find_vacant_tile > },
|
||||
{ "fire_event", &dispatch2<&game_lua_kernel::intf_fire_event, false > },
|
||||
{ "fire_event_by_id", &dispatch2<&game_lua_kernel::intf_fire_event, true > },
|
||||
{ "gamestate_inspector", &dispatch<&game_lua_kernel::intf_gamestate_inspector > },
|
||||
{ "get_all_vars", &dispatch<&game_lua_kernel::intf_get_all_vars > },
|
||||
{ "get_end_level_data", &dispatch<&game_lua_kernel::intf_get_end_level_data > },
|
||||
{ "get_locations", &dispatch<&game_lua_kernel::intf_get_locations > },
|
||||
|
@ -4256,6 +4255,11 @@ game_lua_kernel::game_lua_kernel(game_state & gs, play_controller & pc, reports
|
|||
}
|
||||
|
||||
lua_setglobal(L, "wesnoth");
|
||||
|
||||
lua_getglobal(L, "gui");
|
||||
lua_pushcfunction(L, &dispatch<&game_lua_kernel::intf_gamestate_inspector>);
|
||||
lua_setfield(L, -2, "show_inspector");
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Create the getside metatable.
|
||||
cmd_log_ << lua_team::register_metatable(L);
|
||||
|
|
|
@ -599,7 +599,7 @@ lua_kernel_base::lua_kernel_base()
|
|||
lua_setfield(L, -3, function);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
||||
// Delete dofile and loadfile.
|
||||
lua_pushnil(L);
|
||||
lua_setglobal(L, "dofile");
|
||||
|
@ -639,7 +639,6 @@ lua_kernel_base::lua_kernel_base()
|
|||
{ "set_dialog_active", &lua_gui2::intf_set_dialog_active },
|
||||
{ "set_dialog_visible", &lua_gui2::intf_set_dialog_visible },
|
||||
{ "add_dialog_tree_node", &lua_gui2::intf_add_dialog_tree_node },
|
||||
{ "add_widget_definition", &lua_gui2::intf_add_widget_definition },
|
||||
{ "set_dialog_callback", &lua_gui2::intf_set_dialog_callback },
|
||||
{ "set_dialog_canvas", &lua_gui2::intf_set_dialog_canvas },
|
||||
{ "set_dialog_focus", &lua_gui2::intf_set_dialog_focus },
|
||||
|
@ -650,12 +649,6 @@ lua_kernel_base::lua_kernel_base()
|
|||
{ "require", &dispatch<&lua_kernel_base::intf_require> },
|
||||
{ "kernel_type", &dispatch<&lua_kernel_base::intf_kernel_type> },
|
||||
{ "show_dialog", &lua_gui2::show_dialog },
|
||||
{ "show_menu", &lua_gui2::show_menu },
|
||||
{ "show_message_dialog", &lua_gui2::show_message_dialog },
|
||||
{ "show_popup_dialog", &lua_gui2::show_popup_dialog },
|
||||
{ "show_story", &lua_gui2::show_story },
|
||||
{ "show_message_box", &lua_gui2::show_message_box },
|
||||
{ "show_lua_console", &dispatch<&lua_kernel_base::intf_show_lua_console> },
|
||||
{ "compile_formula", &lua_formula_bridge::intf_compile_formula},
|
||||
{ "eval_formula", &lua_formula_bridge::intf_eval_formula},
|
||||
{ "name_generator", &intf_name_generator },
|
||||
|
@ -679,6 +672,7 @@ lua_kernel_base::lua_kernel_base()
|
|||
//lua_cpp::set_functions(L, cpp_callbacks, 0);
|
||||
lua_setglobal(L, "wesnoth");
|
||||
|
||||
cmd_log_ << "Adding wml module...\n";
|
||||
static luaL_Reg const wml_callbacks[]= {
|
||||
{ "load", &intf_load_wml},
|
||||
{ "parse", &intf_parse_wml},
|
||||
|
@ -695,6 +689,21 @@ lua_kernel_base::lua_kernel_base()
|
|||
luaL_setfuncs(L, wml_callbacks, 0);
|
||||
lua_setglobal(L, "wml");
|
||||
|
||||
cmd_log_ << "Adding gui module...\n";
|
||||
static luaL_Reg const gui_callbacks[]= {
|
||||
{ "show_menu", &lua_gui2::show_menu },
|
||||
{ "show_narration", &lua_gui2::show_message_dialog },
|
||||
{ "show_popup", &lua_gui2::show_popup_dialog },
|
||||
{ "show_story", &lua_gui2::show_story },
|
||||
{ "show_prompt", &lua_gui2::show_message_box },
|
||||
{ "show_lua_console", &dispatch<&lua_kernel_base::intf_show_lua_console> },
|
||||
{ "add_widget_definition", &lua_gui2::intf_add_widget_definition },
|
||||
{ nullptr, nullptr },
|
||||
};
|
||||
lua_newtable(L);
|
||||
luaL_setfuncs(L, gui_callbacks, 0);
|
||||
lua_setglobal(L, "gui");
|
||||
|
||||
// Override the print function
|
||||
cmd_log_ << "Redirecting print function...\n";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue