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 "Delusions", "Entropic Blast", "Necrotic Embrace", "Flametouched", "Shadowtouched",
81 "Blazing Eruption", "Shattering Scream", "Consuming Hunger", "Unstable Soul",
82 "Time Bomb", "Broken Shard",
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", UIParent);
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.stack:SetText(count);
117 frame.cd:SetCooldown(expires - duration, duration);
122 frame.icon:SetTexture(icon);
131 local function updateAuras(unit)
133 for _, i in pairs(units[unit]) do
134 updateAuraFrame(frames[i]);
139 local function updateTotemFrame(frame)
140 print("totem frame not implemented");
143 local function updateTotems(slot)
145 for _, i in pairs(totems[slot]) do
146 updateTotemFrame(frames[i]);
151 local function createTMW(name, config, parent)
152 local frame = CreateFrame("Frame", name, parent);
153 frame:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", config.x, config.y+config.height);
154 frame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", config.x+config.width, config.y);
155 frame.unit = config.unit;
156 frame.spec = config.spec;
157 frame.auras = config.auras;
158 frame.auraFilter = config.auraFilter;
159 frame.totems = config.totems;
161 -- TODO a background, like Masque
162 frame.icon = frame:CreateTexture(nil, "ARTWORK");
163 frame.icon:SetAllPoints();
164 frame.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93);
165 frame.stack = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightHuge"); -- TODO change to number font
166 frame.stack:SetPoint("TOPLEFT");
167 frame.cd = CreateFrame("Cooldown", name.."CD", frame, "CooldownFrameTemplate");
168 frame.cd:SetReverse(true);
169 frame.cd:SetAllPoints();
173 local function initialize()
174 Indicators:SetFrameStrata("LOW");
175 Indicators:SetPoint("BOTTOMLEFT");
176 Indicators:SetWidth(1);
177 Indicators:SetHeight(1);
178 currentSpec = GetSpecialization();
179 local name, realm = UnitFullName("player");
180 if chars[realm] and chars[realm][name] then
181 for _, config in pairs(chars[realm][name]) do
182 table.insert(settings, config)
185 for i, config in pairs(settings) do
187 if not units[config.unit] then units[config.unit] = {} end
188 table.insert(units[config.unit], i);
190 if config.totems then
191 for _, slot in pairs(config.totems) do
192 if not totems[slot] then totems[slot] = {} end
193 table.insert(totems[slot], i);
196 frames[i] = createTMW("OmaTMW"..i, config, Indicators);
199 for _, frame in pairs(frames) do
200 if frame.auras then updateAuraFrame(frame) end
201 if frame.totems then updateTotemFrame(frame) end
205 -- TODO have healthstone icon for player separate from this
206 Indicators:RegisterEvent("UNIT_AURA");
207 Indicators:RegisterEvent("PLAYER_TARGET_CHANGED");
208 Indicators:RegisterEvent("PLAYER_TOTEM_UPDATE");
209 Indicators:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT");
210 Indicators:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED");
211 Indicators:RegisterEvent("PLAYER_LOGIN");
212 Indicators:SetScript("OnEvent", function(self, event, arg1)
213 if event == "UNIT_AURA" then
215 elseif event == "PLAYER_TARGET_CHANGED" then
216 updateAuras("target");
217 elseif event == "PLAYER_TOTEM_UPDATE" then
219 elseif event == "INSTANCE_ENCOUNTER_ENGAGE_UNIT" then
220 for _, boss in pairs(bosses) do
223 elseif event == "PLAYER_SPECIALIZATION_CHANGED" then
224 currentSpec = GetSpecialization();
225 for _, frame in pairs(frames) do
226 if frame.auras then updateAuraFrame(frame) end
227 if frame.totems then updateTotemFrame(frame) end
229 elseif event == "PLAYER_LOGIN" then