Update mainline content to use the wesnoth.audio module
This commit is contained in:
parent
dddd551765
commit
6e9826cfcd
5 changed files with 20 additions and 21 deletions
|
@ -77,7 +77,7 @@ on_event("enemies defeated", function(cx)
|
|||
if wml.variables.wc2_scenario > 4 then
|
||||
return
|
||||
end
|
||||
wesnoth.play_sound("ambient/ship.ogg")
|
||||
wesnoth.audio.play("ambient/ship.ogg")
|
||||
wesnoth.wml_actions.endlevel {
|
||||
result = "victory",
|
||||
carryover_percentage = 0,
|
||||
|
|
|
@ -81,7 +81,7 @@ on_event("die", function(cx)
|
|||
item(ice[mathx.random(#ice)])
|
||||
elseif loc:matches{terrain = "Ww^Bsb|,Ww^Bsb/,Ww^Bsb\\,Wwt^Bsb|,Wwt^Bsb/,Wwt^Bsb\\,Wwg^Bsb|,Wwg^Bsb/,Wwg^Bsb\\"} then
|
||||
map[loc] = "Wwf^Edt"
|
||||
wesnoth.play_sound("water-blast.wav")
|
||||
wesnoth.audio.play("water-blast.wav")
|
||||
item("scenery/castle-ruins.png")
|
||||
elseif loc:matches{terrain = "Rrc"} then
|
||||
if wml.variables["bonus.theme"] == "paradise" then
|
||||
|
|
|
@ -267,27 +267,27 @@ end
|
|||
|
||||
function wml_actions.music(cfg)
|
||||
if cfg.play_once then
|
||||
wesnoth.music_list.play(cfg.name)
|
||||
wesnoth.audio.music_list.play(cfg.name)
|
||||
else
|
||||
if not cfg.append then
|
||||
if cfg.immediate and wesnoth.music_list.current_i then
|
||||
wesnoth.music_list.current.once = true
|
||||
if cfg.immediate and wesnoth.audio.music_list.current_i then
|
||||
wesnoth.audio.music_list.current.once = true
|
||||
end
|
||||
wesnoth.music_list.clear()
|
||||
wesnoth.audio.music_list.clear()
|
||||
end
|
||||
local m = #wesnoth.music_list
|
||||
wesnoth.music_list.add(cfg.name, not not cfg.immediate, cfg.ms_before or 0, cfg.ms_after or 0)
|
||||
local n = #wesnoth.music_list
|
||||
local m = #wesnoth.audio.music_list
|
||||
wesnoth.audio.music_list.add(cfg.name, not not cfg.immediate, cfg.ms_before or 0, cfg.ms_after or 0)
|
||||
local n = #wesnoth.audio.music_list
|
||||
if n == 0 then
|
||||
return
|
||||
end
|
||||
if cfg.shuffle == false then
|
||||
wesnoth.music_list[n].shuffle = false
|
||||
wesnoth.audio.music_list[n].shuffle = false
|
||||
end
|
||||
-- Always overwrite shuffle even if the new track couldn't be added,
|
||||
-- but title shouldn't be overwritten.
|
||||
if cfg.title ~= nil and m ~= n then
|
||||
wesnoth.music_list[n].title = cfg.title
|
||||
wesnoth.audio.music_list[n].title = cfg.title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -295,11 +295,11 @@ end
|
|||
function wml_actions.volume(cfg)
|
||||
if cfg.music then
|
||||
local rel = tonumber(cfg.music) or 100.0
|
||||
wesnoth.music_list.volume = rel
|
||||
wesnoth.audio.music_list.volume = rel
|
||||
end
|
||||
if cfg.sound then
|
||||
local rel = tonumber(cfg.sound) or 100.0
|
||||
wesnoth.sound_volume(rel)
|
||||
wesnoth.audio.volume = rel
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -410,7 +410,7 @@ end
|
|||
|
||||
function wml_actions.sound(cfg)
|
||||
local name = cfg.name or wml.error("[sound] missing required name= attribute")
|
||||
wesnoth.play_sound(name, cfg["repeat"])
|
||||
wesnoth.audio.play(name, cfg["repeat"])
|
||||
end
|
||||
|
||||
function wml_actions.store_locations(cfg)
|
||||
|
@ -837,12 +837,12 @@ end
|
|||
function wml_actions.remove_sound_source(cfg)
|
||||
local ids = cfg.id or wml.error("[remove_sound_source] missing required id= attribute")
|
||||
for _,id in ipairs(ids:split()) do
|
||||
wesnoth.remove_sound_source(id)
|
||||
wesnoth.audio.sources[id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function wml_actions.sound_source(cfg)
|
||||
wesnoth.add_sound_source(cfg)
|
||||
wesnoth.audio.sources[cfg.id] = cfg
|
||||
end
|
||||
|
||||
function wml_actions.deprecated_message(cfg)
|
||||
|
|
|
@ -118,7 +118,7 @@ function wml_actions.harm_unit(cfg)
|
|||
add_tab = true
|
||||
|
||||
if animate and sound then -- for unhealable, that has no sound
|
||||
wesnoth.play_sound (sound)
|
||||
wesnoth.audio.play(sound)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -279,10 +279,9 @@ local function message_user_choice(cfg, speaker, options, text_input, sound)
|
|||
end
|
||||
|
||||
return function()
|
||||
if sound then wesnoth.play_sound(sound) end
|
||||
if sound then wesnoth.audio.play(sound) end
|
||||
if voice then
|
||||
local speech = {
|
||||
id = "wml_message_speaker",
|
||||
sounds = voice,
|
||||
loops = 0,
|
||||
delay = 0,
|
||||
|
@ -291,13 +290,13 @@ local function message_user_choice(cfg, speaker, options, text_input, sound)
|
|||
speech.x = speaker.x
|
||||
speech.y = speaker.y
|
||||
end
|
||||
wesnoth.add_sound_source(speech)
|
||||
wesnoth.audio.sources.wml_message_speaker = speech
|
||||
end
|
||||
|
||||
local option_chosen, ti_content = gui.show_narration(msg_cfg, options, text_input)
|
||||
|
||||
if voice then
|
||||
wesnoth.remove_sound_source("wml_message_speaker")
|
||||
wesnoth.sources.wml_message_speaker = nil
|
||||
end
|
||||
|
||||
if option_chosen == -2 then -- Pressed Escape (only if no input)
|
||||
|
|
Loading…
Add table
Reference in a new issue