Implement throttling sounds and niceify the code a bit
This commit is contained in:
@@ -366,7 +366,7 @@ local function init()
|
||||
alertSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSoundFile" },
|
||||
"OOF.ogg"),
|
||||
combatSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSoundFile" },
|
||||
"StarScream.mp3"),
|
||||
"StarScream.ogg"),
|
||||
helpSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSoundFile" },
|
||||
"MedicGangsterParadise.ogg"),
|
||||
tagSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSoundThrottle" }, 0),
|
||||
|
@@ -2,6 +2,9 @@ local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "MinimapTagger"
|
||||
local HeimdallRoot = "Interface\\AddOns\\Heimdall\\"
|
||||
local SoundRoot = HeimdallRoot .. "Sounds\\"
|
||||
local TextureRoot = HeimdallRoot .. "Texture\\"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.MinimapTagger = {}
|
||||
@@ -49,11 +52,11 @@ function shared.MinimapTagger.Init()
|
||||
self:SetScript("OnUpdate", function(self, elapsed)
|
||||
self.custom.progress = self.custom.progress + elapsed
|
||||
local progress = self.custom.progress / ttl
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Alert progress%%: %f", ModuleName, progress))
|
||||
print(string.format("[%s] Alert progress: %f", ModuleName, self.custom.progress))
|
||||
print(string.format("[%s] Alert ttl: %d", ModuleName, Heimdall_Data.config.minimapTagger.ttl))
|
||||
end
|
||||
-- if Heimdall_Data.config.minimapTagger.debug then
|
||||
-- print(string.format("[%s] Alert progress%%: %f", ModuleName, progress))
|
||||
-- print(string.format("[%s] Alert progress: %f", ModuleName, self.custom.progress))
|
||||
-- print(string.format("[%s] Alert ttl: %d", ModuleName, Heimdall_Data.config.minimapTagger.ttl))
|
||||
-- end
|
||||
self:SetAlpha(1 - progress)
|
||||
|
||||
if progress >= 1 then
|
||||
@@ -74,10 +77,10 @@ function shared.MinimapTagger.Init()
|
||||
frame.custom = { busy = false }
|
||||
local texture = frame:CreateTexture(nil, "ARTWORK")
|
||||
texture:SetAllPoints(frame)
|
||||
texture:SetTexture("Interface\\AddOns\\WeakAuras\\PowerAurasMedia\\Auras\\Aura27")
|
||||
--texture:SetTexture("Interface\\AddOns\\Heimdall\\Texture\\Alert")
|
||||
texture:SetTexture(TextureRoot .. "Alert.tga")
|
||||
table.insert(alertFramePool, frame)
|
||||
end
|
||||
local muteAlertUntil = 0
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param scale number?
|
||||
@@ -96,7 +99,22 @@ function shared.MinimapTagger.Init()
|
||||
return
|
||||
end
|
||||
if Heimdall_Data.config.minimapTagger.alertSound then
|
||||
PlaySoundFile("Interface\\AddOns\\Heimdall\\Sound\\Alert.mp3")
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Playing alert sound: %s", ModuleName,
|
||||
Heimdall_Data.config.minimapTagger.alertSoundFile))
|
||||
end
|
||||
if muteAlertUntil > GetTime() then
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Alert sound is muted until %d", ModuleName, muteAlertUntil))
|
||||
end
|
||||
else
|
||||
muteAlertUntil = GetTime() + Heimdall_Data.config.minimapTagger.alertSoundThrottle
|
||||
local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.alertSoundFile, "Master")
|
||||
if not ok and Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Failed to play alert sound: %s", ModuleName,
|
||||
Heimdall_Data.config.minimapTagger.alertSoundFile))
|
||||
end
|
||||
end
|
||||
end
|
||||
PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.alertTTL)
|
||||
end
|
||||
@@ -109,10 +127,10 @@ function shared.MinimapTagger.Init()
|
||||
frame.custom = { busy = false }
|
||||
local texture = frame:CreateTexture(nil, "ARTWORK")
|
||||
texture:SetAllPoints(frame)
|
||||
texture:SetTexture("Interface\\AddOns\\WeakAuras\\PowerAurasMedia\\Auras\\Aura11")
|
||||
--texture:SetTexture("Interface\\AddOns\\Heimdall\\Texture\\Tag")
|
||||
texture:SetTexture(TextureRoot .. "Tag.tga")
|
||||
table.insert(tagFramePool, frame)
|
||||
end
|
||||
local muteTagUntil = 0
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param scale number?
|
||||
@@ -131,7 +149,22 @@ function shared.MinimapTagger.Init()
|
||||
return
|
||||
end
|
||||
if Heimdall_Data.config.minimapTagger.tagSound then
|
||||
PlaySoundFile("Interface\\AddOns\\Heimdall\\Sound\\Tag.mp3")
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Playing tag sound: %s", ModuleName,
|
||||
Heimdall_Data.config.minimapTagger.tagSoundFile))
|
||||
end
|
||||
if muteTagUntil > GetTime() then
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Tag sound is muted until %d", ModuleName, muteTagUntil))
|
||||
end
|
||||
else
|
||||
muteTagUntil = GetTime() + Heimdall_Data.config.minimapTagger.tagSoundThrottle
|
||||
local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.tagSoundFile, "Master")
|
||||
if not ok and Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Failed to play tag sound: %s", ModuleName,
|
||||
Heimdall_Data.config.minimapTagger.tagSoundFile))
|
||||
end
|
||||
end
|
||||
end
|
||||
PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.tagTTL)
|
||||
end
|
||||
@@ -144,10 +177,10 @@ function shared.MinimapTagger.Init()
|
||||
frame.custom = { busy = false }
|
||||
local texture = frame:CreateTexture(nil, "ARTWORK")
|
||||
texture:SetAllPoints(frame)
|
||||
texture:SetTexture("Interface\\AddOns\\WeakAuras\\PowerAurasMedia\\Auras\\Aura19")
|
||||
--texture:SetTexture("Interface\\AddOns\\Heimdall\\Texture\\Fight")
|
||||
texture:SetTexture(TextureRoot .. "Fight.tga")
|
||||
table.insert(battleFramePool, frame)
|
||||
end
|
||||
local muteBattleUntil = 0
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param scale number?
|
||||
@@ -166,7 +199,22 @@ function shared.MinimapTagger.Init()
|
||||
return
|
||||
end
|
||||
if Heimdall_Data.config.minimapTagger.combatSound then
|
||||
PlaySoundFile("Interface\\AddOns\\Heimdall\\Sound\\Fight.mp3")
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Playing combat sound: %s", ModuleName,
|
||||
Heimdall_Data.config.minimapTagger.combatSoundFile))
|
||||
end
|
||||
if muteBattleUntil > GetTime() then
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Combat sound is muted until %d", ModuleName, muteBattleUntil))
|
||||
end
|
||||
else
|
||||
muteBattleUntil = GetTime() + Heimdall_Data.config.minimapTagger.combatSoundThrottle
|
||||
local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.combatSoundFile, "Master")
|
||||
if not ok and Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Failed to play combat sound: %s", ModuleName,
|
||||
Heimdall_Data.config.minimapTagger.combatSoundFile))
|
||||
end
|
||||
end
|
||||
end
|
||||
PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.combatTTL)
|
||||
end
|
||||
@@ -238,7 +286,8 @@ function shared.MinimapTagger.Init()
|
||||
|
||||
if channelname ~= Heimdall_Data.config.minimapTagger.masterChannel then
|
||||
if Heimdall_Data.config.minimapTagger.debug then
|
||||
print(string.format("[%s] Ignoring message from non-master channel: %s, need %s", ModuleName, channelname, Heimdall_Data.config.minimapTagger.masterChannel))
|
||||
print(string.format("[%s] Ignoring message from non-master channel: %s, need %s", ModuleName, channelname,
|
||||
Heimdall_Data.config.minimapTagger.masterChannel))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
Reference in New Issue
Block a user