- -- tank CD marker
- if next(frame.tankcd) then
- if not frame.defensive:IsShown() then frame.defensive:Show() end
- elseif frame.defensive:IsShown() then
- frame.defensive:Hide();
- end
- -- aura stacks
- if next(frame.stacks) then
- local _, amount = next(frame.stacks);
- frame.stack:SetText(amount);
- if not frame.stack:IsShown() then frame.stack:Show() end
- elseif frame.stack:IsShown() then
- frame.stack:Hide();
+ -- mana, if present
+ if frame.mana ~= nil then
+ local current, max = UnitPower(unit), UnitPowerMax(unit);
+ local ptype = UnitPowerType(unit);
+ if frame.mana.ptype ~= ptype then
+ frame.mana.ptype = ptype;
+ frame.mana:SetVertexColor(unpack(powerColors[ptype]));
+ end
+ if frame.prev.mana ~= current or frame.prev.mmax ~= max then
+ frame.prev.mana = current;
+ frame.prev.mmax = max;
+ if max < 1 then
+ if frame.mana:IsShown() then frame.mana:Hide() end
+ if frame.manatext:IsShown() then frame.manatext:Hide() end
+ elseif max < current then
+ frame.mana:SetWidth(width);
+ frame.manatext:SetText("100");
+ if not frame.mana:IsShown() then frame.mana:Show() end
+ if not frame.manatext:IsShown() then frame.manatext:Show() end
+ elseif current <= 0 then
+ if frame.mana:IsShown() then frame.mana:Hide() end
+ if frame.manatext:IsShown() then frame.manatext:Hide() end
+ else
+ local percent = current/max;
+ frame.mana:SetWidth(percent*width);
+ frame.manatext:SetText(format("%d", percent*100+0.5));
+ if not frame.mana:IsShown() then frame.mana:Show() end
+ if not frame.manatext:IsShown() then frame.manatext:Show() end
+ end
+ end