This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: svn://svn.wowinterface.com/oUF_RuneBar-428/trunk@2 de8deef6-8a7d-401d-9c13-17d23404a81b
- Loading branch information
p3lim-52096
committed
Feb 25, 2009
1 parent
02c6a28
commit 31aec40
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--[[ | ||
Elements handled: | ||
.RuneBar [fontstring or table] | ||
FontString only: | ||
- space: The space between each "counter". (Default: " ") | ||
- symbol: The symbol used when cooldowns are over. (Default: "*") | ||
- interval: The time offset used for the update script. (Default: 0.5) | ||
--]] | ||
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 | ||
function OnUpdateText(self, elapsed) | ||
total = total + elapsed | ||
if(total >= (self.RuneBar.interval or 0.5)) then | ||
self:UpdateElement('RuneBar') | ||
total = 0 | ||
end | ||
end | ||
function OnUpdateBar(self, rune) | ||
local start, duration, ready = GetRuneCooldown(rune) | ||
if(ready) then | ||
self:SetValue(1) | ||
self:SetScript('OnUpdate', nil) | ||
else | ||
self:SetValue((GetTime() - start) / duration) | ||
end | ||
end | ||
end | ||
local function UpdateStatusBar(self, event, rune, usable) | ||
if(rune and not usable and GetRuneType(rune)) then | ||
self.RuneBar[rune]:SetScript('OnUpdate', function(self) OnUpdateBar(self, rune) end) | ||
end | ||
end | ||
local function Update(self, event, rune) | ||
local runebar = self.RuneBar | ||
if(#runebar == 0) then | ||
local text = '' | ||
for i = 1, 6 do | ||
local start, duration, ready, temp = GetRuneCooldown(i) | ||
local r, g, b = unpack(runebar.colors[GetRuneType(i)]) | ||
local temp = ready and (runebar.symbol or '*') or (duration - math.floor(GetTime() - start)) | ||
text = string.format('%s|cff%02x%02x%02x%s%s|r', text, r * 255, g * 255, b * 255, temp, runebar.space or ' ') | ||
end | ||
runebar:SetText(text) | ||
else | ||
for i = 1, 6 do | ||
local runetype = GetRuneType(i) | ||
if(runetype) then | ||
runebar[i]:SetStatusBarColor(unpack(runebar.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 | ||
self:RegisterEvent('RUNE_TYPE_UPDATE', Update) | ||
if(#runebar == 0) then | ||
self:RegisterEvent('RUNE_POWER_UPDATE', Update) | ||
dummy:SetScript('OnUpdate', function(s, e) OnUpdateText(self, e) end) | ||
else | ||
self:RegisterEvent('RUNE_POWER_UPDATE', UpdateStatusBar) | ||
end | ||
RuneFrame:Hide() | ||
return true | ||
end | ||
end | ||
local function Disable(self) | ||
local runebar = self.RuneBar | ||
if(runebar) then | ||
self:RegisterEvent('RUNE_TYPE_UPDATE', Update) | ||
if(#runebar == 0) then | ||
self:UnregisterEvent('RUNE_POWER_UPDATE', Update) | ||
dummy:SetScript('OnUpdate', nil) | ||
else | ||
self:UnregisterEvent('RUNE_POWER_UPDATE', UpdateStatusBar) | ||
end | ||
RuneFrame:Show() | ||
end | ||
end | ||
oUF:AddElement('RuneBar', Update, Enable, Disable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## Interface: 30000 | ||
## Author: p3lim | ||
## Version: 30000.wowi:revision | ||
## Title: oUF RuneBar | ||
## Notes: Death Knight rune support for oUF layouts. | ||
## RequiredDeps: oUF | ||
|
||
oUF_RuneBar.lua |