WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Moving Boss1TargetFrame without taint (https://www.wowinterface.com/forums/showthread.php?t=56004)

tehmoku 01-27-18 04:40 PM

Moving Boss1TargetFrame without taint
 
So here's the entirety of my bossframe code

Lua Code:
  1. --[Bossframe scale]
  2. for i = 1, MAX_BOSS_FRAMES do
  3.     local f = _G["Boss"..i.."TargetFrame"]
  4.     f:SetParent(UIParent)
  5.     f:SetScale(1.2)
  6. end
  7.  
  8. --[Lower the gaps]
  9. for i = 2, MAX_BOSS_FRAMES do
  10.     _G["Boss"..i.."TargetFrame"]:SetPoint("TOPLEFT", _G["Boss"..(i-1).."TargetFrame"], "BOTTOMLEFT", 0, 20)
  11. end
  12.  
  13. --[Bossframe castbars]
  14. hooksecurefunc("Target_Spellbar_AdjustPosition", function()
  15.     for i = 1, MAX_BOSS_FRAMES do
  16.         local b = _G["Boss"..i.."TargetFrameSpellBar"]
  17.         b:SetPoint("TOPLEFT", "Boss"..i.."TargetFrame", "BOTTOMLEFT", -10, 29)
  18.     end
  19. end)
  20.  
  21. --[Set Points]
  22. Boss1TargetFrame:ClearAllPoints()
  23. Boss1TargetFrame:SetPoint("TOPRIGHT",UIParent,"TOPRIGHT",-350,-470)
  24. Boss1TargetFrame.SetPoint = function() end

Obviously what matters is the
Lua Code:
  1. Boss1TargetFrame.SetPoint = function() end

I have tried
Lua Code:
  1. hooksecurefunc("UIParent_ManageFramePositions",function()

with no success.

Lua Code:
  1. -- Boss frames - need to move below buffs/debuffs if both right action bars are showing
  2.     local numBossFrames = 0;
  3.     for i = 1, MAX_BOSS_FRAMES do
  4.         if ( _G["Boss"..i.."TargetFrame"]:IsShown() ) then
  5.             numBossFrames = i;
  6.         end
  7.     end
  8.     if ( numBossFrames > 0 ) then
  9.         if ( rightActionBars > 1 ) then
  10.             anchorY = min(anchorY, buffsAnchorY);
  11.         end
  12.         Boss1TargetFrame:SetPoint("TOPRIGHT", "MinimapCluster", "BOTTOMRIGHT", -(CONTAINER_OFFSET_X * 1.3) + 60, anchorY * 1.333);  -- by 1.333 because it's 0.75 scale
  13.         anchorY = anchorY - (numBossFrames * (68 + BOSS_FRAME_CASTBAR_HEIGHT) + BOSS_FRAME_CASTBAR_HEIGHT);
  14.     end

This is what I could find in UIParent.lua regarding SetPoint for boss1.

Anyway, my question is: does anyone have a way to move Boss1TargetFrame and keep it moved without massively tainting everything?

Kanegasi 01-27-18 04:54 PM

Boss1TargetFrame.SetPoint = function() end is what is causing taints. You cannot replace anything protected without tainting.

It looks like all you're doing is just moving and scaling frames. Use MoveAnything for that (link goes to curse, the upload here at WoWI hasn't been updated since 2011).

tehmoku 01-27-18 05:00 PM

Yep, all I'm doing is moving and scaling. I'm not interested in getting another addon to do that though, if I'm able to do that via my own. Thanks though.

Ammako 01-27-18 05:30 PM

Wouldn't you just be able to do

lua Code:
  1. hooksecurefunc(Boss1TargetFrame, "SetPoint", function()
  2.     Boss1TargetFrame:SetPoint("TOPRIGHT",UIParent,"TOPRIGHT",-350,-470)
  3. end)

Though you might need a workaround like here, if you don't want it to just keep recursively calling itself (might make the game crash?):
https://us.battle.net/forums/en/wow/...9273821#post-5

Quote:

One way to do it is to do a hooksecurefunc(ReputationWatchBar,"SetPoint",func). This will securely call func whenever anything does a ReputationWatchBar:SetPoint(). But since we want to do a SetPoint in this hook itself, we need to be careful it doesn't trigger itself indefinitely. Like this:

lua Code:
  1. hooksecurefunc(ReputationWatchBar,"SetPoint",function(self,_,_,_,_,_,flag)
  2.   if flag~="mbars" then
  3.     self:ClearAllPoints()
  4.     if level==100 then
  5.       self:SetPoint("BOTTOMLEFT",ActionButton1,"TOPLEFT",0,0,"mbars")
  6.     else
  7.       self:SetPoint("BOTTOMLEFT",MultiBarBottomLeftButton1,"TOPLEFT",0,0,"mbars")
  8.     end
  9.   end
  10. end)

Now whenever ReputationWatchBar:SetPoint() happens in the default UI (or another addon), this addon will immediately SetPoint again, passing the "mbars" flag (can be anything, something unique that only this addon knows about) so it knows not to do another SetPoint in response to this SetPoint.
This is for a different frame but I imagine it'd be the same concept.

tehmoku 01-27-18 06:07 PM

Yeah, I have tried this:
Lua Code:
  1. local t
  2. hooksecurefunc(Boss1TargetFrame, "SetPoint", function(self)
  3.     if t then
  4.         return
  5.     end
  6.     t = true
  7.     self:ClearAllPoints()
  8.     self:SetPoint("TOPRIGHT",UIParent,"TOPRIGHT",-310,-510)
  9.     t = nil
  10. end)
which tosses a protected function error

Also trying this for the sake of it, even though they do the same thing:

Lua Code:
  1. hooksecurefunc(Boss1TargetFrame, "SetPoint", function(self,_,_,_,_,_,flag)
  2.     if flag ~= "mbars" then
  3.         self:ClearAllPoints()
  4.         self:SetPoint("TOPRIGHT",UIParent,"TOPRIGHT",-310,-510,"mbars")
  5.     end
  6. end)

And it throws the same error.

EDIT:

I may have been a bit hasty. It looks like those do function as you would expect, but the frame still moves at almost any type of event in combat (changing actionbars for instance). I'm hoping this isn't a case of "tough shit," as I sometimes have to reload or change actionbars in the middle of boss fights. (I am testing by sitting in RFC on the first boss, and haven't been exiting combat between reloads until now)

MunkDev 01-27-18 06:54 PM

This frame is protected, so this would only be possible outside of combat. Not sure if that's the problem you're facing here.

tehmoku 01-27-18 07:01 PM

Quote:

Originally Posted by MunkDev (Post 326656)
This frame is protected, so this would only be possible outside of combat. Not sure if that's the problem you're facing here.

I move a few other protected frames securely though (BuffFrame comes to mind) which stays put in between reloads and events regardless of my combat state. I was hoping that bossframes would do the same--is there no way to keep the frame locked to a certain position when in combat without tainting everything?

With the current code I'm able to move it before combat starts, but it doesn't stay put in combat and reverts to the original location.

Resike 01-28-18 06:12 AM

This is the Uganadan wai my bratha:

Lua Code:
  1. local b = _G.Boss1TargetFrame
  2. b:SetMovable(true)
  3. b:SetUserPlaced(true)
  4. b:ClearAllPoints()
  5. b:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -350, -470)
  6. b:SetMovable(false)
  7.  
  8. local moving
  9. hooksecurefunc(Boss1TargetFrame, "SetPoint", function(self)
  10.     if moving then
  11.         return
  12.     end
  13.     moving = true
  14.     self:SetMovable(true)
  15.     self:SetUserPlaced(true)
  16.     self:ClearAllPoints()
  17.     self:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -350, -470)
  18.     self:SetMovable(false)
  19.     moving = nil
  20. end)

Only call it once at ADDON_LOADED my queen.

zork 01-28-18 07:27 AM

What Resike wrote is the correct.
You can set any Blizzard frame to userplaced/movable. It will ignore any point other then the user placed point.

I do this in rLib. https://github.com/zorker/rothui/blo...gframe.lua#L87

That is how I am able to repoint/resize frames like the ObjectiveTracker or the TalkingHead.
https://github.com/zorker/rothui/blo...r/core.lua#L30
https://github.com/zorker/rothui/blo...d/core.lua#L29

It may be needed to add the ignoreFramePositionManager value.

Resike 01-28-18 08:04 AM

For protected frames i don't think using .ignoreFramePositionManager = true is a good idea, since the whole point of the SetUserPlaced(true) call is to fake that the SetPoint was called by Blizzard code, so there is no chance left for any kind of tainting to happen.

But it's really hard to test this in this current "open the worldmap in combat and shit gets tainted" environment.

Tim 01-28-18 10:23 AM

Quote:

Originally Posted by Resike (Post 326665)
For protected frames i don't think using .ignoreFramePositionManager = true is a good idea, since the whole point of the SetUserPlaced(true) call is to fake that the SetPoint was called by Blizzard code, so there is no chance left for any kind of tainting to happen.

But it's really hard to test this in this current "open the worldmap in combat and shit gets tainted" environment.

Yeah I absolutely hate that bug. I have my ui disable errors when worldmap is opened and then enable them upon closing. Blizzard, fix yo sheet!

tehmoku 01-28-18 11:30 AM

Here is the error I get with Resike's code (and also the position resets) when I swap actionbars in combat.

Code:

1x [ADDON_ACTION_BLOCKED] AddOn '!mUI' tried to call the protected function 'Boss1TargetFrame:ClearAllPoints()'.
!BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
[C]: in function `ClearAllPoints'
!mUI\Bossframes.lua:37: in function <!mUI\Bossframes.lua:30>
[C]: in function `SetPoint'
FrameXML\UIParent.lua:2913: in function `UIParentManageFramePositions'
FrameXML\UIParent.lua:2212: in function <FrameXML\UIParent.lua:2199>
[C]: in function `SetAttribute'
FrameXML\UIParent.lua:2964: in function `UIParent_ManageFramePositions'
FrameXML\ActionBarController.lua:178: in function `ValidateActionBarTransition'
FrameXML\ActionBarController.lua:145: in function `ActionBarController_UpdateAll'
FrameXML\ActionBarController.lua:64: in function <FrameXML\ActionBarController.lua:53>
[C]: in function `ChangeActionBarPage'
FrameXML\ChatFrame.lua:1228: in function `?'
FrameXML\ChatFrame.lua:4527: in function `ChatEdit_ParseText'
FrameXML\ChatFrame.lua:4215: in function `ChatEdit_SendText'
FrameXML\ChatFrame.lua:2767: in function <FrameXML\ChatFrame.lua:2760>

Locals:
InCombatSkipped


Resike 01-28-18 11:35 AM

Quote:

Originally Posted by tehmoku (Post 326669)
Here is the error I get with Resike's code (and also the position resets) when I swap actionbars in combat.

Code:

1x [ADDON_ACTION_BLOCKED] AddOn '!mUI' tried to call the protected function 'Boss1TargetFrame:ClearAllPoints()'.
!BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
[C]: in function `ClearAllPoints'
!mUI\Bossframes.lua:37: in function <!mUI\Bossframes.lua:30>
[C]: in function `SetPoint'
FrameXML\UIParent.lua:2913: in function `UIParentManageFramePositions'
FrameXML\UIParent.lua:2212: in function <FrameXML\UIParent.lua:2199>
[C]: in function `SetAttribute'
FrameXML\UIParent.lua:2964: in function `UIParent_ManageFramePositions'
FrameXML\ActionBarController.lua:178: in function `ValidateActionBarTransition'
FrameXML\ActionBarController.lua:145: in function `ActionBarController_UpdateAll'
FrameXML\ActionBarController.lua:64: in function <FrameXML\ActionBarController.lua:53>
[C]: in function `ChangeActionBarPage'
FrameXML\ChatFrame.lua:1228: in function `?'
FrameXML\ChatFrame.lua:4527: in function `ChatEdit_ParseText'
FrameXML\ChatFrame.lua:4215: in function `ChatEdit_SendText'
FrameXML\ChatFrame.lua:2767: in function <FrameXML\ChatFrame.lua:2760>

Locals:
InCombatSkipped


Does that happens with every other addon disabled too?

tehmoku 01-28-18 11:36 AM

Quote:

Originally Posted by Resike (Post 326670)
Does that happens with every other addon disabled too?

Yes, just mine and bugsack were loaded.

Resike 01-28-18 02:01 PM

I think the problem is that some boss frames get created in combat, so you can't do much about this, just to hide the original boss frames and create your own versions with "BossTargetFrameTemplate", that you create on addon load.

clicket 07-03-18 10:50 PM

Any updates on this?


All times are GMT -6. The time now is 11:09 PM.

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