Quantcast

Fix for main menu bar not working when exitting a vehicle while staying in combat.

urnati [11-24-18 - 21:15]
Fix for main menu bar not working when exitting a vehicle while staying in combat.
Filename
Titan/TitanMovable.lua
diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua
index 5768519..7311183 100755
--- a/Titan/TitanMovable.lua
+++ b/Titan/TitanMovable.lua
@@ -181,6 +181,46 @@ local function DoAdjust(place, force)
 end

 --[[ local
+NAME: SetPosition
+DESC: Adjust a given frame with the passed in values.
+VAR: frame - Text string of the frame name
+VAR: ... - list of frame position info
+NOTE:
+Swiped from Vrul on wowinterface forum
+
+Setting the MainMenuBar was needed because in 8.0.0 Blizzard changed something in the
+way they controlled the frame. With Titan panel and bottom bars the MainMenuBar
+would 'bounce'. Figuring out what the root cause was a bust.
+This fix of setting user placed came from a Titan user.
+
+The table UIPARENT_MANAGED_FRAME_POSITIONS does not hold all Blizzard frames.
+It is cleared for each frame in case the frame is in or might be in the table in the future.
+:NOTE
+--]]
+local function SetPosition(frame, ...)
+    if type(frame) == 'string' then
+        UIPARENT_MANAGED_FRAME_POSITIONS[frame] = nil
+        frame = _G[frame]
+    end
+    if type(frame) == 'table' and type(frame.IsObjectType) == 'function' and frame:IsObjectType('Frame') then
+        local name = frame:GetName()
+        if name then
+            UIPARENT_MANAGED_FRAME_POSITIONS[name] = nil
+        end
+        frame:SetMovable(true)          -- allow frame to move
+        frame:SetUserPlaced(true)       -- tell Blizzard to back off
+        frame:SetDontSavePosition(true)
+        frame:SetAttribute('ignoreFramePositionManager', true)
+        frame.ignoreFramePositionManager = true
+        if ... then
+            frame:ClearAllPoints()
+            frame:SetPoint(...)
+        end
+        frame:SetMovable(false)         -- lock frame from moving
+    end
+end
+
+--[[ local
 NAME: MoveFrame
 DESC: Adjust the given frame. Expected are frames where :GetPoint works
 VAR: frame_ptr - Text string of the frame name
@@ -233,7 +273,6 @@ local function MoveMenuFrame(frame_ptr, start_y, top_bottom, force)
 		elseif ( StatusTrackingBarManager:GetNumberVisibleBars() == 1 ) then
 			yOffset = yOffset + 14;
 		end
-		frame:ClearAllPoints();
 		-- This is a hack because GetPoint on MainMenuBar often returns all nil
 		-- If the scale is is around .85 or higher the bag menu overlaps the main menu
 		local fscale = tonumber(GetCVar("uiScale"))
@@ -244,7 +283,9 @@ local function MoveMenuFrame(frame_ptr, start_y, top_bottom, force)
 			-- Slide the menu bar left depending on scaling to allow bag menu room
 			xOfs = xadj * 6 * -1
 		end
-		frame:SetPoint("BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset);
+--		frame:ClearAllPoints();
+--		frame:SetPoint("BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset);
+		SetPosition(frame, "BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset)
 		adj = true
 	else
 		-- Unknown frame...
@@ -458,13 +499,13 @@ function TitanMovable_AddonAdjust(frame, bool)
 	end
 end

---[[ Titan
+--[[ local
 NAME: TitanMovableFrame_MoveFrames
 DESC: Loop through MData calling each frame's 'move' function for each Titan controlled frame.
 Then update the chat and open bag frames.
 OUT: None
 --]]
-function TitanMovableFrame_MoveFrames(force)
+local function TitanMovableFrame_MoveFrames(force)
 	local move_count = 0
 	if not InCombatLockdown() then
 		for i = 1,#MData,1 do
@@ -518,7 +559,13 @@ function TitanPanel_AdjustFrames(force)
 	-- force is passed to cover cases where Titan should always adjust
 	-- such as when the user has just deselected both top or bottom bars
 	local f = force or false -- do not require the parameter
-
+if InCombatLockdown() then
+TitanDebug("_AdjustFrames"
+.." "..tostring(ActionBarBusy())
+.." MMB:"..tostring(MainMenuBar:IsShown())
+.." OAB:"..tostring(OverrideActionBar:IsShown())
+, "warning")
+end
 	-- Adjust frame positions top and bottom based on user choices
 	TitanMovableFrame_MoveFrames(f)
 end
@@ -581,16 +628,6 @@ function TitanMovable_SecureFrames()
 		TitanPanelAce:SecureHook("UpdateContainerFrameAnchors", Titan_ContainerFrames_Relocate) -- ContainerFrame.lua
 		TitanPanelAce:SecureHook(WorldMapFrame.BorderFrame.MaximizeMinimizeFrame.MinimizeButton, "Show", TitanPanel_AdjustFrames) -- WorldMapFrame.lua

-		--[[
-		Setting the MainMenuBar was needed because in 8.0.0 Blizzard changed something in the
-		way they controlled the frame. With Titan panel and bottom bars the MainMenuBar
-		would 'bounce'. Figuring out what the root cause was a bust.
-		This fix came from a Titan user.
-		--]]
-		MainMenuBar:SetMovable(true);
-		MainMenuBar:SetUserPlaced(true);
-		MainMenuBar:SetMovable(false);
-
 		TitanPanelAce:SecureHook("OrderHall_CheckCommandBar", TitanPanel_AdjustFrames)
 	end

@@ -604,3 +641,9 @@ function TitanMovable_SecureFrames()
 		TitanPanelAce:SecureHook(VideoOptionsFrame, "Hide", Titan_AdjustUIScale) -- VideoOptionsFrame.xml
 	end
 end
+function TitanMovable_Unhook_SecureFrames()
+--[[
+This is a debug attempt to fix an issue when a player is dumped from a vehicle while still in combat.
+--]]
+	TitanPanelAce:UnhookAll()
+end