From d2d9530971bdceaebbc2a9be63fe997be585b4b5 Mon Sep 17 00:00:00 2001 From: urnati Date: Wed, 4 Mar 2026 21:58:46 -0500 Subject: [PATCH] - XP : remove Kill to level if secret values - Gold : Add sort descending option - Titan menu: Add Edit Mode OR Config Bars All - Titan : Fix for #1453 when LDB uses Blizzard_Menu scheme --- Titan/Titan.lua | 31 +++++++++++++++++++++++++++++++ Titan/TitanGlobal.lua | 7 +++++++ Titan/TitanLDB.lua | 14 +++++++++++--- TitanGold/TitanGold.lua | 39 +++++++++++++++++++++++++++++++++------ TitanXP/TitanXP.lua | 25 +++++++++++++++++++++---- 5 files changed, 103 insertions(+), 13 deletions(-) diff --git a/Titan/Titan.lua b/Titan/Titan.lua index 25b264a..b1b7c74 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -2120,6 +2120,22 @@ local function AddPlugin(owner, bar, category) end end +local function GetLayout() + local res = "" + + -- Defined in as part of the Edit Mode frame + --../Blizzard_EditMode/Shared/EditModeManager.lua + local EMM = EditModeManagerFrame + local layout = EMM:GetActiveLayoutInfo() + if layout then + res = layout.layoutName + else + res = "Layout?" + end + + return res +end + ---Generate and display right click menu options for user. ---@param owner table Plugin frame ---@param rootDescription table Menu context root @@ -2173,6 +2189,21 @@ local function GeneratorFunction(owner, rootDescription) end Titan_Menu.AddDivider(root) + if Titan_Global.switch.can_edit_ui then + local lay_out = GetLayout() + Titan_Menu.AddCommand(root, id, HUD_EDIT_MODE_MENU..": "..lay_out, + function() + ShowUIPanel(EditModeManagerFrame) + end + ) + else + local config = L["TITAN_PANEL_MENU_CONFIGURATION"].." " + Titan_Menu.AddCommand(root, id, config..L["TITAN_PANEL_MENU_OPTIONS_BARS_ALL"], + function() + TitanUpdateConfig("init") + AceConfigDialog:Open("Titan Panel Globals") + end) + end -- Hold off for a rewrite using Blizz API over Ace --[[ if Titan_Global.switch.midnight then diff --git a/Titan/TitanGlobal.lua b/Titan/TitanGlobal.lua index acf611c..1aef95e 100644 --- a/Titan/TitanGlobal.lua +++ b/Titan/TitanGlobal.lua @@ -21,6 +21,13 @@ Titan_Global.switch = {} -- reserved for flags needed because feature / function -- As much as possible, use something in the API to determine feature, not API version. -- Set defaults to retail feature / function +Titan_Global.switch.has_secrets = true -- if UI is using secret values +if C_Secrets then + Titan_Global.switch.has_secrets = true -- +else + Titan_Global.switch.has_secrets = false -- +end + Titan_Global.switch.can_edit_ui = true -- if user can modify UI if C_EditMode then Titan_Global.switch.can_edit_ui = true -- User changes UI diff --git a/Titan/TitanLDB.lua b/Titan/TitanLDB.lua index 0e2a64c..9ab5e21 100644 --- a/Titan/TitanLDB.lua +++ b/Titan/TitanLDB.lua @@ -300,9 +300,17 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) -- OnClick elseif event:find("OnClick") then TitanPluginframe:SetScript("OnClick", function(self, button) - if TITAN_PANEL_MOVING == 0 then + if TITAN_PANEL_MOVING == 0 then -- no move in progress func(self, button) end + + --[[ 2026 Mar + Discovered that the Blizzard_Menu system, when used by an LDB, + is set up and shown before we get here. + So... make assumption that menus will be closed on a mouse click. + --]] + + --[===[ -- implement a safeguard, since the DO may actually use -- Blizzy dropdowns ! if not TitanPanelRightClickMenu_IsVisible() then @@ -310,10 +318,10 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) else TitanUtils_CloseAllControlFrames(); end + --]===] end ) - -- OnEnter - else + else -- OnEnter / OnLeave TitanPluginframe:SetScript("OnEnter", function(self) -- Check for tooltip libs without embedding them diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua index 645f314..62a8049 100644 --- a/TitanGold/TitanGold.lua +++ b/TitanGold/TitanGold.lua @@ -406,11 +406,11 @@ end ---@return table sorted May not be need but it is explicit local function SortByIndex(gold_table) -- local by_realm = TitanGetVar(TITAN_GOLD_ID, "GroupByRealm") - local by_name = TitanGetVar(TITAN_GOLD_ID, "SortByName") + local sort_by = TitanGetVar(TITAN_GOLD_ID, "SortByName") -- This section will sort the array based on user preference -- * by name or by gold amount descending -- * grouping by realm if selected - if by_name == true then + if sort_by == "NameAsc" then table.sort(gold_table, function(key1, key2) return key1.char_name < key2.char_name end) @@ -425,10 +425,16 @@ local function SortByIndex(gold_table) return false end) --]] - else -- by gold + elseif sort_by == "GoldAsc" then -- by gold ascending table.sort(gold_table, function(key1, key2) return key1.gold < key2.gold end) + elseif sort_by == "GoldDec" then -- by gold descending + table.sort(gold_table, function(key1, key2) + return key1.gold > key2.gold + end) + else + -- should not get here end return gold_table @@ -720,12 +726,29 @@ local function Initialize_Array() else -- exists, use as is end + + if TitanSettings.Players[index].Info[TITAN_GOLD_ID].show == nil then + TitanSettings.Players[index].Info[TITAN_GOLD_ID].show = true -- default + else + -- exists, use as is + end else -- ignore custom profiles or toons not logged into yet end end end + -- 2026 Mar : Repurposed to add sort gold decsending + -- Translate the user setting as user logs into toons or profile changes + local sort_by = TitanGetVar(TITAN_GOLD_ID, "SortByName") + if sort_by == true then + TitanSetVar(TITAN_GOLD_ID, "SortByName", "NameAsc") + elseif sort_by == false or sort_by == nil then + TitanSetVar(TITAN_GOLD_ID, "SortByName", "GoldAsc") + else + -- already set + end + local msg = ">Init done : " .. " " .. tostring(GOLD_INITIALIZED) .. "" .. " " .. info .. "" @@ -795,9 +818,13 @@ local function GeneratorFunction(owner, rootDescription) local opts_sort = Titan_Menu.AddButton(root, L["TITAN_GOLD_SORT_BY"]) do -- next level options + -- NameAsc | GoldAsc | GoldDec [Ascend, Descend] local disp = { -- selectors using the same option - label, value - { L["TITAN_GOLD_TOGGLE_SORT_GOLD"], false }, - { L["TITAN_GOLD_TOGGLE_SORT_NAME"], true }, +-- { L["TITAN_GOLD_TOGGLE_SORT_GOLD"], false }, +-- { L["TITAN_GOLD_TOGGLE_SORT_NAME"], "true" }, + { "Sort by Name", "NameAsc" }, + { "Sort by Gold Ascending", "GoldAsc" }, + { "Sort by Gold Descending", "GoldDec" }, } Titan_Menu.AddSelectorList(opts_sort, id, nil, "SortByName", disp) @@ -924,7 +951,7 @@ local function OnLoad(self) ShowCoinLabels = true, ShowCoinIcons = false, ShowGoldOnly = false, - SortByName = true, + SortByName = "NameAsc", -- NameAsc | GoldAsc | GoldDec [Ascend, Descend] ViewAll = true, ShowIcon = true, ShowLabelText = false, diff --git a/TitanXP/TitanXP.lua b/TitanXP/TitanXP.lua index 8cef68e..35b03a2 100644 --- a/TitanXP/TitanXP.lua +++ b/TitanXP/TitanXP.lua @@ -174,7 +174,12 @@ local function OnShow(self) self:RegisterEvent("TIME_PLAYED_MSG"); self:RegisterEvent("PLAYER_XP_UPDATE"); self:RegisterEvent("PLAYER_LEVEL_UP"); - self:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); + + if Titan_Global.switch.has_secrets then + -- Do not register + else + self:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); + end RefreshPlayed() -- TIME_PLAYED_MSG @@ -202,7 +207,11 @@ local function OnHide(self) self:UnregisterEvent("TIME_PLAYED_MSG"); self:UnregisterEvent("PLAYER_XP_UPDATE"); self:UnregisterEvent("PLAYER_LEVEL_UP"); - self:UnregisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); + if Titan_Global.switch.has_secrets then + -- Nothing to do + else + self:UnregisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); + end AceTimer:CancelTimer(XPTimer.timer) XPTimer.running = false @@ -445,6 +454,15 @@ local function GetTooltipText() numofgains = 0 --_G["UNKNOWN"] end + local kills = "" + if Titan_Global.switch.has_secrets then + -- Nothing to do + else + kills = + format(L["TITAN_XP_KILLS_LABEL"], comma_value(txp.lastMobXP)) .. + "\t" .. TitanUtils_GetHighlightText(comma_value(numofkills)) .. "\n" + end + res = "" .. L["TITAN_XP_TOOLTIP_TOTAL_TIME"] .. "\t" .. TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(totalTime)) .. "\n" .. @@ -468,8 +486,7 @@ local function GetTooltipText() format(L["TITAN_XP_PERCENT_FORMAT"], toLevelXPPercent)) .. "\n" .. L["TITAN_XP_TOOLTIP_SESSION_XP"] .. "\t" .. TitanUtils_GetHighlightText(comma_value(txp.sessionXP)) .. "\n" .. - format(L["TITAN_XP_KILLS_LABEL"], comma_value(txp.lastMobXP)) .. - "\t" .. TitanUtils_GetHighlightText(comma_value(numofkills)) .. "\n" .. + kills .. format(L["TITAN_XP_XPGAINS_LABEL"], comma_value(txp.XPGain)) .. "\t" .. TitanUtils_GetHighlightText(comma_value(numofgains)) .. "\n" .. "\n" .. -- 1.7.9.5