Thread Tools Display Modes
06-16-17, 12:32 AM   #1
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
Paladin class bar wont show first login

Hey, everyone. I do not post here very often though I do lurk a lot. As I love seeing what add-ons people are making. I'm going to ask for a bit of help and guidance here so bare with me.

Currently, my paladin class bar (HolyPower) won't show on the first login. If you reload it will show. I will show the code I am using for this and where I am placing the code.

Currently, for the modules for class power, I am using this.

Lua Code:
  1. local K, C, _ = unpack(select(2, ...))
  2. if C.Unitframe.Enable ~= true then return end
  3.  
  4. local _G = _G
  5.  
  6. local UnitExists = _G.UnitExists
  7.  
  8. local CMS = CreateFrame("Frame")
  9.  
  10. -- GLOBALS: oUF_KkthnxPlayer, TotemFrame, RuneFrame, SPEC_MAGE_ARCANE, MageArcaneChargesFrame, SPEC_MONK_BREWMASTER, MonkStaggerBar
  11. -- GLOBALS: SPEC_MONK_WINDWALKER, MonkHarmonyBarFrame, SPEC_PALADIN_RETRIBUTION, PaladinPowerBarFrame, ComboPointPlayerFrame
  12. -- GLOBALS: WarlockPowerFrame, oUF_KkthnxPet
  13.  
  14. local function CustomTotemFrame_Update()
  15.     local hasPet = UnitExists("pet") and oUF_KkthnxPet and oUF_KkthnxPet:IsShown()
  16.  
  17.     if (K.Class == "WARLOCK") then
  18.         if (hasPet) then
  19.             TotemFrame:SetPoint("TOPLEFT", oUF_KkthnxPlayer, "BOTTOMLEFT", 0, -75)
  20.         else
  21.             TotemFrame:SetPoint("TOPLEFT", oUF_KkthnxPlayer, "BOTTOMLEFT", 25, -25)
  22.         end
  23.     end
  24.  
  25.     if (K.Class == "SHAMAN") then
  26.         if (hasPet) then
  27.             TotemFrame:SetPoint("TOPLEFT", oUF_KkthnxPlayer, "BOTTOMLEFT", 0, -75)
  28.         else
  29.             TotemFrame:SetPoint("TOPLEFT", oUF_KkthnxPlayer, "BOTTOMLEFT", 25, -25)
  30.         end
  31.     end
  32.  
  33.     if (K.Class == "PALADIN" or K.Class == "DEATHKNIGHT" or K.Class == "DRUID" or K.Class == "MAGE" or K.Class == "MONK") then
  34.         TotemFrame:SetPoint("TOPLEFT", oUF_KkthnxPlayer, "BOTTOMLEFT", 25, 0)
  35.     end
  36. end
  37. hooksecurefunc("TotemFrame_Update", CustomTotemFrame_Update)
  38.  
  39. function CMS:SetupAlternatePowerBar(self)
  40.     self.AdditionalPower = K.CreateOutsideBar(self, false, 0, 0, 1)
  41.     self.DruidMana = self.AdditionalPower
  42.     self.AdditionalPower.colorPower = true
  43.  
  44.     self.AdditionalPower.Value = K.SetFontString(self.AdditionalPower, C.Media.Font, 10, nil, "CENTER")
  45.     self.AdditionalPower.Value:SetPoint("CENTER", self.AdditionalPower, 0, 0.5)
  46.     self.AdditionalPower.Value:Hide()
  47.  
  48.     self.AdditionalPower.Smooth = C.Unitframe.Smooth
  49.     self.AdditionalPower.SmoothSpeed = C.Unitframe.SmoothSpeed * 10
  50.     self:Tag(self.AdditionalPower.Value, "[KkthnxUI:DruidMana]")
  51. end
  52.  
  53. function CMS:HideAltResources()
  54.     if (K.Class == "SHAMAN") then
  55.         TotemFrame:Hide()
  56.     elseif (K.Class == "DEATHKNIGHT") then
  57.         RuneFrame:Hide()
  58.     elseif (K.Class == "MAGE" and K.Spec == SPEC_MAGE_ARCANE) then
  59.         MageArcaneChargesFrame:Hide()
  60.     elseif (K.Class == "MONK") then
  61.         if (K.Spec == SPEC_MONK_BREWMASTER) then
  62.             MonkStaggerBar:Hide()
  63.         elseif (K.Spec == SPEC_MONK_WINDWALKER) then
  64.             MonkHarmonyBarFrame:Hide()
  65.         end
  66.     elseif (K.Class == "PALADIN" and K.Spec == SPEC_PALADIN_RETRIBUTION) then
  67.         PaladinPowerBarFrame:Hide()
  68.     elseif (K.Class == "ROGUE") then
  69.         ComboPointPlayerFrame:Hide()
  70.     elseif (K.Class == "WARLOCK") then
  71.         WarlockPowerFrame:Hide()
  72.     end
  73. end
  74.  
  75. function CMS:ShowAltResources()
  76.     if (K.Class == "SHAMAN") then
  77.         TotemFrame:Show()
  78.     elseif (K.Class == "DEATHKNIGHT") then
  79.         RuneFrame:Show()
  80.     elseif (K.Class == "MAGE" and K.Spec == SPEC_MAGE_ARCANE) then
  81.         MageArcaneChargesFrame:Show()
  82.     elseif (K.Class == "MONK") then
  83.         if (K.Spec == SPEC_MONK_BREWMASTER) then
  84.             MonkStaggerBar:Show()
  85.         elseif (K.Spec == SPEC_MONK_WINDWALKER) then
  86.             MonkHarmonyBarFrame:Show()
  87.         end
  88.     elseif (K.Class == "PALADIN" and K.Spec == SPEC_PALADIN_RETRIBUTION) then
  89.         PaladinPowerBarFrame:Show()
  90.     elseif (K.Class == "ROGUE") then
  91.         ComboPointPlayerFrame:Show()
  92.     elseif (K.Class == "WARLOCK") then
  93.         WarlockPowerFrame:Show()
  94.     end
  95. end
  96.  
  97. function CMS:SetupResources(self)
  98.     -- Alternate Mana Bar
  99.     if (C.UnitframePlugins.AdditionalPower) and (K.Class == "DRUID" or K.Class == "SHAMAN" or K.Class == "PRIEST") then
  100.         K.CMS:SetupAlternatePowerBar(self)
  101.     end
  102.  
  103.     -- Warlock Soul Shards
  104.     if (K.Class == "WARLOCK") then
  105.         WarlockPowerFrame:ClearAllPoints()
  106.         WarlockPowerFrame:SetParent(oUF_KkthnxPlayer)
  107.         WarlockPowerFrame:SetPoint("TOP", oUF_KkthnxPlayer, "BOTTOM", 30, -2)
  108.     end
  109.  
  110.     -- Holy Power Bar (Retribution Only)
  111.     if (K.Class == "PALADIN" and K.Spec == SPEC_PALADIN_RETRIBUTION) then
  112.         PaladinPowerBarFrame:ClearAllPoints()
  113.         PaladinPowerBarFrame:SetParent(oUF_KkthnxPlayer)
  114.         PaladinPowerBarFrame:SetPoint("TOP", oUF_KkthnxPlayer, "BOTTOM", 25, 2)
  115.     PaladinPowerBarFrame:Show()
  116.     end
  117.  
  118.     -- Monk Chi / Stagger Bar
  119.     if (K.Class == "MONK") then
  120.         -- Windwalker Chi
  121.         MonkHarmonyBarFrame:ClearAllPoints()
  122.         MonkHarmonyBarFrame:SetParent(oUF_KkthnxPlayer)
  123.         MonkHarmonyBarFrame:SetPoint("TOP", oUF_KkthnxPlayer, "BOTTOM", 30, 18)
  124.  
  125.         -- Brewmaster Stagger Bar
  126.         MonkStaggerBar:ClearAllPoints()
  127.         MonkStaggerBar:SetParent(oUF_KkthnxPlayer)
  128.         MonkStaggerBar:SetPoint("TOP", oUF_KkthnxPlayer, "BOTTOM", 30, -2)
  129.     end
  130.  
  131.     -- Deathknight Runebar
  132.     if (K.Class == "DEATHKNIGHT") then
  133.         RuneFrame:ClearAllPoints()
  134.         RuneFrame:SetParent(oUF_KkthnxPlayer)
  135.         RuneFrame:SetPoint("TOP", self.Power, "BOTTOM", 2, -2)
  136.     end
  137.  
  138.     -- Arcane Mage
  139.     if (K.Class == "MAGE") then
  140.         MageArcaneChargesFrame:ClearAllPoints()
  141.         MageArcaneChargesFrame:SetParent(oUF_KkthnxPlayer)
  142.         MageArcaneChargesFrame:SetPoint("TOP", oUF_KkthnxPlayer, "BOTTOM", 30, -2)
  143.     end
  144.  
  145.     -- Combo Point Frame
  146.     if (K.Class == "ROGUE" or K.Class == "DRUID") then
  147.         ComboPointPlayerFrame:ClearAllPoints()
  148.         ComboPointPlayerFrame:SetParent(oUF_KkthnxPlayer)
  149.         ComboPointPlayerFrame:SetPoint("TOPLEFT", self.Power, "BOTTOMLEFT", -3, 2)
  150.     end
  151.  
  152.     -- Finish TotemFrame
  153.     if (K.Class == "SHAMAN" or K.Class == "WARLOCK" or K.Class == "DRUID" or K.Class == "PALADIN" or K.Class == "DEATHKNIGHT" or K.Class == "MAGE" or K.Class == "MONK") then
  154.         TotemFrame:SetFrameStrata("LOW")
  155.         TotemFrame:SetParent(oUF_KkthnxPlayer)
  156.         CustomTotemFrame_Update()
  157.     end
  158.     -- Register the event!
  159.     self:RegisterEvent("PLAYER_TOTEM_UPDATE", CustomTotemFrame_Update)
  160. end
  161.  
  162. K.CMS = CMS

Now I have to spawn this all in my unit frame code which is very long. I'm going to just place it in a gist if you all do not mind.

https://gist.github.com/Kkthnx/4b1e3...5764bfd7aa9220

Idk why it will not spawn on the first login. Any advice would help. Thank you kindly.

Oh here is where I place the code.
https://gist.github.com/Kkthnx/4b1e3...rames-lua-L239
https://gist.github.com/Kkthnx/4b1e3...rames-lua-L252
https://gist.github.com/Kkthnx/4b1e3...rames-lua-L600
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.

Last edited by Kkthnx : 06-16-17 at 12:51 PM.
  Reply With Quote
06-16-17, 12:20 PM   #2
briskman3000
A Flamescale Wyrmkin
 
briskman3000's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 108
Maybe I'm missing it, but I don't see a register to PLAYER_LOGIN or PLAYER_ENTERING_WORLD, either of which would spawn the frame on first login
__________________
My Addons: Convert Ratings Honor Track
  Reply With Quote
06-16-17, 12:40 PM   #3
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
Originally Posted by briskman3000 View Post
Maybe I'm missing it, but I don't see a register to PLAYER_LOGIN or PLAYER_ENTERING_WORLD, either of which would spawn the frame on first login
Doesn't change it. I just tried that and it still won't spawn per first login.
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.
  Reply With Quote
06-16-17, 09:44 PM   #4
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
Alright so after some testing. It seems like
Lua Code:
  1. GetSpecialization()
isn't always available at first login. After a reload it is fine. Is there any way around this?
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.
  Reply With Quote
06-16-17, 09:57 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Register the PLAYER_SPECIALIZATION_CHANGED event.

Where are you using GetSpecialization()? It's not in the code shown.

PLAYER_SPECIALIZATION_CHANGED fires before PLAYER_LOGIN so GetSpecialization() should be usable by then even on a cold login.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-16-17 at 10:19 PM.
  Reply With Quote
06-16-17, 10:19 PM   #6
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
Originally Posted by Fizzlemizz View Post
Register the PLAYER_SPECIALIZATION_CHANGED event.
I can see needing this for when changing specs though really wasn't an issue though it could help later on. As for my current issue which still stands. It seems like

Lua Code:
  1. GetSpecialization()

returns nil on the first login. So when I am checking in my code for

Lua Code:
  1. elseif (K.Class == "PALADIN" and K.Spec == SPEC_PALADIN_RETRIBUTION) then

K.Spec being GetSpecialization() it won't work first login. Preventing the HolyPowerBar from appearing until the player manually /reload their UI and it will work fine from then on out.

I run it out of my Init.lua file.
Lua Code:
  1. AddOn.Spec = GetSpecialization() or 0

Going further into this. If I comment the code out checking for the spec. It works first login. So this is why I feel like Its not there on a first login.
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.

Last edited by Kkthnx : 06-16-17 at 10:22 PM.
  Reply With Quote
06-16-17, 10:28 PM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
I don't see where
Code:
AddOn.Spec = GetSpecialization() or 0
is being called.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
06-16-17, 11:01 PM   #8
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
Originally Posted by Fizzlemizz View Post
I don't see where
Code:
AddOn.Spec = GetSpecialization() or 0
is being called.
Init.lua file
Lua Code:
  1. local AddOnName, Engine = ...
  2.  
  3. --[[
  4. -- NOTE: KkthnxUI uses "#4488ff color RGB value is (68, 136, 255)" for its primary color
  5. -- NOTE: KkthnxUI uses "#ffbb44 color RGB value is (255, 187, 68)" for its secondary color
  6.  
  7. -- NOTE: Uncomment this to see the primary color
  8. print("|cff4488ff#4488ff color|r")
  9. -- NOTE: Uncomment this to see the secondary color
  10. print("|cffffbb44#ffbb44 color|r")
  11. ]]--
  12.  
  13. -- Lua API
  14. local _G = _G
  15. local string_lower = string.lower
  16. local select = select
  17.  
  18. -- Wow API
  19. local GetAddOnEnableState = _G.GetAddOnEnableState
  20. local GetAddOnInfo = _G.GetAddOnInfo
  21. local GetBuildInfo = _G.GetBuildInfo
  22. local GetSpecialization = _G.GetSpecialization
  23. local UnitClass = _G.UnitClass
  24. local UnitName = _G.UnitName
  25. local UnitLevel = _G.UnitLevel
  26.  
  27. local AddOn = LibStub("AceAddon-3.0"):NewAddon(AddOnName, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0")
  28. local Locale = LibStub("AceLocale-3.0"):GetLocale(AddOnName, false)
  29.  
  30. Engine[1] = AddOn
  31. Engine[2] = {}
  32. Engine[3] = Locale
  33.  
  34. _G[AddOnName] = Engine -- Allow other addons to use our Engine
  35.  
  36. -- Check role to return what role the player is.
  37. function AddOn:UnitRole()
  38.     local playerSpec = GetSpecialization()
  39.     local playerClass = select(2, UnitClass("player"))
  40.     local playerLevel = UnitLevel("player")
  41.  
  42.     if (not playerSpec or playerLevel > 10) then return end
  43.  
  44.     local playerRoles = {
  45.         ["DEATHKNIGHT"] = {"Tank", "Melee", "Melee"},
  46.         ["DEMONHUNTER"] = {"Melee", "Tank"},
  47.         ["DRUID"] = {"Caster", "Melee", "Tank", "Healer"},
  48.         ["HUNTER"] = {"Melee", "Melee", "Melee"},
  49.         ["MAGE"] = {"Caster", "Caster", "Caster"},
  50.         ["MONK"] = {"Tank", "Healer", "Melee"},
  51.         ["PALADIN"] = {"Healer", "Tank", "Melee"},
  52.         ["PRIEST"] = {"Healer", "Healer", "Caster"},
  53.         ["ROGUE"] = {"Melee", "Melee", "Melee"},
  54.         ["SHAMAN"] = {"Caster", "Melee", "Healer"},
  55.         ["WARLOCK"] = {"Caster", "Caster", "Caster"},
  56.         ["WARRIOR"] = {"Melee", "Melee", "Tank"}
  57.     }
  58.  
  59.     return playerRoles[playerClass][playerSpec]
  60. end
  61.  
  62. AddOn.Title = GetAddOnMetadata(AddOnName, "Title")
  63. AddOn.Version = GetAddOnMetadata(AddOnName, "Version")
  64. AddOn.Noop = function() return end
  65. AddOn.Name = UnitName("player")
  66. AddOn.GUID = UnitGUID("player")
  67. AddOn.Class = select(2, UnitClass("player"))
  68. AddOn.Role = AddOn.UnitRole("player")
  69. AddOn.Spec = GetSpecialization() or 0
  70. AddOn.Race = select(2, UnitRace("player"))
  71. AddOn.Level = UnitLevel("player")
  72. AddOn.Client = GetLocale()
  73. AddOn.Realm = GetRealmName()
  74. AddOn.LSM = LibStub and LibStub:GetLibrary("LibSharedMedia-3.0", true)
  75. AddOn.OmniCC = select(4, GetAddOnInfo("OmniCC"))
  76. AddOn.Resolution = ({GetScreenResolutions()})[GetCurrentResolution()] or GetCVar("gxWindowedResolution")
  77. AddOn.ScreenWidth, AddOn.ScreenHeight = DecodeResolution(AddOn.Resolution)
  78. AddOn.PriestColors = {r = 0.86, g = 0.92, b = 0.98, colorStr = "dbebfa"}
  79. AddOn.Color = AddOn.Class == "PRIEST" and AddOn.PriestColors or (CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[AddOn.Class] or RAID_CLASS_COLORS[AddOn.Class])
  80. AddOn.TexCoords = {0.08, 0.92, 0.08, 0.92}
  81. AddOn.WoWPatch, AddOn.WoWBuild, AddOn.WoWPatchReleaseDate, AddOn.TocVersion = GetBuildInfo()
  82. AddOn.WoWBuild = select(2, GetBuildInfo()) AddOn.WoWBuild = tonumber(AddOn.WoWBuild)
  83.  
  84. AddOn.AddOns = {}
  85. for i = 1, GetNumAddOns() do
  86.     local AddOnName = GetAddOnInfo(i)
  87.     AddOn.AddOns[string_lower(AddOnName)] = GetAddOnEnableState(AddOn.Name, AddOnName) > 0
  88. end
  89.  
  90. -- Register events for CheckRole function.
  91. local Loading = CreateFrame("Frame")
  92. Loading:RegisterEvent("PLAYER_LOGIN")
  93. Loading:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  94. Loading:RegisterEvent("PLAYER_TALENT_UPDATE")
  95. Loading:RegisterEvent("CHARACTER_POINTS_CHANGED")
  96. Loading:RegisterEvent("UNIT_INVENTORY_CHANGED")
  97. Loading:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
  98. Loading:SetScript("OnEvent", function()
  99.     AddOn:UnitRole()
  100. end)
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.
  Reply With Quote
06-17-17, 12:09 AM   #9
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
All that Addon.xxx = yyy (well, anything requiring character or other addon data) should at least go into the OnEvent script under a
Code:
 if event == "PLAYER_LOGIN" then
      Addon.xxx = yyy
end
code block so that the system has a chance to do some loading for your character before actually trying to initialise those variables. It's why K.Spec is failing first time in.

you will have to change
Code:
Loading:SetScript("OnEvent", function()
too
Code:
Loading:SetScript("OnEvent", function(self, event)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-17-17 at 01:13 AM.
  Reply With Quote
06-17-17, 04:55 AM   #10
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
In the long run you are better off to create your own special power bar frame rather then reusing the existing Blizzard ones, i havn't done this for every special bar but here is my combo frame, which looks (even better since the default combo frame using broken textures)/behaves exacly as the default one, just this is your own:

Lua Code:
  1. function Player:CreateComboFrame()
  2.     if self.frame.combo then
  3.         return
  4.     end
  5.  
  6.     self.frame.combo = CreateFrame("Frame", nil, self.frame, "ClassPowerBarFrame")
  7.     Mixin(self.frame.combo, ClassPowerBar, ComboPointPowerBar)
  8.     self.frame.combo:SetSize(126, 18)
  9.  
  10.     self.frame.combo.Background = self.frame.combo:CreateTexture("Overlay")
  11.     self.frame.combo.Background:SetAtlas("ComboPoints-AllPointsBG")
  12.     self.frame.combo.Background:SetAllPoints(self.frame.combo)
  13.  
  14.     self.frame.combo.Combo1 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointPlayerTemplate")
  15.     self.frame.combo.Combo1:SetPoint("TopLeft", self.frame.combo, "TopLeft", 12, -4)
  16.     self.frame.combo.Combo2 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointPlayerTemplate")
  17.     self.frame.combo.Combo2:SetPoint("Left", self.frame.combo.Combo1, "Right", 1, 0)
  18.     self.frame.combo.Combo3 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointPlayerTemplate")
  19.     self.frame.combo.Combo3:SetPoint("Left", self.frame.combo.Combo2, "Right", 1, 0)
  20.     self.frame.combo.Combo4 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointPlayerTemplate")
  21.     self.frame.combo.Combo4:SetPoint("Left", self.frame.combo.Combo3, "Right", 1, 0)
  22.     self.frame.combo.Combo5 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointPlayerTemplate")
  23.     self.frame.combo.Combo5:SetPoint("Left", self.frame.combo.Combo4, "Right", 1, 0)
  24.     self.frame.combo.Combo6 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointPlayerTemplate")
  25.     self.frame.combo.Combo6:SetPoint("Left", self.frame.combo.Combo5, "Right", 1, 0)
  26.  
  27.     self.frame.combo.ComboPoints = { }
  28.     self.frame.combo.ComboPoints[1] = self.frame.combo.Combo1
  29.     self.frame.combo.ComboPoints[2] = self.frame.combo.Combo2
  30.     self.frame.combo.ComboPoints[3] = self.frame.combo.Combo3
  31.     self.frame.combo.ComboPoints[4] = self.frame.combo.Combo4
  32.     self.frame.combo.ComboPoints[5] = self.frame.combo.Combo5
  33.     self.frame.combo.ComboPoints[6] = self.frame.combo.Combo6
  34.  
  35.     self.frame.combo.Combo1:SetSize(20, 20)
  36.     self.frame.combo.Combo2:SetSize(20, 20)
  37.     self.frame.combo.Combo3:SetSize(20, 20)
  38.     self.frame.combo.Combo4:SetSize(20, 20)
  39.     self.frame.combo.Combo5:SetSize(20, 20)
  40.     self.frame.combo.Combo6:SetSize(20, 20)
  41.  
  42.     self.frame.combo.Combo1.PointOff:SetSize(20, 20)
  43.     self.frame.combo.Combo2.PointOff:SetSize(20, 20)
  44.     self.frame.combo.Combo3.PointOff:SetSize(20, 20)
  45.     self.frame.combo.Combo4.PointOff:SetSize(20, 20)
  46.     self.frame.combo.Combo5.PointOff:SetSize(20, 20)
  47.     self.frame.combo.Combo6.PointOff:SetSize(20, 20)
  48.  
  49.     self.frame.combo.Combo1.Point:SetSize(20, 20)
  50.     self.frame.combo.Combo2.Point:SetSize(20, 20)
  51.     self.frame.combo.Combo3.Point:SetSize(20, 20)
  52.     self.frame.combo.Combo4.Point:SetSize(20, 20)
  53.     self.frame.combo.Combo5.Point:SetSize(20, 20)
  54.     self.frame.combo.Combo6.Point:SetSize(20, 20)
  55.  
  56.     self.frame.combo.Combo1.Point:SetTexture("Interface\\Common\\Indicator-Red")
  57.     self.frame.combo.Combo2.Point:SetTexture("Interface\\Common\\Indicator-Red")
  58.     self.frame.combo.Combo3.Point:SetTexture("Interface\\Common\\Indicator-Red")
  59.     self.frame.combo.Combo4.Point:SetTexture("Interface\\Common\\Indicator-Red")
  60.     self.frame.combo.Combo5.Point:SetTexture("Interface\\Common\\Indicator-Red")
  61.     self.frame.combo.Combo6.Point:SetTexture("Interface\\Common\\Indicator-Red")
  62.  
  63.     self.frame.combo.ComboBonus1 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointBonusPlayerTemplate")
  64.     self.frame.combo.ComboBonus1:SetPoint("TopLeft", self.frame.combo, "TopLeft", 7, 0)
  65.     self.frame.combo.ComboBonus2 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointBonusPlayerTemplate")
  66.     self.frame.combo.ComboBonus2:SetPoint("Left", self.frame.combo.ComboBonus1, "Right", 12, 0)
  67.     self.frame.combo.ComboBonus3 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointBonusPlayerTemplate")
  68.     self.frame.combo.ComboBonus3:SetPoint("Left", self.frame.combo.ComboBonus2, "Right", 12, 0)
  69.     self.frame.combo.ComboBonus4 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointBonusPlayerTemplate")
  70.     self.frame.combo.ComboBonus4:SetPoint("Left", self.frame.combo.ComboBonus3, "Right", 12, 0)
  71.     self.frame.combo.ComboBonus5 = CreateFrame("Frame", nil, self.frame.combo, "ComboPointBonusPlayerTemplate")
  72.     self.frame.combo.ComboBonus5:SetPoint("Left", self.frame.combo.ComboBonus4, "Right", 12, 0)
  73.  
  74.     self.frame.combo.ComboBonus = { }
  75.     self.frame.combo.ComboBonus[1] = self.frame.combo.ComboBonus1
  76.     self.frame.combo.ComboBonus[2] = self.frame.combo.ComboBonus2
  77.     self.frame.combo.ComboBonus[3] = self.frame.combo.ComboBonus3
  78.     self.frame.combo.ComboBonus[4] = self.frame.combo.ComboBonus4
  79.     self.frame.combo.ComboBonus[5] = self.frame.combo.ComboBonus5
  80.  
  81.     self.frame.combo.ComboBonus[1]:SetSize(10, 10)
  82.     self.frame.combo.ComboBonus[2]:SetSize(10, 10)
  83.     self.frame.combo.ComboBonus[3]:SetSize(10, 10)
  84.     self.frame.combo.ComboBonus[4]:SetSize(10, 10)
  85.     self.frame.combo.ComboBonus[5]:SetSize(10, 10)
  86.  
  87.     self.frame.combo:OnLoad()
  88.     self.frame.combo:SetScript("OnEvent", self.frame.combo.OnEvent)
  89.  
  90.     self.frame.combo.class = self.unitClass
  91. end

All you have to do is to :SetParent, :SetPoint after this and it works out of the box.
  Reply With Quote
06-17-17, 05:06 AM   #11
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
I had a similar issue with my "arrows" a few weeks back.

Here's my code for my class bars, hope it helps

Lua Code:
  1. -----------------------------------------------------
  2. --- Heavy Modifed Version of Neal's "Neav" nPower! --
  3. -----------------------------------------------------
  4.  
  5. local PowerBar = CreateFrame("Frame")
  6.  
  7. function PowerBar:CreateBar()
  8.     local StatusBar = CreateFrame("StatusBar", nil, UIParent)
  9.     StatusBar:Size(198, 8)
  10.     StatusBar:Point("CENTER", UIParent, 0, -102)
  11.     StatusBar:SetStatusBarTexture("Interface\\Buttons\\WHITE8x8")
  12.     StatusBar:CreateBackdrop()
  13.     StatusBar:Hide()
  14.  
  15.     StatusBar:RegisterEvent("PLAYER_REGEN_ENABLED")
  16.     StatusBar:RegisterEvent("PLAYER_REGEN_DISABLED")
  17.     StatusBar:RegisterEvent("PLAYER_TARGET_CHANGED")
  18.     StatusBar:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
  19.     StatusBar:RegisterEvent("RUNE_TYPE_UPDATE")
  20.     StatusBar:RegisterUnitEvent("UNIT_COMBO_POINTS", "player")
  21.     StatusBar:RegisterUnitEvent("UNIT_DISPLAYPOWER", "player")
  22.     StatusBar:RegisterUnitEvent("UNIT_POWER_FREQUENT", "player")
  23.     StatusBar:SetScript("OnEvent", PowerBar.OnEvent)
  24.    
  25.     local Animation = A["Animation"]
  26.     Animation:AddSmooth(StatusBar)
  27.  
  28.     local InvisFrame = CreateFrame("Frame", nil, StatusBar)
  29.     InvisFrame:SetFrameLevel(StatusBar:GetFrameLevel() + 2)
  30.     InvisFrame:SetAllPoints()
  31.  
  32.     local Text = InvisFrame:CreateFontString(nil, "OVERLAY")
  33.     Text:SetFontTemplate(C.Media.Font2, 18)
  34.     Text:Point("CENTER", StatusBar)
  35.    
  36.     local ExtraText = InvisFrame:CreateFontString(nil, "OVERLAY")
  37.     ExtraText:SetFontTemplate(C.Media.Font2, 24)
  38.     ExtraText:Point("CENTER", StatusBar, 0, 32)
  39.    
  40.     local ArrowDown = StatusBar:CreateTexture(nil, "OVERLAY")
  41.     ArrowDown:Size(12, 12)
  42.     ArrowDown:SetTexture(C.Media.PowerArrowDown)
  43.  
  44.     local ArrowUp = StatusBar:CreateTexture(nil, "OVERLAY")
  45.     ArrowUp:Size(12, 12)
  46.     ArrowUp:SetTexture(C.Media.PowerArrowUp)
  47.    
  48.     if (Class == "DEATHKNIGHT") then
  49.         local Runes = {}   
  50.    
  51.         for i = 1, 6 do
  52.             local RuneText = StatusBar:CreateFontString(nil, "OVERLAY")
  53.             RuneText:SetFontTemplate(C.Media.Font2, 22)
  54.             RuneText:SetTextColor(0.00, 0.82, 1.00)
  55.        
  56.             Runes[i] = RuneText
  57.         end
  58.  
  59.         Runes[1]:Point("CENTER", StatusBar, -86.5, 32)
  60.         Runes[2]:Point("CENTER", StatusBar, -51.5, 32)
  61.         Runes[3]:Point("CENTER", StatusBar, -16.5, 32)
  62.         Runes[4]:Point("CENTER", StatusBar, 16.5, 32)
  63.         Runes[5]:Point("CENTER", StatusBar, 51.5, 32)
  64.         Runes[6]:Point("CENTER", StatusBar, 86.5, 32)
  65.    
  66.         self.Runes = Runes
  67.     end
  68.    
  69.     self.StatusBar = StatusBar
  70.     self.Text = Text
  71.     self.ExtraText = ExtraText
  72.     self.ArrowDown = ArrowDown
  73.     self.ArrowUp = ArrowUp
  74. end
  75.  
  76. function PowerBar:UpdateBar()
  77.     local StatusBar = self.StatusBar
  78.     local Text = self.Text
  79.  
  80.     local Min, Max = UnitPower("player"), UnitPowerMax("player")
  81.     local R, G, B = A.ColorGradient(Min, Max, 0.8, 0, 0, 0.8, 0.8, 0, 0, 0.8, 0)
  82.  
  83.     if (StatusBar) then
  84.         StatusBar:SetMinMaxValues(0, Max)
  85.         StatusBar:SetValue(Min)    
  86.  
  87.         local PowerType, PowerToken = UnitPowerType("player")
  88.         local PowerColor = A.Colors.power[PowerToken]
  89.        
  90.         if (PowerColor) then
  91.             StatusBar:SetStatusBarColor(PowerColor[1], PowerColor[2], PowerColor[3])
  92.             StatusBar:SetBackdropColor(PowerColor[1]*0.5, PowerColor[2]*0.5, PowerColor[3]*0.5)
  93.         end
  94.     end
  95.  
  96.     if (Text) then
  97.         --Text:SetText(A.ShortNumbers(Min) .. " (" .. math.floor(Min/Max*100) ..  "%)")
  98.         Text:SetText(A.ShortNumbers(Min))
  99.         Text:SetTextColor(R, G, B)
  100.     end
  101.    
  102.     self.ArrowDown:SetVertexColor(R, G, B)
  103.     self.ArrowDown:Point("TOP", self.StatusBar, "BOTTOMLEFT", Min / Max * 198, 0)
  104.    
  105.     self.ArrowUp:SetVertexColor(R, G, B)
  106.     self.ArrowUp:Point("BOTTOM", self.ArrowDown, "TOP", 0, 8)
  107. end
  108.  
  109. function PowerBar:UpdateExtraPoints()
  110.     local PowerType
  111.     local Text = self.ExtraText
  112.  
  113.     if (Class == "ROGUE" or Class == "DRUID") then
  114.         PowerType = UnitPower("player", SPELL_POWER_COMBO_POINTS)
  115.     elseif (Class == "PALADIN") then
  116.         PowerType = UnitPower("player", SPELL_POWER_HOLY_POWER)
  117.     elseif (Class == "WARLOCK") then
  118.         PowerType = UnitPower("player", SPELL_POWER_SOUL_SHARDS)
  119.     elseif (Class == "MONK") then
  120.         PowerType = UnitPower("player", SPELL_POWER_CHI)
  121.     elseif (Class == "MAGE") then
  122.         PowerType = UnitPower("player", SPELL_POWER_ARCANE_CHARGES)
  123.     else
  124.         return
  125.     end
  126.  
  127.     if (Text) then
  128.         if (PowerType == 1) then
  129.             Text:SetTextColor(0.80, 0.22, 0)
  130.         elseif (PowerType == 2) then
  131.             Text:SetTextColor(0.80, 0.42, 0)
  132.         elseif (PowerType == 3) then
  133.             Text:SetTextColor(0.80, 0.62, 0)
  134.         elseif (PowerType == 4) then
  135.             Text:SetTextColor(0.80, 0.82, 0)
  136.         elseif (PowerType == 5) then
  137.             Text:SetTextColor(0, 1, 0)
  138.         end
  139.        
  140.         Text:SetText(PowerType == 0 and "" or PowerType)
  141.     end
  142. end
  143.  
  144. function PowerBar:RuneCooldown(self)
  145.     if (Class == "DEATHKNIGHT") then
  146.         local Start, Duration, RuneIsReady = GetRuneCooldown(self)
  147.         local Time = floor(GetTime() - Start)
  148.         local Cooldown = ceil(Duration - Time)
  149.  
  150.         if (RuneIsReady) then
  151.             return "#"
  152.         elseif (Cooldown) then
  153.             return Cooldown
  154.         end
  155.     end
  156. end
  157.  
  158. function PowerBar:UpdateRunes()
  159.     if (Class == "DEATHKNIGHT") then
  160.         PowerBar:SetScript("OnUpdate", function(self, Elapsed)
  161.             self.Update = (self.Update or 0) + Elapsed
  162.  
  163.             if (self.Update > 0.1) then
  164.                 for i = 1, 6 do
  165.                     local RuneText = self.Runes[i]
  166.                     RuneText:SetText(PowerBar:RuneCooldown(i))
  167.                 end
  168.  
  169.                 self.Update = 0
  170.             end
  171.         end)
  172.     end
  173. end
  174.  
  175. function PowerBar:OnEvent(event)
  176.     PowerBar:UpdateBar()
  177.     PowerBar:UpdateExtraPoints()
  178.     PowerBar:UpdateRunes()
  179.    
  180.     if (event == "PLAYER_REGEN_DISABLED") then
  181.         self:Show()
  182.     elseif (event == "PLAYER_REGEN_ENABLED") then
  183.         self:Hide()
  184.     end
  185. end
  186.  
  187. function PowerBar:Enable()
  188.     if not (self.IsCreated) then
  189.         PowerBar:CreateBar()
  190.    
  191.         self.IsCreated = true
  192.     end
  193. end
  194.  
  195. PowerBar:RegisterEvent("PLAYER_LOGIN")
  196. PowerBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  197. PowerBar:RegisterEvent("ADDON_LOADED")
  198.  
  199. PowerBar:SetScript("OnEvent", function(self, event)
  200.     PowerBar:Enable()
  201. end)
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Paladin class bar wont show first login

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