From 39680504162887dff11304a8bb59eaef63459979 Mon Sep 17 00:00:00 2001 From: urnati Date: Mon, 10 Apr 2023 20:30:21 -0400 Subject: [PATCH] - Another fix for Profile copy - Add Config flag to hide top bar(s) when in BG or arena --- Titan/LDBToTitan.lua | 8 ++++- Titan/TitanConfig.lua | 22 ++++++++++-- Titan/TitanPanel.lua | 81 +++++++++++++++++++++++++++++++++++++----- Titan/TitanPanelTemplate.lua | 4 +-- 4 files changed, 100 insertions(+), 15 deletions(-) diff --git a/Titan/LDBToTitan.lua b/Titan/LDBToTitan.lua index 2aa4b0c..03c3560 100644 --- a/Titan/LDBToTitan.lua +++ b/Titan/LDBToTitan.lua @@ -879,7 +879,13 @@ print("LDB macrotext" -- If plugins have already been registered and loaded then get this one loaded -- This works because the .registry is now set if Titan__InitializedPEW then - TitanPanel_PlayerEnteringWorld() +--[[ +print("LDB late" +.." id: '"..tostring(registry.id).."' " +) +--]] + TitanUtils_RegisterPluginList() +-- TitanPanel_PlayerEnteringWorld() end end diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index 42a72b3..20c8a4c 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -38,15 +38,15 @@ changes = changes ..TitanUtils_GetGoldText("7.00.00.100007 : 2023/03/31\n") ..TitanUtils_GetGreenText("Titan : \n") ..TitanUtils_GetHighlightText("" - .."- NEW : 10 Short bars! See new Configuration > Titan Bar Help for enabling and using.\n" + .."- NEW : 10 Short bars! See new consolidated Configuration > Titan Bar Help for enabling and using.\n" .."- NEW : Skins OR solid color selectable in Config - Global or per bar. \n" .."- NEW : Can Hide any Titan bar by right click on the Titan bar (not a plugin) then click Hide.\n" .."- NEW : Hide in Combat is now selectable in Config - Global or per bar.\n" .."- NOTE : Solid colors are done via the default color picker. Download an enhacned color picker for more options.\n" - .."- NOTE : Downgrading from 7.xx to 6.xx bars wil appear as they were. You may need to hide / show plugins.\n" + .."- NOTE : Downgrading from 7.xx to 6.xx bars - Prior to downgrading, place any plugins on one of the original full width Titan Bars. \nTitan 6.xx will throw an error IF any plugin is assigned to any Short Bar. If Titan throws an error, wipe the Titan saved variables.\n" .."- Configuration > Bars has a new consolidated config for all Titan bars.\n" .."- Configuration > Transparency moved into Bars.\n" - .."- Configuration > Titan Bar Help has details on bars.\n" + .."- Configuration > Titan Bar Help has details on using Titan bars.\n" .."- Configuration > Skins shows available skins.\n" .."- Remove adjustment of XP & status bars and Bag & Menu buttons.\n" .."- Remove unused timers; only LDB timer left.\n" @@ -1431,6 +1431,22 @@ print("Color new:" get = function() return TitanPanelGetVar("UseGlobal_HideInCombat") end, set = function() TitanPanelToggleVar("UseGlobal_HideInCombat"); end, }, + arenaspacer = { -- spacer + order = 200, type = "description", width = "full", + name = " ", + }, + confarenadesc = { + order = 201, width = "full", + type = "header", + name = BATTLEGROUND.." / "..ARENA, --L["TITAN_PANEL_MENU_COMMAND"], + }, + setarenauseglobal = { + name = HIDE, --L["TITAN_PANEL_MENU_HIDE_IN_COMBAT"], + desc = "Hide in Battleground or Arena", --L["TITAN_PANEL_MENU_HIDE_IN_COMBAT_DESC"], + order = 205, type = "toggle", width = "full", + get = function() return TitanPanelGetVar("HideTopBars") end, + set = function() TitanPanelToggleVar("HideTopBars"); end, + }, } } diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua index 3e07e3a..691ea30 100644 --- a/Titan/TitanPanel.lua +++ b/Titan/TitanPanel.lua @@ -303,7 +303,12 @@ NOTE: - This is also used when a LDB plugin is created after Titan runs the 'player entering world' code. :NOTE --]] -function TitanPanel_PlayerEnteringWorld() +function TitanPanel_PlayerEnteringWorld(reload) +--[[ +print("PEW" +.." "..tostring(Titan__InitializedPEW).."" +) +--]] if Titan__InitializedPEW then -- Currently no additional steps needed else @@ -445,6 +450,9 @@ function TitanPanelBarButton:ADDON_LOADED(addon) -- Cannot seem to move the 'top' part of the frame. _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_ENABLED"); _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_REGEN_DISABLED"); + _G[TITAN_PANEL_CONTROL]:RegisterEvent("ZONE_CHANGED"); + _G[TITAN_PANEL_CONTROL]:RegisterEvent("ZONE_CHANGED_INDOORS"); + _G[TITAN_PANEL_CONTROL]:RegisterEvent("ZONE_CHANGED_NEW_AREA"); else -- User loaded wrong Titan version; tried to use retail on Classic or Classic Era -- Could save the user grief; Titan could mangle the saved vars on a version mismatch. @@ -473,7 +481,7 @@ print("PLAYER_ENTERING_WORLD" --]] call_success, -- needed for pcall ret_val = -- actual return values - pcall (TitanPanel_PlayerEnteringWorld) + pcall (TitanPanel_PlayerEnteringWorld, arg2) -- pcall does not allow errors to propagate out. Any error -- is returned as text with the success / fail. -- Think of it as sort of a try - catch block @@ -523,20 +531,31 @@ function TitanPanelBarButton:PLAYER_LOGOUT() Titan__InitializedPEW = nil end --- +function TitanPanelBarButton:ZONE_CHANGED() + TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED") +end + +function TitanPanelBarButton:ZONE_CHANGED_INDOORS() + TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_INDOORS") +end + +function TitanPanelBarButton:ZONE_CHANGED_NEW_AREA() + TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_NEW_AREA") +end + function TitanPanelBarButton:PET_BATTLE_OPENING_START() --- TitanDebug("Pet_battle start: ") + TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_OPENING_START") -- Hide all bars and hiders - TitanPanelBarButton_HideAllBars() +-- TitanPanelBarButton_HideAllBars() end function TitanPanelBarButton:PET_BATTLE_CLOSE() - -- A combat check will be done inside the adjust TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_CLOSE") end --- --- + function TitanPanelBarButton:PLAYER_REGEN_ENABLED() + TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_ENABLED") +--[===[ for idx,v in pairs (TitanBarData) do if TitanBarDataVars[idx].show then -- if TitanPanelGetVar(v.name.."_Show") then @@ -546,9 +565,12 @@ function TitanPanelBarButton:PLAYER_REGEN_ENABLED() end end end +--]===] end function TitanPanelBarButton:PLAYER_REGEN_DISABLED() + TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_DISABLED") +--[===[ for idx,v in pairs (TitanBarData) do if TitanBarDataVars[idx].show then -- if TitanPanelGetVar(v.name.."_Show") then @@ -558,6 +580,7 @@ function TitanPanelBarButton:PLAYER_REGEN_DISABLED() end end end +--]===] end -- @@ -1186,6 +1209,11 @@ VAR: None OUT: None --]] function TitanPanelBarButton_DisplayBarsWanted(reason) +--[===[ +print("_DisplayBarsWanted" +.." "..tostring(reason).."" +) +--]===] -- Check all bars to see if the user has requested they be shown for idx,v in pairs (TitanBarData) do -- Show / hide plus kick auto hide, if needed @@ -1254,6 +1282,38 @@ function TitanPanelBarButton_HideBottomBars() end end +local function showBar(frame_str) + -- Conditions where this bar should not be shown... + local flag = true -- only set false for known conditions + + if frame_str == TITAN_PANEL_DISPLAY_PREFIX.."Bar" + or frame_str == TITAN_PANEL_DISPLAY_PREFIX.."Bar2" + then + -- ===== Battleground or Arena : User selected + if (TitanPanelGetVar("HideTopBars") == true) + and (C_PvP.IsBattleground() + or C_PvP.IsArena() + -- or GetZoneText() == "Stormwind City" + ) + then + flag = false + end + -- ===== In Pet Battle + if C_PetBattles.IsInBattle() + then + flag = false + end + end + + -- ===== In Combat : User selected + if TitanBarDataVars[frame_str].hide_in_combat + or TitanPanelGetVar("UseGlobal_HideInCombat") then + flag = false + end + + return flag +end + --[[ Titan NAME: TitanPanelBarButton_Show DESC: Show / hide the given Titan bar based on the user selection. @@ -1274,7 +1334,10 @@ function TitanPanelBarButton_Show(frame) local bott = TitanBarData[frame].bott -- Show the display bar if the user requested it - if TitanBarDataVars[frame].show then + -- And there are no conditions preventing... + if TitanBarDataVars[frame].show -- User requested + and showBar(frame) -- No preventing condition + then display:ClearAllPoints(); --[===[ local sx, sy = TitanUtils_ScreenSize(false) diff --git a/Titan/TitanPanelTemplate.lua b/Titan/TitanPanelTemplate.lua index 61a2491..8019499 100644 --- a/Titan/TitanPanelTemplate.lua +++ b/Titan/TitanPanelTemplate.lua @@ -1393,7 +1393,7 @@ DESC: Apply saved Bar position to the Bar frame. VAR: frame_str - string name of the Bar frame OUT: None NOTE: -- Bit of a sledge hammer; used when loading a profile over the current one so the Bars ready to be placed. +- Bit of a sledge hammer; used when loading a profile over the current so the Bars are properly placed. :NOTE --]] function TitanPanelButton_ApplyBarPos(frame_str) @@ -1405,7 +1405,7 @@ function TitanPanelButton_ApplyBarPos(frame_str) if bdata.user_move then frame:SetPoint(bdata.show.pt, bdata.show.rel_fr, bdata.show.rel_pt, fdata.off_x, fdata.off_y) else - -- Set bar, ignore + -- Set full bar, ignore end end end -- 1.7.9.5