-
Notifications
You must be signed in to change notification settings - Fork 0
/
FishingAudio.lua
63 lines (56 loc) · 1.71 KB
/
FishingAudio.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local feature = ns.Register({
identifier = "FishingAudio",
description = "Enhances audio while fishing making it easier to hear bait splash.",
category = "profession",
config = {
master = 1,
music = 0,
sound = 1,
ambience = 0,
},
data = {
fishingInProgress = false,
master = 0,
music = 0,
sound = 0,
ambience = 0,
}
})
local function saveSoundSettings()
feature.data.master = GetCVar("MasterVolume")
feature.data.music = GetCVar("MusicVolume")
feature.data.sound = GetCVar("SoundVolume")
feature.data.ambience = GetCVar("AmbienceVolume")
end
local function restoreSoundSettings()
SetCVar("MasterVolume", feature.data.master)
SetCVar("MusicVolume", feature.data.music)
SetCVar("SoundVolume", feature.data.sound)
SetCVar("AmbienceVolume", feature.data.ambience)
end
local function fishingSoundSettings()
SetCVar("MasterVolume", feature.config.master)
SetCVar("MusicVolume", feature.config.music)
SetCVar("SoundVolume", feature.config.sound)
SetCVar("AmbienceVolume", feature.config.ambience)
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("SPELLCAST_CHANNEL_START")
frame:RegisterEvent("SPELLCAST_CHANNEL_STOP")
frame:RegisterEvent("SPELLCAST_INTERRUPTED")
frame:RegisterEvent("PLAYER_LOGOUT")
frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end
if event == "SPELLCAST_CHANNEL_START" then
if CastingBarText ~= nil and CastingBarText:GetText() == "Fishing" then
saveSoundSettings()
fishingSoundSettings()
feature.data.fishingInProgress = true
end
else
if feature.data.fishingInProgress then
restoreSoundSettings()
feature.data.fishingInProgress = false
end
end
end)