Initial commit
p3lim-52096 [12-27-08 - 06:27]
Initial commit
git-svn-id: svn://svn.wowinterface.com/oUF_Reputation-398/trunk@2 f82d3c14-86d8-4125-bab8-f0c326a23617
diff --git a/oUF_Reputation/oUF_Reputation.lua b/oUF_Reputation/oUF_Reputation.lua
new file mode 100644
index 0000000..374c1af
--- /dev/null
+++ b/oUF_Reputation/oUF_Reputation.lua
@@ -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
diff --git a/oUF_Reputation/oUF_Reputation.toc b/oUF_Reputation/oUF_Reputation.toc
new file mode 100644
index 0000000..46a5bd6
--- /dev/null
+++ b/oUF_Reputation/oUF_Reputation.toc
@@ -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