Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fixed issue with single colors replaced
Browse files Browse the repository at this point in the history
Fixed issue with colors not being applied at load

git-svn-id: svn://svn.wowinterface.com/oUF_RuneBar-428/trunk@6 de8deef6-8a7d-401d-9c13-17d23404a81b
  • Loading branch information
p3lim-52096 committed Jun 25, 2009
1 parent 687dfab commit f65d333
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions oUF_RuneBar/oUF_RuneBar.lua
Expand Up @@ -16,15 +16,6 @@ local unpack = unpack
local floor = math.floor
local format = string.format
local localized, class = UnitClass('player')
local dummy = CreateFrame('Frame')
local colors = {
[1] = {0.77, 0.12, 0.23},
[2] = {0.3, 0.8, 0.1},
[3] = {0, 0.4, 0.7},
[4] = {0.8, 0.8, 0.8},
}
local OnUpdateBar, OnUpdateText
do
local total = 0
Expand Down Expand Up @@ -57,38 +48,39 @@ local function UpdateStatusBar(self, event, rune, usable)
if(self.RuneBar.PostUpdate) then self.RuneBar:PostUpdate(event, rune, usable) end
end
local function Update(self, event, rune)
local runebar = self.RuneBar
if(#runebar == 0) then
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(runebar.colors[GetRuneType(i)])
local r, g, b = unpack(bar.colors[GetRuneType(i)])
text = format('%s|cff%02x%02x%02x%s%s|r', text, r * 255, g * 255, b * 255, ready and (runebar.symbol or '*') or floor(duration - floor(GetTime() - start)), i ~= 6 and (runebar.space or ' ') or '')
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
runebar:SetText(text)
bar:SetText(text)
else
for i = 1, 6 do
local runetype = GetRuneType(i)
if(runetype) then
runebar[i]:SetStatusBarColor(unpack(runebar.colors[runetype]))
bar[i]:SetStatusBarColor(unpack(bar.colors[runetype]))
end
end
end
end
local function Enable(self, unit)
local runebar = self.RuneBar
if(runebar and unit == 'player' and class == 'DEATHKNIGHT') then
runebar.colors = self.colors.runes or colors
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', #runebar == 0 and Update or UpdateStatusBar)
self:RegisterEvent('RUNE_POWER_UPDATE', #bar == 0 and Update or UpdateStatusBar)
if(#runebar == 0) then
dummy:SetScript('OnUpdate', function(s, e) OnUpdateText(self, e) end)
if(#bar == 0) then
CreateFrame('Frame'):SetScript('OnUpdate', function(_, elapsed) OnUpdateText(self, elapsed) end)
end
RuneFrame:Hide()
Expand All @@ -98,11 +90,11 @@ local function Enable(self, unit)
end
local function Disable(self)
local runebar = self.RuneBar
if(runebar) then
local bar = self.RuneBar
if(bar) then
self:RegisterEvent('RUNE_TYPE_UPDATE', Update)
if(#runebar == 0) then
if(#bar == 0) then
self:UnregisterEvent('RUNE_POWER_UPDATE', Update)
dummy:SetScript('OnUpdate', nil)
else
Expand Down

0 comments on commit f65d333

Please sign in to comment.