Move Lua undo API into experimental
This commit is contained in:
parent
10d67aa82a
commit
38ae304725
3 changed files with 21 additions and 6 deletions
15
data/lua/core/game_events.lua
Normal file
15
data/lua/core/game_events.lua
Normal file
|
@ -0,0 +1,15 @@
|
|||
--[========[Game Event Functions]========]
|
||||
|
||||
if wesnoth.kernel_type() == "Game Lua Kernel" then
|
||||
-- The undo API is still experimental, so move those functions
|
||||
|
||||
-- Make sure wesnoth.experimental.game_events actually exists
|
||||
-- It's done this way so it doesn't break if we later need to add things here from C++
|
||||
wesnoth.experimental = wesnoth.experimental or {}
|
||||
wesnoth.experimental.game_events = wesnoth.experimental.game_events or {}
|
||||
|
||||
wesnoth.experimental.game_events.set_undoable = wesnoth.game_events.set_undoable
|
||||
wesnoth.experimental.game_events.add_undo_actions = wesnoth.game_events.add_undo_actions
|
||||
wesnoth.game_events.set_undoable = nil
|
||||
wesnoth.game_events.add_undo_actions = nil
|
||||
end
|
|
@ -87,9 +87,9 @@ local function status_anim_update(is_undo)
|
|||
end
|
||||
end
|
||||
if not is_undo then
|
||||
wesnoth.game_events.set_undoable(true)
|
||||
wesnoth.experimental.game_events.set_undoable(true)
|
||||
if changed_something then
|
||||
wesnoth.game_events.add_undo_actions(function(_)
|
||||
wesnoth.experimental.game_events.add_undo_actions(function(_)
|
||||
status_anim_update(true)
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -645,11 +645,11 @@ function wml_actions.put_to_recall_list(cfg)
|
|||
end
|
||||
|
||||
function wml_actions.allow_undo(cfg)
|
||||
wesnoth.game_events.set_undoable(true)
|
||||
wesnoth.experimental.game_events.set_undoable(true)
|
||||
end
|
||||
|
||||
function wml_actions.disallow_undo(cfg)
|
||||
wesnoth.game_events.set_undoable(false)
|
||||
wesnoth.experimental.game_events.set_undoable(false)
|
||||
end
|
||||
|
||||
function wml_actions.allow_end_turn(cfg)
|
||||
|
@ -1032,8 +1032,8 @@ end
|
|||
|
||||
function wml_actions.on_undo(cfg)
|
||||
if cfg.delayed_variable_substitution then
|
||||
wesnoth.game_events.add_undo_actions(wml.literal(cfg));
|
||||
wesnoth.experimental.game_events.add_undo_actions(wml.literal(cfg));
|
||||
else
|
||||
wesnoth.game_events.add_undo_actions(wml.parsed(cfg));
|
||||
wesnoth.experimental.game_events.add_undo_actions(wml.parsed(cfg));
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue