Skip to content

Commit

Permalink
move clear_menu_item to lua implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Dec 24, 2014
1 parent 41e54fd commit 09ce8b5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 4 additions & 0 deletions data/lua/wml-tags.lua
Expand Up @@ -1322,6 +1322,10 @@ function wml_actions.disallow_end_turn(cfg)
wesnoth.allow_end_turn(false)
end

function wml_actions.clear_menu_item(cfg)
wesnoth.clear_menu_item(cfg.id)
end

function wml_actions.set_menu_item(cfg)
wesnoth.set_menu_item(cfg.id, cfg)
end
Expand Down
13 changes: 0 additions & 13 deletions src/game_events/action_wml.cpp
Expand Up @@ -555,19 +555,6 @@ WML_HANDLER_FUNCTION(clear_global_variable,/**/,pcfg)
verify_and_clear_global_variable(pcfg);
}

WML_HANDLER_FUNCTION(clear_menu_item, /*event_info*/, cfg)
{
const std::string ids = cfg["id"].str();
BOOST_FOREACH(const std::string& id, utils::split(ids, ',', utils::STRIP_SPACES)) {
if(id.empty()) {
WRN_NG << "[clear_menu_item] has been given an empty id=, ignoring" << std::endl;
continue;
}

resources::gamedata->get_wml_menu_items().erase(id);
}
}

WML_HANDLER_FUNCTION(color_adjust, /*event_info*/, cfg)
{
game_display &screen = *resources::screen;
Expand Down
15 changes: 15 additions & 0 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -783,6 +783,20 @@ int game_lua_kernel::intf_set_menu_item(lua_State *L)
return 0;
}

int game_lua_kernel::intf_clear_menu_item(lua_State *L)
{
std::string ids(luaL_checkstring(L, 1));
BOOST_FOREACH(const std::string& id, utils::split(ids, ',', utils::STRIP_SPACES)) {
if(id.empty()) {
WRN_LUA << "[clear_menu_item] has been given an empty id=, ignoring" << std::endl;
continue;
}

gamedata().get_wml_menu_items().erase(id);
}
return 0;
}

int game_lua_kernel::intf_shroud_op(lua_State *L, bool place_shroud)
{
vconfig cfg = luaW_checkvconfig(L, 1);
Expand Down Expand Up @@ -3069,6 +3083,7 @@ game_lua_kernel::game_lua_kernel(const config &cfg, CVideo * video, game_state &
{ "add_tile_overlay", boost::bind(&game_lua_kernel::intf_add_tile_overlay, this, _1) },
{ "allow_end_turn", boost::bind(&game_lua_kernel::intf_allow_end_turn, this, _1) },
{ "allow_undo", boost::bind(&game_lua_kernel::intf_allow_undo, this, _1) },
{ "clear_menu_item", boost::bind(&game_lua_kernel::intf_clear_menu_item, this, _1) },
{ "clear_messages", boost::bind(&game_lua_kernel::intf_clear_messages, this, _1) },
{ "delay", boost::bind(&game_lua_kernel::intf_delay, this, _1) },
{ "extract_unit", boost::bind(&game_lua_kernel::intf_extract_unit, this, _1) },
Expand Down
1 change: 1 addition & 0 deletions src/scripting/game_lua_kernel.hpp
Expand Up @@ -107,6 +107,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_clear_menu_item(lua_State *L);
int intf_set_menu_item(lua_State *L);
int intf_shroud_op(lua_State *L, bool place_shroud);
int intf_simulate_combat(lua_State *L);
Expand Down

0 comments on commit 09ce8b5

Please sign in to comment.