Skip to content

Commit

Permalink
Sound Warning: Treat TTS as a sound
Browse files Browse the repository at this point in the history
  • Loading branch information
InfusOnWoW committed Jan 23, 2024
1 parent 0dcc134 commit f60955c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions WeakAuras/AuraWarnings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local AddonName, Private = ...
--- @alias AuraWarningSeverity
--- | "info"
--- | "sound"
--- | "tts"
--- | "warning"
--- | "error"

Expand Down Expand Up @@ -63,6 +64,7 @@ end
local severityLevel = {
info = 0,
sound = 1,
tts = 1,
warning = 2,
error = 3
}
Expand All @@ -71,6 +73,7 @@ local severityLevel = {
local icons = {
info = [[Interface/friendsframe/informationicon.blp]],
sound = [[chatframe-button-icon-voicechat]],
tts = [[chatframe-button-icon-tts]],
warning = [[Interface/buttons/adventureguidemicrobuttonalert.blp]],
error = [[Interface/DialogFrame/UI-Dialog-Icon-AlertNew]]
}
Expand All @@ -79,6 +82,7 @@ local icons = {
local titles = {
info = L["Information"],
sound = L["Sound"],
tts = L["Text To Speech"],
warning = L["Warning"],
error = L["Error"],
}
Expand Down Expand Up @@ -142,6 +146,7 @@ function Private.AuraWarnings.FormatWarnings(uid)
result = AddMessages(result, messagePerSeverity["error"], icons["error"], mixedSeverity)
result = AddMessages(result, messagePerSeverity["warning"], icons["warning"], mixedSeverity)
result = AddMessages(result, messagePerSeverity["sound"], icons["sound"], mixedSeverity)
result = AddMessages(result, messagePerSeverity["tts"], icons["tts"], mixedSeverity)
result = AddMessages(result, messagePerSeverity["info"], icons["info"], mixedSeverity)
return icons[maxSeverity], titles[maxSeverity], result
end
29 changes: 26 additions & 3 deletions WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2818,30 +2818,53 @@ local oldDataStub2 = {
}

function Private.UpdateSoundIcon(data)
local function anySoundCondition()
local function testConditions()
local sound, tts
if data.conditions then
for _, condition in ipairs(data.conditions) do
for changeIndex, change in ipairs(condition.changes) do
if change.property == "sound" then
return true
sound = true
end
if change.property == "chat" and change.value and change.value.message_type == "TTS" then
tts = true
end
if sound and tts then break end
end
end
end
return sound, tts
end

local soundCondition, ttsCondition = testConditions()

-- sound
if data.actions.start.do_sound or data.actions.finish.do_sound then
Private.AuraWarnings.UpdateWarning(data.uid, "sound_action", "sound", L["This aura plays a sound via an action."])
else
Private.AuraWarnings.UpdateWarning(data.uid, "sound_action")
end

if anySoundCondition() then
if soundCondition then
Private.AuraWarnings.UpdateWarning(data.uid, "sound_condition", "sound", L["This aura plays a sound via a condition."])
else
Private.AuraWarnings.UpdateWarning(data.uid, "sound_condition")
end

-- tts
if (data.actions.start.do_message and data.actions.start.message_type == "TTS")
or (data.actions.finish.do_message and data.actions.finish.message_type == "TTS")
then
Private.AuraWarnings.UpdateWarning(data.uid, "tts_action", "tts", L["This aura plays a Text To Speech via an action."])
else
Private.AuraWarnings.UpdateWarning(data.uid, "tts_action")
end

if ttsCondition then
Private.AuraWarnings.UpdateWarning(data.uid, "tts_condition", "tts", L["This aura plays a Text To Speech via a condition."])
else
Private.AuraWarnings.UpdateWarning(data.uid, "tts_condition")
end
end

function WeakAuras.PreAdd(data)
Expand Down

0 comments on commit f60955c

Please sign in to comment.