From 2f51fd4bffa998a3fad0c345d235e3c8f131b677 Mon Sep 17 00:00:00 2001 From: vaisest <4550061+vaisest@users.noreply.github.com> Date: Tue, 28 Jul 2026 22:48:59 +0300 Subject: [PATCH 1/3] Add comparisons to config tab tooltips --- src/Classes/ConfigTab.lua | 59 +++++++++++++++++++++++++++++++++++---- src/Modules/Build.lua | 1 + 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/Classes/ConfigTab.lua b/src/Classes/ConfigTab.lua index 652b76d0e8..87c831d78b 100644 --- a/src/Classes/ConfigTab.lua +++ b/src/Classes/ConfigTab.lua @@ -28,14 +28,20 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont self.configSetOrderList = { 1 } self:NewConfigSet(1) self:SetActiveConfigSet(1, true) - + self.enemyLevel = 1 self.sectionList = { } self.varControls = { } - + self.toggleConfigs = false + -- A misc calculator function which is updated by the build when it is rebuilt + ---@type fun(): table + self.calcFunc = nil + -- A calculator base output matching the calcFunc which is updated by the build when it is rebuilt + ---@type table + self.calcBase = nil self.controls.sectionAnchor = new("LabelControl", { "TOPLEFT", self, "TOPLEFT" }, { 0, 20, 0, 0 }, "") -- Set selector @@ -582,12 +588,14 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont end return innerLabel end + local outputCache = {} + local outputCacheRevision = nil local innerTooltipFunc = control.tooltipFunc - control.tooltipFunc = function (tooltip, ...) + control.tooltipFunc = function(tooltip, mode, index, value) tooltip:Clear() if innerTooltipFunc then - innerTooltipFunc(tooltip, ...) + innerTooltipFunc(tooltip, mode, index, value) else local tooltipText = control:GetProperty("tooltipText") if tooltipText and tooltipText ~= '' then @@ -596,10 +604,51 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont end local shown = type(innerShown) == "boolean" and innerShown or innerShown() - local cur = self.configSets[self.activeConfigSetId].input[varData.var] + local inputs = self.configSets[self.activeConfigSetId].input + local cur = inputs[varData.var] local def = self:GetDefaultState(varData.var, type(cur)) if not shown and cur ~= nil and cur ~= def then tooltip:AddLine(14, colorCodes.NEGATIVE.."This config option is conditional with missing source and is invalid.") + else + -- avoid adding comparisons for number inputs as the + -- input gets applied as soon as the user types, which + -- means comparisons dont make sense here + if not self.calcFunc then + self.calcFunc, self.calcBase = self.build.calcsTab:GetMiscCalculator(self.build) + end + if (varData.type == "check") or (varData.type == "list") then + local valueMapped = (varData.type == "check") and (not cur) or + (type(value) == "table") and (value.val) or value + if (valueMapped ~= cur) then + local buildFlag = self.build.buildFlag + tooltip:AddSeparator(10) + -- clear cache if build has been edited + if outputCacheRevision ~= self.build.outputRevision then + outputCache = {} + outputCacheRevision = self.build.outputRevision + end + inputs[varData.var] = valueMapped + self:BuildModList() + + local key = string.format("%s:%s", tostring(valueMapped), tostring(cur)) + outputCache[key] = outputCache[key] or self.calcFunc() + + inputs[varData.var] = cur + self:BuildModList() + + -- building the mod lists flags the build for a + -- rebuild, but we don't actually want that as + -- we restore the previous state if the user + -- hasn't actually clicked + self.build.buildFlag = buildFlag + local prefix = (varData.type == "check") and "^7Toggling this" or "^7Selecting this" + self.build:AddStatComparesToTooltip(tooltip, self.calcBase, outputCache[key], prefix .. " option will give you:") + -- clear tooltip if it only has our separator + if #tooltip.lines == 1 then + tooltip:Clear() + end + end + end end end end diff --git a/src/Modules/Build.lua b/src/Modules/Build.lua index b809dbe01d..69398829e8 100644 --- a/src/Modules/Build.lua +++ b/src/Modules/Build.lua @@ -1242,6 +1242,7 @@ function buildMode:OnFrame(inputEvents) self.buildFlag = false self.calcsTab:BuildOutput() self:RefreshStatList() + self.configTab.calcFunc, self.configTab.calcBase = self.calcsTab:GetMiscCalculator(self) end if main.showThousandsSeparators ~= self.lastShowThousandsSeparators then self:RefreshStatList() From e91b24dc6c9cd4f0061a2c873942f921d3305313 Mon Sep 17 00:00:00 2001 From: vaisest <4550061+vaisest@users.noreply.github.com> Date: Tue, 28 Jul 2026 23:28:17 +0300 Subject: [PATCH 2/3] Cleanup --- src/Classes/ConfigTab.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Classes/ConfigTab.lua b/src/Classes/ConfigTab.lua index 87c831d78b..9d667d356b 100644 --- a/src/Classes/ConfigTab.lua +++ b/src/Classes/ConfigTab.lua @@ -617,8 +617,12 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont self.calcFunc, self.calcBase = self.build.calcsTab:GetMiscCalculator(self.build) end if (varData.type == "check") or (varData.type == "list") then - local valueMapped = (varData.type == "check") and (not cur) or - (type(value) == "table") and (value.val) or value + local valueMapped + if varData.type == "check" then + valueMapped = not cur + else + valueMapped = type(value) == "table" and value.val or value + end if (valueMapped ~= cur) then local buildFlag = self.build.buildFlag tooltip:AddSeparator(10) @@ -627,15 +631,16 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont outputCache = {} outputCacheRevision = self.build.outputRevision end - inputs[varData.var] = valueMapped - self:BuildModList() - local key = string.format("%s:%s", tostring(valueMapped), tostring(cur)) - outputCache[key] = outputCache[key] or self.calcFunc() + if not outputCache[key] then + inputs[varData.var] = valueMapped + self:BuildModList() - inputs[varData.var] = cur - self:BuildModList() + outputCache[key] = self.calcFunc() + inputs[varData.var] = cur + self:BuildModList() + end -- building the mod lists flags the build for a -- rebuild, but we don't actually want that as -- we restore the previous state if the user From c1011f1faf59fd89f413a2ba580b6332ed026723 Mon Sep 17 00:00:00 2001 From: vaisest <4550061+vaisest@users.noreply.github.com> Date: Thu, 30 Jul 2026 16:29:07 +0300 Subject: [PATCH 3/3] cspell --- src/Classes/ConfigTab.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Classes/ConfigTab.lua b/src/Classes/ConfigTab.lua index 9d667d356b..77a5093869 100644 --- a/src/Classes/ConfigTab.lua +++ b/src/Classes/ConfigTab.lua @@ -612,7 +612,7 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont else -- avoid adding comparisons for number inputs as the -- input gets applied as soon as the user types, which - -- means comparisons dont make sense here + -- means comparisons don't make sense here if not self.calcFunc then self.calcFunc, self.calcBase = self.build.calcsTab:GetMiscCalculator(self.build) end