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

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


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