move allow_undo, allow_end_turn impl's to lua
This commit is contained in:
parent
0d76ac3be7
commit
41e54fd009
4 changed files with 30 additions and 16 deletions
|
@ -1310,6 +1310,18 @@ function wml_actions.full_heal(cfg)
|
|||
end
|
||||
end
|
||||
|
||||
function wml_actions.allow_undo(cfg)
|
||||
wesnoth.allow_undo()
|
||||
end
|
||||
|
||||
function wml_actions.allow_end_turn(cfg)
|
||||
wesnoth.allow_end_turn(true)
|
||||
end
|
||||
|
||||
function wml_actions.disallow_end_turn(cfg)
|
||||
wesnoth.allow_end_turn(false)
|
||||
end
|
||||
|
||||
function wml_actions.set_menu_item(cfg)
|
||||
wesnoth.set_menu_item(cfg.id, cfg)
|
||||
end
|
||||
|
|
|
@ -541,17 +541,6 @@ wml_action::wml_action(const std::string & tag, handler function)
|
|||
static void wml_func_##pname(const queued_event& pei, const vconfig& pcfg)
|
||||
|
||||
|
||||
WML_HANDLER_FUNCTION(allow_end_turn, /*event_info*/, /*cfg*/)
|
||||
{
|
||||
resources::gamedata->set_allow_end_turn(true);
|
||||
}
|
||||
|
||||
/// Allow undo sets the flag saying whether the event has mutated the game to false.
|
||||
WML_HANDLER_FUNCTION(allow_undo,/*event_info*/,/*cfg*/)
|
||||
{
|
||||
resources::game_events->pump().context_mutated(false);
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(animate_unit, event_info, cfg)
|
||||
{
|
||||
const events::command_disabler disable_commands;
|
||||
|
@ -593,11 +582,6 @@ WML_HANDLER_FUNCTION(deprecated_message, /*event_info*/, cfg)
|
|||
handle_deprecated_message( cfg.get_parsed_config() );
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(disallow_end_turn, /*event_info*/, /*cfg*/)
|
||||
{
|
||||
resources::gamedata->set_allow_end_turn(false);
|
||||
}
|
||||
|
||||
static void on_replay_error(const std::string& message, bool /*b*/)
|
||||
{
|
||||
ERR_NG << "Error via [do_command]:" << std::endl;
|
||||
|
|
|
@ -2920,6 +2920,20 @@ static int intf_debug_ai(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/// Allow undo sets the flag saying whether the event has mutated the game to false.
|
||||
int game_lua_kernel::intf_allow_end_turn(lua_State * L)
|
||||
{
|
||||
gamedata().set_allow_end_turn(lua_toboolean(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Allow undo sets the flag saying whether the event has mutated the game to false.
|
||||
int game_lua_kernel::intf_allow_undo(lua_State *)
|
||||
{
|
||||
play_controller_.pump().context_mutated(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct lua_report_generator : reports::generator
|
||||
{
|
||||
|
@ -3053,6 +3067,8 @@ game_lua_kernel::game_lua_kernel(const config &cfg, CVideo * video, game_state &
|
|||
};
|
||||
lua_cpp::Reg const cpp_callbacks[] = {
|
||||
{ "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_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) },
|
||||
|
|
|
@ -70,6 +70,8 @@ class game_lua_kernel : public lua_kernel_base
|
|||
friend class game_config_manager; // to allow it to call extract_preload_scripts
|
||||
|
||||
// Private lua callbacks
|
||||
int intf_allow_end_turn(lua_State *);
|
||||
int intf_allow_undo(lua_State *);
|
||||
int intf_get_unit(lua_State *);
|
||||
int intf_get_units(lua_State *);
|
||||
int intf_get_displayed_unit(lua_State*);
|
||||
|
|
Loading…
Add table
Reference in a new issue