Advertisement
Guest User

Ion PVPframe error fix

a guest
Mar 7th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 32.20 KB | None | 0 0
  1. --Ion Menu Bar, a World of Warcraft® user interface addon.
  2. --Copyright© 2006-2012 Connor H. Chenoweth, aka Maul - All rights reserved.
  3.  
  4. local ION, GDB, CDB, PEW = Ion
  5.  
  6. ION.MENUIndex = {}
  7.  
  8. local MENUIndex = ION.MENUIndex
  9.  
  10. local menubarsGDB, menubarsCDB, menubtnsGDB, menubtnsCDB
  11.  
  12. local ANCHOR = setmetatable({}, { __index = CreateFrame("Frame") })
  13.  
  14. local STORAGE = CreateFrame("Frame", nil, UIParent)
  15.  
  16. local L = LibStub("AceLocale-3.0"):GetLocale("Ion")
  17.  
  18. IonMenuGDB = {
  19.     menubars = {},
  20.     menubtns = {},
  21.     scriptProfile = false,
  22.     firstRun = true,
  23. }
  24.  
  25. IonMenuCDB = {
  26.     menubars = {},
  27.     menubtns = {},
  28. }
  29.  
  30. local gDef = {
  31.  
  32.     snapTo = false,
  33.     snapToFrame = false,
  34.     snapToPoint = false,
  35.     point = "BOTTOMRIGHT",
  36.     x = -154.5,
  37.     y = 33,
  38. }
  39.  
  40. local menuElements = {}
  41. local addonData, sortData = {}, {}
  42.  
  43. local sort = table.sort
  44. local format = string.format
  45.  
  46. local GetAddOnInfo = _G.GetAddOnInfo
  47. local GetAddOnMemoryUsage = _G.GetAddOnMemoryUsage
  48. local GetAddOnCPUUsage = _G.GetAddOnCPUUsage
  49. local GetScriptCPUUsage = _G.GetScriptCPUUsage
  50. local UpdateAddOnMemoryUsage = _G.UpdateAddOnMemoryUsage
  51. local UpdateAddOnCPUUsage = _G.UpdateAddOnCPUUsage
  52.  
  53. local GetParentKeys = ION.GetParentKeys
  54.  
  55. local defGDB, defCDB = CopyTable(IonMenuGDB), CopyTable(IonMenuCDB)
  56.  
  57. local configData = {
  58.  
  59.     stored = false,
  60. }
  61.  
  62.  
  63. local function updateTabard(button)
  64.  
  65.     local emblem = select(10, GetGuildLogoInfo())
  66.  
  67.     if (emblem) then
  68.  
  69.         if (not button.tabard:IsShown()) then
  70.  
  71.             button:SetNormalTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Up")
  72.             button:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Down")
  73.  
  74.             button.tabard:Show()
  75.         end
  76.  
  77.         SetSmallGuildTabardTextures("player", button.tabard.emblem, button.tabard.background)
  78.  
  79.     else
  80.         if (button.tabard:IsShown()) then
  81.  
  82.             button:SetNormalTexture("Interface\\Buttons\\UI-MicroButton-Socials-Up")
  83.             button:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Socials-Down")
  84.             button:SetDisabledTexture("Interface\\Buttons\\UI-MicroButton-Socials-Disabled")
  85.  
  86.             button.tabard:Hide()
  87.         end
  88.     end
  89. end
  90.  
  91. local function updateMicroButtons()
  92.  
  93.     local playerLevel = UnitLevel("player")
  94.  
  95.     if (IonCharacterButton and CharacterFrame:IsShown()) then
  96.  
  97.         IonCharacterButton:SetButtonState("PUSHED", 1)
  98.         ION.CharacterButton_SetPushed(IonCharacterButton)
  99.  
  100.     elseif (IonCharacterButton) then
  101.  
  102.         IonCharacterButton:SetButtonState("NORMAL")
  103.         ION.CharacterButton_SetNormal(IonCharacterButton)
  104.     end
  105.  
  106.     if (IonSpellbookButton and SpellBookFrame:IsShown()) then
  107.  
  108.         IonSpellbookButton:SetButtonState("PUSHED", 1)
  109.  
  110.     elseif (IonSpellbookButton) then
  111.  
  112.         IonSpellbookButton:SetButtonState("NORMAL")
  113.     end
  114.  
  115.     if (IonTalentButton and PlayerTalentFrame and PlayerTalentFrame:IsShown()) then
  116.  
  117.         IonTalentButton:SetButtonState("PUSHED", 1)
  118.  
  119.     elseif (IonTalentButton) then
  120.  
  121.         if (playerLevel < SHOW_TALENT_LEVEL) then
  122.  
  123.             IonTalentButton:GetNormalTexture():SetDesaturated(1)
  124.             IonTalentButton:GetNormalTexture():SetVertexColor(0.5,0.5,0.5)
  125.             IonTalentButton:GetPushedTexture():SetDesaturated(1)
  126.             IonTalentButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Talents-Up")
  127.             IonTalentButton:SetHighlightTexture("")
  128.             IonTalentButton.disabledTooltip = format(FEATURE_BECOMES_AVAILABLE_AT_LEVEL, SHOW_TALENT_LEVEL)
  129.  
  130.         else
  131.             IonTalentButton:GetNormalTexture():SetDesaturated(nil)
  132.             IonTalentButton:GetNormalTexture():SetVertexColor(1,1,1)
  133.             IonTalentButton:GetPushedTexture():SetDesaturated(nil)
  134.             IonTalentButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Talents-Down")
  135.             IonTalentButton:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  136.             IonTalentButton:SetButtonState("NORMAL")
  137.             IonTalentButton.disabledTooltip = nil
  138.         end
  139.  
  140.     end
  141.  
  142.     if (IonQuestLogButton and QuestLogFrame:IsShown()) then
  143.  
  144.         IonQuestLogButton:SetButtonState("PUSHED", 1)
  145.  
  146.     elseif (IonQuestLogButton) then
  147.  
  148.         IonQuestLogButton:SetButtonState("NORMAL")
  149.     end
  150.  
  151.     if (IonLatencyButton and (GameMenuFrame:IsShown() or InterfaceOptionsFrame:IsShown() or (KeyBindingFrame and KeyBindingFrame:IsShown()) or (MacroFrame and MacroFrame:IsShown()))) then
  152.  
  153.         IonLatencyButton:SetButtonState("PUSHED", 1)
  154.         ION.LatencyButton_SetPushed(IonLatencyButton)
  155.  
  156.     elseif (IonLatencyButton) then
  157.  
  158.         IonLatencyButton:SetButtonState("NORMAL")
  159.         ION.LatencyButton_SetNormal(IonLatencyButton)
  160.     end
  161.  
  162.     if (IonPVPButton and (PVPUIFrame and PVPUIFrame:IsShown())) then
  163.  
  164.         IonPVPButton:SetButtonState("PUSHED", 1)
  165.         ION.PVPButton_SetPushed(IonPVPButton)
  166.  
  167.     elseif (IonPVPButton) then
  168.  
  169.         if (playerLevel < SHOW_PVP_LEVEL) then
  170.  
  171.             IonPVPButton:GetNormalTexture():SetDesaturated(1)
  172.             IonPVPButton:GetNormalTexture():SetVertexColor(0.5,0.5,0.5)
  173.             IonPVPButton:GetPushedTexture():SetDesaturated(1)
  174.             IonPVPButton.faction:SetDesaturated(1)
  175.             IonPVPButton.faction:SetVertexColor(0.5,0.5,0.5)
  176.             IonPVPButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Up")
  177.             IonPVPButton:SetHighlightTexture("")
  178.             IonPVPButton.disabledTooltip = format(FEATURE_BECOMES_AVAILABLE_AT_LEVEL, SHOW_PVP_LEVEL)
  179.  
  180.         else
  181.             IonPVPButton:GetNormalTexture():SetDesaturated(nil)
  182.             IonPVPButton:GetNormalTexture():SetVertexColor(1,1,1)
  183.             IonPVPButton:GetPushedTexture():SetDesaturated(nil)
  184.             IonPVPButton.faction:SetDesaturated(nil)
  185.             IonPVPButton.faction:SetVertexColor(1,1,1)
  186.             IonPVPButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Down")
  187.             IonPVPButton:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  188.             IonPVPButton:SetButtonState("NORMAL")
  189.             IonPVPButton.disabledTooltip = nil
  190.             ION.PVPButton_SetNormal(IonPVPButton)
  191.         end
  192.     end
  193.  
  194.     if (IonGuildButton and ((GuildFrame and GuildFrame:IsShown()) or (LookingForGuildFrame and LookingForGuildFrame:IsShown()))) then
  195.  
  196.         IonGuildButton:SetButtonState("PUSHED", 1)
  197.         IonGuildButton.tabard:SetPoint("TOPLEFT", -1, -1)
  198.         IonGuildButton.tabard:SetAlpha(0.5)
  199.  
  200.     elseif (IonGuildButton) then
  201.  
  202.         IonGuildButton:GetNormalTexture():SetDesaturated(nil)
  203.         IonGuildButton:GetNormalTexture():SetVertexColor(1,1,1)
  204.         IonGuildButton:GetPushedTexture():SetDesaturated(nil)
  205.         IonGuildButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Socials-Down")
  206.         IonGuildButton:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  207.         IonGuildButton:SetButtonState("NORMAL")
  208.         IonGuildButton.tabard:SetPoint("TOPLEFT", 0, 0)
  209.         IonGuildButton.tabard:SetAlpha(1.0)
  210.         IonGuildButton.disabledTooltip = nil
  211.  
  212.         if (IsInGuild()) then
  213.             updateTabard(IonGuildButton)
  214.         end
  215.     end
  216.  
  217.     if (IonLFDButton and PVEFrame and PVEFrame:IsShown())  then
  218.  
  219.         IonLFDButton:SetButtonState("PUSHED", 1)
  220.  
  221.     elseif (IonLFDButton) then
  222.  
  223.         if (playerLevel < SHOW_LFD_LEVEL) then
  224.  
  225.             IonLFDButton:GetNormalTexture():SetDesaturated(1)
  226.             IonLFDButton:GetNormalTexture():SetVertexColor(0.5,0.5,0.5)
  227.             IonLFDButton:GetPushedTexture():SetDesaturated(1)
  228.             IonLFDButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-LFG-Up")
  229.             IonLFDButton:SetHighlightTexture("")
  230.             IonLFDButton.disabledTooltip = format(FEATURE_BECOMES_AVAILABLE_AT_LEVEL, SHOW_LFD_LEVEL)
  231.  
  232.         else
  233.             IonLFDButton:GetNormalTexture():SetDesaturated(nil)
  234.             IonLFDButton:GetNormalTexture():SetVertexColor(1,1,1)
  235.             IonLFDButton:GetPushedTexture():SetDesaturated(nil)
  236.             IonLFDButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-LFG-Down")
  237.             IonLFDButton:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  238.             IonLFDButton:SetButtonState("NORMAL")
  239.             IonLFDButton.disabledTooltip = nil
  240.         end
  241.  
  242.     end
  243.  
  244.     if (IonCompanionButton and PetJournalParent and PetJournalParent:IsShown())  then
  245.  
  246.         IonCompanionButton:SetButtonState("PUSHED", 1)
  247.  
  248.     elseif (IonCompanionButton) then
  249.  
  250.         IonCompanionButton:GetNormalTexture():SetDesaturated(nil)
  251.         IonCompanionButton:GetNormalTexture():SetVertexColor(1,1,1)
  252.         IonCompanionButton:GetPushedTexture():SetDesaturated(nil)
  253.         IonCompanionButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Mounts-Down")
  254.         IonCompanionButton:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  255.         IonCompanionButton:SetButtonState("NORMAL")
  256.         IonCompanionButton.disabledTooltip = nil
  257.  
  258.     end
  259.  
  260.     if (IonEJButton and EncounterJournal and EncounterJournal:IsShown())  then
  261.  
  262.         IonEJButton:SetButtonState("PUSHED", 1)
  263.  
  264.     elseif (IonEJButton) then
  265.  
  266.         IonEJButton:GetNormalTexture():SetDesaturated(nil)
  267.         IonEJButton:GetNormalTexture():SetVertexColor(1,1,1)
  268.         IonEJButton:GetPushedTexture():SetDesaturated(nil)
  269.         IonEJButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-EJ-Down")
  270.         IonEJButton:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  271.         IonEJButton:SetButtonState("NORMAL")
  272.         IonEJButton.disabledTooltip = nil
  273.  
  274.     end
  275.  
  276.     if (IonHelpButton and HelpFrame:IsShown()) then
  277.  
  278.         IonHelpButton:SetButtonState("PUSHED", 1)
  279.  
  280.     elseif (IonHelpButton) then
  281.  
  282.         IonHelpButton:SetButtonState("NORMAL")
  283.     end
  284.  
  285.     if (IonAchievementButton and AchievementFrame and AchievementFrame:IsShown()) then
  286.  
  287.         IonAchievementButton:SetButtonState("PUSHED", 1)
  288.  
  289.     elseif (IonAchievementButton) then
  290.  
  291.         if ((HasCompletedAnyAchievement() or IsInGuild()) and CanShowAchievementUI()) then
  292.  
  293.             IonAchievementButton:GetNormalTexture():SetDesaturated(nil)
  294.             IonAchievementButton:GetNormalTexture():SetVertexColor(1,1,1)
  295.             IonAchievementButton:GetPushedTexture():SetDesaturated(nil)
  296.             IonAchievementButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Achievement-Down")
  297.             IonAchievementButton:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  298.             IonAchievementButton:SetButtonState("NORMAL")
  299.             IonAchievementButton.disabledTooltip = nil
  300.  
  301.         else
  302.  
  303.             IonAchievementButton:GetNormalTexture():SetDesaturated(1)
  304.             IonAchievementButton:GetNormalTexture():SetVertexColor(0.5,0.5,0.5)
  305.             IonAchievementButton:GetPushedTexture():SetDesaturated(1)
  306.             IonAchievementButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Achievement-Up")
  307.             IonAchievementButton:SetHighlightTexture("")
  308.             IonAchievementButton.disabledTooltip = "Feature becomes available after you earn your first achievement"
  309.  
  310.         end
  311.     end
  312.  
  313.  
  314. end
  315.  
  316. function ION.CharacterButton_OnLoad(self)
  317.  
  318.     self.portrait = _G[self:GetName().."Portrait"]
  319.     SetPortraitTexture(self.portrait, "player")
  320.  
  321.     self:SetNormalTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Up")
  322.     self:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Down")
  323.     self:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  324.     self:RegisterEvent("UNIT_PORTRAIT_UPDATE")
  325.     self:RegisterEvent("UPDATE_BINDINGS")
  326.     self.tooltipText = MicroButtonTooltipText(CHARACTER_BUTTON, "TOGGLECHARACTER0")
  327.     self.newbieText = NEWBIE_TOOLTIP_CHARACTER
  328.  
  329.     menuElements[#menuElements+1] = self
  330. end
  331.  
  332. function ION.CharacterButton_OnMouseDown(self)
  333.  
  334.     if (self.down) then
  335.         self.down = nil
  336.         ToggleCharacter("PaperDollFrame")
  337.         return
  338.     end
  339.     ION.CharacterButton_SetPushed(self)
  340.     self.down = 1
  341. end
  342.  
  343. function ION.CharacterButton_OnMouseUp(self)
  344.  
  345.     if (self.down) then
  346.         self.down = nil
  347.         if (self:IsMouseOver()) then
  348.             ToggleCharacter("PaperDollFrame")
  349.         else
  350.             updateMicroButtons()
  351.         end
  352.         return
  353.     end
  354.     if (self:GetButtonState() == "NORMAL") then
  355.         ION.CharacterButton_SetPushed(self)
  356.         self.down = 1
  357.     else
  358.         ION.CharacterButton_SetNormal(self)
  359.         self.down = 1
  360.     end
  361. end
  362.  
  363. function ION.CharacterButton_OnEvent(self, event, ...)
  364.  
  365.     if (event == "UNIT_PORTRAIT_UPDATE") then
  366.  
  367.         if (... == "player") then
  368.             SetPortraitTexture(self.portrait, ...)
  369.         end
  370.  
  371.     elseif (event == "UPDATE_BINDINGS") then
  372.  
  373.         self.tooltipText = MicroButtonTooltipText(CHARACTER_BUTTON, "TOGGLECHARACTER0")
  374.     end
  375. end
  376.  
  377. function ION.CharacterButton_SetPushed(self)
  378.     self.portrait:SetTexCoord(0.2666, 0.8666, 0, 0.8333)
  379.     self.portrait:SetAlpha(0.5)
  380. end
  381.  
  382. function ION.CharacterButton_SetNormal(self)
  383.     self.portrait:SetTexCoord(0.2, 0.8, 0.0666, 0.9)
  384.     self.portrait:SetAlpha(1.0)
  385. end
  386.  
  387. function ION.SpellbookButton_OnLoad(self)
  388.  
  389.     self:SetAttribute("type", "macro")
  390.     self:SetAttribute("*macrotext*", "/click SpellbookMicroButton")
  391.     self:RegisterEvent("UPDATE_BINDINGS")
  392.  
  393.     LoadMicroButtonTextures(self, "Spellbook")
  394.     menuElements[#menuElements+1] = self
  395. end
  396.  
  397. function ION.SpellbookButton_OnClick(self)
  398.     if (not InCombatLockdown()) then
  399.         ToggleSpellBook(BOOKTYPE_SPELL)
  400.     end
  401. end
  402.  
  403. function ION.SpellbookButton_OnEnter(self)
  404.     self.tooltipText = MicroButtonTooltipText(SPELLBOOK_ABILITIES_BUTTON, "TOGGLESPELLBOOK")
  405.     GameTooltip_AddNewbieTip(self, self.tooltipText, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_SPELLBOOK)
  406. end
  407.  
  408. function ION.SpellbookButton_OnEvent(self, event, ...)
  409.     self.tooltipText = MicroButtonTooltipText(SPELLBOOK_ABILITIES_BUTTON, "TOGGLESPELLBOOK")
  410. end
  411.  
  412. function ION.TalentButton_OnLoad(self)
  413.  
  414.     LoadMicroButtonTextures(self, "Talents")
  415.  
  416.     self:SetAttribute("type", "macro")
  417.     self:SetAttribute("*macrotext*", "/click TalentMicroButton")
  418.  
  419.     self.tooltipText = MicroButtonTooltipText(TALENTS_BUTTON, "TOGGLETALENTS")
  420.     self.newbieText = NEWBIE_TOOLTIP_TALENTS
  421.     self:RegisterEvent("PLAYER_LEVEL_UP")
  422.     self:RegisterEvent("UPDATE_BINDINGS")
  423.     self:RegisterEvent("UNIT_LEVEL")
  424.     self:RegisterEvent("PLAYER_ENTERING_WORLD")
  425.  
  426.     self:HookScript("OnEnter", function(self) if (self.disabledTooltip) then GameTooltip:AddLine(self.disabledTooltip, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true) GameTooltip:Show() end end)
  427.  
  428.     menuElements[#menuElements+1] = self
  429. end
  430.  
  431. function ION.TalentButton_OnEvent(self, event, ...)
  432.  
  433.     if (event == "PLAYER_LEVEL_UP") then
  434.  
  435.         UpdateMicroButtons()
  436.  
  437.         if (not CharacterFrame:IsShown()) then
  438.             SetButtonPulse(self, 60, 1)
  439.         end
  440.  
  441.     elseif (event == "UNIT_LEVEL" or event == "PLAYER_ENTERING_WORLD") then
  442.  
  443.         UpdateMicroButtons()
  444.  
  445.     elseif (event == "UPDATE_BINDINGS") then
  446.  
  447.         self.tooltipText =  MicroButtonTooltipText(TALENTS_BUTTON, "TOGGLETALENTS")
  448.     end
  449. end
  450.  
  451. function ION.AchievementButton_OnLoad(self)
  452.     LoadMicroButtonTextures(self, "Achievement")
  453.     self:RegisterEvent("PLAYER_ENTERING_WORLD")
  454.     self:RegisterEvent("UPDATE_BINDINGS")
  455.  
  456.     menuElements[#menuElements+1] = self
  457. end
  458.  
  459. function ION.AchievementButton_OnEvent(self, event, ...)
  460.  
  461.     if (event == "PLAYER_ENTERING_WORLD") then
  462.         AchievementMicroButton_OnEvent(self, event, ...)
  463.     elseif (event == "UPDATE_BINDINGS") then
  464.         self.tooltipText =  MicroButtonTooltipText(TALENTS_BUTTON, "TOGGLETALENTS")
  465.     end
  466. end
  467.  
  468. function ION.AchievementButton_OnClick(self)
  469.     ToggleAchievementFrame()
  470. end
  471.  
  472. function ION.AchievementButton_OnEnter(self)
  473.     self.tooltipText = MicroButtonTooltipText(ACHIEVEMENT_BUTTON, "TOGGLEACHIEVEMENT")
  474.     GameTooltip_AddNewbieTip(self, self.tooltipText, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_ACHIEVEMENT)
  475.     if (self.disabledTooltip) then
  476.         GameTooltip:AddLine("\n"..self.disabledTooltip, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true)
  477.     end
  478.     GameTooltip:Show()
  479. end
  480.  
  481. function ION.QuestLogButton_OnLoad(self)
  482.     LoadMicroButtonTextures(self, "Quest")
  483.     self.tooltipText = MicroButtonTooltipText(QUESTLOG_BUTTON, "TOGGLEQUESTLOG")
  484.     self.newbieText = NEWBIE_TOOLTIP_QUESTLOG
  485.  
  486.     menuElements[#menuElements+1] = self
  487. end
  488.  
  489. function ION.QuestLogButton_OnEvent(self, event, ...)
  490.     self.tooltipText = MicroButtonTooltipText(QUESTLOG_BUTTON, "TOGGLEQUESTLOG")
  491. end
  492.  
  493. function ION.QuestLogButton_OnClick(self)
  494.     ToggleFrame(QuestLogFrame)
  495. end
  496.  
  497. --      IonGuildButton.tabard:SetPoint("TOPLEFT", -1, -1) IonGuildButton.tabard:SetAlpha(0.5)
  498.  
  499. function ION.GuildButton_OnLoad(self)
  500.  
  501.     self:SetAttribute("type", "macro")
  502.     self:SetAttribute("*macrotext*", "/click GuildMicroButton")
  503.     self:SetScript("OnMouseDown", function(self) self.tabard:SetPoint("TOPLEFT", -1, -1) self.tabard:SetAlpha(0.5) end)
  504.     self:RegisterEvent("UPDATE_BINDINGS")
  505.     self:RegisterEvent("PLAYER_GUILD_UPDATE")
  506.  
  507.     LoadMicroButtonTextures(self, "Socials")
  508.     self.tooltipText = MicroButtonTooltipText(GUILD, "TOGGLEGUILDTAB")
  509.     self.newbieText = NEWBIE_TOOLTIP_GUILDTAB
  510.  
  511.     self:HookScript("OnEnter", function(self) if (self.disabledTooltip) then GameTooltip:AddLine(self.disabledTooltip, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true) GameTooltip:Show() end end)
  512.  
  513.     updateTabard(self)
  514.  
  515.     menuElements[#menuElements+1] = self
  516. end
  517.  
  518. function ION.GuildButton_OnEvent(self, event, ...)
  519.     if (event == "UPDATE_BINDINGS") then
  520.         self.tooltipText = MicroButtonTooltipText(GUILD, "TOGGLEGUILDTAB")
  521.     elseif (event == "PLAYER_GUILD_UPDATE") then
  522.         UpdateMicroButtons()
  523.     end
  524. end
  525.  
  526. function ION.PVPButton_OnLoad(self)
  527.  
  528.     self:RegisterEvent("UPDATE_BINDINGS")
  529.     self:SetNormalTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Up")
  530.     self:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Down")
  531.     self:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight")
  532.     self.faction = _G[self:GetName().."Faction"]
  533.  
  534.     local factionGroup = UnitFactionGroup("player")
  535.  
  536.     if (factionGroup) then
  537.         self.factionGroup = factionGroup
  538.         self.faction:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..self.factionGroup)
  539.     end
  540.  
  541.     self.tooltipText = MicroButtonTooltipText(PLAYER_V_PLAYER, "TOGGLECHARACTER4")
  542.     self.newbieText = NEWBIE_TOOLTIP_PVP
  543.  
  544.     self:HookScript("OnEnter", function(self) if (self.disabledTooltip) then GameTooltip:AddLine(self.disabledTooltip, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true) GameTooltip:Show() end end)
  545.  
  546.     menuElements[#menuElements+1] = self
  547. end
  548.  
  549. function ION.PVPButton_OnEvent(self, event, ...)
  550.     self.tooltipText = MicroButtonTooltipText(PLAYER_V_PLAYER, "TOGGLECHARACTER4")
  551.     self.newbieText = NEWBIE_TOOLTIP_PVP
  552. end
  553.  
  554. function ION.PVPButton_OnMouseDown(self)
  555.  
  556.     if (self.disabledTooltip) then
  557.         self.faction:SetVertexColor(1,1,1)
  558.         return
  559.     end
  560.  
  561.     if (self.down) then
  562.         self.down = nil
  563.  
  564.         if (PVPUIFrame) then
  565.             ToggleFrame(PVPUIFrame)
  566.         else
  567.             LoadAddOn("Blizzard_PVPUI")
  568.             ToggleFrame(PVPUIFrame)
  569.         end
  570.         return
  571.     end
  572.  
  573.     ION.PVPButton_SetPushed(self)
  574.  
  575.     self.down = 1
  576. end
  577.  
  578. function ION.PVPButton_OnMouseUp(self)
  579.  
  580.     if (self.disabledTooltip) then
  581.         self.faction:SetVertexColor(0.5,0.5,0.5)
  582.         return
  583.     end
  584.  
  585.     if (self.down) then
  586.         self.down = nil
  587.         if self:IsMouseOver() then
  588.             if (PVPUIFrame) then
  589.                 ToggleFrame(PVPUIFrame)
  590.             else
  591.                 LoadAddOn("Blizzard_PVPUI")
  592.                 ToggleFrame(PVPUIFrame)
  593.             end
  594.         else
  595.             updateMicroButtons()
  596.         end
  597.         return
  598.     end
  599.  
  600.     if (self:GetButtonState() == "NORMAL") then
  601.         ION.PVPButton_SetPushed(self)
  602.     else
  603.         ION.PVPButton_SetNormal(self)
  604.     end
  605.  
  606.     self.down = 1
  607. end
  608.  
  609. function ION.PVPButton_SetPushed(self)
  610.     self.faction:SetPoint("TOP", self, "TOP", 5, -31)
  611.     self.faction:SetAlpha(0.5)
  612. end
  613.  
  614. function ION.PVPButton_SetNormal(self)
  615.     self.faction:SetPoint("TOP", self, "TOP", 6, -30)
  616.     self.faction:SetAlpha(1.0)
  617. end
  618.  
  619. function ION.LFDButton_OnLoad(self)
  620.  
  621.     self:RegisterEvent("UPDATE_BINDINGS")
  622.     self.tooltipText = MicroButtonTooltipText(DUNGEONS_BUTTON, "TOGGLELFGPARENT")
  623.     self.newbieText = NEWBIE_TOOLTIP_LFGPARENT
  624.  
  625.     LoadMicroButtonTextures(self, "LFG")
  626.  
  627.     self:HookScript("OnEnter", function(self) if (self.disabledTooltip) then GameTooltip:AddLine(self.disabledTooltip, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true) GameTooltip:Show() end end)
  628.  
  629.     menuElements[#menuElements+1] = self
  630. end
  631.  
  632. function ION.LFDButton_OnEvent(self, event, ...)
  633.     self.tooltipText = MicroButtonTooltipText(DUNGEONS_BUTTON, "TOGGLELFGPARENT")
  634.     self.newbieText = NEWBIE_TOOLTIP_LFGPARENT
  635. end
  636.  
  637. function ION.LFDButton_OnClick(self)
  638.  
  639.     if (self.disabledTooltip) then
  640.         return
  641.     end
  642.  
  643.     if (ToggleLFDParentFrame) then
  644.         ToggleLFDParentFrame()
  645.     elseif (ToggleLFDParentFrame) then
  646.         ToggleLFDParentFrame()
  647.     end
  648. end
  649.  
  650. function ION.CompanionButton_OnLoad(self)
  651.  
  652.     self:RegisterEvent("UPDATE_BINDINGS")
  653.     self.tooltipText = MicroButtonTooltipText(MOUNTS_AND_PETS, "TOGGLEMOUNTJOURNAL")
  654.     self.newbieText = NEWBIE_TOOLTIP_MOUNTS_AND_PETS
  655.  
  656.     LoadMicroButtonTextures(self, "Mounts")
  657.  
  658.     self:HookScript("OnEnter", function(self) if (self.disabledTooltip) then GameTooltip:AddLine(self.disabledTooltip, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true) GameTooltip:Show() end end)
  659.  
  660.     menuElements[#menuElements+1] = self
  661.  
  662. end
  663.  
  664. function ION.CompanionButton_OnEvent(self, event, ...)
  665.  
  666.     self.tooltipText = MicroButtonTooltipText(MOUNTS_AND_PETS, "TOGGLEMOUNTJOURNAL")
  667.     self.newbieText = NEWBIE_TOOLTIP_MOUNTS_AND_PETS
  668. end
  669.  
  670. function ION.CompanionButton_OnClick(self)
  671.  
  672.     TogglePetJournal()
  673. end
  674.  
  675. function ION.EJButton_OnLoad(self)
  676.  
  677.     self:RegisterEvent("UPDATE_BINDINGS")
  678.     self.tooltipText = MicroButtonTooltipText(ENCOUNTER_JOURNAL, "TOGGLEENCOUNTERJOURNAL")
  679.     self.newbieText = NEWBIE_TOOLTIP_ENCOUNTER_JOURNAL
  680.  
  681.     LoadMicroButtonTextures(self, "EJ")
  682.  
  683.     self:HookScript("OnEnter", function(self) if (self.disabledTooltip) then GameTooltip:AddLine(self.disabledTooltip, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, true) GameTooltip:Show() end end)
  684.  
  685.     menuElements[#menuElements+1] = self
  686.  
  687. end
  688.  
  689. function ION.EJButton_OnEvent(self, event, ...)
  690.  
  691.     self.tooltipText = MicroButtonTooltipText(ENCOUNTER_JOURNAL, "TOGGLEENCOUNTERJOURNAL")
  692.     self.newbieText = NEWBIE_TOOLTIP_ENCOUNTER_JOURNAL
  693.  
  694. end
  695.  
  696. function ION.EJButton_OnClick(self)
  697.  
  698.     if (self.disabledTooltip) then
  699.         return
  700.     end
  701.  
  702.     if (not EncounterJournal) then
  703.         EncounterJournal_LoadUI()
  704.     end
  705.  
  706.     if (EncounterJournal) then
  707.         ToggleFrame(EncounterJournal)
  708.     end
  709. end
  710.  
  711. function ION.HelpButton_OnLoad(self)
  712.     LoadMicroButtonTextures(self, "Help")
  713.     self.tooltipText = HELP_BUTTON
  714.     self.newbieText = NEWBIE_TOOLTIP_HELP
  715.  
  716.     menuElements[#menuElements+1] = self
  717. end
  718.  
  719. function ION.HelpButton_OnClick(self)
  720.     ToggleHelpFrame()
  721. end
  722.  
  723. function ION.LatencyButton_OnLoad(self)
  724.  
  725.     self.hover = nil
  726.     self.elapsed = 0
  727.     self.overlay = _G[self:GetName().."Overlay"]
  728.     self.overlay:SetWidth(self:GetWidth()+1)
  729.     self.overlay:SetHeight(self:GetHeight())
  730.     self.tooltipText = MicroButtonTooltipText(MAINMENU_BUTTON, "TOGGLEGAMEMENU")
  731.     self.newbieText = NEWBIE_TOOLTIP_MAINMENU
  732.     self:RegisterForClicks("LeftButtonDown", "RightButtonDown", "LeftButtonUp", "RightButtonUp")
  733.     self:RegisterEvent("ADDON_LOADED")
  734.     self:RegisterEvent("UPDATE_BINDINGS")
  735.  
  736.     menuElements[#menuElements+1] = self
  737.  
  738. end
  739.  
  740. function ION.LatencyButton_OnEvent(self, event, ...)
  741.  
  742.     if (event == "ADDON_LOADED" and ...=="Ion-MenuBar") then
  743.         self.lastStart = 0
  744.         if (GDB) then
  745.             self.enabled = GDB.scriptProfile
  746.         end
  747.         GameMenuFrame:HookScript("OnShow", ION.LatencyButton_SetPushed)
  748.         GameMenuFrame:HookScript("OnHide", ION.LatencyButton_SetNormal)
  749.     end
  750.  
  751.     self.tooltipText = MicroButtonTooltipText(MAINMENU_BUTTON, "TOGGLEGAMEMENU")
  752. end
  753.  
  754. function ION.LatencyButton_OnClick(self, button, down)
  755.  
  756.     if (button == "RightButton") then
  757.  
  758.         if (IsShiftKeyDown()) then
  759.  
  760.             if (GDB.scriptProfile) then
  761.  
  762.                 SetCVar("scriptProfile", "0")
  763.                 GDB.scriptProfile = false
  764.             else
  765.  
  766.                 SetCVar("scriptProfile", "1")
  767.                 GDB.scriptProfile = true
  768.  
  769.             end
  770.  
  771.             ReloadUI()
  772.  
  773.         end
  774.  
  775.         if (not down) then
  776.  
  777.             if (self.alt_tooltip) then
  778.                 self.alt_tooltip = false
  779.             else
  780.                 self.alt_tooltip = true
  781.             end
  782.  
  783.             ION.LatencyButton_SetNormal()
  784.         else
  785.             ION.LatencyButton_SetPushed()
  786.         end
  787.  
  788.         ION.LatencyButton_OnEnter(self)
  789.  
  790.     elseif (IsShiftKeyDown()) then
  791.  
  792.         ReloadUI()
  793.  
  794.     else
  795.  
  796.         if (self.down) then
  797.             self.down = nil;
  798.             if (not GameMenuFrame:IsShown()) then
  799.                 CloseMenus()
  800.                 CloseAllWindows()
  801.                 PlaySound("igMainMenuOpen")
  802.                 ShowUIPanel(GameMenuFrame)
  803.             else
  804.                 PlaySound("igMainMenuQuit")
  805.                 HideUIPanel(GameMenuFrame)
  806.                 ION.LatencyButton_SetNormal()
  807.             end
  808.             if (InterfaceOptionsFrame:IsShown()) then
  809.                 InterfaceOptionsFrameCancel:Click()
  810.             end
  811.             return;
  812.         end
  813.         if (self:GetButtonState() == "NORMAL") then
  814.             ION.LatencyButton_SetPushed()
  815.             self.down = 1;
  816.         else
  817.  
  818.             self.down = 1;
  819.         end
  820.     end
  821. end
  822.  
  823. function ION.LatencyButton_OnUpdate(self, elapsed)
  824.  
  825.     self.elapsed = self.elapsed + elapsed
  826.  
  827.     if (self.elapsed > 2.5) then
  828.  
  829.         local r, g, rgbValue
  830.         local bandwidthIn, bandwidthOut, latency = GetNetStats()
  831.  
  832.         if (latency <= 1000) then
  833.             rgbValue = math.floor((latency/1000)*100)
  834.         else
  835.             rgbValue = 100
  836.         end
  837.  
  838.         if (rgbValue < 50) then
  839.             r=rgbValue/50; g=1-(rgbValue/100)
  840.         else
  841.             r=1; g=abs((rgbValue/100)-1)
  842.         end
  843.  
  844.         self.overlay:SetVertexColor(r, g, 0)
  845.  
  846.         if (self.hover) then
  847.             ION.LatencyButton_OnEnter(self)
  848.         end
  849.  
  850.         if (self.enabled) then
  851.  
  852.             UpdateAddOnCPUUsage()
  853.             UpdateAddOnMemoryUsage()
  854.  
  855.             self.lastUsage = self.currUsage or 0
  856.  
  857.             self.currUsage = GetScriptCPUUsage()
  858.  
  859.             self.usage = self.currUsage - self.lastUsage
  860.         end
  861.  
  862.         self.elapsed = 0
  863.     end
  864. end
  865.  
  866. function ION.LatencyButton_OnEnter(self)
  867.  
  868.     self.hover = 1
  869.  
  870.     if (self.alt_tooltip and not IonMenuBarTooltip.wasShown) then
  871.  
  872.         ION.LatencyButton_AltOnEnter(self)
  873.         IonMenuBarTooltip:AddLine("\nLatency Button by LedMirage of MirageUI")
  874.         GameTooltip:Hide()
  875.         IonMenuBarTooltip:Show()
  876.  
  877.     elseif (self:IsMouseOver()) then
  878.  
  879.         MainMenuBarPerformanceBarFrame_OnEnter(self)
  880.  
  881.         local objects = ION:GetParentKeys(GameTooltip)
  882.  
  883.         local foundion, text
  884.  
  885.         for k,v in pairs(objects) do
  886.             if (_G[v]:IsObjectType("FontString")) then
  887.                 text = _G[v]:GetText()
  888.                 if (text) then
  889.                     foundion = text:match("%s+Ion$")
  890.                 end
  891.             end
  892.         end
  893.  
  894.         if (not foundion) then
  895.             for i=1, GetNumAddOns() do
  896.                 if (select(1,GetAddOnInfo(i)) == "Ion") then
  897.                     local mem = GetAddOnMemoryUsage(i)
  898.                     if (mem > 1000) then
  899.                         mem = mem / 1000
  900.                     end
  901.                     GameTooltip:AddLine(format(ADDON_MEM_MB_ABBR, mem, select(1,GetAddOnInfo(i))), 1.0, 1.0, 1.0)
  902.                 end
  903.             end
  904.         end
  905.  
  906.         GameTooltip:AddLine("\nLatency Button by LedMirage of MirageUI")
  907.  
  908.         IonMenuBarTooltip:Hide()
  909.         GameTooltip:Show()
  910.     end
  911. end
  912.  
  913. function ION.LatencyButton_AltOnEnter(self)
  914.  
  915.     if (not IonMenuBarTooltip:IsVisible()) then
  916.         IonMenuBarTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE")
  917.     end
  918.  
  919.     if (self.enabled) then
  920.  
  921.         IonMenuBarTooltip:SetText("Script Profiling is |cff00ff00Enabled|r", 1, 1, 1)
  922.         IonMenuBarTooltip:AddLine("(Shift-RightClick to Disable)", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
  923.         IonMenuBarTooltip:AddLine("\n|cfff00000Warning:|r Script Profiling Affects Game Performance\n", 1, 1, 1, 1)
  924.  
  925.         for i=1, GetNumAddOns() do
  926.  
  927.             local name,_,_,enabled = GetAddOnInfo(i)
  928.  
  929.             if (not addonData[i]) then
  930.                 addonData[i] = { name = name, enabled = enabled }
  931.             end
  932.  
  933.             local addon = addonData[i]
  934.  
  935.             addon.currMem = GetAddOnMemoryUsage(i)
  936.  
  937.             if (not addon.maxMem or addon.maxMem < addon.currMem) then
  938.                 addon.maxMem = addon.currMem
  939.             end
  940.  
  941.             local currCPU = GetAddOnCPUUsage(i)
  942.  
  943.             if (addon.lastUsage) then
  944.  
  945.                 addon.currCPU = (currCPU - addon.lastUsage)/2.5
  946.  
  947.                 if (not addon.maxCPU or addon.maxCPU < addon.currCPU) then
  948.                     addon.maxCPU = addon.currCPU
  949.                 end
  950.             else
  951.                 addon.currCPU = currCPU
  952.             end
  953.  
  954.             if (self.usage > 0) then
  955.                 addon.percentCPU = addon.currCPU/self.usage * 100
  956.             else
  957.                 addon.percentCPU = 0
  958.             end
  959.  
  960.             addon.lastUsage = currCPU
  961.  
  962.             if (self.lastStart > 0) then
  963.                 addon.avgCPU = currCPU / self.lastStart
  964.             end
  965.         end
  966.  
  967.         if (self.usage) then
  968.             IonMenuBarTooltip:AddLine("|cffffffff("..format("%.2f",(self.usage) / 2.5).."ms)|r Total Script CPU Time\n", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
  969.         end
  970.  
  971.         wipe(sortData)
  972.  
  973.         for i,v in ipairs(addonData) do
  974.  
  975.             if (addonData[i].enabled) then
  976.  
  977.                 local addLine = ""
  978.  
  979.                 if (addonData[i].currCPU and addonData[i].currCPU > 0) then
  980.  
  981.                     addLine = addLine..format("%.2f", addonData[i].currCPU).."ms/"..format("%.1f", addonData[i].percentCPU).."%)|r "
  982.  
  983.                     local num = tonumber(addLine:match("^%d+"))
  984.  
  985.                     if (num and num < 10) then
  986.                         addLine = "0"..addLine
  987.                     end
  988.  
  989.                     if (addonData[i].name) then
  990.                         addLine = "|cffffffff("..addLine..addonData[i].name.." "
  991.                     end
  992.  
  993.                     tinsert(sortData, addLine)
  994.                 end
  995.             end
  996.         end
  997.  
  998.         sort(sortData, function(a,b) return a>b end)
  999.  
  1000.         for i,v in ipairs(sortData) do
  1001.             IonMenuBarTooltip:AddLine(v, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
  1002.         end
  1003.     else
  1004.  
  1005.         IonMenuBarTooltip:SetText("Script Profiling is |cfff00000Disabled|r", 1, 1, 1)
  1006.         IonMenuBarTooltip:AddLine("(Shift-RightClick to Enable)", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
  1007.         IonMenuBarTooltip:AddLine("\n|cfff00000Warning:|r Script Profiling Affects Game Performance\n", 1, 1, 1, 1)
  1008.     end
  1009. end
  1010.  
  1011. function ION.LatencyButton_OnLeave(self)
  1012.  
  1013.     if (GameTooltip:IsVisible()) then
  1014.         self.hover = nil
  1015.         GameTooltip:Hide()
  1016.     end
  1017. end
  1018.  
  1019. function ION.LatencyButton_SetPushed()
  1020.     IonLatencyButtonOverlay:SetPoint("CENTER", IonLatencyButton, "CENTER", -1, -2)
  1021. end
  1022.  
  1023. function ION.LatencyButton_SetNormal()
  1024.     IonLatencyButtonOverlay:SetPoint("CENTER", IonLatencyButton, "CENTER", 0, -0.5)
  1025. end
  1026.  
  1027. function ANCHOR:SetData(bar)
  1028.  
  1029.     if (bar) then
  1030.  
  1031.         self.bar = bar
  1032.  
  1033.         self:SetFrameStrata(bar.gdata.objectStrata)
  1034.         self:SetScale(bar.gdata.scale)
  1035.     end
  1036.  
  1037.     self:SetFrameLevel(4)
  1038. end
  1039.  
  1040. function ANCHOR:SaveData()
  1041.  
  1042.     -- empty
  1043.  
  1044. end
  1045.  
  1046. function ANCHOR:LoadData(spec, state)
  1047.  
  1048.     local id = self.id
  1049.  
  1050.     self.GDB = menubtnsGDB
  1051.     self.CDB = menubtnsCDB
  1052.  
  1053.     if (self.GDB and self.CDB) then
  1054.  
  1055.         if (not self.GDB[id]) then
  1056.             self.GDB[id] = {}
  1057.         end
  1058.  
  1059.         if (not self.GDB[id].config) then
  1060.             self.GDB[id].config = CopyTable(configData)
  1061.         end
  1062.  
  1063.         if (not self.CDB[id]) then
  1064.             self.CDB[id] = {}
  1065.         end
  1066.  
  1067.         if (not self.CDB[id].data) then
  1068.             self.CDB[id].data = {}
  1069.         end
  1070.  
  1071.         self.config = self.GDB [id].config
  1072.  
  1073.         self.data = self.CDB[id].data
  1074.     end
  1075. end
  1076.  
  1077. function ANCHOR:SetGrid(show, hide)
  1078.  
  1079.     --empty
  1080.  
  1081. end
  1082.  
  1083. function ANCHOR:SetAux()
  1084.  
  1085.     -- empty
  1086.  
  1087. end
  1088.  
  1089. function ANCHOR:LoadAux()
  1090.  
  1091.     -- empty
  1092.  
  1093. end
  1094.  
  1095. function ANCHOR:SetDefaults()
  1096.  
  1097.     -- empty
  1098.  
  1099. end
  1100.  
  1101. function ANCHOR:GetDefaults()
  1102.  
  1103.     --empty
  1104.  
  1105. end
  1106.  
  1107. function ANCHOR:SetType(save)
  1108.  
  1109.     if (menuElements[self.id]) then
  1110.  
  1111.         self:SetWidth(menuElements[self.id]:GetWidth()*0.90)
  1112.         self:SetHeight(menuElements[self.id]:GetHeight()/1.60)
  1113.         self:SetHitRectInsets(self:GetWidth()/2, self:GetWidth()/2, self:GetHeight()/2, self:GetHeight()/2)
  1114.  
  1115.         self.element = menuElements[self.id]
  1116.  
  1117.         local objects = ION:GetParentKeys(self.element)
  1118.  
  1119.         for k,v in pairs(objects) do
  1120.             local name = v:gsub(self.element:GetName(), "")
  1121.             self[name:lower()] = _G[v]
  1122.         end
  1123.  
  1124.         self.element.normaltexture = self.element:CreateTexture("$parentNormalTexture", "OVERLAY", "IonCheckButtonTextureTemplate")
  1125.         self.element.normaltexture:ClearAllPoints()
  1126.         self.element.normaltexture:SetPoint("CENTER", 0, 0)
  1127.         self.element.icontexture = self.element:GetNormalTexture()
  1128.         self.element:ClearAllPoints()
  1129.         self.element:SetParent(self)
  1130.         self.element:Show()
  1131.         self.element:SetPoint("BOTTOM", self, "BOTTOM", 0, -1)
  1132.         self.element:SetHitRectInsets(3, 3, 23, 3)
  1133.  
  1134.     end
  1135. end
  1136.  
  1137. local function controlOnEvent(self, event, ...)
  1138.  
  1139.     if (event == "ADDON_LOADED" and ... == "Ion-MenuBar") then
  1140.  
  1141.         hooksecurefunc("UpdateMicroButtons", updateMicroButtons)
  1142.  
  1143.         GDB = IonMenuGDB; CDB = IonMenuCDB
  1144.  
  1145.         for k,v in pairs(defGDB) do
  1146.             if (GDB[k] == nil) then
  1147.                 GDB[k] = v
  1148.             end
  1149.         end
  1150.  
  1151.         for k,v in pairs(defCDB) do
  1152.             if (CDB[k] == nil) then
  1153.                 CDB[k] = v
  1154.             end
  1155.         end
  1156.  
  1157.         menubarsGDB = GDB.menubars
  1158.         menubarsCDB = CDB.menubars
  1159.  
  1160.         menubtnsGDB = GDB.menubtns
  1161.         menubtnsCDB = CDB.menubtns
  1162.  
  1163.         ION:RegisterBarClass("menu", "Menu Bar", "Menu Button", menubarsGDB, menubarsCDB, MENUIndex, menubtnsGDB, "CheckButton", "IonAnchorButtonTemplate", { __index = ANCHOR }, #menuElements, false, STORAGE, gDef, nil, true)
  1164.  
  1165.         ION:RegisterGUIOptions("menu", { AUTOHIDE = true, SHOWGRID = false, SPELLGLOW = false, SNAPTO = true, DUALSPEC = false, HIDDEN = true, LOCKBAR = false, TOOLTIPS = true }, false, false)
  1166.  
  1167.         if (GDB.firstRun) then
  1168.  
  1169.             local bar, object = ION:CreateNewBar("menu", 1, true)
  1170.  
  1171.             for i=1,#menuElements do
  1172.                 object = ION:CreateNewObject("menu", i)
  1173.                 bar:AddObjectToList(object)
  1174.             end
  1175.  
  1176.             GDB.firstRun = false
  1177.  
  1178.         else
  1179.  
  1180.             for id,data in pairs(menubarsGDB) do
  1181.                 if (data ~= nil) then
  1182.                     ION:CreateNewBar("menu", id)
  1183.                 end
  1184.             end
  1185.  
  1186.             for id,data in pairs(menubtnsGDB) do
  1187.                 if (data ~= nil) then
  1188.                     ION:CreateNewObject("menu", id)
  1189.                 end
  1190.             end
  1191.         end
  1192.  
  1193.         STORAGE:Hide()
  1194.  
  1195.     elseif (event == "PLAYER_LOGIN") then
  1196.  
  1197.     elseif (event == "PLAYER_ENTERING_WORLD" and not PEW) then
  1198.  
  1199.         PEW = true
  1200.     end
  1201. end
  1202.  
  1203. local frame = CreateFrame("Frame", nil, UIParent)
  1204. frame:SetScript("OnEvent", controlOnEvent)
  1205. frame:RegisterEvent("ADDON_LOADED")
  1206. frame:RegisterEvent("PLAYER_LOGIN")
  1207. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement