Thread Tools Display Modes
Unread 07-11-12, 03:48 AM   #1
Miiru
A Wyrmkin Dreamwalker
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 53
Weird parenting Problem

Code:
local function Border(arg1,arg2,arg3,arg4,arg5,arg6)
local f = CreateFrame("Frame", "nil", arg1)
f:SetSize(arg2, arg3)
f:SetPoint(arg4,arg5,arg6 )
f:SetBackdrop({
bgFile = "",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border_blue.blp",
edgeSize = 14,
})
f:SetBackdropColor(0, 0, 0, 0)
f:SetBackdropBorderColor(1, 1, 1)	
end


local frame = CreateFrame("FRAME");
frame:RegisterEvent("ADDON_LOADED")
function frame:OnEvent(event, arg1)

if event == "ADDON_LOADED" and arg1 == "Blizzard_TalentUI" then
child1,child2 = PlayerTalentFrameSpecializationSpellScrollFrameScrollChildAbility1:GetRegions();
child1:Hide()
child2:SetTexCoord(0.85, 0.15, 0.15, 0.85)
Border(PlayerTalentFrameSpecializationSpellScrollFrameScrollChildAbility1,58,58,"Center",0,0)
		
end
end


frame:SetScript("OnEvent", frame.OnEvent);
works just fine, however if i try to do the same with PlayerTalentFrameSpecializationSpellScrollFrameScrollChildAbility2, 3 or 4 it throws me a attempt to index global error.

I took a look at the Blizzard-TalentUi.lua but couldnt find anything that makes those different from the first one :S

After opening the window, i can hide that specific frame just fine with /run :Hide() so i guess it's registered after the first one?
Attached Thumbnails
Click image for larger version

Name:	bleh2.png
Views:	373
Size:	428.9 KB
ID:	7030  
__________________
LFGFrame.lua - Line 596-597
--Since time applies for all players, no reason to display it once for each.
--We may have to change this if we let players group with their past selves via time travel.

Last edited by Miiru : 07-11-12 at 03:53 AM.
Miiru is offline  
Unread 07-11-12, 10:39 AM   #2
Meorawr
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 193
The frames don't exist until PlayerTalentFrame_CreateSpecSpellButton is called with the ability index as the second argument.

Hook that function when ADDON_LOADED fires for Blizzard_TalentUI and then parent whatever you need to the created frame within the hook.
Meorawr is offline  
Unread 07-11-12, 11:31 AM   #3
Miiru
A Wyrmkin Dreamwalker
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 53
Sounds complicated :| Never worked with hooking functions...

edit: It looks like i somehow got it together. Thanks

I managed to parent a border to the Frame, now whats left is hiding the one child and the settexcoords stuff
__________________
LFGFrame.lua - Line 596-597
--Since time applies for all players, no reason to display it once for each.
--We may have to change this if we let players group with their past selves via time travel.

Last edited by Miiru : 07-11-12 at 11:39 AM.
Miiru is offline  
Unread 07-11-12, 11:38 AM   #4
Meorawr
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 193
Example code, this'll set the scale of spec buttons 2-<whatever the limit is> to be twice as large.

Lua Code:
  1. local f = CreateFrame("Frame");
  2. f:RegisterEvent("ADDON_LOADED");
  3. f:SetScript("OnEvent", function(self, event, arg1)
  4.       -- These are not the addons you're looking for.
  5.       if(event ~= "ADDON_LOADED"
  6.       or arg1 ~= "Blizzard_TalentUI") then
  7.          return;
  8.       end
  9.       -- Hook function.
  10.       hooksecurefunc("PlayerTalentFrame_CreateSpecSpellButton", function(frame, index)
  11.             -- Determine the name of the created frame.
  12.             local scrollChild = frame.spellsScroll.child;
  13.             local name = scrollChild:GetName() .. "Ability" .. index;
  14.             local button = _G[name];
  15.             -- And now do what you need with the button!
  16.             print(button);
  17.             button:SetScale(2.0);
  18.       end);
  19.       -- In addition, note that SpellSpecButton1 SHOULD exist when the hook is already in place. So you'll need to do stuff to it now as well.
  20. end);

Edit: Oh, you figured it out. Damn it
Meorawr is offline  
Unread 07-11-12, 11:45 AM   #5
Miiru
A Wyrmkin Dreamwalker
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 53
Ok i got it to work now, you're my hero

And i learned something new ^.^
__________________
LFGFrame.lua - Line 596-597
--Since time applies for all players, no reason to display it once for each.
--We may have to change this if we let players group with their past selves via time travel.
Miiru is offline  
 

Go BackWoWInterface » WoD Beta » MoP archived threads » Weird parenting Problem

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