Quantcast WoWInterface - View Single Post - Azerite bar not showing
View Single Post
09-29-18, 05:31 AM   #14
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 756
Lua Code:
  1. local SCALE         = 1
  2. --local WIDTH           = 348
  3. local WIDTH         = 236
  4. local HEIGHT        = 8
  5. local _, CLASS      = UnitClass('player')
  6. local COLOR         = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[CLASS] or RAID_CLASS_COLORS[CLASS]
  7. local POSITION      = {'CENTER', UIParent, 'CENTER', 0, 17}
  8. local OFFSET        = -13
  9. local TIP           = {'TOPRIGHT', UIParent, -275, -235}
  10. -- local TEXTURE        = [[Interface\AddOns\LynExperience\assets\statusbar]]
  11. local CLASSCOLOR    = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[CLASS] or RAID_CLASS_COLORS[CLASS]
  12.  
  13. f = CreateFrame('Frame', nil, UIParent)
  14. f:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], POSITION[5])
  15. f:SetWidth(WIDTH)
  16. f:SetHeight(HEIGHT)
  17. f:SetScale(SCALE)
  18.  
  19.  
  20. local setBar = function(frame)
  21. --  frame:SetStatusBarTexture(TEXTURE)
  22.     frame:SetWidth(WIDTH)
  23.     frame:SetHeight(HEIGHT)
  24.     frame:SetScale(SCALE)
  25. end
  26.  
  27. local setBackdrop = function(frame)
  28.     frame.bg = CreateFrame('Frame', nil, frame)
  29.     frame.bg:SetBackdrop({
  30.         bgFile = [[Interface/Buttons/WHITE8X8]],
  31.         tiled = false,
  32.         insets = {left = 0, right = 0, top = 0, bottom = 0}
  33.     })
  34.     frame.bg:SetPoint('TOPLEFT', frame, 0, 0)
  35.     frame.bg:SetPoint('BOTTOMRIGHT', frame, 0, 0)
  36.     frame.bg:SetFrameLevel(1)
  37.     frame.bg:SetBackdropColor(0, 0, 0, 0.2)
  38.  
  39.     frame.shadow = CreateFrame('Frame', nil, frame)
  40.     frame.shadow:SetBackdrop({
  41.         bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
  42.         tiled = false,
  43.         insets = {left = 0, right = 0, top = 0, bottom = 0}
  44.     })
  45.     frame.shadow:SetPoint('TOPLEFT', frame, -3, 3)
  46.     frame.shadow:SetPoint('BOTTOMRIGHT', frame, 3, -3)
  47.     frame.shadow:SetFrameLevel(0)
  48.     frame.shadow:SetBackdropColor(0, 0, 0, 0)
  49. end
  50. local azerite = CreateFrame('StatusBar', nil, f, 'AnimatedStatusBarTemplate')
  51. setBar(azerite)
  52. azerite:SetFrameLevel(4)
  53. azerite:SetStatusBarColor(.9, .8, .6)
  54. azerite:SetAnimatedTextureColors(.9, .8, .6)
  55. azerite:SetPoint(POSITION[1], POSITION[2], POSITION[3], POSITION[4], POSITION[5] + OFFSET)
  56. setBackdrop(azerite)
  57.  
  58. local azerite_update = function(self,event)
  59.     local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
  60.     if azeriteItemLocation then
  61.         local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation)
  62.         local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation)
  63.         local xpToNextLevel = totalLevelXP - xp
  64.         if not azerite:IsShown() then
  65.             azerite:Show()
  66.         end
  67.  
  68.         azerite:SetAnimatedValues(xp, 0, totalLevelXP)
  69.     else
  70.         if azerite:IsShown() then
  71.             azerite:Hide()
  72.         end
  73.     end
  74.     if event == 'AZERITE_ITEM_EXPERIENCE_CHANGED' or event == 'PLAYER_ENTERING_WORLD' then
  75.         if not azerite:IsShown() then
  76.             azerite:Show()
  77.         end
  78.     end
  79. end
  80. local showAzeriteTooltip = function(self)
  81.     local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem();
  82.     local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation);
  83.     local azeriteItemName = azeriteItem:GetItemName();
  84.     local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation)
  85.     local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation)
  86.     local xpToNextLevel = totalLevelXP - xp
  87.     GameTooltip:SetOwner(self, 'ANCHOR_NONE')
  88.     GameTooltip:SetPoint(TIP[1], TIP[2], TIP[3], TIP[4], TIP[5])
  89.     GameTooltip:SetText(AZERITE_POWER_TOOLTIP_TITLE:format(currentLevel, xpToNextLevel), HIGHLIGHT_FONT_COLOR:GetRGB());
  90.     GameTooltip:AddLine(AZERITE_POWER_TOOLTIP_BODY:format(azeriteItemName));
  91.  
  92.     GameTooltip:Show()
  93. end
  94. azerite:SetScript('OnEnter', showAzeriteTooltip)
  95. azerite:SetScript('OnLeave', function() GameTooltip:Hide() end)
  96. azerite:SetScript("OnEvent",azerite_update)
  97. azerite:RegisterEvent('AZERITE_ITEM_EXPERIENCE_CHANGED')
  98. azerite:RegisterEvent('PLAYER_ENTERING_WORLD')

Had some time to test it ... for the tooltip you need to create the values in the correct scope.
They're local to your azerite_update function.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote