WoWInterface SVN oUF_Reputation

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

trunk/oUF_Reputation/oUF_Reputation.lua New file
0,0 → 1,74
--[[
 
Elements handled:
.Reputation [statusbar]
.Reputation.Text [fontstring] (optional)
 
Shared:
- Colors [table] - will use blizzard colors if not set
- Tooltip [boolean]
- MouseOver [boolean]
 
--]]
local function Tooltip(self, min, max, name, id)
GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT', 5, -5)
GameTooltip:AddLine(string.format('%s (%s)', name, _G['FACTION_STANDING_LABEL'..id]))
GameTooltip:AddLine(string.format('%d/%d (%.1f%%)', min, max, min/max*100))
GameTooltip:Show()
end
 
local function Update(self, event, unit)
local bar = self.Reputation
 
if(GetWatchedFactionInfo()) then
local name, id, min, max, value = GetWatchedFactionInfo()
bar:SetMinMaxValues(min, max)
bar:SetValue(value)
bar:EnableMouse()
bar:SetStatusBarColor(unpack(bar.Colors or {FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b}))
 
if(not bar.MouseOver) then
bar:SetAlpha(1)
end
 
if(bar.Text) then
bar.Text:SetFormattedText('%d / %d - %s', value - min, max - min, name)
end
 
if(bar.Tooltip and bar.MouseOver) then
bar:SetScript('OnEnter', function() bar:SetAlpha(1); Tooltip(bar, value - min, max - min, name, id) end)
bar:SetScript('OnLeave', function() bar:SetAlpha(0); GameTooltip:Hide() end)
elseif(bar.Tooltip and not bar.MouseOver) then
bar:SetScript('OnEnter', function() Tooltip(bar, value - min, max - min, name, id) end)
bar:SetScript('OnLeave', function() GameTooltip:Hide() end)
elseif(bar.MouseOver and not bar.Tooltip) then
bar:SetScript('OnEnter', function() bar:SetAlpha(1) end)
bar:SetScript('OnLeave', function() bar:SetAlpha(0) end)
end
end
end
 
local function Enable(self, unit)
local reputation = self.Experience
if(reputation and unit == 'player') then
self:RegisterEvent('UPDATE_FACTION', Update)
 
if(not reputation:GetStatusBarTexture()) then
reputation:SetStatusBarTexture([=[Interface\TargetingFrame\UI-StatusBar]=])
end
 
if(reputation.MouseOver) then
reputation:SetAlpha(0)
end
 
return true
end
end
 
local function Disable(self)
if(self.Reputation) then
self:UnregisterEvent('UPDATE_FACTION', Update)
end
end
 
oUF:AddElement('Reputation', Update, Enable, Disable)
\ No newline at end of file
trunk/oUF_Reputation/oUF_Reputation.toc New file
0,0 → 1,8
## Interface: 30000
## Author: p3lim
## Version: 30000.wowi:revision
## Title: oUF Reputation
## Notes: Reputation Bar support for oUF layouts.
## RequiredDeps: oUF
 
oUF_Reputation.lua
\ No newline at end of file