Skip to content

Commit

Permalink
Updated oUF element "Runes" with changes from oUF pull request 269
Browse files Browse the repository at this point in the history
  • Loading branch information
Blazeflack committed Aug 4, 2016
1 parent cdb02cf commit 5ea56aa
Showing 1 changed file with 11 additions and 58 deletions.
69 changes: 11 additions & 58 deletions ElvUI/Libraries/oUF/elements/runebar.lua
Expand Up @@ -30,10 +30,10 @@
local Rune = CreateFrame('StatusBar', nil, self)
Rune:SetSize(120 / 6, 20)
Rune:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', index * 120 / 6, 0)
Runes[index] = Rune
end
-- Register with oUF
self.Runes = Runes
Expand All @@ -46,41 +46,10 @@
]]

if select(2, UnitClass("player")) ~= "DEATHKNIGHT" then return end
local isBetaClient = select(4, GetBuildInfo()) >= 70000

local parent, ns = ...
local oUF = ns.oUF

local runemap, UpdateType
if(not isBetaClient) then
oUF.colors.runes = {
{1, 0, 0}, -- blood
{0, .5, 0}, -- unholy
{0, 1, 1}, -- frost
{.9, .1, 1}, -- death
}

runemap = { 1, 2, 5, 6, 3, 4 }

UpdateType = function(self, event, rid, alt)
local runes = self.Runes
local rune = runes[runemap[rid]]
local colors = self.colors.runes[GetRuneType(rid) or alt]
local r, g, b = colors[1], colors[2], colors[3]

rune:SetStatusBarColor(r, g, b)

if(rune.bg) then
local mu = rune.bg.multiplier or 1
rune.bg:SetVertexColor(r * mu, g * mu, b * mu)
end

if(runes.PostUpdateType) then
return runes:PostUpdateType(rune, rid, alt)
end
end
end

local OnUpdate = function(self, elapsed)
local duration = self.duration + elapsed
if(duration >= self.max) then
Expand All @@ -93,7 +62,7 @@ end

local Update = function(self, event, rid)
local runes = self.Runes
local rune = runes[isBetaClient and rid or runemap[rid]]
local rune = runes[rid]
if(not rune) then return end

local start, duration, runeReady
Expand Down Expand Up @@ -156,7 +125,7 @@ local function RunesDisable(self)
self:RegisterEvent("UNIT_EXITED_VEHICLE", VisibilityPath)

self.Runes:Hide()

if self.Runes.PostUpdateVisibility then
self.Runes:PostUpdateVisibility(false, self.Runes.isEnabled)
end
Expand Down Expand Up @@ -199,45 +168,29 @@ local Enable = function(self, unit)
runes.ForceUpdate = ForceUpdate

for i=1, 6 do
local rune = runes[isBetaClient and i or runemap[i]]
local rune = runes[i]

local r, g, b = unpack(self.colors.power.RUNES)
if(rune:IsObjectType'StatusBar' and not rune:GetStatusBarTexture()) then
rune:SetStatusBarTexture[[Interface\TargetingFrame\UI-StatusBar]]

if(isBetaClient) then
local colors = oUF.colors.power.RUNES
rune:SetStatusBarColor(colors[1], colors[2], colors[3])

if(rune.bg) then
local mu = rune.bg.multiplier or 1
rune.bg:SetVertexColor(r * mu, g * mu, b * mu)
end
end
rune:SetStatusBarColor(r, g, b)
end

if(not isBetaClient) then
-- From my minor testing this is a okey solution. A full login always remove
-- the death runes, or at least the clients knowledge about them.
UpdateType(self, nil, i, math.floor((i+1)/2))
if(rune.bg) then
local mu = rune.bg.multiplier or 1
rune.bg:SetVertexColor(r * mu, g * mu, b * mu)
end
end

self:RegisterEvent("RUNE_POWER_UPDATE", Path, true)

if(not isBetaClient) then
self:RegisterEvent("RUNE_TYPE_UPDATE", UpdateType, true)
end

return true
end
end

local Disable = function(self)
self:UnregisterEvent("RUNE_POWER_UPDATE", Path)

if(not isBetaClient) then
self:UnregisterEvent("RUNE_TYPE_UPDATE", UpdateType)
end

RunesDisable(self)
end

Expand Down

0 comments on commit 5ea56aa

Please sign in to comment.