Quantcast

- Config to reloadui on selecting do not adjust screen

urnati [10-15-18 - 00:14]
- Config to reloadui on selecting do not adjust screen
- Panel changes to support Config
- Movable changes to support Config
Filename
Titan/TitanConfig.lua
Titan/TitanMovable.lua
Titan/TitanPanel.lua
diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua
index f219c2c..cba44d3 100644
--- a/Titan/TitanConfig.lua
+++ b/Titan/TitanConfig.lua
@@ -60,7 +60,7 @@ local function TitanAdjustPanelScale(scale)
 	TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true)
 end

--- About config section
+-- helper functions
 --[[ local
 NAME: TitanPanel_TicketReload
 DESC: When the user changes the option to adjust for the Blizz ticket frame the UI must be reloaded. Ask the user if they want to do it now.
@@ -74,7 +74,7 @@ local function TitanPanel_TicketReload()
 		button1 = ACCEPT,
 		button2 = CANCEL,
 		OnAccept = function(self)
-			TitanPanelToggleVar("TicketAdjust");
+			TitanPanelBarButton_ToggleScreenAdjust()
 			ReloadUI();
 			end,
 		showAlert = 1,
@@ -85,6 +85,54 @@ local function TitanPanel_TicketReload()
 	StaticPopup_Show("TITAN_RELOAD");
 end

+local function TitanPanel_ScreenAdjustReload()
+	if TitanPanelGetVar("ScreenAdjust") then
+		-- if set then clear it - the screen will adjust
+		TitanPanelBarButton_ToggleScreenAdjust()
+	else
+		-- if NOT set then need a reload - the screen will NOT adjust
+		StaticPopupDialogs["TITAN_RELOAD"] = {
+			text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n"
+				..L["TITAN_PANEL_RELOAD"],
+			button1 = ACCEPT,
+			button2 = CANCEL,
+			OnAccept = function(self)
+				TitanPanelToggleVar("ScreenAdjust");
+				ReloadUI();
+				end,
+			showAlert = 1,
+			timeout = 0,
+			whileDead = 1,
+			hideOnEscape = 1
+		};
+		StaticPopup_Show("TITAN_RELOAD");
+	end
+end
+local function TitanPanel_AuxScreenAdjustReload()
+	if TitanPanelGetVar("AuxScreenAdjust") then
+		-- if set then clear it - the screen will adjust
+		TitanPanelBarButton_ToggleAuxScreenAdjust()
+	else
+		-- if NOT set then need a reload - the screen will NOT adjust
+		StaticPopupDialogs["TITAN_RELOAD"] = {
+			text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]).."\n\n"
+				..L["TITAN_PANEL_RELOAD"],
+			button1 = ACCEPT,
+			button2 = CANCEL,
+			OnAccept = function(self)
+				TitanPanelToggleVar("AuxScreenAdjust");
+				ReloadUI();
+--				TitanPanelBarButton_ToggleAuxScreenAdjust();
+				end,
+			showAlert = 1,
+			timeout = 0,
+			whileDead = 1,
+			hideOnEscape = 1
+		};
+		StaticPopup_Show("TITAN_RELOAD");
+	end
+end
+
 -------------
 -- skins config section
 --[[ local
@@ -730,7 +778,7 @@ local optionsBars = {
 			desc = L["TITAN_PANEL_MENU_DISABLE_PUSH"],
 			order = 301, type = "toggle", width = "full",
 			get = function() return TitanPanelGetVar("ScreenAdjust") end,
-			set = function() TitanPanelBarButton_ToggleScreenAdjust(); end,
+			set = function() TitanPanel_ScreenAdjustReload() end,
 		},
 		optionminimap = {
 			name = L["TITAN_PANEL_MENU_DISABLE_MINIMAP_PUSH"],
@@ -844,7 +892,7 @@ local optionsAuxBars = {
 			desc = L["TITAN_PANEL_MENU_DISABLE_PUSH"],
 			order = 301, type = "toggle", width = "full",
 			get = function() return TitanPanelGetVar("AuxScreenAdjust") end,
-			set = function() TitanPanelBarButton_ToggleAuxScreenAdjust(); end,
+			set = function() TitanPanel_AuxScreenAdjustReload(); end,
 		},
 		optionlog = {
 			name = L["TITAN_PANEL_MENU_DISABLE_LOGS"],
diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua
index 36fde90..407716d 100755
--- a/Titan/TitanMovable.lua
+++ b/Titan/TitanMovable.lua
@@ -150,15 +150,19 @@ 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)
+local function DoAdjust(place, force)
 	local res = false -- assume we will not adjust
-	-- This is more work than it should be but Titan uses nil or true to be 'true' for these flags
+	-- force is passed to cover cases where the user has just deselected both top or bottom bars
+	-- When that happens we need to still 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 TitanPanelGetVar("Bar_Show") or TitanPanelGetVar("Bar2_Show") then
+			if force then
+				res = true
+			elseif TitanPanelGetVar("Bar_Show") or TitanPanelGetVar("Bar2_Show") then
 				res = true
 			end
 		end
@@ -166,7 +170,9 @@ local function DoAdjust(place)
 		if TitanPanelGetVar("AuxScreenAdjust") == 1 then
 			-- do not adjust
 		else
-			if TitanPanelGetVar("AuxBar_Show") or TitanPanelGetVar("AuxBar2_Show") then
+			if force then
+				res = true
+			elseif TitanPanelGetVar("AuxBar_Show") or TitanPanelGetVar("AuxBar2_Show") then
 				res = true
 			end
 		end
@@ -181,7 +187,7 @@ VAR: frame_ptr - Text string of the frame name
 VAR: start_y - Any offset due to the specific frame
 OUT: top_bottom - Frame is at top or bottom, expecting Titan constant for top or bottom
 --]]
-local function MoveFrame(frame_ptr, start_y, top_bottom)
+local function MoveFrame(frame_ptr, start_y, top_bottom, force)
 	local frame = _G[frame_ptr]
 	local adj = false
 	if frame and (frame:IsUserPlaced()
@@ -190,7 +196,7 @@ local function MoveFrame(frame_ptr, start_y, top_bottom)
 	then
 		-- skip this frame
 	else
-		if DoAdjust(top_bottom) and frame:IsShown() then
+		if DoAdjust(top_bottom, force) and frame:IsShown() then
 			local y = TitanMovable_GetPanelYOffset(top_bottom) + (start_y or 0) -- includes scale adjustment
 			local point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint()
 			frame:ClearAllPoints();
@@ -212,13 +218,13 @@ VAR: frame_ptr - Text string of the frame name
 VAR: start_y - Any offset due to the specific frame
 OUT: top_bottom - Frame is at top or bottom, expecting Titan constant for top or bottom
 --]]
-local function MoveMenuFrame(frame_ptr, start_y, top_bottom)
+local function MoveMenuFrame(frame_ptr, start_y, top_bottom, force)
 	local frame = _G[frame_ptr]
 	local adj = false
 	if frame and (frame:IsUserPlaced()
 			or frame.MALockPointHook  -- Allow MoveAnything to be used w/o error
 		)
-		and DoAdjust(top_bottom)
+		and DoAdjust(top_bottom, force)
 	then
 		local yOffset = TitanMovable_GetPanelYOffset(top_bottom) -- includes scale adjustment
 --		xOffset = TitanMovableFrame_GetXOffset(frame, top_bottom);
@@ -364,19 +370,19 @@ NOTE:
 --]]
 local MData = {
 	[1] = {frameName = "PlayerFrame",
-		move = function () MoveFrame("PlayerFrame", 0, TITAN_PANEL_PLACE_TOP) end,
+		move = function (force) MoveFrame("PlayerFrame", 0, TITAN_PANEL_PLACE_TOP, force) end,
 		addonAdj = false, },
 	[2] = {frameName = "TargetFrame",
-		move = function () MoveFrame("TargetFrame", 0, TITAN_PANEL_PLACE_TOP) end,
+		move = function (force) MoveFrame("TargetFrame", 0, TITAN_PANEL_PLACE_TOP, force) end,
 		addonAdj = false, },
 	[3] = {frameName = "PartyMemberFrame1",
-		move = function () MoveFrame("PartyMemberFrame1", 20, TITAN_PANEL_PLACE_TOP) end,
+		move = function (force) MoveFrame("PartyMemberFrame1", 20, TITAN_PANEL_PLACE_TOP, force) end,
 		addonAdj = false, },
 	[4] = {frameName = "TicketStatusFrame",
-		move = function () MoveFrame("TicketStatusFrame", 0, TITAN_PANEL_PLACE_TOP) end,
+		move = function (force) MoveFrame("TicketStatusFrame", 0, TITAN_PANEL_PLACE_TOP, force) end,
 		addonAdj = false, },
 	[5] = {frameName = "BuffFrame",
-		move = function ()
+		move = function (force)
 			-- properly adjust buff frame(s) if GM Ticket is visible

 			-- Use IsShown rather than IsVisible. In some cases (after closing
@@ -389,30 +395,30 @@ local MData = {
 			else
 				yOffset = -13
 			end
-			MoveFrame("BuffFrame", yOffset, TITAN_PANEL_PLACE_TOP) end,
+			MoveFrame("BuffFrame", yOffset, TITAN_PANEL_PLACE_TOP, force) end,
 		addonAdj = false, },
 	[6] = {frameName = "MinimapCluster",
-		move = function ()
+		move = function (force)
 			local yOffset = 0
 			if MinimapBorderTop
 			and not MinimapBorderTop:IsShown() then
 				yOffset = yOffset + (MinimapBorderTop:GetHeight() * 3/5) - 5
 			end
-			MoveFrame("MinimapCluster", yOffset, TITAN_PANEL_PLACE_TOP) end,
+			MoveFrame("MinimapCluster", yOffset, TITAN_PANEL_PLACE_TOP, force) end,
 		addonAdj = false, },
 	[7] = {frameName = "MultiBarRight",
-		move = function ()
-			MoveFrame("MultiBarRight", 0, TITAN_PANEL_PLACE_BOTTOM) end,
+		move = function (force)
+			MoveFrame("MultiBarRight", 0, TITAN_PANEL_PLACE_BOTTOM, force) end,
 		addonAdj = false, },
 	[8] = {frameName = "OverrideActionBar",
-		move = function () MoveFrame("OverrideActionBar", 0, TITAN_PANEL_PLACE_BOTTOM) end,
+		move = function (force) MoveFrame("OverrideActionBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end,
 		addonAdj = false, },
 	[9] = {frameName = "MicroButtonAndBagsBar",
-		move = function () MoveFrame("MicroButtonAndBagsBar", 0, TITAN_PANEL_PLACE_BOTTOM) end,
+		move = function (force) MoveFrame("MicroButtonAndBagsBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end,
 		addonAdj = false, },
 	[10] = {frameName = "MainMenuBar", -- MainMenuBar
-		move = function ()
-			MoveMenuFrame("MainMenuBar", 0, TITAN_PANEL_PLACE_BOTTOM) end,
+		move = function (force)
+			MoveMenuFrame("MainMenuBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end,
 		addonAdj = false, },
 --]]
 }
@@ -458,7 +464,7 @@ DESC: Loop through MData calling each frame's 'move' function for each Titan con
 Then update the chat and open bag frames.
 OUT: None
 --]]
-local function TitanMovableFrame_MoveFrames()
+local function TitanMovableFrame_MoveFrames(force)
 	local move_count = 0
 	if not InCombatLockdown() then
 		for i = 1,#MData,1 do
@@ -467,7 +473,7 @@ local function TitanMovableFrame_MoveFrames()
 					-- An addon has taken control of the frame so skip
 				else
 					-- Adjust the frame per MData
-					MData[i].move()
+					MData[i].move(force)
 --[[
 					local ok, msg = pcall(function () MData[i].move() end)
 					if ok then
@@ -508,9 +514,13 @@ OUT:  None
 NOTE:
 :NOTE
 --]]
-function TitanPanel_AdjustFrames()
-	-- Adjust frame positions top and bottom
-	TitanMovableFrame_MoveFrames()
+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
+
+	-- Adjust frame positions top and bottom based on user choices
+	TitanMovableFrame_MoveFrames(f)
 end

 --[[ Titan
@@ -535,7 +545,8 @@ function Titan_AdjustScale()
 				, TITAN_PANEL_PLACE_TOP);
 		end

-		TitanPanelBarButton_DisplayBarsWanted()
+		TitanMovableFrame_MoveFrames()
+--		TitanPanelBarButton_DisplayBarsWanted()
 		TitanPanel_RefreshPanelButtons();
 	end
 end
@@ -563,8 +574,8 @@ function TitanMovable_SecureFrames()
 		TitanPanelAce:SecureHook(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml
 		TitanPanelAce:SecureHook(TicketStatusFrame, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml
 		TitanPanelAce:SecureHook("TargetFrame_Update", TitanPanel_AdjustFrames) -- TargetFrame.lua
-		TitanPanelAce:SecureHook(MainMenuBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml
-		TitanPanelAce:SecureHook(MainMenuBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml
+--		TitanPanelAce:SecureHook(MainMenuBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml
+--		TitanPanelAce:SecureHook(MainMenuBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml
 		TitanPanelAce:SecureHook(OverrideActionBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml
 		TitanPanelAce:SecureHook(OverrideActionBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml
 		TitanPanelAce:SecureHook("UpdateContainerFrameAnchors", Titan_ContainerFrames_Relocate) -- ContainerFrame.lua
@@ -579,6 +590,8 @@ function TitanMovable_SecureFrames()
 		MainMenuBar:SetMovable(true);
 		MainMenuBar:SetUserPlaced(true);
 		MainMenuBar:SetMovable(false);
+
+		TitanPanelAce:SecureHook("OrderHall_CheckCommandBar", TitanPanel_AdjustFrames)
 	end

 	if not TitanPanelAce:IsHooked("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) then
diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua
index 22267ba..d691a3d 100644
--- a/Titan/TitanPanel.lua
+++ b/Titan/TitanPanel.lua
@@ -370,7 +370,7 @@ function TitanPanel_PlayerEnteringWorld()
 		elseif TitanGetVar(TITAN_CLOCK_ID, "Format") then
 			ServerHourFormat[realmName] = TitanGetVar(TITAN_CLOCK_ID, "Format")
 		end
-
+
 		-- Check to see if we should kill off the OrderHallCommandBar
 		if not TitanAllGetVar("OrderHall") then
 			local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanelOHCB", "AceHook-3.0")
@@ -387,6 +387,7 @@ function TitanPanel_PlayerEnteringWorld()
 			local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanelOHCB", "AceHook-3.0")
 			TitanPanelAce:Unhook("OrderHall_CheckCommandBar")
 		end
+
 	end
 	local _ = nil
 	TitanSettings.Player,_,_ = TitanUtils_GetPlayer()
@@ -420,7 +421,7 @@ function TitanPanel_PlayerEnteringWorld()
 	Titan__InitializedPEW = true

 	-- Move frames
-	TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true)
+	TitanPanel_AdjustFrames()
 	TitanMovable_SecureFrames()

 	-- Secondary failsafe check for bottom frame adjustment
@@ -498,7 +499,7 @@ function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue)
 		if TitanPlayerSettings and TitanPanelGetVar("Scale") then
 			Titan_AdjustScale()
 			-- Adjust frame positions
-			TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true)
+			TitanPanel_AdjustFrames()
 		end
 	end
 end
@@ -524,7 +525,7 @@ end

 function TitanPanelBarButton:PLAYER_REGEN_ENABLED()
 	-- Outside combat check to see if frames need correction
-	TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true)
+	TitanPanel_AdjustFrames()
 end

 function TitanPanelBarButton:ACTIVE_TALENT_GROUP_CHANGED()
@@ -532,10 +533,13 @@ function TitanPanelBarButton:ACTIVE_TALENT_GROUP_CHANGED()
 end

 function TitanPanelBarButton:UNIT_ENTERED_VEHICLE(self, ...)
-	TitanMovable_AdjustTimer("Vehicle")
+	-- If in combat close all control frames and menus
+	TitanUtils_CloseAllControlFrames();
+	TitanUtils_CloseRightClickMenu();
 end
 function TitanPanelBarButton:UNIT_EXITED_VEHICLE(self, ...)
-	TitanMovable_AdjustTimer("Vehicle")
+	-- A combat check will be done inside the adjust
+	TitanPanel_AdjustFrames()
 end
 --
 function TitanPanelBarButton:PET_BATTLE_OPENING_START()
@@ -544,9 +548,8 @@ function TitanPanelBarButton:PET_BATTLE_OPENING_START()
 	TitanPanelBarButton_HideAllBars()
 end
 function TitanPanelBarButton:PET_BATTLE_CLOSE()
---	TitanDebug("Pet_battle end: ")
-	-- Show the bars the user had selected
-	TitanPanelBarButton_DisplayBarsWanted()
+	-- A combat check will be done inside the adjust
+	TitanPanel_AdjustFrames()
 end
 --
 --
@@ -691,7 +694,7 @@ local function handle_reset_cmds(cmd_list)
 			-- Adjust panel scale
 			Titan_AdjustScale()
 			-- Adjust frame positions
-			TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true)
+			TitanPanel_AdjustFrames()
 			TitanPrint(L["TITAN_PANEL_SLASH_RESP3"], "info")
 		else
 			TitanPrint(L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"], "warning")
@@ -1126,7 +1129,7 @@ NOTE:
 function TitanPanelBarButton_ToggleScreenAdjust()
 	-- Turn on / off adjusting of other frames around Titan
 	TitanPanelToggleVar("ScreenAdjust");
-	TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_TOP, true)
+	TitanPanel_AdjustFrames(true)
 end

 --[[ Titan
@@ -1141,7 +1144,7 @@ NOTE:
 function TitanPanelBarButton_ToggleAuxScreenAdjust()
 	-- turn on / off adjusting of frames at the bottom of the screen
 	TitanPanelToggleVar("AuxScreenAdjust");
-	TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTTOM, true)
+	TitanPanel_AdjustFrames(true)
 end

 --[[ Titan
@@ -1232,7 +1235,7 @@ function TitanPanelBarButton_DisplayBarsWanted()
 	TitanAnchors()

 	-- Adjust other frames because the bars shown / hidden may have changed
-	TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true)
+	TitanPanel_AdjustFrames(true)
 end

 --[[ Titan