Quantcast

Initial commit

p3lim-52096 [08-27-08 - 15:58]
Initial commit

git-svn-id: svn://svn.wowinterface.com/oUF_Experience-227/trunk@3 f81be506-7a38-4956-9b9f-d707db2888a5
Filename
oUF_Experience/oUF_Experience.lua
oUF_Experience/oUF_Experience.toc
diff --git a/oUF_Experience/oUF_Experience.lua b/oUF_Experience/oUF_Experience.lua
new file mode 100644
index 0000000..0ed1741
--- /dev/null
+++ b/oUF_Experience/oUF_Experience.lua
@@ -0,0 +1,36 @@
+local function UpdateElement(self, bar)
+	if(UnitLevel('player') < 70) then
+		local min, max = UnitXP('player'), UnitXPMax('player')
+
+		bar:SetMinMaxValues(0, max)
+		bar:SetValue(min)
+
+		if(bar.text) then
+			bar.text:SetFormattedText('%s / %s', min, max)
+		end
+	else
+		bar:Hide()
+		self:UnregisterEvent('PLAYER_XP_UPDATE')
+		self:UnregisterEvent('PLAYER_LEVEL_UP')
+		self:UnregisterEvent('UPDATE_EXHAUSTION')
+	end
+end
+
+function oUF:PLAYER_XP_UPDATE()
+	if(self.Experience) then
+		UpdateElement(self, self.Experience)
+	end
+end
+
+oUF:RegisterInitCallback(function(self)
+	if(self.Experience) then
+		self:RegisterEvent('PLAYER_XP_UPDATE')
+		self:RegisterEvent('PLAYER_LEVEL_UP')
+		self:RegisterEvent('UPDATE_EXHAUSTION')
+
+		self.PLAYER_LEVEL_UP = self.PLAYER_XP_UPDATE
+		self.UPDATE_EXHAUSTION = self.PLAYER_XP_UPDATE
+		-- force update at load
+		UpdateElement(self, self.Experience)
+	end
+end)
\ No newline at end of file
diff --git a/oUF_Experience/oUF_Experience.toc b/oUF_Experience/oUF_Experience.toc
new file mode 100644
index 0000000..cdea127
--- /dev/null
+++ b/oUF_Experience/oUF_Experience.toc
@@ -0,0 +1,8 @@
+## Interface: 20400
+## Author: p3lim
+## Version: Revision wowi:revision
+## Title: oUF Experience
+## Notes: Experience Bar support for oUF layouts.
+## RequiredDeps: oUF
+
+oUF_Experience.lua