Thread Tools Display Modes
11-08-10, 04:19 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
oUF_Experience and oUF_Reputation

In case someone needs some info on how to do it:

Experience bar
lua Code:
  1. [code]
  2.   --create the exp bar
  3.   local createExpBar = function(self)
  4.     local cfg = self.cfg.expbar
  5.     if not cfg.show then return end
  6.    
  7.     local w, h = 360, 5
  8.    
  9.     local f = CreateFrame("StatusBar","oUF_DiabloExpBar",self)
  10.     f:SetFrameStrata("LOW")
  11.     f:SetFrameLevel(5)
  12.     f:SetSize(w,h)
  13.     f:SetPoint(cfg.pos.a1, cfg.pos.af, cfg.pos.a2, cfg.pos.x, cfg.pos.y)
  14.     f:SetScale(cfg.scale)
  15.     f:SetStatusBarTexture(cfg.texture)
  16.     f:SetStatusBarColor(0.7,0,0.8)
  17.    
  18.     local r = CreateFrame("StatusBar",nil,f)
  19.     r:SetAllPoints(f)
  20.     r:SetStatusBarTexture(cfg.texture)
  21.     r:SetStatusBarColor(1,0.8,0.1,0.6)
  22.    
  23.     func.applyDragFunctionality(f)
  24.    
  25.     local t = r:CreateTexture(nil,"BACKGROUND",nil,-8)
  26.     t:SetAllPoints(r)
  27.     t:SetTexture(cfg.texture)
  28.     t:SetVertexColor(0.7,0,0.8,0.3)
  29.     f.bg = t
  30.  
  31.     f:SetScript("OnEnter", function(s)
  32.       mxp = UnitXPMax("player")
  33.       xp = UnitXP("player")
  34.       rxp = GetXPExhaustion()    
  35.       GameTooltip:SetOwner(s, "ANCHOR_TOP")
  36.       GameTooltip:AddLine("Experience / Rested", 0, 1, 0.5, 1, 1, 1)
  37.       if UnitLevel("player") ~= MAX_PLAYER_LEVEL then
  38.         GameTooltip:AddDoubleLine(COMBAT_XP_GAIN, xp.."/"..mxp.." ("..floor((xp/mxp)*1000)/10 .."%)",0.7,0,0.8,1,1,1)
  39.         if rxp then
  40.           GameTooltip:AddDoubleLine(TUTORIAL_TITLE26, rxp .." (".. floor((rxp/mxp)*1000)/10 .."%)", 1,0.8,0.1,1,1,1)
  41.         end
  42.       end        
  43.       GameTooltip:Show()    
  44.     end)
  45.     f:SetScript("OnLeave", function(s) GameTooltip:Hide() end)
  46.    
  47.     self.Experience = f
  48.     self.Experience.Rested = r
  49.    
  50.   end
  51. [/code]

Reputation bar:
lua Code:
  1. [code]  
  2.   --create the reputation bar
  3.   local createRepBar = function(self)
  4.     local cfg = self.cfg.repbar
  5.     if not cfg.show then return end
  6.    
  7.     local w, h = 360, 5
  8.    
  9.     local f = CreateFrame("StatusBar","oUF_DiabloRepBar",self)
  10.     f:SetFrameStrata("LOW")
  11.     f:SetFrameLevel(5)
  12.     f:SetSize(w,h)
  13.     f:SetPoint(cfg.pos.a1, cfg.pos.af, cfg.pos.a2, cfg.pos.x, cfg.pos.y)
  14.     f:SetScale(cfg.scale)
  15.     f:SetStatusBarTexture(cfg.texture)
  16.     f:SetStatusBarColor(0,0.7,0)
  17.    
  18.     func.applyDragFunctionality(f)
  19.    
  20.     local t = f:CreateTexture(nil,"BACKGROUND",nil,-8)
  21.     t:SetAllPoints(f)
  22.     t:SetTexture(cfg.texture)
  23.     t:SetVertexColor(0,0.7,0)
  24.     t:SetAlpha(0.3)
  25.     f.bg = t
  26.  
  27.     f:SetScript("OnEnter", function(s)
  28.       name, standing, minrep, maxrep, value = GetWatchedFactionInfo()
  29.       GameTooltip:SetOwner(s, "ANCHOR_TOP")
  30.       GameTooltip:AddLine("Reputation", 0, 1, 0.5, 1, 1, 1)
  31.       if name then
  32.         GameTooltip:AddDoubleLine(FACTION, name, FACTION_BAR_COLORS[standing].r, FACTION_BAR_COLORS[standing].g, FACTION_BAR_COLORS[standing].b,1,1,1)
  33.         GameTooltip:AddDoubleLine(STANDING, _G["FACTION_STANDING_LABEL"..standing], FACTION_BAR_COLORS[standing].r, FACTION_BAR_COLORS[standing].g, FACTION_BAR_COLORS[standing].b,1,1,1)
  34.         GameTooltip:AddDoubleLine(REPUTATION, value-minrep .."/"..maxrep-minrep.." ("..floor((value-minrep)/(maxrep-minrep)*1000)/10 .."%)", FACTION_BAR_COLORS[standing].r, FACTION_BAR_COLORS[standing].g, FACTION_BAR_COLORS[standing].b,1,1,1)
  35.       end    
  36.       GameTooltip:Show()    
  37.     end)
  38.     f:SetScript("OnLeave", function(s) GameTooltip:Hide() end)
  39.    
  40.     self.Reputation = f
  41.    
  42.   end
  43. [/code]
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-08-10 at 04:21 PM.
  Reply With Quote
11-08-10, 05:22 PM   #2
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
I have implemented oUF_Experience not Reputation, but thanks for the info.

I can leave mine here too, don't think it will be too different:

lua Code:
  1. -- oUF_Experience
  2.     local function ExperienceBar(self, unit)
  3.    
  4.         if(IsAddOnLoaded('oUF_Experience')) then
  5.            
  6.             local Experience = CreateFrame('StatusBar', nil, self)
  7.             Experience:SetStatusBarTexture(fill_texture)
  8.             Experience:SetStatusBarColor(178/255, 53/255, 240/255,1)
  9.             Experience:SetPoint('BOTTOM', self.InfoBar,'TOP', 0, 6)
  10.             Experience:SetHeight(cfg.expbar_height)
  11.             Experience:SetWidth(cfg.mainframe_width)
  12.                    
  13.             local Rested = CreateFrame('StatusBar', nil, Experience)
  14.             Rested:SetStatusBarTexture(fill_texture)
  15.             Rested:SetStatusBarColor(35/255, 127/255, 255/255,1)
  16.             Rested:SetAllPoints(Experience)
  17.             if(UnitLevel('player') < MAX_PLAYER_LEVEL) then SetBackdrop(Rested, 2, 2, 2, 2) end -- Avoids Backdrop being displayed when in Vehicles (Bug with oUF_Experience?)
  18.            
  19.             self.Experience = Experience
  20.             self.Experience.Rested = Rested
  21.             self.Experience.PostUpdate = ExperiencePostUpdate
  22.                
  23.             -- Tooltip
  24.             self.Experience:EnableMouse()
  25.             self.Experience:HookScript('OnLeave', GameTooltip_Hide)
  26.             self.Experience:HookScript('OnEnter', XPTooltip)           
  27.         end
  28.     end

lua Code:
  1. -- Experience Bar Post Update
  2.     local ExperiencePostUpdate = function (Experience, unit, min, max)
  3.    
  4.         local exhaustion = GetXPExhaustion()
  5.         if(Experience.Rested) then
  6.             Experience.exhaustion = exhaustion
  7.         end
  8.     end
  9.            
  10.     -- Get Unit Experience
  11.     local function xp(unit)
  12.    
  13.         if(unit == 'pet') then
  14.             return GetPetExperience()
  15.         else
  16.             return UnitXP(unit), UnitXPMax(unit)
  17.         end
  18.     end
  19.    
  20.     -- Game Tooltip for oUF_Experience
  21.     local function XPTooltip(self)
  22.    
  23.         local unit = self.__owner.unit
  24.         local min, max = xp(unit)
  25.  
  26.         GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT', 5, -5)
  27.         GameTooltip:AddLine(format('|cffb235f0XP: %d / %d (%d%%)', min, max, min / max * 100))
  28.  
  29.         if(self.exhaustion) then
  30.             GameTooltip:AddLine(format('|cff1369caRested: %d (%d%%)', self.exhaustion, self.exhaustion / max * 100))
  31.         end
  32.         GameTooltip:Show()
  33.     end
__________________
My oUF Layout: oUF Lumen
  Reply With Quote
11-09-10, 03:14 AM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
here is my exp layout, i dont think it works with the newest once.

lua Code:
  1. if(IsAddOnLoaded('oUF_Experience')) then
  2.             self.Experience = CreateFrame('StatusBar', nil, self)
  3.             self.Experience:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -13)
  4.             self.Experience:SetStatusBarTexture(texture)
  5.             self.Experience:SetStatusBarColor(0,.7,1)
  6.             self.Experience:SetHeight(15)
  7.             self.Experience:SetWidth((unit == 'pet') and 150 or width)
  8.             self.Experience:SetBackdrop(backdrop)
  9.             self.Experience:SetBackdropColor(0, 0, 0, .5)
  10.             self.Experience.Tooltip = true
  11.  
  12.             CreateBorder(self.Experience, 12, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3)
  13.  
  14.             self.Experience.Text = self.Experience:CreateFontString(nil, 'OVERLAY')
  15.             self.Experience.Text:SetFont(font, fontsize, 'OUTLINE')
  16.             self.Experience.Text:SetPoint('CENTER', self.Experience)
  17.             self.Experience.bg = self.Experience:CreateTexture(nil, 'BORDER')
  18.             self.Experience.bg:SetAllPoints(self.Experience)
  19.             self.Experience.bg:SetTexture(0, 0, 0, .5)
  20.         end
  Reply With Quote
11-09-10, 09:49 AM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
I have wikis with examples out already.

https://github.com/p3lim/oUF_Experience/wiki
https://github.com/p3lim/oUF_Reputation/wiki
  Reply With Quote
11-16-10, 11:01 AM   #5
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
p3lim, you might consider adding your github link to your signature, for obvious reasons.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-16-10, 11:15 AM   #6
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
The Result of implementing oUF_Experience and Reputation:



Added the tooltips for extra bling.
__________________
My oUF Layout: oUF Lumen
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF_Experience and oUF_Reputation


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off