Lua: Replace uses of deprecated (moved) interface functions

This commit is contained in:
Celtic Minstrel 2019-11-16 12:35:20 -05:00
parent f016ac7183
commit 0ee05637d9
16 changed files with 48 additions and 48 deletions

View file

@ -76,10 +76,10 @@
[lua]
code=<<
local _ = wesnoth.textdomain "wesnoth-dw"
local old_unit_status = wesnoth.theme_items.unit_status
local old_unit_status = wesnoth.interface.game_display.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
function wesnoth.interface.game_display.unit_status()
local u = wesnoth.interface.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()

View file

@ -15,7 +15,7 @@ for i, action_id in ipairs(skippable_actions) do
skip_actions[action_id] = wesnoth.wml_actions[action_id]
wesnoth.wml_actions[action_id] = function(cfg)
if wesnoth.is_skipping_messages() then
if wesnoth.interface.is_skipping_messages() then
return
end

View file

@ -1,10 +1,10 @@
-- #textdomain wesnoth-utbs
local _ = wesnoth.textdomain "wesnoth-utbs"
local old_unit_status = wesnoth.theme_items.unit_status
local old_unit_status = wesnoth.interface.game_display.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
function wesnoth.interface.game_display.unit_status()
local u = wesnoth.interface.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()

View file

@ -18,7 +18,7 @@
local students = wesnoth.units.find_on_map { side = wesnoth.current.side, { "filter_adjacent", { id = teacher.id } } }
if #students > 0 then -- don't divide by zero
wesnoth.scroll_to_tile(teacher.x, teacher.y)
wesnoth.interface.scroll_to_hex(teacher.x, teacher.y)
local function cf(u1, u2)
-- criteria: the unit with lower level comes first
@ -54,7 +54,7 @@
student.experience = student.experience + xp_to_add
-- performance-wise, string concatenation is slower than string interpolation
-- but it's way more readable than two nested interpolations...
wesnoth.float_label(student.x, student.y, "<span color='cyan'>" .. tostring(_ "+%d XP"):format(xp_to_add) .. "</span>")
wesnoth.interface.float_label(student.x, student.y, "<span color='cyan'>" .. tostring(_ "+%d XP"):format(xp_to_add) .. "</span>")
if student.experience >= student.max_experience then
-- advance unit, animate and fire events
student:advance(true, true)

View file

@ -28,7 +28,7 @@ on_event("die", function()
u_killer_cfg.max_hitpoints = u_killer_cfg.max_hitpoints + 1
u_killer_cfg.hitpoints = u_killer_cfg.hitpoints + 1
wesnoth.units.to_map(u_killer_cfg)
wesnoth.float_label(ec.x2, ec.y2, _ "+1 max HP", "0,255,0")
wesnoth.interface.float_label(ec.x2, ec.y2, _ "+1 max HP", "0,255,0")
return
end
end
@ -41,5 +41,5 @@ on_event("die", function()
},
})
u_killer.hitpoints = u_killer.hitpoints + 1
wesnoth.float_label(ec.x2, ec.y2, _ "+1 max HP", "0,255,0")
wesnoth.interface.float_label(ec.x2, ec.y2, _ "+1 max HP", "0,255,0")
end)

View file

@ -316,9 +316,9 @@ function wml_actions.scroll_to(cfg)
local loc = wesnoth.get_locations( cfg )[1]
if not loc then return end
if not utils.optional_side_filter(cfg) then return end
wesnoth.scroll_to_tile(loc[1], loc[2], cfg.check_fogged, cfg.immediate)
wesnoth.interface.scroll_to_hex(loc[1], loc[2], cfg.check_fogged, cfg.immediate)
if cfg.highlight then
wesnoth.highlight_hex(loc[1], loc[2])
wesnoth.interface.highlight_hex(loc[1], loc[2])
wml_actions.redraw{}
end
end
@ -327,19 +327,19 @@ function wml_actions.scroll_to_unit(cfg)
local u = wesnoth.units.find_on_map(cfg)[1]
if not u then return end
if not utils.optional_side_filter(cfg, "for_side", "for_side") then return end
wesnoth.scroll_to_tile(u.x, u.y, cfg.check_fogged, cfg.immediate)
wesnoth.interface.scroll_to_hex(u.x, u.y, cfg.check_fogged, cfg.immediate)
if cfg.highlight then
wesnoth.highlight_hex(u.x, u.y)
wesnoth.interface.highlight_hex(u.x, u.y)
wml_actions.redraw{}
end
end
function wml_actions.lock_view(cfg)
wesnoth.lock_view(true)
wesnoth.interface.lock(true)
end
function wml_actions.unlock_view(cfg)
wesnoth.lock_view(false)
wesnoth.interface.lock(false)
end
function wml_actions.select_unit(cfg)
@ -528,7 +528,7 @@ function wml_actions.delay(cfg)
local delay = tonumber(cfg.time) or
helper.wml_error "[delay] missing required time= attribute."
local accelerate = cfg.accelerate or false
wesnoth.delay(delay, accelerate)
wesnoth.interface.delay(delay, accelerate)
end
function wml_actions.floating_text(cfg)
@ -536,7 +536,7 @@ function wml_actions.floating_text(cfg)
local text = cfg.text or helper.wml_error("[floating_text] missing required text= attribute")
for i, loc in ipairs(locs) do
wesnoth.float_label(loc[1], loc[2], text, cfg.color)
wesnoth.interface.float_label(loc[1], loc[2], text, cfg.color)
end
end
@ -708,11 +708,11 @@ function wml_actions.disallow_end_turn(cfg)
end
function wml_actions.clear_menu_item(cfg)
wesnoth.clear_menu_item(cfg.id)
wesnoth.interface.clear_menu_item(cfg.id)
end
function wml_actions.set_menu_item(cfg)
wesnoth.set_menu_item(cfg.id, cfg)
wesnoth.interface.set_menu_item(cfg.id, cfg)
end
function wml_actions.place_shroud(cfg)
@ -760,12 +760,12 @@ function wml_actions.scroll(cfg)
end
end
if have_human or #sides == 0 then
wesnoth.scroll(cfg.x or 0, cfg.y or 0)
wesnoth.interface.scroll(cfg.x or 0, cfg.y or 0)
end
end
function wml_actions.color_adjust(cfg)
wesnoth.color_adjust(cfg)
wesnoth.interface.color_adjust(cfg)
end
function wml_actions.end_turn(cfg)
@ -864,8 +864,8 @@ wml_actions.unstore_unit = function(cfg)
if color == nil and cfg.red and cfg.blue and cfg.green then
color = cfg.red .. "," .. cfg.green .. "," .. cfg.blue
end
if text ~= nil and not wesnoth.is_skipping_messages() then
wesnoth.float_label(x, y, text, color)
if text ~= nil and not wesnoth.interface.is_skipping_messages() then
wesnoth.interface.float_label(x, y, text, color)
end
if advance then
unit:advance(animate, cfg.fire_event)
@ -947,7 +947,7 @@ function wesnoth.wml_actions.change_theme(cfg)
end
function wesnoth.wml_actions.zoom(cfg)
wesnoth.zoom(cfg.factor, cfg.relative)
wesnoth.interface.zoom(cfg.factor, cfg.relative)
end
function wesnoth.wml_actions.story(cfg)

View file

@ -69,7 +69,7 @@ local function add_animation(anim, cfg)
-- TODO: The last argument is currently unused
-- (should make the game not scroll if view locked or prefs disables it)
wesnoth.scroll_to_tile(unit.x, unit.y, true, false, true, false)
wesnoth.interface.scroll_to_hex(unit.x, unit.y, true, false, true, false)
local facing = wml.get_child(cfg, "facing")
if facing then

View file

@ -41,7 +41,7 @@ function wml_actions.harm_unit(cfg)
if animate then
if animate ~= "defender" and harmer and harmer.valid then
wesnoth.scroll_to_tile(harmer.x, harmer.y, true)
wesnoth.interface.scroll_to_hex(harmer.x, harmer.y, true)
wml_actions.animate_unit {
flag = "attack",
hits = true,
@ -52,7 +52,7 @@ function wml_actions.harm_unit(cfg)
T.facing { x = unit_to_harm.x, y = unit_to_harm.y },
}
end
wesnoth.scroll_to_tile(unit_to_harm.x, unit_to_harm.y, true)
wesnoth.interface.scroll_to_hex(unit_to_harm.x, unit_to_harm.y, true)
end
-- the two functions below are taken straight from the C++ engine,
@ -160,7 +160,7 @@ function wml_actions.harm_unit(cfg)
end
end
wesnoth.float_label( unit_to_harm.x, unit_to_harm.y, string.format( "<span foreground='red'>%s</span>", text ) )
wesnoth.interface.float_label( unit_to_harm.x, unit_to_harm.y, string.format( "<span foreground='red'>%s</span>", text ) )
local function calc_xp( level ) -- to calculate the experience in case of kill
if level == 0 then return math.ceil(wesnoth.game_config.kill_experience / 2)
@ -183,7 +183,7 @@ function wml_actions.harm_unit(cfg)
end
if animate then
wesnoth.delay(delay)
wesnoth.interface.delay(delay)
end
if variable then

View file

@ -4,7 +4,7 @@ local wml_actions = wesnoth.wml_actions
local scenario_items = {}
local next_item_name = 0
local function add_overlay(x, y, cfg)
wesnoth.add_tile_overlay(x, y, cfg)
wesnoth.interface.add_hex_overlay(x, y, cfg)
local items = scenario_items[x * 10000 + y]
if not items then
items = {}
@ -27,7 +27,7 @@ end
local function remove_overlay(x, y, name)
local items = scenario_items[x * 10000 + y]
if not items then return end
wesnoth.remove_tile_overlay(x, y, name)
wesnoth.interface.remove_hex_overlay(x, y, name)
if name then
for i = #items,1,-1 do
local item = items[i]

View file

@ -42,7 +42,7 @@ function wesnoth.wml_actions.kill(cfg)
wesnoth.fire_event("last breath", death_loc, killer_loc)
end
if cfg.animate and unit.valid == "map" then
wesnoth.scroll_to_tile(death_loc, true)
wesnoth.interface.scroll_to_hex(death_loc, true)
local anim = wesnoth.create_animator()
local primary = wml.get_child(cfg, "primary_attack")
local secondary = wml.get_child(cfg, "secondary_attack")

View file

@ -302,7 +302,7 @@ local function message_user_choice(cfg, speaker, options, text_input, sound)
end
if option_chosen == -2 then -- Pressed Escape (only if no input)
wesnoth.skip_messages()
wesnoth.interface.skip_messages()
end
local result_cfg = {}
@ -372,7 +372,7 @@ function wesnoth.wml_actions.message(cfg)
-- Check if there is any input to be made, if not the message may be skipped
local has_input = text_input ~= nil or #options > 0
if not has_input and wesnoth.is_skipping_messages() then
if not has_input and wesnoth.interface.is_skipping_messages() then
-- No input to get and the user is not interested either
log("Skipping [message] because user not interested", "debug")
return
@ -410,17 +410,17 @@ function wesnoth.wml_actions.message(cfg)
-- Nothing to do here
elseif speaker == "narrator" then
-- Narrator, so deselect units
wesnoth.deselect_hex()
wesnoth.interface.deselect_hex()
-- The speaker is expected to be either nil or a unit later
speaker = nil
wesnoth.fire("redraw")
else
-- Check ~= false, because the default if omitted should be true
if cfg.scroll ~= false then
wesnoth.scroll_to_tile(speaker.x, speaker.y, true, false, true)
wesnoth.interface.scroll_to_hex(speaker.x, speaker.y, true, false, true)
end
wesnoth.highlight_hex(speaker.x, speaker.y)
wesnoth.interface.highlight_hex(speaker.x, speaker.y)
wesnoth.fire("redraw")
end
@ -448,7 +448,7 @@ function wesnoth.wml_actions.message(cfg)
-- Unhilight the speaker
if speaker and not cfg.highlight == false then
wesnoth.deselect_hex()
wesnoth.interface.deselect_hex()
end
if #options > 0 then

View file

@ -52,7 +52,7 @@ function wml_actions.object(cfg)
if not silent then
unit:select(false)
wesnoth.highlight_hex(unit.x, unit.y)
wesnoth.interface.highlight_hex(unit.x, unit.y)
end
-- Mark this item as used up

View file

@ -1285,9 +1285,9 @@ end
function has_teleport(u)
return u:ability("teleport")
end
local old_unit_status = wesnoth.theme_items.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
local old_unit_status = wesnoth.interface.game_display.unit_status
function wesnoth.interface.game_display.unit_status()
local u = wesnoth.interface.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.entangled then

View file

@ -52,7 +52,7 @@ return function()
-- Reached the lobby. Random delay before we start actually simulating activity.
-- This is here to avoid a situation where activity arrives in bursts after a script
-- has launched, say, 100 copies of Wesnoth at the same time.
wesnoth.delay(wesnoth.random(15000))
wesnoth.interface.delay(wesnoth.random(15000))
events, context, info = coroutine.yield()
@ -82,7 +82,7 @@ return function()
end
end
wesnoth.delay(15000)
wesnoth.interface.delay(15000)
events, context, info = coroutine.yield()
end

View file

@ -526,7 +526,7 @@ void lua_interpreter::controller::input_keypress_callback(bool& handled,
handled = true;
halt = true;
// Commands such as `wesnoth.zoom` might cause the display to redraw and leave the window half-drawn.
// Commands such as `wesnoth.interface.zoom` might cause the display to redraw and leave the window half-drawn.
// This preempts that.
window.set_is_dirty(true);

View file

@ -228,7 +228,7 @@ private:
/**
an object to leave the synced context during draw or unsynced wml items when we dont know whether we are in a synced context or not.
if we are in a synced context we leave the synced context, otherwise it has no effect.
we need this because we might call lua's wesnoth.theme_items during draw and we dont want to have that an effect on the gamestate in this case.
we need this because we might call lua's wesnoth.interface.game_display during draw and we dont want to have that an effect on the gamestate in this case.
*/
class set_scontext_unsynced
{