WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   StatusTrackingBarManager (https://www.wowinterface.com/forums/showthread.php?t=59116)

Vurse 04-30-22 10:10 AM

StatusTrackingBarManager
 
Is there a simple code I could add to my addon that prevents the StatusTrackingBar (Honor Bar, EXP Bar, Rep Bar etc, StatusTrackingBarManager controls all of these I believe) from moving the action bars and stance buttons without having to reanchor everything to UI Parent and stuff. I've also tried UnregisterAllEvents which seemed to work but when the bar updated (combat etc) it broke

Xrystal 05-03-22 12:57 PM

An existing addon ? Probably one of the action bar addons maybe has something. Otherwise ...

Looking at the blizzard code it looks like the MainMenuBar is also doing something to put things back.

https://www.townlong-yak.com/framexm...ainMenuBar.lua
https://www.townlong-yak.com/framexm...ingManager.lua

StatusTrackingManagerMixin:UpdateBarsShown is executed after any statusbar event is triggered
StatusTrackingManagerMixin:LayoutBars(visBars) is called at the end of that function
which calls self:GetParent():OnStatusBarsUpdated() which is MainMenuBarMixin:OnStatusBarsUpdated()
which then calls MainMenuBarMixin:SetPositionForStatusBars()

LayoutBars essentially repositions the bars in line with their parents position which by default is the MainMenuBar. So outside of re-parenting and dealing with any issues arising outside of that you might be able to hook into StatusTrackingManagerMixin:LayoutBar(bar, barWidth, isTopBar, isDouble) and reset the layout of each bar as you wish it to be.

I haven't played with mixin overriding to know if it is possible though.

SDPhantom 05-03-22 05:18 PM

Quote:

Originally Posted by Xrystal (Post 340591)
LayoutBars essentially repositions the bars in line with their parents position which by default is the MainMenuBar. So outside of re-parenting and dealing with any issues arising outside of that you might be able to hook into StatusTrackingManagerMixin:LayoutBar(bar, barWidth, isTopBar, isDouble) and reset the layout of each bar as you wish it to be.

Not completely true. The repositioning is further down the line at MainMenuBarMixin:SetPositionForStatusBars(). It queries StatusTrackingBarManager:GetNumberVisibleBars() and sets .yOffset accordingly. UIParent_ManageFramePositions() (frontend for FramePositionDelegate:UIParentManageFramePositions()) reads .yOffset and is the one responsible for moving the frame. This process is susceptible to taint, so manipulating .yOffset will throw errors in combat.

It is possible to stop this by nuking MainMenuBarMixin:SetPositionForStatusBars(). As MainMenuBar is already instantiated, changing MainMenuBarMixin won't do anything. You'll have to modify MainMenuBar:SetPositionForStatusBars() instead.
Code:

MainMenuBar.SetPositionForStatusBars=function() end;


Note UIParent_ManageFramePositions() will still try to move MainMenuBar whenever any other part of the UI calls it. Since MainMenuBarMixin:SetPositionForStatusBars() would no longer be changing .yOffset, it'll always snap the the same spot. If you want to set your own anchor, the code block at UIParent.lua:3340 allows bypassing this by setting MainMenuBar as user-placed.
Lua Code:
  1. MainMenuBar:SetMovable(true);-- Required for :SetUserPlaced()
  2. MainMenuBar:SetUserPlaced(true);--  Set user-placed flag

While :SetMovable() does allow dragging frames and sizing them, this doesn't happen unless :StartMoving() or :StartSizing() is called. This doesn't happen for MainMenuBar.

Vurse 05-16-22 06:52 AM

Thank you both for the help, the snippets you provided SDPhantom worked. Thank you so much again I think I was trying to overcomplicate it.. but then again the WoW API is somewhat a mess at least to me. <3

Also this is what I use now and it seems to work perfectly.

Lua Code:
  1. MainMenuBar:SetMovable(true); --Required for :SetUserPlaced()
  2. MainMenuBar:SetUserPlaced(true); --Set user-placed flag
  3. MainMenuBar.SetPositionForStatusBars=function() end;
  4. StatusTrackingBarManager:Hide()


All times are GMT -6. The time now is 04:52 PM.

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