4 local GetSpecialization = GetSpecialization;
5 local UnitExists = UnitExists;
6 local UnitAura = UnitAura;
8 -- character specific frames
14 spec = 3, -- Retribution
16 auraFilter = "PLAYER HARMFUL",
17 x = 570, -- placed over Innervate frame
24 spec = 3, -- Retribution
25 auras = {"Divine Purpose"},
26 auraFilter = "PLAYER HELPFUL",
34 spec = 2, -- Protection
35 auras = {"Shield of the Righteous"},
36 auraFilter = "PLAYER HELPFUL",
44 auras = {"Divine Shield"},
45 auraFilter = "PLAYER HELPFUL",
56 -- unit = unitID where to check auras, not required for totem checkers
57 -- spec = player spec index to show frame, if nil show always
58 -- auras = list of auras to track, in priority order
59 -- auraFilter = filter for UnitAura
60 -- totems = list of totem slots to track, in priority order, only checked if auras is nil
61 -- x = x position relative to UIParent bottom left
62 -- y = y position relative to UIParent bottom left
66 -- global frames' settings
70 auras = {"Innervate"},
71 auraFilter = "HELPFUL",
80 "Necrotic Embrace", "Flametouched", "Shadowtouched", "Blazing Eruption",
81 "Shattering Scream", "Consuming Hunger", "Unstable Soul", "Time Bomb",
84 auraFilter = "HARMFUL",
93 local units = {}; -- mapping from unitID to frames
94 local totems = {}; -- mapping to frames with totems
96 for i = 1, MAX_BOSS_FRAMES do
97 bosses[i] = "boss"..i;
99 local currentSpec = 0; -- 0 is invalid
101 local Indicators = CreateFrame("Frame", "OmaTMW");
103 local function updateAuraFrame(frame)
104 local unit = frame.unit;
105 if UnitExists(unit) and (not frame.spec or frame.spec == currentSpec) then
106 local name, icon, count, duration, expires;
107 for _, aura in pairs(frame.auras) do
108 name, _, icon, count, _, duration, expires = UnitAura(unit, aura, nil, frame.auraFilter);
111 frame.cd:SetCooldown(expires - duration, duration);
116 frame.icon:SetTexture(icon);
125 local function updateAuras(unit)
127 for _, i in pairs(units[unit]) do
128 updateAuraFrame(frames[i]);
133 local function updateTotemFrame(frame)
134 print("totem frame not implemented");
137 local function updateTotems(slot)
139 for _, i in pairs(totems[slot]) do
140 updateTotemFrame(frames[i]);
145 local function createTMW(name, config)
146 local frame = CreateFrame("Frame", name, UIParent);
147 frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", config.x, config.y+config.height);
148 frame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMLEFT", config.x+config.width, config.y);
149 frame.unit = config.unit;
150 frame.spec = config.spec;
151 frame.auras = config.auras;
152 frame.auraFilter = config.auraFilter;
153 frame.totems = config.totems;
155 -- TODO a background, like Masque, stack count
156 frame.icon = frame:CreateTexture(nil, "ARTWORK");
157 frame.icon:SetAllPoints();
158 frame.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93);
159 frame.cd = CreateFrame("Cooldown", name.."CD", frame, "CooldownFrameTemplate");
160 frame.cd:SetReverse(true);
161 frame.cd:SetAllPoints();
165 local function initialize()
166 Indicators:SetFrameStrata("LOW");
167 currentSpec = GetSpecialization();
168 local name, realm = UnitFullName("player");
169 if chars[realm] and chars[realm][name] then
170 for _, config in pairs(chars[realm][name]) do
171 table.insert(settings, config)
174 for i, config in pairs(settings) do
176 if not units[config.unit] then units[config.unit] = {} end
177 table.insert(units[config.unit], i);
179 if config.totems then
180 for _, slot in pairs(config.totems) do
181 if not totems[slot] then totems[slot] = {} end
182 table.insert(totems[slot], i);
185 frames[i] = createTMW("OmaTMW"..i, config);
188 for _, frame in pairs(frames) do
189 if frame.auras then updateAuraFrame(frame) end
190 if frame.totems then updateTotemFrame(frame) end
194 -- TODO have healthstone icon for player separate from this
195 Indicators:RegisterEvent("UNIT_AURA");
196 Indicators:RegisterEvent("PLAYER_TARGET_CHANGED");
197 Indicators:RegisterEvent("PLAYER_TOTEM_UPDATE");
198 Indicators:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT");
199 Indicators:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED");
200 Indicators:RegisterEvent("PLAYER_LOGIN");
201 Indicators:SetScript("OnEvent", function(self, event, arg1)
202 if event == "UNIT_AURA" then
204 elseif event == "PLAYER_TARGET_CHANGED" then
205 updateAuras("target");
206 elseif event == "PLAYER_TOTEM_UPDATE" then
208 elseif event == "INSTANCE_ENCOUNTER_ENGAGE_UNIT" then
209 for _, boss in pairs(bosses) do
212 elseif event == "PLAYER_SPECIALIZATION_CHANGED" then
213 currentSpec = GetSpecialization();
214 for _, frame in pairs(frames) do
215 if frame.auras then updateAuraFrame(frame) end
216 if frame.totems then updateTotemFrame(frame) end
218 elseif event == "PLAYER_LOGIN" then