View Single Post
03-29-21, 08:24 AM   #9
yess
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 29
Originally Posted by Xrystal View Post
If you want to catch changes to combat mode to apply settings before combat
No that is not what I want.

Originally Posted by Xrystal View Post
PLAYER_REGEN_DISABLED may trigger after UNIT_ENTERING_VEHICLE or before. Similarly PLAYER_REGEN_ENABLED may trigger before UNIT_EXITING_VEHICLE or after.
You misunderstood. Yes these events can fire after you entered and vehicle if your combat status changes.
The interesting part is that they trigger EVERY time when you enter a vehicle DURING a combat situation.

So the sequence of of the events when entering a vehicle is:

Player not in combat:
UNIT_ENTERING_VEHICLE
UNIT_ENTERED_VEHICLE

Player pulls and after that enters a vehicle:

PLAYER_REGEN_DISABLED <-- player pulled
UNIT_ENTERING_VEHICLE
PLAYER_REGEN_ENABLED --> this here caused my function MoveAndLockMainMenuBar() (called by a timer), to occasionally set MainMenuBar:SetUserPlaced(true) as InCombatLockDown() and UnitInVehicle("Player") booth returns false! In this stage!
PLAYER_REGEN_DISABLED
UNIT_ENTERED_VEHICLE
...
UNIT_EXITING_VEHICLE
... --blizzards code repositions the MainMenuBar and it breaks due to MainMenuBar:SetUserPlaced(true)
UNIT_EXITED_VEHICLE
PLAYER_REGEN_ENABLED (combat actually ended and we are not in a vehicle) --> MoveAndLockMainMenuBar()

Originally Posted by Xrystal View Post
Not too much helpful but they may be events you hadn't considered before.
Yeah, I ended up using UNIT_EXITING_VEHICLE to unlock the action bar:

Code:
function ChocolateBar:UNIT_EXITING_VEHICLE()
	MainMenuBar:SetMovable(true)
	MainMenuBar:SetUserPlaced(false)
	MainMenuBar:SetMovable(false)
end

-- between these events blizzards code will reposition the MainMenuBar
-- and as SetUserPlaced is false, it will not break 

function ChocolateBar:UNIT_EXITED_VEHICLE()
        -- MoveAndLockMainMenuBar()
        -- this will schedule the repositioning and check every n seconds if combat has ended and it is save to move the bar again
	self:Refresh(MainMenuBar, PlayerFrame) 
end
The downside is that until combat ends the action bar (MainMenuBar) will continue to be positioned wrong (bottom at the screen above the bottom ChocolateBar).

Easy fix for my initial problem but what a headache to find this out
  Reply With Quote