Thread: artifact xp bar
View Single Post
09-02-16, 11:14 AM   #21
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
The derArtifactBar itself isn't recreated constantly, but a dynamic container frame with just a FontString on it. This creates one FontString attached directly to derArtifactBar. I also made a few optimizations.

Lua Code:
  1. local AXP_COLOR = { r = 0.6, g = 0.2, b = 0.1 }
  2.  
  3. local derArtifactBar = CreateFrame("Statusbar", "derArtifactBar",artifactFrame)
  4. derArtifactBar:SetPoint("CENTER", 0, 0)
  5. derArtifactBar:SetHeight(18)
  6. derArtifactBar:SetWidth(artifactFrame:GetWidth() * .968)
  7. derArtifactBar:SetStatusBarTexture("Interface\\AddOns\\_Deranjata\\media\\cast\\Waterline")
  8. derArtifactBar:SetStatusBarColor(AXP_COLOR.r, AXP_COLOR.g, AXP_COLOR.b, 0.5)
  9. derArtifactBar:SetBackdrop({
  10.     bgFile =  "Interface\\AddOns\\_Deranjata\\media\\cast\\Lines",
  11.     insets = { left = 1, right = 1, top = 1, bottom = 1 }
  12. })
  13. derArtifactBar:SetBackdropColor(0.1, 0.1, 0.1)
  14. derArtifactBar:SetBackdropBorderColor(0.6, 0.6, 0.6)
  15.  
  16. derArtifactBar.Text=derArtifactBar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  17. derArtifactBar.Text:SetPoint("CENTER")     
  18.  
  19. derArtifactBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  20. derArtifactBar:RegisterEvent("ARTIFACT_XP_UPDATE")
  21. derArtifactBar:RegisterEvent("UNIT_INVENTORY_CHANGED")
  22. derArtifactBar:SetScript("OnEvent", function(self, event, ...)
  23.     if not HasArtifactEquipped() then self:Hide() return end
  24.     self:Show()
  25.  
  26.     local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  27.     local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP)
  28.     self:SetMinMaxValues(0,xpForNextPoint)
  29.     self:SetValue(artifactXP)
  30.  
  31.     self.Text:SetFormattedText("Artifact XP: %d / %d ",artifactXP,xpForNextPoint)
  32. end)
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote