WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   ToggleTalentFrame() / ToggleGlyphFrame() taint issue (https://www.wowinterface.com/forums/showthread.php?t=52107)

MunkDev 03-21-15 09:23 AM

ToggleTalentFrame() / ToggleGlyphFrame() taint issue
 
Hello, I'm trying to create a custom game menu and I'm having trouble with two buttons pertaining to the talent and glyph frames.

The taint issue comes from calling ToggleTalentFrame() and ToggleGlyphFrame() insecurely. Since these frames are not loaded by default, I can't use ToggleFrame() as I do with the Spellbook. My question is whether it's possible to actually open these frames with code without it blowing up in my face.

Edit: Here's the updated code:
Lua Code:
  1. local function ToggleTalentUI()
  2.     if not PlayerTalentFrame then
  3.         LoadAddOn("Blizzard_TalentUI");
  4.     end
  5.     ShowUIPanel(PlayerTalentFrame);
  6. end
  7.  
  8. local customButtons = {
  9.     {name = "Character",    title = "Character Info",   ClickFunc = ToggleCharacter,    arg = "PaperDollFrame"},
  10.     {name = "Spellbook",    title = "Spellbook",        ClickFunc = ToggleFrame,        arg = SpellBookFrame},
  11.     {name = "Talent",       title = "Specialization",   ClickFunc = ToggleTalentUI,     arg = nil},
  12.     {name = "Bag",          title = "Bags",             ClickFunc = ToggleAllBags,      arg = nil},
  13.     {name = "Achievement",  title = "Achievements",     ClickFunc = ToggleAchievementFrame, arg = nil},
  14.     {name = "QuestLog",     title = "Quest Log",        ClickFunc = ToggleQuestLog,     arg = nil},
  15.     {name = "LFD",          title = "Group Finder",     ClickFunc = PVEFrame_ToggleFrame, arg = nil},
  16.     {name = "PvP",          title = "PvP",              ClickFunc = TogglePVPUI,        arg = nil},
  17.     {name = "Collections",  title = "Collections",      ClickFunc = ToggleCollectionsJournal, arg = nil},
  18.     {name = "EJ",           title = "Dungeon Journal",  ClickFunc = ToggleEncounterJournal, arg = nil},
  19.     {name = "Garrison",     title = "Garrison Report",  ClickFunc = ToggleGarrisonReport, arg = nil},
  20.     {name = "Score",        title = "Score Screen",     ClickFunc = ToggleWorldStateScoreFrame, arg = nil},
  21.     {name = "Social",       title = "Social",           ClickFunc = ToggleFriendsFrame, arg = nil},
  22.     {name = "Guild",        title = "Guild",            ClickFunc = ToggleGuildFrame,   arg = nil},
  23. }
  24.  
  25. for i, btn in pairs(customButtons) do
  26.     local button = CreateFrame("BUTTON", "GameMenuButton"..btn.name, GameMenuFrame, "GameMenuButtonTemplate");
  27.     local anchor = customButtons[i-1] and customButtons[i-1].name or nil;
  28.     button:SetText(btn.title);
  29.     if anchor then
  30.         button:SetPoint("TOP", _G["GameMenuButton"..anchor], "BOTTOM", 0, -1);
  31.     else
  32.         button:SetPoint("TOPRIGHT", GameMenuFrame, "TOPRIGHT", -20, -20);
  33.     end
  34.     button:SetScript("OnClick", function(...)
  35.         ToggleFrame(GameMenuFrame);
  36.         btn.ClickFunc(btn.arg);
  37.     end);
  38.     table.insert(buttons, button);
  39. end
Here's what it ends up looking like atm.

10leej 03-21-15 10:16 AM

I use this in Click Menu for the talents, I don't call glyphs though.

Code:

if (not PlayerTalentFrame) then
LoadAddOn('Blizzard_TalentUI')
end

if (not GlyphFrame) then
  LoadAddOn('Blizzard_GlyphUI')
end

securecall(ToggleTalentFrame)


Clamsoda 03-21-15 10:21 AM

I know a decent way to avoid taint is to run the click method on any buttons that exist. You could run the click method on the micro menus' TalentMicroButton. You could then run the click method on the "Glyphs" tab.

Lua Code:
  1. TalentMicroButton:Click()

Lua Code:
  1. if (PlayerTalentFrame:IsShown()) then
  2.     PlayerTalentFrameTab3:Click()
  3. end

I know that doesn't help with load on demand issues, but it is a start.

Resike 03-21-15 10:25 AM

Lua Code:
  1. ShowUIPanel(PlayerTalentFrame) -- Always opens on the last used tab
  2. HideUIPanel(PlayerTalentFrame)
  3.  
  4. PlayerTalentFrame_Toggle(GetActiveSpecGroup()) -- 1 for primary 2 for secondary
  5.  
  6. PlayerTalentFrame_ToggleGlyphFrame(GetActiveSpecGroup()) -- 1 for primary 2 for secondary

MunkDev 03-21-15 10:30 AM

Resike: Your approach works for opening the talent frame, but using
Lua Code:
  1. PlayerTalentFrame_ToggleGlyphFrame(GetActiveSpecGroup())
seems to still cause the taint in the glyph frame.

The other solutions you guys provided cause full on taint, just like my original approach.

Edit: Maybe I should add I'm not clicking these with my mouse.

MunkDev 03-21-15 11:02 AM

Bah, I've decided against a dedicated Glyph button. It's not that necessary.
Thanks for the help everyone. :)

Resike 03-21-15 11:04 AM

Quote:

Originally Posted by MunkDev (Post 307676)
Bah, I've decided against a dedicated Glyph button. It's not that necessary.
Thanks for the help everyone. :)

Nononon, here you go:
Lua Code:
  1. function ToggleTalentTab(tabNumber)
  2.     if not PlayerTalentFrame or not PlayerTalentFrame:IsShown() then
  3.         GlyphFrame_LoadUI()
  4.         ShowUIPanel(PlayerTalentFrame)
  5.         PanelTemplates_SetTab(PlayerTalentFrame, tabNumber)
  6.         PlayerTalentFrame_HideTalentTab()
  7.         PlayerTalentFrame_HideSpecsTab()
  8.         PlayerTalentFrame_ShowGlyphFrame()
  9.         PlayerTalentFrame_HidePetSpecTab()
  10.     else
  11.         HideUIPanel(PlayerTalentFrame)
  12.     end
  13. end
  14.  
  15. -- To toggle tabs [1-4]
  16. ToggleTalentTab(3)

Edit: Made some changes should work for every tab now and it's toggleable.

MunkDev 03-21-15 11:10 AM

Quote:

Originally Posted by Resike (Post 307677)
Nononon, here you go:
Lua Code:
  1. function ToggleTalentTab(tabNumber)
  2.         if not PlayerTalentFrame:IsShown() then
  3.             GlyphFrame_LoadUI()
  4.             ShowUIPanel(PlayerTalentFrame)
  5.             PanelTemplates_SetTab(PlayerTalentFrame, tabNumber)
  6.             PlayerTalentFrame_HideTalentTab()
  7.             PlayerTalentFrame_HideSpecsTab()
  8.             PlayerTalentFrame_ShowGlyphFrame()
  9.             PlayerTalentFrame_HidePetSpecTab()
  10.         else
  11.                 HideUIPanel(PlayerTalentFrame)
  12.         end
  13. end
  14.  
  15. -- To show it [1-4] tabs
  16. ToggleTalentTab(3)

Lol. That actually works! Alright, I'll keep it. Haha. Thanks. :D

Resike 03-21-15 11:14 AM

Quote:

Originally Posted by MunkDev (Post 307678)
Lol. That actually works! Alright, I'll keep it. Haha. Thanks. :D

No problem, well we elminated an another nasty taint.

MunkDev 03-21-15 11:16 AM

This does work for the glyph frame, but it opens the glyph frame regardless of the tabnumber given!

Resike 03-21-15 11:44 AM

Quote:

Originally Posted by MunkDev (Post 307680)
This does work for the glyph frame, but it opens the glyph frame regardless of the tabnumber given!

Havn't really tested the last one through, but try this one:

Lua Code:
  1. function ToggleTalentTab(tabNumber)
  2.     if not PlayerTalentFrame then
  3.         LoadAddOn("Blizzard_TalentUI")
  4.     end
  5.     if not PlayerTalentFrame:IsShown() then
  6.         -- To prevent feral specs to pop up
  7.         if type(tabNumber) ~= "number" then
  8.             return
  9.         end
  10.         if tabNumber < 1 or tabNumber > 4 then
  11.             return
  12.         end
  13.         ShowUIPanel(PlayerTalentFrame)
  14.         PanelTemplates_SetTab(PlayerTalentFrame, tabNumber)
  15.         if tabNumber == 1 then
  16.             PlayerTalentFrame_ShowsSpecTab()
  17.             PlayerTalentFrame_HideTalentTab()
  18.             PlayerTalentFrame_HideGlyphFrame()
  19.             PlayerTalentFrame_HidePetSpecTab()
  20.         elseif tabNumber == 2 then
  21.             PlayerTalentFrame_HideSpecsTab()
  22.             PlayerTalentFrame_ShowTalentTab()
  23.             PlayerTalentFrame_HideGlyphFrame()
  24.             PlayerTalentFrame_HidePetSpecTab()
  25.             -- This is some serious real hack here
  26.             HideUIPanel(PlayerTalentFrame)
  27.             ShowUIPanel(PlayerTalentFrame)
  28.         elseif tabNumber == 3 then
  29.             GlyphFrame_LoadUI()
  30.             PlayerTalentFrame_HideTalentTab()
  31.             PlayerTalentFrame_HideSpecsTab()
  32.             PlayerTalentFrame_ShowGlyphFrame()
  33.             PlayerTalentFrame_HidePetSpecTab()
  34.         elseif tabNumber == 4 then
  35.             PlayerTalentFrame_HideTalentTab()
  36.             PlayerTalentFrame_HideSpecsTab()
  37.             PlayerTalentFrame_HideGlyphFrame()
  38.             PlayerTalentFrame_ShowPetSpecTab()
  39.         end
  40.     else
  41.         HideUIPanel(PlayerTalentFrame)
  42.     end
  43. end

Edit: Fixed a typo.

Lua Code:
  1. PlayerTalentFrame_ShowsSpecTab
  2. PlayerTalentFrame_HideSpecsTab

Seems like the show is only spec, while the hide function is specs.

This should work now properly.

The best thing if you call it without an argument 2-3 times then you can choose a feral spec. :P

evilbib 08-22-15 04:42 AM

Lua Code:
  1. PanelTemplates_SetTab(PlayerTalentFrame, tabNumber)

Actually this causes a taint if you want to remove talents (glyphs are working). Is there a way around?


All times are GMT -6. The time now is 05:02 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI