Advertisement
Guest User

bXP

a guest
Nov 6th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. media = {
  2. flat = "Interface\\Buttons\\WHITE8x8",
  3. font = "Interface\\Addons\\bXP\\font.ttf"
  4. }
  5. config = {
  6. enable = 1,
  7. spawn = {"BOTTOM", UIParent, "BOTTOM", 0, 100},
  8. width = 378,
  9. height = 5,
  10. color = {.4, .1, 0.6, 1},
  11. restedcolor = {.2, .4, 0.8, 1}
  12. }
  13. local bar = CreateFrame("frame", "bXP", UIParent)
  14. bar:SetPoint(unpack(config.spawn))
  15. bar:SetFrameStrata("LOW")
  16. bar:SetWidth(config.width)
  17. bar:SetHeight(config.height)
  18. bar:SetBackdrop({bgFile = media.flat, insets = {top = -2, left = -2, bottom = -2, right = -2}})
  19. bar:SetBackdropColor(0,0,0,1)
  20. bar:Hide()
  21.  
  22. xpbar = CreateFrame('StatusBar', nil, bar)
  23. xpbar:SetAllPoints(bar)
  24. xpbar:SetStatusBarTexture(media.flat)
  25. xpbar:SetWidth(config.width)
  26. xpbar:SetHeight(config.height)
  27. xpbar:SetValue(0)
  28.  
  29. rxpbar = CreateFrame('StatusBar', nil, bar)
  30. rxpbar:SetAllPoints(bar)
  31. rxpbar:SetStatusBarTexture(media.flat)
  32. rxpbar:SetWidth(config.width)
  33. rxpbar:SetHeight(config.height)
  34. rxpbar:SetValue(0)
  35. rxpbar:SetStatusBarColor(unpack(config.restedcolor))
  36. rxpbar:SetAlpha(0.4)
  37. rxpbar:Hide()
  38.  
  39. bar:SetScript("OnDragStart", function(self) if IsAltKeyDown() then bar:StartMoving() end end)
  40. bar:SetScript("OnDragStop", function(self) bar:StopMovingOrSizing() end)
  41. bar:SetScript("OnEnter", function() xpbar.text:SetAlpha(1) end)
  42. bar:SetScript("OnLeave", function() xpbar.text:SetAlpha(0) end)
  43. bar:SetClampedToScreen(true)
  44. bar:SetMovable(true)
  45. bar:SetUserPlaced(true)
  46. bar:EnableMouse(true)
  47. bar:RegisterForDrag("LeftButton","RightButton")
  48.  
  49. bar.bg = bar:CreateTexture("bg", 'BORDER')
  50. bar.bg:SetAllPoints(bar)
  51. bar.bg:SetTexture(media.flat)
  52. bar.bg:SetVertexColor(0.16,0.16,0.16,1)
  53.  
  54. xpbar.text = xpbar:CreateFontString("XP Text")
  55. xpbar.text:SetPoint("CENTER", bar, 0,0)
  56. xpbar.text:SetFont(media.font, 10, "OUTLINE")
  57. xpbar.text:SetAlpha(0)
  58.  
  59. bar:RegisterEvent("PLAYER_XP_UPDATE")
  60. bar:RegisterEvent("PLAYER_LEVEL_UP")
  61. bar:RegisterEvent("PLAYER_ENTERING_WORLD")
  62. bar:RegisterEvent("UPDATE_EXHAUSTION");
  63. bar:RegisterEvent("UPDATE_FACTION")
  64.  
  65. bar:SetScript("OnEvent", function()
  66. xp = UnitXP("player")
  67. mxp = UnitXPMax("player")
  68. rxp = GetXPExhaustion("player")
  69. name, standing, minrep, maxrep, value = GetWatchedFactionInfo()
  70.  
  71. xpbar:SetMinMaxValues(0,mxp)
  72. if UnitLevel("player") == MAX_PLAYER_LEVEL or IsXPUserDisabled == true then
  73. if name then
  74. xpbar:SetStatusBarColor(FACTION_BAR_COLORS[standing].r, FACTION_BAR_COLORS[standing].g, FACTION_BAR_COLORS[standing].b, 1)
  75. xpbar:SetMinMaxValues(minrep,maxrep)
  76. xpbar:SetValue(value)
  77. xpbar.text:SetText(value-minrep.." / "..maxrep-minrep.." | "..floor(((value-minrep)/(maxrep-minrep))*1000)/10 .."% | ".. name)
  78. bar:Show()
  79. else
  80. bar:Hide()
  81. end
  82. else
  83. xpbar:SetStatusBarColor(unpack(config.color))
  84. xpbar:SetValue(xp)
  85. if rxp then
  86. xpbar.text:SetText(format(xp).." / "..format(mxp).." | "..floor((xp/mxp)*1000)/10 .."%" .. " (+"..format(rxp)..")")
  87. xpbar:SetMinMaxValues(0,mxp)
  88. xpbar:SetStatusBarColor(unpack(config.restedcolor))
  89. xpbar:SetValue(xp)
  90. if (rxp+xp) >= mxp then
  91. rxpbar:SetValue(mxp)
  92. else
  93. rxpbar:SetValue(rxp+xp)
  94. end
  95. rxpbar:Show()
  96. bar:Show()
  97. elseif xp then
  98. xpbar.text:SetText(formatNumber(xp).." / "..formatNumber(mxp).." | "..floor((xp/mxp)*1000)/10 .."%")
  99. rxpbar:Hide()
  100. end
  101. end
  102. end)
  103. bar:SetScript("OnLeave", function() xpbar.text:SetAlpha(0) end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement