View Single Post
11-10-14, 12:27 PM   #12
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
I've changed it a little so it works without your UI and both bars show up like they should.

Lua Code:
  1. local Experience = CreateFrame("Frame", nil, UIParent)
  2.  
  3. local ExperienceBar = CreateFrame('StatusBar', nil, UIParent)
  4. local ExperienceBarRested = CreateFrame('StatusBar', nil, UIParent)
  5.  
  6. local InvisFrame = CreateFrame("Frame", nil, ExperienceBar)
  7. InvisFrame:SetFrameStrata("HIGH")
  8. InvisFrame:SetFrameLevel(5)
  9. InvisFrame:SetAllPoints()
  10.  
  11. local ExperienceFont = InvisFrame:CreateFontString(nil, 'OVERLAY')  
  12.  
  13. local function UpdateExp()
  14.     local Current, Max = UnitXP("player"), UnitXPMax("player")
  15.     local Rested = GetXPExhaustion()
  16.     local IsRested = GetRestState()
  17.    
  18.     ExperienceBar:SetMinMaxValues(0, Max)
  19.     ExperienceBar:SetValue(Current)
  20.    
  21.     if (IsRested == 1 and Rested) then      
  22.         ExperienceBarRested:SetMinMaxValues(0, Max)
  23.         ExperienceBarRested:SetValue(Rested + Current)
  24.         ExperienceFont:SetText(""..Current.." / "..Max.."("..Rested..")")
  25.     else
  26.         ExperienceBar:SetValue(0)
  27.         ExperienceFont:SetText(""..Current.." / "..Max.."")
  28.     end
  29. end
  30.  
  31. ExperienceBar:SetPoint('CENTER', UIParent,"CENTER")
  32. ExperienceBar:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
  33. ExperienceBar:SetSize(235, 18)
  34. ExperienceBar:SetStatusBarColor(0.6, 0, 0.6)
  35. --[[ExperienceBar:SetBackdrop({
  36.     bgFile = AftermathhUI.media.blank,
  37.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  38.     })
  39. ]]--
  40. --ExperienceBar:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  41.  
  42. --CreateBorderLight(ExperienceBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 3)
  43.  
  44. ExperienceBar:EnableMouse()
  45.    
  46. ExperienceBarRested:SetSize(230, 18)
  47. ExperienceBarRested:SetAlpha(0.5)
  48. ExperienceBarRested:SetParent(ExperienceBar)
  49. ExperienceBarRested:SetAllPoints(ExperienceBar)
  50. ExperienceBarRested:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
  51. ExperienceBarRested:SetStatusBarColor(0, 144/255, 1)
  52.  
  53. ExperienceFont:SetFont("Fonts\\FRIZQT__.TTF", 12)    
  54.  
  55.  
  56. Experience:RegisterEvent("PLAYER_XP_UPDATE")
  57. Experience:RegisterEvent("PLAYER_LEVEL_UP")
  58. Experience:RegisterEvent("UPDATE_EXHAUSTION")
  59. Experience:RegisterEvent("PLAYER_ENTERING_WORLD")
  60. Experience:RegisterEvent("PLAYER_UPDATE_RESTING")
  61.  
  62. Experience:SetScript("OnEvent", UpdateExp)
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote