move replace_schedule impl to lua

This commit is contained in:
Chris Beck 2014-12-23 23:35:10 -05:00
parent fa32be5602
commit defb9e5051
4 changed files with 22 additions and 12 deletions

View file

@ -1346,3 +1346,7 @@ function wml_actions.time_area(cfg)
wesnoth.add_time_area(cfg.id, cfg)
end
end
function wml_actions.replace_schedule(cfg)
wesnoth.replace_schedule(cfg)
end

View file

@ -1619,18 +1619,6 @@ WML_HANDLER_FUNCTION(replace_map, /*event_info*/, cfg)
ai::manager::raise_map_changed();
}
/// Replacing the current time of day schedule.
WML_HANDLER_FUNCTION(replace_schedule, /*event_info*/, cfg)
{
if(cfg.get_children("time").empty()) {
ERR_NG << "attempted to to replace ToD schedule with empty schedule" << std::endl;
} else {
resources::tod_manager->replace_schedule(cfg.get_parsed_config());
resources::screen->new_turn();
LOG_NG << "replaced ToD schedule\n";
}
}
WML_HANDLER_FUNCTION(reset_fog, /*event_info*/, cfg)
{
toggle_fog(false, cfg, cfg["reset_view"].to_bool(false));

View file

@ -2989,6 +2989,22 @@ int game_lua_kernel::intf_remove_time_area(lua_State * L)
return 0;
}
/// Replacing the current time of day schedule.
int game_lua_kernel::intf_replace_schedule(lua_State * L)
{
vconfig cfg = luaW_checkvconfig(L, 1);
if(cfg.get_children("time").empty()) {
ERR_LUA << "attempted to to replace ToD schedule with empty schedule" << std::endl;
} else {
tod_man().replace_schedule(cfg.get_parsed_config());
if (game_display_) {
game_display_->new_turn();
}
LOG_LUA << "replaced ToD schedule\n";
}
return 0;
}
namespace {
struct lua_report_generator : reports::generator
@ -3165,6 +3181,7 @@ game_lua_kernel::game_lua_kernel(const config &cfg, CVideo * video, game_state &
{ "put_unit", boost::bind(&game_lua_kernel::intf_put_unit, this, _1) },
{ "remove_shroud", boost::bind(&game_lua_kernel::intf_shroud_op, this, _1, false) },
{ "remove_tile_overlay", boost::bind(&game_lua_kernel::intf_remove_tile_overlay, this, _1) },
{ "replace_schedule", boost::bind(&game_lua_kernel::intf_replace_schedule, 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) },

View file

@ -124,6 +124,7 @@ class game_lua_kernel : public lua_kernel_base
int intf_add_tile_overlay(lua_State *L);
int intf_remove_tile_overlay(lua_State *L);
int intf_delay(lua_State *L);
int intf_replace_schedule(lua_State *l);
int intf_get_all_vars(lua_State *L);
int impl_theme_item(lua_State *L, std::string name);
int impl_theme_items_get(lua_State *L);