+-- Bres.lua
+local _;
+local min, ceil = math.min, math.ceil;
+local GetSpellCharges = GetSpellCharges;
+local GetTime = GetTime;
+local CTimerAfter = C_Timer.After;
+
+local frame = CreateFrame("Frame", "OmaBres", UIParent);
+
+local function tick()
+ local charges, maxCharges, start, duration = GetSpellCharges(20484); -- Rebirth
+ if charges then
+ frame:Show();
+ local remain = duration - (GetTime() - start);
+ if remain < 0 then
+ frame:Hide();
+ CTimerAfter(5, tick);
+ return;
+ end
+ frame.charge:SetText(charges);
+ frame.cd:SetCooldown(start, duration);
+ CTimerAfter(min(ceil(remain), 5), tick);
+ else
+ frame:Hide();
+ CTimerAfter(5, tick);
+ end
+end
+
+local function bres()
+ frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 580, 0);
+ frame:SetWidth(48);
+ frame:SetHeight(48);
+ frame.base = frame:CreateTexture(nil, "BACKGROUND");
+ frame.base:SetAllPoints();
+ frame.base:SetColorTexture(0, 0, 0, 0.5);
+ frame.icon = frame:CreateTexture(nil, "BORDER");
+ frame.icon:SetPoint("TOPLEFT", frame.base, "TOPLEFT", 1, -1);
+ frame.icon:SetPoint("BOTTOMRIGHT", frame.base, "BOTTOMRIGHT", -1, 1);
+ frame.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93);
+ frame.icon:SetTexture(136080); -- Rebirth
+ frame.charge = frame:CreateFontString(nil, "OVERLAY", "NumberFontNormalLarge");
+ frame.charge:SetPoint("BOTTOMRIGHT");
+ frame.cd = CreateFrame("Cooldown", "OmaBresCD", frame, "CooldownFrameTemplate");
+ frame.cd:SetAllPoints();
+ frame:UnregisterAllEvents();
+ tick();
+end
+
+frame:SetScript("OnEvent", function(self, event)
+ return bres();
+end);
+frame:RegisterEvent("PLAYER_LOGIN");