local Settings = OmaRFSettings;
local majorAuras = Settings.MajorAuras;
-local watchedAuras = {};
+local watchedAuras = {};
local updaters = {};
local updating = {};
+local updateAuras;
local M = {};
OmaRFIndicators = M;
tex.icon = true;
frame.majors[i] = tex;
end
+
+ frame.throttle = function()
+ frame.throttled = nil;
+ updateAuras(frame, frame.displayed);
+ end;
end
local function remaining(text, expires, current)
ind:Hide();
end
-function M.CheckIndicators(frame, unit)
+function M.UpdateAuras(frame, unit)
+ local current = GetTime();
+ if frame.throttled then
+ print("updateAuras throttled for ", unit); -- TODO debug print
+ return;
+ elseif frame.prevUpdate - current < 0.1 then
+ frame.throttled = true;
+ return CTimerAfter(0.1, frame.throttle);
+ end
+
for _, ind in pairs(frame.inds) do
hideInd(ind);
end
+ local icon, count, expires, id;
+ local showInds, needUpdate = false, false;
+ local i = 1;
+ while true do
+ _, _, icon, count, _, _, expires, _, _, _, id = UnitAura(unit, i, "PLAYER HELPFUL");
+ if not id then break end
+ local pos = watchedAuras[id];
+ if pos then
+ needUpdate = showInd(frame.inds[pos], expires, current, count, icon) or needUpdate;
+ showInds = true;
+ end
+ i = i + 1;
+ end
+
+ if showInds then
+ frame.indBase:Show();
+ if needUpdate and not updating[frame] then
+ updating[frame] = true; -- race?
+ -- create a function for updating the indicator
+ local func = updaters[frame];
+ if not func then
+ func = function() updateIndicators(frame) end;
+ updaters[frame] = func;
+ end
+ CTimerAfter(0.20, func);
+ end
+ else
+ frame.indBase:Hide();
+ end
+end
+updateAuras = M.UpdateAuras;
+
+function M.UpdateMajorAuras(frame, unit)
for _, ind in pairs(frame.majors) do
hideInd(ind);
end
- local name, icon, count, expires, caster, id;
- local showInds, showMajors, needUpdate = false, false, false;
+ local icon, count, expires, id;
+ local showMajors, needUpdate = false, false;
local majorPos = 1;
local alert = false; -- color the whole bar
local current = GetTime();
- for spell, pos in pairs(watchedAuras) do
- name, _, icon, count, _, _, expires = UnitAura(unit, spell, nil, "PLAYER HELPFUL");
- if name then
- needUpdate = showInd(frame.inds[pos], expires, current, count, icon) or needUpdate;
- showInds = true;
- end
- end
-
local i = 1;
while true do
- name, _, icon, count, _, _, expires, caster, _, _, id = UnitAura(unit, i, "HARMFUL");
+ _, _, icon, count, _, _, expires, _, _, _, id = UnitAura(unit, i, "HARMFUL");
if not id or majorPos > 3 then break end
- local major = majorAuras[id] or majorAuras[name];
+ local major = majorAuras[id];
if major then
needUpdate = showInd(frame.majors[majorPos], expires, current, count, icon) or needUpdate;
if major.bar then alert = true end
i = i + 1;
end
- if showInds or showMajors then
- frame.indBase:Show();
+ if showMajors then
frame.majorBase:Show();
if needUpdate and not updating[frame] then
updating[frame] = true; -- race?
CTimerAfter(0.20, func);
end
else
- frame.indBase:Hide();
frame.majorBase:Hide();
end