end |
end |
|
local function UpdateStatusBar(self, event, rune, usable) |
local function statusbar(self, event, rune, usable) |
local bar = self.RuneBar |
if(rune and not usable and GetRuneType(rune)) then |
self.RuneBar[rune]:SetScript('OnUpdate', function(self) OnUpdateBar(self, rune) end) |
bar[rune]:SetScript('OnUpdate', function(self) updateBar(self, rune) end) |
end |
|
if(self.RuneBar.PostUpdate) then self.RuneBar:PostUpdate(event, rune, usable) end |
for index = 1, 6 do |
local runetype = GetRuneType(index) |
if(runetype) then |
bar[index]:SetStatusBarColor(unpack(bar.colors[runetype])) |
end |
end |
|
if(bar.PostUpdate) then bar:PostUpdate(event, rune, usable) end |
end |
|
local function Update(self) |
local bar = self.RuneBar |
if(#bar == 0) then |
local text = '' |
for i = 1, 6 do |
local start, duration, ready = GetRuneCooldown(i) |
local r, g, b = unpack(bar.colors[GetRuneType(i)]) |
local function fontstring(self) |
local text, str = self.RuneBar, '' |
|
text = format('%s|cff%02x%02x%02x%s%s|r', text, r * 255, g * 255, b * 255, ready and (bar.symbol or '*') or floor(duration - floor(GetTime() - start)), i ~= 6 and (bar.space or ' ') or '') |
end |
for index = 1, 6 do |
local start, duration, ready = GetRuneCooldown(i) |
local r, g, b = unpack(text.colors[GetRuneType(index)]) |
|
bar:SetText(text) |
else |
for i = 1, 6 do |
local runetype = GetRuneType(i) |
if(runetype) then |
bar[i]:SetStatusBarColor(unpack(bar.colors[runetype])) |
end |
end |
str = format('%s|cff%02x%02x%02x%s%s|r', str, r * 255, g * 255, b * 255, ready and (text.symbol or '*') or floor(duration - floor(GetTime() - start)), index ~= 6 and (text.space or ' ') or '') |
end |
|
text:SetText(str) |
end |
|
local function Enable(self, unit) |
local function enable(self, unit) |
local bar = self.RuneBar |
if(bar and unit == 'player' and select(2, UnitClass('player')) == 'DEATHKNIGHT') then |
local c = self.colors.runes or {} |
bar.colors = {c[1] or {0.77, 0.12, 0.23}, c[2] or {0.3, 0.8, 0.1}, c[3] or {0, 0.4, 0.7}, c[4] or {0.8, 0.8, 0.8}} |
|
self:RegisterEvent('RUNE_TYPE_UPDATE', Update) |
self:RegisterEvent('RUNE_POWER_UPDATE', #bar == 0 and Update or UpdateStatusBar) |
if(#bar == 0) then |
self:RegisterEvent('RUNE_TYPE_UPDATE', fontstring) |
self:RegisterEvent('RUNE_POWER_UPDATE', fontstring) |
|
if(#bar == 0) then |
CreateFrame('Frame'):SetScript('OnUpdate', function(_, elapsed) OnUpdateText(self, elapsed) end) |
bar.dummy = CreateFrame('Frame', nil, self) |
bar.dummy:SetScript('OnUpdate', function(_, elapsed) updateText(self, elapsed) end) |
else |
for i = 1, 6 do |
bar[i]:SetMinMaxValues(0, 1) |
self:RegisterEvent('RUNE_TYPE_UPDATE', statusbar) |
self:RegisterEvent('RUNE_POWER_UPDATE', statusbar) |
|
for index = 1, 6 do |
bar[index]:SetMinMaxValues(0, 1) |
end |
end |
|