From ef9d77d7de7f6a166b8e890029646537caa74c7d Mon Sep 17 00:00:00 2001 From: urnati Date: Wed, 5 Dec 2018 22:08:39 -0500 Subject: [PATCH] Reduced the times setting / using IsUserPlaced on MainMenuBar. --- Titan/TitanMovable.lua | 123 ++++++++++++++++++++++++++---------------------- Titan/TitanPanel.lua | 17 +------ 2 files changed, 68 insertions(+), 72 deletions(-) diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua index 33d959d..871dc9c 100755 --- a/Titan/TitanMovable.lua +++ b/Titan/TitanMovable.lua @@ -50,6 +50,42 @@ hooksecurefunc(FrameRef, "SetPoint", function(self) end) --]] +--[[ local +NAME: DoAdjust +DESC: See if Titan should adjust based only on its own flags. +VAR: place - top or bottom +OUT: boolean - true to adjust, false if not +--]] +local function DoAdjust(place, force) + local res = false -- assume we will not adjust + -- force is passed to cover cases where the user has just deselected both top or bottom bars + -- When that happens we need to adjust + + -- We did it to ourselves - if (Aux)ScreenAdjust is true it means the user wants Titan to NOT adjust... + if place == TITAN_PANEL_PLACE_TOP then + if TitanPanelGetVar("ScreenAdjust") == 1 then + -- do not adjust + else + if force then + res = true + elseif TitanPanelGetVar("Bar_Show") or TitanPanelGetVar("Bar2_Show") then + res = true + end + end + elseif place == TITAN_PANEL_PLACE_BOTTOM then + if TitanPanelGetVar("AuxScreenAdjust") == 1 then + -- do not adjust + else + if force then + res = true + elseif TitanPanelGetVar("AuxBar_Show") or TitanPanelGetVar("AuxBar2_Show") then + res = true + end + end + end + return res +end + --[[ Titan NAME: TitanMovable_MenuBar_Disable DESC: Handle the main menu bar so Blizzard does not get upset. @@ -61,8 +97,11 @@ NOTE: :NOTE --]] function TitanMovable_MenuBar_Disable() - MainMenuBar:SetMovable(true); - MainMenuBar:SetUserPlaced(false); + if DoAdjust(TITAN_PANEL_PLACE_BOTTOM, false) then +--TitanPrint("TitanMovable_MenuBar_Disable - DoAdjust", "warning") + MainMenuBar:SetMovable(true); + MainMenuBar:SetUserPlaced(false); + end end --[[ Titan @@ -78,12 +117,16 @@ NOTE: :NOTE --]] function TitanMovable_MenuBar_Enable() - if InCombatLockdown() then + if InCombatLockdown() or UnitInVehicle("player") then -- wait until out of combat... + -- if player is in vehicle then do not set user is placed, + -- needed whether in taxi or other vehicle that may replace the main menu bar else - MainMenuBar:SetMovable(true); - MainMenuBar:SetUserPlaced(true); - MainMenuBar:SetMovable(false); + if DoAdjust(TITAN_PANEL_PLACE_BOTTOM, false) then + MainMenuBar:SetMovable(true); + MainMenuBar:SetUserPlaced(true); + MainMenuBar:SetMovable(false); + end end end @@ -182,42 +225,6 @@ local function TitanMovableFrame_GetXOffset(frame, point) end --[[ local -NAME: DoAdjust -DESC: See if Titan should adjust based only on its own flags. -VAR: place - top or bottom -OUT: boolean - true to adjust, false if not ---]] -local function DoAdjust(place, force) - local res = false -- assume we will not adjust - -- force is passed to cover cases where the user has just deselected both top or bottom bars - -- When that happens we need to adjust - - -- We did it to ourselves - if (Aux)ScreenAdjust is true it means the user wants Titan to NOT adjust... - if place == TITAN_PANEL_PLACE_TOP then - if TitanPanelGetVar("ScreenAdjust") == 1 then - -- do not adjust - else - if force then - res = true - elseif TitanPanelGetVar("Bar_Show") or TitanPanelGetVar("Bar2_Show") then - res = true - end - end - elseif place == TITAN_PANEL_PLACE_BOTTOM then - if TitanPanelGetVar("AuxScreenAdjust") == 1 then - -- do not adjust - else - if force then - res = true - elseif TitanPanelGetVar("AuxBar_Show") or TitanPanelGetVar("AuxBar2_Show") then - res = true - end - end - end - return res -end - ---[[ local NAME: SetPosition DESC: Adjust a given frame with the passed in values. VAR: frame - Text string of the frame name @@ -538,7 +545,21 @@ Then update the chat and open bag frames. OUT: None --]] local function TitanMovableFrame_MoveFrames(force) - local move_count = 0 + local move_count = 0 -- debug + --[[ + Setting the MainMenuBar as user placed is needed because in 8.0.0 Blizzard changed something in the + way they controlled the frame. With Titan panel and bottom bars enabled the MainMenuBar + would 'bounce'. Figuring out the true root cause was a bust. + This idea of user placed came from a Titan user who is an addon developer. + However setting user placed causes the main menu bar to not act as we desire due to the way Blizzard coded the bar. + For now we will try to minimize the side effects... + + Later Titan checks rely on the user placed flag so it needs to be set early. + --]] + if DoAdjust(TITAN_PANEL_PLACE_BOTTOM, force) then + TitanMovable_MenuBar_Enable() + end + if not InCombatLockdown() then for i = 1,#MData,1 do if MData[i] then @@ -582,14 +603,14 @@ end --[[ Titan NAME: TitanPanel_AdjustFrames DESC: Adjust the frames for the Titan visible bars. -This is a shell for the actual Movable routine by other Titan routines and used by hooks +This is a shell for the actual Movable routine used by other Titan routines and secure hooks OUT: None NOTE: :NOTE --]] 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 + -- such as when the user has just de/selected top or bottom bars local f = force or false -- do not require the parameter -- Adjust frame positions top and bottom based on user choices @@ -635,18 +656,6 @@ NOTE: :NOTE --]] function TitanMovable_SecureFrames() - --[[ - Setting the MainMenuBar as user placed 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 the true root cause was a bust. - This fix idea came from a Titan user who is an addon developer. Although it seems a bit of a hack. - - Later Titan checks rely on the user placed flag so it needs to be set early. - --]] - MainMenuBar:SetMovable(true); - MainMenuBar:SetUserPlaced(true); - MainMenuBar:SetMovable(false); - if not TitanPanelAce:IsHooked("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) then TitanPanelAce:SecureHook("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) -- FloatingChatFrame end diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua index ab3eff7..2cf7c96 100644 --- a/Titan/TitanPanel.lua +++ b/Titan/TitanPanel.lua @@ -421,8 +421,8 @@ function TitanPanel_PlayerEnteringWorld() Titan__InitializedPEW = true -- Move frames - TitanPanel_AdjustFrames() TitanMovable_SecureFrames() + TitanPanel_AdjustFrames() -- Secondary failsafe check for bottom frame adjustment -- @@ -524,9 +524,6 @@ function TitanPanelBarButton:PLAYER_REGEN_DISABLED() end function TitanPanelBarButton:PLAYER_REGEN_ENABLED() - -- Needed because 8.0 made changes to the menu bar processing (see TitanMovable) - TitanMovable_MenuBar_Enable() - -- Outside combat check to see if frames need correction TitanPanel_AdjustFrames() end @@ -536,8 +533,6 @@ function TitanPanelBarButton:ACTIVE_TALENT_GROUP_CHANGED() end function TitanPanelBarButton:UNIT_ENTERED_VEHICLE(self, ...) ---TitanPrint("UNIT_ENTERED_VEHICLE - ", "warning") - -- If in combat close all control frames and menus TitanUtils_CloseAllControlFrames(); TitanUtils_CloseRightClickMenu(); @@ -545,16 +540,8 @@ function TitanPanelBarButton:UNIT_ENTERED_VEHICLE(self, ...) TitanMovable_MenuBar_Disable() end function TitanPanelBarButton:UNIT_EXITED_VEHICLE(self, ...) - -- Needed because 8.0 made changes to the menu bar processing (see TitanMovable) - if InCombatLockdown() then ---TitanPrint("UNIT_EXITED_VEHICLE - nyl", "warning") - else ---TitanPrint("UNIT_EXITED_VEHICLE - enable", "warning") - TitanMovable_MenuBar_Enable() - end - -- A combat check will be done inside the adjust - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(true) end --]] -- -- 1.7.9.5