66 lines
2.5 KiB
Lua
66 lines
2.5 KiB
Lua
local _, P = ...
|
||
|
||
-- GunSilencerForever owns sound playback and its saved settings. Use its public
|
||
-- commands so toggles immediately update the mute list and the options window.
|
||
-- No sound hooks, polling, frame movement, or global SFX-volume changes here.
|
||
local function ready()
|
||
return type(GunSilencerForeverDB) == "table"
|
||
and SlashCmdList and type(SlashCmdList.GUNSILENCERFOREVER) == "function"
|
||
end
|
||
|
||
local function run(command)
|
||
SlashCmdList.GUNSILENCERFOREVER(command)
|
||
end
|
||
|
||
function P.InitializeGunAudio()
|
||
if not RuenUIDB or not ready() then return false end
|
||
if RuenUIDB.gunAudioVersion == 1 then return true end
|
||
if RuenUIDB.disabled then
|
||
run("off")
|
||
return false
|
||
end
|
||
-- Once per account. Later /gsf and /ruen guns choices survive login, alts,
|
||
-- reloads, and /ruen apply. Bow and crossbow draw sounds stay native.
|
||
run("draw off")
|
||
run("volume 100")
|
||
run("guns on")
|
||
run("on")
|
||
RuenUIDB.gunAudioVersion = 1
|
||
return true
|
||
end
|
||
|
||
function P.StopGunAudio()
|
||
if ready() then run("off") end
|
||
end
|
||
|
||
function P.GunAudioCommand(argument)
|
||
if not ready() then
|
||
return P.Localized(
|
||
"Gun Silencer Forever is not loaded. Fully exit WoW and relaunch after installing the complete Ruen package; enable GunSilencerForever in AddOns.",
|
||
"Gun Silencer Forever не загружен. Полностью закройте и запустите WoW после установки полного комплекта Ruen; включите GunSilencerForever в списке модификаций.")
|
||
end
|
||
local arg = (argument or ""):lower():match("^%s*(.-)%s*$")
|
||
local volume = tonumber(arg:match("^(%d+)$") or arg:match("^volume%s+(%d+)$"))
|
||
if not (arg == "" or arg == "status" or arg == "on" or arg == "off"
|
||
or arg == "settings" or (volume and volume >= 10 and volume <= 100)) then
|
||
return P.Localized("/ruen guns on|off|status|settings; /ruen guns 10–100 (rounded to tens).",
|
||
"/ruen guns on|off|status|settings; /ruen guns 10–100 (округляется до десятков).")
|
||
end
|
||
P.InitializeGunAudio()
|
||
if arg == "on" then
|
||
run("draw off")
|
||
run("guns on")
|
||
run("on")
|
||
RuenUIDB.gunAudioVersion = 1
|
||
elseif arg == "off" then
|
||
run("off")
|
||
RuenUIDB.gunAudioVersion = 1
|
||
elseif arg == "settings" then
|
||
run("")
|
||
elseif volume then
|
||
run("volume " .. volume)
|
||
else
|
||
run("status")
|
||
end
|
||
end
|