-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathPlater_GhostAuras.lua
76 lines (60 loc) · 2.5 KB
/
Plater_GhostAuras.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
64
65
66
67
68
69
70
71
72
73
74
75
76
local Plater = _G.Plater
local DF = DetailsFramework
local _
local IS_WOW_PROJECT_MAINLINE = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_NOT_MAINLINE = WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_CLASSIC_ERA = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local IS_WOW_PROJECT_CLASSIC_TBC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
Plater.Auras.GhostAuras = {}
function Plater.Auras.GhostAuras.GetPlayerSpecInfo()
local specId
local specName
local specIndex = 0 --fallback for TBC
local _, playerClass = UnitClass("player")
if (IS_WOW_PROJECT_MAINLINE) then --retail
specIndex = GetSpecialization()
if (specIndex) then
specId, specName = GetSpecializationInfo(specIndex)
end
end
return specIndex, specId, specName, playerClass
end
function Plater.Auras.GhostAuras.GetAuraListForCurrentSpec()
local specIndex, specId, specName, playerClass = Plater.Auras.GhostAuras.GetPlayerSpecInfo()
if not playerClass or not specIndex then return nil end
--get the aura list from db, format: [spellId] = true
local profile = Plater.db.profile
local auraList = profile.ghost_auras.auras[playerClass][specIndex]
if not auraList then --fallback create for spec if needed
profile.ghost_auras.auras[playerClass][specIndex] = {}
auraList = profile.ghost_auras.auras[playerClass][specIndex]
end
return auraList
end
function Plater.Auras.GhostAuras.AddGhostAura(spellId)
local auraList = Plater.Auras.GhostAuras.GetAuraListForCurrentSpec()
auraList[spellId] = true
Plater.UpdateGhostAurasCache()
end
function Plater.Auras.GhostAuras.RemoveGhostAura(spellId)
local auraList = Plater.Auras.GhostAuras.GetAuraListForCurrentSpec()
auraList[spellId] = nil
Plater.UpdateGhostAurasCache()
end
--refresh caches when spec changes
local specChangeFrame = CreateFrame("frame")
if IS_WOW_PROJECT_MAINLINE then
specChangeFrame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
else
--specChangeFrame:RegisterEvent("CHARACTER_POINTS_CHANGED") --not needed for TBC/Classic, as there is no spec differences in the config, just class.
end
specChangeFrame:SetScript("OnEvent", function(self, event, ...)
Plater.RefreshAuraCache()
Plater.UpdateAuraCache()
local ghostAurasOptionsFrame = _G.PlaterOptionsPanelContainerGhostAurasFrame
if (ghostAurasOptionsFrame) then
if (ghostAurasOptionsFrame:IsShown()) then
Plater.Auras.GhostAuras.SetSpec()
end
end
end)