WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Old method of frame placement no longer working. (https://www.wowinterface.com/forums/showthread.php?t=44088)

suicidalkatt 09-01-12 02:48 AM

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.

zork 09-01-12 03:12 AM

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.

suicidalkatt 09-01-12 03:44 AM

Quote:

Originally Posted by zork (Post 261675)
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)

zork 09-01-12 04:51 AM

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.

suicidalkatt 09-01-12 05:11 AM

Quote:

Originally Posted by zork (Post 261695)
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)

zork 09-01-12 05:50 AM

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)

suicidalkatt 09-01-12 06:08 AM

Quote:

Originally Posted by zork (Post 261702)
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?

zork 09-01-12 06:21 AM

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)

suicidalkatt 09-01-12 06:59 AM

Quote:

Originally Posted by zork (Post 261707)
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 :)

Phanx 09-01-12 07:39 PM

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...

suicidalkatt 09-02-12 12:37 AM

Quote:

Originally Posted by Phanx (Post 261847)
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".

zork 09-02-12 02:50 AM

Can you post your final code?

suicidalkatt 09-02-12 03:58 AM

Quote:

Originally Posted by zork (Post 261896)
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.


All times are GMT -6. The time now is 03:26 AM.

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