Thread Tools Display Modes
09-01-12, 02:48 AM   #1
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
DurabilityFrame SetPoint Hook to reparent

So, previous in 4.3 I was using a simple hooksecurefunc to "SetPoint" for the DurabilityFrame to allow me to set a custom point for the frame.

For some reason unknown to me this method no longer works and there has been 0 changes to the durability frame.

My Code:
Lua Code:
  1. local function UpdatePoint()
  2.     DurabilityFrame:ClearAllPoints()
  3.     DurabilityFrame:SetPoint("TOPRIGHT",Minimap,"BOTTOMLEFT",-20,-20)
  4. end
  5.  
  6. hooksecurefunc(DurabilityFrame,"SetPoint",function(self,_,parent)
  7.     if (parent == "MinimapCluster") or (parent == _G["MinimapCluster"]) then
  8.         UpdatePoint()
  9.     end
  10. end)
  11.  
  12. tinsert(TUSUI.Updaters, UpdatePoint)

Can anyone point me as to what is preventing me from updating the point correctly?

Edit: Just to make this clear, the function UpdatePoint() is getting called and my global table insert is just to make sure it gets called again after my addon is loaded.

Last edited by suicidalkatt : 09-02-12 at 04:54 AM.
  Reply With Quote
09-01-12, 03:12 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
If you add print() debugs. Does the function get called twice on loadup like you say?
Is the parent element still the MinimapCluster?

If I do
Lua Code:
  1. /run print(DurabilityFrame:GetParent():GetName())
I get UIParent. (Which is correct because the parent in FrameXML\DurablityFrame.xml is UIParent)

If I had to do sth like this the first thing I do is to get the latest FrameXML files.
I then use TotalCommander (Windows) and to a text-search (Alt+F7) in the FrameXML folder for the string "DurabilityFrame".

The only occurence of DurabilityFrame:SetPoint is in UIParent.lua.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 09-01-12 at 03:28 AM.
  Reply With Quote
09-01-12, 03:44 AM   #3
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by zork View Post
If you add print() debugs. Does the function get called twice on loadup like you say?
Is the parent element still the MinimapCluster?

If I do
Lua Code:
  1. /run print(DurabilityFrame:GetParent():GetName())
I get UIParent. (Which is correct because the parent in FrameXML\DurablityFrame.xml is UIParent)

If I had to do sth like this the first thing I do is to get the latest FrameXML files.
I then use TotalCommander (Windows) and to a text-search (Alt+F7) in the FrameXML folder for the string "DurabilityFrame".

The only occurence of DurabilityFrame:SetPoint is in UIParent.lua.
Yes it does get called twice on load up with print("DurabilityFrame SetPoint hooked / updated"). Regardless once SetPoint is hooked should it not always update from that point? I don't see how it's getting reparented, I even added SetParent(Minimap) still doesn't matter.

Edit: DurabilityFrame.lua also has a few lines of SetPoint without a parent frame labeled, also Minimap is the parent for the frame in the DurabilityFrame.xml which still seems strange that UIParent is being set.

Edit 2: I have 010 Editor (total boss text / hex editor)

Last edited by suicidalkatt : 09-01-12 at 03:47 AM.
  Reply With Quote
09-01-12, 04:51 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
In my FrameXML\DurabilityFrame.xml the parent is UIParent.
https://github.com/Ketho/wow-ui-sour...tyFrame.xml#L4

Have you tried:
Lua Code:
  1. DurabilityFrame.ignoreFramePositionManager = true

In the XML at the bottom the frame position manager is called "OnShow". Setting the ignore value may help.
Additionally enabling SetUserPlaced(true), SetMovable(true) can help sometimes too.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 09-01-12 at 04:54 AM.
  Reply With Quote
09-01-12, 05:11 AM   #5
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by zork View Post
In my FrameXML\DurabilityFrame.xml the parent is UIParent.
https://github.com/Ketho/wow-ui-sour...tyFrame.xml#L4

Have you tried:
Lua Code:
  1. DurabilityFrame.ignoreFramePositionManager = true

In the XML at the bottom the frame position manager is called "OnShow". Setting the ignore value may help.
Additionally enabling SetUserPlaced(true), SetMovable(true) can help sometimes too.
I had no knowledge of the UIParent_ManageFramePosition funciton. TIL.

Still doesn't let me change its point. I'm really clueless at this point as to what is preventing it's placement from changing.

Lua Code:
  1. local function UpdatePoint()
  2.     DurabilityFrame.ignoreFramePositionManager = true
  3.     DurabilityFrame:SetMovable(true)
  4.     DurabilityFrame:SetUserPlaced(true)
  5.     DurabilityFrame:ClearAllPoints()
  6.     DurabilityFrame:SetParent(Minimap)
  7.     DurabilityFrame:SetPoint("LEFT",Minimap,"LEFT",-20,-20)
  8.     print("DurabilityFrame Point Updated")
  9. end
  10.  
  11. hooksecurefunc(DurabilityFrame,"SetPoint",function(self,_,parent)
  12.     if (parent == "MinimapCluster") or (parent == _G["MinimapCluster"]) then
  13.         UpdatePoint()
  14.     end
  15. end)
  16.  
  17. tinsert(TUSUI.Updaters, UpdatePoint)
  Reply With Quote
09-01-12, 05:50 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
This works for me:
Lua Code:
  1. local frame = CreateFrame("Frame", "rMM_DurabilityDragFrame", UIParent)
  2.   frame:SetSize(DurabilityFrame:GetWidth(),DurabilityFrame:GetHeight())
  3.   frame:SetPoint("CENTER",0,0)
  4.   --frame:SetPoint(DurabilityFrame:GetPoint())
  5.   --rCreateDragFrame(frame, dragFrameList, -2 , true) --frame, dragFrameList, inset, clamp
  6.   DurabilityFrame:SetParent(frame)
  7.   DurabilityFrame:SetAllPoints(frame)
  8.   hooksecurefunc(DurabilityFrame, "SetPoint", function(...)
  9.     DurabilityFrame:SetAllPoints(frame)
  10.   end)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
09-01-12, 06:08 AM   #7
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by zork View Post
This works for me:
(snip)
That seems to work for me as well.

Interesting that you'd have to go that route to be able to place it in a different location.

Is there some handling of the Minimap children I'm not aware of?
  Reply With Quote
09-01-12, 06:21 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
No your problem is the condition inside the hook function. Just print all the ... variables and you will find out why. You don't need another surrounding frame. You just have to fix the condition. Make sure not to get into a loophole.

Lua Code:
  1. --hook
  2. hooksecurefunc(DurabilityFrame, "SetPoint", function(...)
  3.   local a, b, c, d, e = ...
  4.   print(a)
  5.   print(b)
  6.   print(c)
  7.   print(d)
  8.   print(e)
  9.   --DurabilityFrame:SetPoint()--make sure to only call this if needed
  10. end)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 09-01-12 at 06:25 AM.
  Reply With Quote
09-01-12, 06:59 AM   #9
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by zork View Post
No your problem is the condition inside the hook function. Just print all the ... variables and you will find out why. You don't need another surrounding frame. You just have to fix the condition. Make sure not to get into a loophole.

-snip
I see now... Makes sense. Thank you for your time Zork I appreciate it
  Reply With Quote
09-01-12, 07:39 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
There seem to be an awful lot of threads popping up recently about moving the DurabilityFrame... why don't you guys just look at addons that already do it successfully (SmoothDurability, for one), instead of trying to reinvent the wheel? It took me about 90 seconds (at most) of looking at its code to figure out how to move the frame...
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-02-12, 12:37 AM   #11
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by Phanx View Post
There seem to be an awful lot of threads popping up recently about moving the DurabilityFrame... why don't you guys just look at addons that already do it successfully (SmoothDurability, for one), instead of trying to reinvent the wheel? It took me about 90 seconds (at most) of looking at its code to figure out how to move the frame...
I wanted to see the reasoning behind my own old method and what was causing the issue. Perhaps reinventing the wheel may not always be the best / fastest solution, but it certainly has helped me learn a few things rather than say "oh that works".
  Reply With Quote
09-02-12, 02:50 AM   #12
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Can you post your final code?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
09-02-12, 03:58 AM   #13
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by zork View Post
Can you post your final code?
Lua Code:
  1. local function UpdatePoint()
  2.     DurabilityFrame.ignoreFramePositionManager = true
  3.     DurabilityFrame:ClearAllPoints()
  4.     DurabilityFrame:SetParent(Minimap)
  5.     DurabilityFrame:SetPoint("TOPRIGHT",Minimap,"BOTTOMLEFT",-20,-20)
  6. end
  7.  
  8. hooksecurefunc(DurabilityFrame,"SetPoint",function(self,_,parent)
  9.     if parent ~= _G["Minimap"] then
  10.         UpdatePoint()
  11.     end
  12. end)
  13.  
  14. tinsert(TUSUI.Updaters, UpdatePoint)

Edit: I had to wrap this into a frame and run the hook after "PLAYER_ENTERING_WORLD" to prevent some strange WoW client crash.

Last edited by suicidalkatt : 09-02-12 at 08:22 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Old method of frame placement no longer working.

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