move "set_menu_item" to be implemented via lua rather than C++

This commit is contained in:
Chris Beck 2014-12-23 17:55:09 -05:00
parent d72aa90532
commit eb71fc4d3b
4 changed files with 12 additions and 26 deletions

View file

@ -1309,3 +1309,7 @@ function wml_actions.full_heal(cfg)
end
end
end
function wml_actions.set_menu_item(cfg)
wesnoth.set_menu_item(cfg.id, cfg)
end

View file

@ -1801,32 +1801,6 @@ WML_HANDLER_FUNCTION(set_global_variable,/**/,pcfg)
verify_and_set_global_variable(pcfg);
}
/// Setting of menu items
WML_HANDLER_FUNCTION(set_menu_item, /*event_info*/, cfg)
{
/*
[set_menu_item]
id=test1
image="buttons/group_all.png"
description="Summon Troll"
[show_if]
[not]
[have_unit]
x,y=$x1,$y1
[/have_unit]
[/not]
[/show_if]
[filter_location]
[/filter_location]
[command]
{LOYAL_UNIT $side_number (Troll) $x1 $y1 (Myname) ( _ "Myname")}
[/command]
[/set_menu_item]
*/
std::string id = cfg["id"];
resources::gamedata->get_wml_menu_items().set_item(id, cfg);
}
WML_HANDLER_FUNCTION(set_variable, /*event_info*/, cfg)
{
game_data *gameinfo = resources::gamedata;

View file

@ -758,6 +758,12 @@ int game_lua_kernel::intf_set_variable(lua_State *L)
return 0;
}
int game_lua_kernel::intf_set_menu_item(lua_State *L)
{
gamedata().get_wml_menu_items().set_item(luaL_checkstring(L, 1), luaW_checkvconfig(L,2));
return 0;
}
/**
* Highlights the given location on the map.
* - Args 1,2: location.
@ -3031,6 +3037,7 @@ game_lua_kernel::game_lua_kernel(const config &cfg, CVideo * video, game_state &
{ "remove_tile_overlay", boost::bind(&game_lua_kernel::intf_remove_tile_overlay, this, _1) },
{ "scroll_to_tile", boost::bind(&game_lua_kernel::intf_scroll_to_tile, this, _1) },
{ "select_hex", boost::bind(&game_lua_kernel::intf_select_hex, this, _1) },
{ "set_menu_item", boost::bind(&game_lua_kernel::intf_set_menu_item, this, _1) },
{ "set_terrain", boost::bind(&game_lua_kernel::intf_set_terrain, this, _1) },
{ "set_variable", boost::bind(&game_lua_kernel::intf_set_variable, this, _1) },
{ "set_village_owner", boost::bind(&game_lua_kernel::intf_set_village_owner, this, _1) },

View file

@ -105,6 +105,7 @@ class game_lua_kernel : public lua_kernel_base
int intf_extract_unit(lua_State *L);
int intf_find_vacant_tile(lua_State *L);
int intf_float_label(lua_State *L);
int intf_set_menu_item(lua_State *L);
int intf_simulate_combat(lua_State *L);
int intf_scroll_to_tile(lua_State *L);
int intf_select_hex(lua_State *L);