View Single Post
09-06-13, 01:58 AM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by almty1 View Post
Hey, thanks for looking at this. I started this addon so I could display my bottom bars without using KGPanels. I was simply able to hide this bazookaBar in a script in KGPanels is why I mentioned that. I think I figured out the issue though it seems kind of hacky. I'm trying to hide the panel before its initialized. The code below stopped the error from popping up. I made a delay in the topmenu on event script. Bazooka must be creating the frame after a event that hasn't happened yet when I try to run my function.

Lua Code:
  1. local aegerUI = ...
  2.  
  3. local MEDIAPATH = "Interface\\AddOns\\aegerUI\\Media\\"
  4. local classcolor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[(select(2, UnitClass("player")))]
  5.  
  6.  
  7. local topmenu = CreateFrame("Frame", "topmenu", UIParent)
  8. topmenu:RegisterEvent("ADDON_LOADED")
  9. topmenu:RegisterEvent("ONUPDATE")
  10. topmenu:RegisterEvent("ONLOAD")
  11. topmenu:Hide()
  12.  
  13. local topmenuborder = CreateFrame("Frame", "topmenuborder", UIParent)
  14. topmenuborder:RegisterEvent("PLAYER_REGEN_ENABLED")
  15. topmenuborder:RegisterEvent("PLAYER_REGEN_DISABLED")
  16. topmenuborder:Hide()
  17.  
  18. function topmenudisplay()
  19.  
  20. if TopmenuShow == 1 then
  21. topmenu:Show()
  22. topmenuborder:Show()
  23. _G["BazookaBar_1"]:Show()
  24. else
  25. if TopmenuShow == nil then
  26. topmenu:Hide()
  27. topmenuborder:Hide()
  28. _G["BazookaBar_1"]:Hide()
  29. end
  30. end
  31. end
  32.  
  33. topmenu:SetScript("OnEvent", function(self, event, ...)
  34. local timeleft = 1 --set the countdown to w/e you want
  35. local f = CreateFrame("Frame", nil, UIParent)
  36. f:SetScript("OnUpdate", function(_,arg)
  37.   timeleft = timeleft - arg
  38.   if timeleft >= 0 then
  39.     timeleft = nil
  40.     f:SetScript("OnUpdate", nil)
  41.     topmenudisplay()
  42.   end
  43. end)
  44. end)
  45.  
  46. local function flip(texture,horizontal)
  47.     local ULx,ULy,LLx,LLy,URx,URy,LRx,LRy = texture:GetTexCoord()
  48.     if horizontal then
  49.         texture:SetTexCoord(URx, URy, LRx, LRy, ULx, ULy, LLx, LLy)
  50.     else
  51.         texture:SetTexCoord(LLx, LLy,ULx, ULy, LRx, LRy, URx, URy)
  52.     end
  53. end
  54.  
  55. topmenu:SetScript("OnShow", function(self)
  56.   self:SetScript("OnShow", nil)
  57.   PetBattleFrame:HookScript("OnShow",function() self:Hide() end)
  58.   PetBattleFrame:HookScript("OnHide",function() self:Show() end)
  59.  
  60.   local tmdisplay = self:CreateTexture(nil, "BACKGROUND")
  61.     tmdisplay:SetSize(500, 36)
  62.     tmdisplay:SetPoint("TOP", UIParent, "TOP",0 ,3)
  63.     tmdisplay:SetPoint("CENTER", UIParent, "CENTER")
  64.     tmdisplay:SetTexture(MEDIAPATH .. "topmenu")
  65.     tmdisplay:SetVertexColor(0, 0, 0, .5)
  66.     flip(tmdisplay,false)
  67.    
  68. end)
  69.  
  70. topmenuborder:SetScript("OnShow", function(self)
  71.  
  72.   PetBattleFrame:HookScript("OnShow",function() self:Hide() end)
  73.   PetBattleFrame:HookScript("OnHide",function() self:Show() end)
  74.  
  75.   local tmborderdisplay = self:CreateTexture(nil, "BORDER")
  76.     tmborderdisplay:SetSize(502, 46)
  77.     tmborderdisplay:SetPoint("TOP", UIParent, "TOP", 0, 10)
  78.     tmborderdisplay:SetPoint("CENTER", UIParent, "CENTER")
  79.     tmborderdisplay:SetTexture(MEDIAPATH .. "topmenuborder")
  80.     tmborderdisplay:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1.0)
  81.     flip(tmborderdisplay,false)
  82.     topmenuborder:HookScript("OnEvent", function(self, event)
  83.     if event == "PLAYER_REGEN_DISABLED" then
  84.     tmborderdisplay:SetVertexColor(1, 0, 0)
  85.     elseif event == "PLAYER_REGEN_ENABLED" then
  86.     tmborderdisplay:SetVertexColor(classcolor.r, classcolor.g, classcolor.b, 1.0)
  87. end
  88. end)
  89. end)
  90.  
  91. SlashCmdList.TOPMENUSHOW = function()
  92.     TopmenuShow = 1
  93.     ReloadUI()
  94. end
  95. SLASH_TOPMENUSHOW1 = "/tmshow"
  96.  
  97. SlashCmdList.TOPMENUHIDE = function()
  98.     TopmenuShow = nil
  99.     ReloadUI()
  100. end
  101. SLASH_TOPMENUHIDE1 = "/tmhide"
The frame names in your code should be nils:

Lua Code:
  1. local topmenu = CreateFrame("Frame", nil, UIParent)
  2. local topmenuborder = CreateFrame("Frame",nil, UIParent)

Else your frames gonna be globals.
  Reply With Quote