-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
52 lines (41 loc) · 1.24 KB
/
Core.lua
File metadata and controls
52 lines (41 loc) · 1.24 KB
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
local addonName, HealthAlert = ...
LibStub('AceAddon-3.0'):NewAddon(HealthAlert, 'HealthAlert', 'AceConsole-3.0', 'AceEvent-3.0')
--- @class HealthAlert
_G[addonName] = HealthAlert
local f = CreateFrame("Frame", "HealthAlert", UIParent)
f:SetScript("OnUpdate", function()
HealthAlert:OnUpdate()
end)
HealthAlert.MainFrame = f
function HealthAlert:OnInitialize()
self.db = LibStub('AceDB-3.0'):New('HealthAlertOptions', self.HealthAlertOptions)
end
function HealthAlert:OnEnable()
SetupOptionsPanel()
end
function HealthAlert:OnUpdate()
local s = self.db.global
if (s.LastAlertUnixTime + s.SoundIntervalSeconds) < time() then
self.db.global.LastAlertUnixTime = time()
if UnitAffectingCombat('player') and
(UnitHealth('player') / UnitHealthMax('player') * 100) <= s.HealthPercent
then
self:RunAlerts()
end
end
end
function HealthAlert:PlayAlertSound(s)
PlaySoundFile(s, self.db.global.SoundChannel)
end
function HealthAlert:ShowRaidWarning(text)
RaidNotice_AddMessage(RaidWarningFrame, text, ChatTypeInfo["RAID_WARNING"]);
end
function HealthAlert:RunAlerts()
local s = self.db.global
if not s.MuteAlertSound then
self:PlayAlertSound(s.AlertSound)
end
if not s.DisableRaidWarning then
self:ShowRaidWarning(s.RaidWarningText)
end
end