Thread Tools Display Modes
07-31-16, 09:48 PM   #1
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
Stand Alone Artifact Bar

hey has anyone figure out how to do a stand alone artifact bar yet, im trying but getting absolutely nowhere, so bad i just cntr+a ---> delete the code i was working on, i really dont know how the hell its working at all


would like it to be similar to my XP bar/rep bar and only toggle on once i am at the level necessary to use artifact power


here is the code to my XP bar to give an idea
however it would be tied to an identical frame on the other side of the screen

Lua Code:
  1. --[[  Player xp bar  ]]--
  2.  
  3. local XP_COLOR   = { r = 0.6, g = 0,   b = 0.5 }
  4. local REST_COLOR = { r = 0.2, g = 0.2, b = 0.8 }
  5.  
  6. ------------------------------------------------------------------------
  7. -- Object creation
  8.  
  9. local f = CreateFrame("Frame", "derXPBar", XPFrame)
  10. f:SetPoint("CENTER", 0, 0)
  11. f:SetHeight(17)
  12. f:SetWidth(XPFrame:GetWidth() * .968)
  13.  
  14.  
  15. f:SetBackdrop({
  16.     bgFile =  "Interface\\AddOns\\_Deranjata\\media\\cast\\Lines",
  17. --  edgeFile = "Interface\\BUTTONS\\WHITE8X8", edgeSize = 1,
  18.     insets = { left = 1, right = 1, top = 1, bottom = 1 }
  19. })
  20.  
  21. f:SetBackdropColor(0.1, 0.1, 0.1)
  22. f:SetBackdropBorderColor(0.6, 0.6, 0.6)
  23.  
  24. local restBar = CreateFrame("StatusBar", nil, f)
  25. restBar:SetPoint("BOTTOMLEFT", 1, 1)
  26. restBar:SetPoint("TOPRIGHT", -1, -1)
  27. restBar:SetStatusBarTexture("Interface\\AddOns\\_Deranjata\\media\\cast\\Waterline")
  28. restBar:SetStatusBarColor(REST_COLOR.r, REST_COLOR.g, REST_COLOR.b, 0.5)
  29.  
  30. local bar = CreateFrame("StatusBar", nil, restBar)
  31. bar:SetAllPoints(true)
  32. bar:SetStatusBarTexture("Interface\\AddOns\\_Deranjata\\media\\cast\\Waterline")
  33.  
  34. local text = bar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  35. text:SetPoint("CENTER")
  36.  
  37. ------------------------------------------------------------------------
  38. -- Display logic
  39.  
  40. local mode = "XP"
  41.  
  42. function f:Update(event, arg1)
  43.     if event == "PET_BATTLE_OPENING_START" or C_PetBattles.IsInBattle() then
  44.         return f:Hide()
  45.         else f:Show()
  46.     end
  47.  
  48.     local level = event == "PLAYER_LEVEL_UP" and arg1 or UnitLevel("player")
  49.     if level == MAX_PLAYER_LEVEL or mode == "REP" then
  50.         local name, standing, min, max, rep = GetWatchedFactionInfo()
  51.         if name then
  52.             text:SetFormattedText("%s: %d / %d %s", name, max - rep, max - min, UnitSex("player") == 3 and _G["FACTION_STANDING_LABEL"..standing.."_FEMALE"] or  _G["FACTION_STANDING_LABEL"..standing])
  53.  
  54.             bar:SetMinMaxValues(min, max)
  55.             bar:SetValue(rep)
  56.  
  57.             local color = FACTION_BAR_COLORS[standing]
  58.             bar:SetStatusBarColor(color.r, color.g, color.b)
  59.  
  60.             restBar:SetMinMaxValues(0, 1)
  61.             restBar:SetValue(0)
  62.  
  63.             return
  64.         end
  65.     end
  66.  
  67.     local xp, max, rest = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion()
  68.     text:SetFormattedText("Level %d XP: %d / %d", level, xp, max)
  69.  
  70.     bar:SetMinMaxValues(0, max)
  71.     bar:SetValue(xp)
  72.  
  73.     if rest then
  74.         bar:SetStatusBarColor(REST_COLOR.r, REST_COLOR.g, REST_COLOR.b)
  75.         restBar:SetMinMaxValues(0, max)
  76.         restBar:SetValue( (xp + rest > max) and max or (xp + rest) )
  77.     else
  78.         bar:SetStatusBarColor(XP_COLOR.r, XP_COLOR.g, XP_COLOR.b)
  79.         restBar:SetMinMaxValues(0, 1)
  80.         restBar:SetValue(0)
  81.     end
  82. end
  83.  
  84. ------------------------------------------------------------------------
  85. -- Update on events
  86.  
  87. f:RegisterEvent("PET_BATTLE_OPENING_START")
  88. f:RegisterEvent("PET_BATTLE_CLOSE")
  89. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  90. f:RegisterEvent("PLAYER_LEVEL_UP")
  91. f:RegisterEvent("PLAYER_XP_UPDATE")
  92. f:RegisterEvent("UPDATE_EXHAUSTION")
  93. f:RegisterEvent("UPDATE_FACTION")
  94.  
  95. f:SetScript("OnEvent", f.Update)
  96. hooksecurefunc("SetWatchedFactionIndex", f.Update)
  97.  
  98. ------------------------------------------------------------------------
  99. -- Toggle mode on click
  100.  
  101. f:EnableMouse(true)
  102. f:SetScript("OnMouseUp", function(self, button)
  103.     if button == "RightButton" and IsShiftKeyDown() then
  104.         mode = mode == "XP" and "REP" or "XP"
  105.     end
  106.     self:Update()
  107. end)
  108.  
  109.  
  110.  
  111.  
  112.  
  113. --Here We have the Artifact Frame
__________________
  Reply With Quote
08-01-16, 12:23 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
For mine is just a frame with a texture and a FontString using SetTexCoords etc in the SetValue function but the essential plumbing is (Texture or StatusBar):

Lua Code:
  1. ab:RegisterEvent("PLAYER_ENTERING_WORLD")
  2. ab:RegisterEvent("ARTIFACT_XP_UPDATE")
  3. ab:RegisterEvent("UNIT_INVENTORY_CHANGED")
  4. ab:SetScript("OnEvent", function(self, event, ...)
  5.         local showArtifact = HasArtifactEquipped()
  6.         if not showArtifact then
  7.             if self:IsShown() then
  8.                 self:Hide()
  9.             end
  10.             return
  11.         end
  12.         if not self:IsShown() then
  13.             self:Show()
  14.         end
  15.         local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  16.         local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP)
  17.         SetValue(self, artifactXP/xpForNextPoint)
  18.     end)

My text is a simple percentage of progression so the artifactXP/xpForNextPoint works for bar progress and text.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-01-16 at 12:55 AM.
  Reply With Quote
08-01-16, 11:03 AM   #3
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
Originally Posted by Fizzlemizz View Post
For mine is just a frame with a texture and a FontString using SetTexCoords etc in the SetValue function but the essential plumbing is (Texture or StatusBar):


My text is a simple percentage of progression so the artifactXP/xpForNextPoint works for bar progress and text.
so in theory if i had a frame that has a size of x tall and y wide and its name is artifactFrame and i ran this script it should theoretically work?

Lua Code:
  1. --Here We have the Artifact Frame
  2.  
  3.  
  4. local f = CreateFrame("Frame", "derArtifactBar",artifactFrame)
  5. derArtifactBar:SetPoint("CENTER", 0, 0)
  6. derArtifactBar:SetHeight(17)
  7. derArtifactBar:SetWidth(derArtifactBar:GetWidth() * .968)
  8.  
  9.  
  10. derArtifactBar:SetBackdrop({
  11.     bgFile =  "Interface\\AddOns\\_Deranjata\\media\\cast\\Lines",
  12. --  edgeFile = "Interface\\BUTTONS\\WHITE8X8", edgeSize = 1,
  13.     insets = { left = 1, right = 1, top = 1, bottom = 1 }
  14. })
  15. derArtifactBar:SetBackdropColor(0.1, 0.1, 0.1)
  16. derArtifactBar:SetBackdropBorderColor(0.6, 0.6, 0.6)
  17.  
  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.         local showArtifact = HasArtifactEquipped()
  24.         if not showArtifact then
  25.             if self:IsShown() then
  26.                 self:Hide()
  27.             end
  28.             return
  29.         end
  30.         if not self:IsShown() then
  31.             self:Show()
  32.         end
  33.         local itemID, altItemID, name, icon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  34.         local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP)
  35.         SetValue(self, artifactXP/xpForNextPoint)
  36.     end)
__________________
  Reply With Quote
08-01-16, 11:22 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
The actual setting of the display size is handled in SetValue. My bar is a globe/flask that fills bottom to top and I don't show any text if the value is zero.

Size is the width/height of my bar.

Lua Code:
  1. local size = 33
  2. local function SetValue(self, value)
  3.     local bv = value
  4.     if value == 0 then bv = .01 end
  5.     local yos = 1-bv
  6.     if bv > 1 then bv = 1 end
  7.     self.Fill:SetHeight(size * bv)
  8.     self.Fill:SetTexCoord(0, 1, yos, 1)
  9.     if value == 0 then
  10.         self.Text:SetText("")
  11.     else
  12.         self.Text:SetText(floor(value*100).."%")
  13.     end
  14. end

You could use the same to set the value for a statusbar.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-01-16 at 11:28 AM.
  Reply With Quote
08-01-16, 01:16 PM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Here is what i've made
Lua Code:
  1. local AArtifactPowerBar = CreateFrame('StatusBar', "AArtifactPowerBar", UIParent)
  2. AArtifactPowerBar:SetFrameLevel(5)
  3. AArtifactPowerBar:SetPoint('LEFT', oUF_AftermathhPlayer, 223, -180)
  4. AArtifactPowerBar:SetStatusBarTexture(AftermathhUI.media.texture)
  5. AArtifactPowerBar:SetSize(235, 20)
  6. AArtifactPowerBar:SetStatusBarColor(157/255, 138/255, 108/255)
  7. AArtifactPowerBar:SetBackdrop({
  8.     bgFile = "Interface\\Buttons\\WHITE8x8",
  9.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  10.     })
  11. AArtifactPowerBar:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  12.  
  13. CreateBorderLight(AArtifactPowerBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 3)
  14.  
  15. local InvisFrame = CreateFrame("Frame", nil, AArtifactPowerBar)
  16. InvisFrame:SetFrameStrata("HIGH")
  17. InvisFrame:SetFrameLevel(5)
  18. InvisFrame:SetAllPoints()
  19.  
  20. local AArtifactPowerBarFont = InvisFrame:CreateFontString(nil, 'OVERLAY')  
  21. AArtifactPowerBarFont:SetPoint('CENTER', AArtifactPowerBar)
  22. AArtifactPowerBarFont:SetFont(AftermathhUI.media.font, 12, AftermathhUI.media.fontflag)    
  23. AArtifactPowerBarFont:SetShadowOffset(1, -1)
  24. AArtifactPowerBarFont:SetShadowColor(0,0,0)
  25.  
  26. local function ArtifactPowerBar()
  27.     local hAE = HasArtifactEquipped()
  28.  
  29.     if hAE then
  30.         local _, _, _, _, totalxp, pointsSpent, _, _, _, _, _, _ = C_ArtifactUI.GetEquippedArtifactInfo()
  31.         local _, xp, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalxp)
  32.  
  33.         AArtifactPowerBar:SetMinMaxValues(min(0, xp), xpForNextPoint)
  34.         AArtifactPowerBar:SetValue(xp)
  35.         AArtifactPowerBarFont:SetText(""..xp.." / "..xpForNextPoint.." ("..xpForNextPoint - xp..")")
  36.     elseif not hAE then
  37.         AArtifactPowerBar:Hide()
  38.     end
  39.    
  40.     AArtifactPowerBar:SetScript("OnEnter", function()
  41.         GameTooltip:SetOwner(AArtifactPowerBar, "ANCHOR_CURSOR")
  42.         GameTooltip:ClearLines()
  43.         if hAE then
  44.             local _, _, _, _, totalxp, pointsSpent, _, _, _, _, _, _ = C_ArtifactUI.GetEquippedArtifactInfo()
  45.             local numPointsAvailableToSpend, xp, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalxp)
  46.            
  47.             GameTooltip:AddLine("|cffffd200Artifact Power|r")
  48.             GameTooltip:AddDoubleLine("Current Artifact Power", xp, 1, 1, 1, 1, 1, 1)
  49.             GameTooltip:AddDoubleLine("Remaining Artifact Power To Next Level", xpForNextPoint - xp, 1, 1, 1, 1, 1, 1)
  50.             GameTooltip:AddDoubleLine("Artifact Power Points To Spend", numPointsAvailableToSpend, xpForNextPoint, 1, 1, 1, 1, 1, 1)
  51.         end
  52.         GameTooltip:Show()
  53.     end)
  54.     AArtifactPowerBar:SetScript("OnLeave", function() GameTooltip:Hide() end)
  55. end
  56.  
  57. AArtifactPowerBar:RegisterEvent("ARTIFACT_XP_UPDATE")
  58. AArtifactPowerBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  59. AArtifactPowerBar:RegisterEvent("UNIT_INVENTORY_CHANGED")
  60. AArtifactPowerBar:SetScript("OnEvent", ArtifactPowerBar)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Stand Alone Artifact Bar


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