Thread Tools Display Modes
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,323
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
09-02-16, 11:31 AM   #22
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
All i want to do is update the bar and text when the events happen
__________________
  Reply With Quote
09-02-16, 11:43 AM   #23
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
Originally Posted by SDPhantom View Post
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.
ok i see what you did here you cleaned up the has artifact query, then altered the local bar and local text to be self initiated rather then being"seperate varibles" that cause a "statusbar taint essentially"...

is this correct?

sorry i am self teaching as i go and much of my code is probably this dirty
__________________
  Reply With Quote
09-02-16, 11:59 AM   #24
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
More like you were creating new FontStrings on top of the previous ones each time the function was run and setting the text in them instead of just creating one when you make your bar and change the text in that. The code I posted does the later for you.

As far as cleaning up the event handler, nothing happens if you call frame:Show() on a frame that's already shown. The same could be said for frame:Hide() on a frame that isn't shown. Also, if you're only going to use the return of a function once, there isn't much sense to store it in a local and then use it. You can use function calls and other expressions directly in an if statement.
__________________
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)

Last edited by SDPhantom : 09-02-16 at 12:04 PM.
  Reply With Quote
09-02-16, 12:01 PM   #25
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
Originally Posted by SDPhantom View Post
More like you were creating new FontStrings on top of the previous ones each time the function was run and setting the text in them instead of just creating one when you make your bar and change the text in that. The code I posted does the later for you.
I appreciate the help. Like i said... learning as i go so its a little precarious sometimes. More like smash face on wall difficult but hey whatever
__________________
  Reply With Quote
09-02-16, 12:22 PM   #26
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
Like me sometimes when I run into a lot of Blizzard-induced bugs.
__________________
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

WoWInterface » Developer Discussions » Lua/XML Help » artifact xp bar

Thread Tools
Display Modes

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