From 6570afb70a99a94b0cbfcd0557a61598fa0b81a3 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 2 Jul 2026 03:05:51 -0500 Subject: [PATCH] eqcompare: collapse basestats/extendedstats checkboxes into a mode dropdown Replace the two-checkbox arrangement (Compare Base Stats + Compare Extended Stats, with the latter gated on the former) with a single "Item Comparison" dropdown offering Off / Base / Extended. Migrate existing configs. Also route CreateConfig's value-change sites through pfUI.events ("config:changed", category, config) so callers can react to arbitrary setting changes without frame-specific plumbing. Use it here to grey out "Always Show Item Comparison" when the mode is Off. --- api/config.lua | 18 +++++++++++++++-- modules/eqcompare.lua | 5 +++-- modules/gui.lua | 47 +++++++++++++++++++++++++------------------ 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/api/config.lua b/api/config.lua index 3dddb1fe..0f5dd729 100644 --- a/api/config.lua +++ b/api/config.lua @@ -751,8 +751,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("tooltip", nil, "movespeed", "0") pfUI:UpdateConfig("tooltip", nil, "alpha", "0.8") pfUI:UpdateConfig("tooltip", nil, "alwaysperc", "0") - pfUI:UpdateConfig("tooltip", "compare", "basestats", "1") - pfUI:UpdateConfig("tooltip", "compare", "extendedstats", "1") + pfUI:UpdateConfig("tooltip", "compare", "mode", "extended") pfUI:UpdateConfig("tooltip", "compare", "showalways", "0") pfUI:UpdateConfig("tooltip", "vendor", "showalways", "1") pfUI:UpdateConfig("tooltip", "questitem", "showquest", "1") @@ -1373,6 +1372,21 @@ function pfUI:MigrateConfig() end end + -- migrate tooltip.compare.basestats + extendedstats into a single mode dropdown + if pfUI_config.tooltip and pfUI_config.tooltip.compare then + local cmp = pfUI_config.tooltip.compare + if cmp.basestats or cmp.extendedstats then + if cmp.basestats == "0" then + cmp.mode = "off" + elseif cmp.extendedstats == "0" then + cmp.mode = "base" + else + cmp.mode = "extended" + end + cmp.basestats = nil + cmp.extendedstats = nil + end + end -- Remove "Show only own debuffs" from unitframes and nameplates -- (feature was removed; only Target Debuff Bar in buffwatch keeps it) diff --git a/modules/eqcompare.lua b/modules/eqcompare.lua index 5dfcacb4..c89e1424 100644 --- a/modules/eqcompare.lua +++ b/modules/eqcompare.lua @@ -252,12 +252,13 @@ pfUI:RegisterModule("eqcompare", function () AddHeader(ShoppingTooltip2) end - if C.tooltip.compare.basestats == "1" then + local mode = C.tooltip.compare.mode + if mode ~= "off" then local equippedLink = GetInventoryItemLink("player", slotID) if newLink and equippedLink then local delta = C_Item.GetItemStatDelta(equippedLink, newLink) if delta then - if C.tooltip.compare.extendedstats == "1" then + if mode == "extended" then local keys = {} for _, k in ipairs(BASE_STAT_KEYS) do table.insert(keys, k) end for _, k in ipairs(EXTENDED_STAT_KEYS) do table.insert(keys, k) end diff --git a/modules/gui.lua b/modules/gui.lua index 4d3eb17a..93893724 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1,5 +1,5 @@ pfUI:RegisterModule("gui", function () - local Reload, U, CreateConfig, CreateTabFrame, CreateArea, CreateGUIEntry, EntryUpdate, MakeDependent + local Reload, U, CreateConfig, CreateTabFrame, CreateArea, CreateGUIEntry, EntryUpdate -- "searchDB" gets populated when CreateConfig is called. The table holds -- information about the title, its parent buttons and the frame itself: @@ -212,6 +212,7 @@ pfUI:RegisterModule("gui", function () if not this:GetParent():IsShown() then category[config] = r .. "," .. g .. "," .. b .. "," .. a if ufunc then ufunc() else pfUI.gui.settingChanged = true end + pfUI.events:TriggerEvent("config:changed", category, config) end end @@ -278,6 +279,7 @@ pfUI:RegisterModule("gui", function () if this:GetText() ~= this:GetParent().category[this:GetParent().config] then this:GetParent().category[this:GetParent().config] = this:GetText() if ufunc then ufunc() else pfUI.gui.settingChanged = true end + pfUI.events:TriggerEvent("config:changed", category, config) end this:SetTextColor(.2,1,.8,1) else @@ -328,6 +330,7 @@ pfUI:RegisterModule("gui", function () end if ufunc then ufunc() else pfUI.gui.settingChanged = true end + pfUI.events:TriggerEvent("config:changed", category, config) end) if category[config] == "1" then frame.input:SetChecked() end @@ -360,6 +363,7 @@ pfUI:RegisterModule("gui", function () if category and category[config] ~= value then category[config] = value if ufunc then ufunc() else pfUI.gui.settingChanged = true end + pfUI.events:TriggerEvent("config:changed", category, config) end end @@ -394,6 +398,7 @@ pfUI:RegisterModule("gui", function () end category[config] = newconf if ufunc then ufunc() else pfUI.gui.settingChanged = true end + pfUI.events:TriggerEvent("config:changed", category, config) frame.input:UpdateMenu() end) @@ -409,6 +414,7 @@ pfUI:RegisterModule("gui", function () CreateQuestionDialog(T["New entry:"], function() category[config] = category[config] .. "#" .. this:GetParent().input:GetText() if ufunc then ufunc() else pfUI.gui.settingChanged = true end + pfUI.events:TriggerEvent("config:changed", category, config) frame.input:UpdateMenu() end, false, true) end) @@ -594,24 +600,9 @@ pfUI:RegisterModule("gui", function () CreateBackdropShadow(pfUI.gui) table.insert(UISpecialFrames, "pfConfigGUI") - function MakeDependent(child, parent) - local function refresh() - if parent.input:GetChecked() then - child.input:Enable() - child.caption:SetTextColor(1, 1, 1) - else - child.input:Disable() - child.caption:SetTextColor(0.5, 0.5, 0.5) - end - end - refresh() - HookScript(parent.input, "OnClick", refresh) - end - -- make some locals available to thirdparty pfUI.gui.Reload = Reload pfUI.gui.CreateConfig = CreateConfig - pfUI.gui.MakeDependent = MakeDependent pfUI.gui.CreateGUIEntry = CreateGUIEntry pfUI.gui.UpdaterFunctions = U @@ -2763,10 +2754,26 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, T["Show Movement Speed"], C.tooltip, "movespeed", "checkbox") CreateConfig(nil, T["Custom Transparency"], C.tooltip, "alpha") CreateConfig(nil, T["Status Bar Texture"], C.tooltip.statusbar, "texture", "dropdown", pfUI.gui.dropdowns.uf_bartexture) - local baseCompare = CreateConfig(nil, T["Compare Item Base Stats"], C.tooltip.compare, "basestats", "checkbox") - local extCompare = CreateConfig(nil, T["Compare Extended Stats (AP/Crit/etc.)"], C.tooltip.compare, "extendedstats", "checkbox") - MakeDependent(extCompare, baseCompare) - CreateConfig(nil, T["Always Show Item Comparison"], C.tooltip.compare, "showalways", "checkbox") + CreateConfig(nil, T["Item Comparison"], C.tooltip.compare, "mode", "dropdown", { + "off:"..(T["Off"] or "Off"), + "base:"..(T["Base Stats"] or "Base Stats"), + "extended:"..(T["Extended Stats"] or "Extended Stats"), + }) + local showAlways = CreateConfig(nil, T["Always Show Item Comparison"], C.tooltip.compare, "showalways", "checkbox") + local function gate() + local on = C.tooltip.compare.mode ~= "off" + if on then + showAlways.input:Enable() + showAlways.caption:SetTextColor(1, 1, 1) + else + showAlways.input:Disable() + showAlways.caption:SetTextColor(0.5, 0.5, 0.5) + end + end + gate() + pfUI.events:RegisterCallback("config:changed", function(_, cat, key) + if cat == C.tooltip.compare and key == "mode" then gate() end + end, "eqcompare-showalways-gate") CreateConfig(nil, T["Always Show Extended Vendor Values"], C.tooltip.vendor, "showalways", "checkbox") CreateConfig(U["questitem"], T["Show Related Quest On Questitems"], C.tooltip.questitem, "showquest", "checkbox") CreateConfig(U["questitem"], T["Show Required Questitem Count"], C.tooltip.questitem, "showcount", "checkbox")