Thread Tools Display Modes
01-27-18, 04:40 PM   #1
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
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?
  Reply With Quote
01-27-18, 04:54 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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).
  Reply With Quote
01-27-18, 05:00 PM   #3
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
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.
  Reply With Quote
01-27-18, 05:30 PM   #4
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
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

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.

Last edited by Ammako : 01-27-18 at 05:35 PM.
  Reply With Quote
01-27-18, 06:07 PM   #5
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
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)

Last edited by tehmoku : 01-27-18 at 10:25 PM.
  Reply With Quote
01-27-18, 06:54 PM   #6
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
This frame is protected, so this would only be possible outside of combat. Not sure if that's the problem you're facing here.
__________________
  Reply With Quote
01-27-18, 07:01 PM   #7
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
Originally Posted by MunkDev View Post
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.

Last edited by tehmoku : 01-27-18 at 07:34 PM.
  Reply With Quote
01-28-18, 06:12 AM   #8
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
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.

Last edited by Resike : 01-28-18 at 06:14 AM.
  Reply With Quote
01-28-18, 07:27 AM   #9
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
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.
__________________
| 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
01-28-18, 08:04 AM   #10
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
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.

Last edited by Resike : 01-28-18 at 08:08 AM.
  Reply With Quote
01-28-18, 10:23 AM   #11
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 309
Originally Posted by Resike View Post
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!
__________________
AddOns: Tim @ WoWInterface
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
01-28-18, 11:30 AM   #12
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
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

Last edited by tehmoku : 01-28-18 at 11:59 AM. Reason: Accuracy
  Reply With Quote
01-28-18, 11:35 AM   #13
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by tehmoku View Post
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?
  Reply With Quote
01-28-18, 11:36 AM   #14
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
Originally Posted by Resike View Post
Does that happens with every other addon disabled too?
Yes, just mine and bugsack were loaded.

Last edited by tehmoku : 01-28-18 at 11:55 AM.
  Reply With Quote
01-28-18, 02:01 PM   #15
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
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.

Last edited by Resike : 01-28-18 at 02:16 PM.
  Reply With Quote
07-03-18, 10:50 PM   #16
clicket
A Deviate Faerie Dragon
 
clicket's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2018
Posts: 12
Any updates on this?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Moving Boss1TargetFrame without taint


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