From 5c40d86534b10fe287073646ac41b2ad07729dc5 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Mon, 24 Apr 2023 06:20:30 +0200 Subject: [PATCH] Highlight borders for changed config options in config tab (#5717) This highlights borders for controls for changed config options when they are in non-default state. Useful for quickly checking what options user configured and prevents forgetting about some config set by accident (dropdowns in non-default state are especially hard to spot) Signed-off-by: Tomas Slusny --- src/Classes/CheckBoxControl.lua | 3 +++ src/Classes/ConfigTab.lua | 17 ++++++++++++++++- src/Classes/DropDownControl.lua | 3 +++ src/Classes/EditControl.lua | 3 +++ src/Modules/ConfigOptions.lua | 4 ++-- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Classes/CheckBoxControl.lua b/src/Classes/CheckBoxControl.lua index 162c32fd5c..97ae93c440 100644 --- a/src/Classes/CheckBoxControl.lua +++ b/src/Classes/CheckBoxControl.lua @@ -38,6 +38,9 @@ function CheckBoxClass:Draw(viewPort, noTooltip) SetDrawColor(0.33, 0.33, 0.33) elseif mOver then SetDrawColor(1, 1, 1) + elseif self.borderFunc then + r, g, b = self.borderFunc() + SetDrawColor(r, g, b) else SetDrawColor(0.5, 0.5, 0.5) end diff --git a/src/Classes/ConfigTab.lua b/src/Classes/ConfigTab.lua index 143fc6b152..a27a8a2c69 100644 --- a/src/Classes/ConfigTab.lua +++ b/src/Classes/ConfigTab.lua @@ -453,8 +453,23 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont end end + local innerShown = control.shown + if not varData.doNotHighlight then + control.borderFunc = function() + local shown = type(innerShown) == "boolean" and innerShown or innerShown() + local cur = self.input[varData.var] + local def = self:GetDefaultState(varData.var, type(cur)) + if cur ~= nil and cur ~= def then + if not shown then + return 0.753, 0.502, 0.502 + end + return 0.451, 0.576, 0.702 + end + return 0.5, 0.5, 0.5 + end + end + if not varData.hideIfInvalid then - local innerShown = control.shown control.shown = function() local shown = type(innerShown) == "boolean" and innerShown or innerShown() local cur = self.input[varData.var] diff --git a/src/Classes/DropDownControl.lua b/src/Classes/DropDownControl.lua index 2663ffa499..39aaf303fb 100644 --- a/src/Classes/DropDownControl.lua +++ b/src/Classes/DropDownControl.lua @@ -235,6 +235,9 @@ function DropDownClass:Draw(viewPort, noTooltip) SetDrawColor(0.33, 0.33, 0.33) elseif mOver or self.dropped then SetDrawColor(1, 1, 1) + elseif self.borderFunc then + r, g, b = self.borderFunc() + SetDrawColor(r, g, b) else SetDrawColor(0.5, 0.5, 0.5) end diff --git a/src/Classes/EditControl.lua b/src/Classes/EditControl.lua index a7ca0ca497..337497f341 100644 --- a/src/Classes/EditControl.lua +++ b/src/Classes/EditControl.lua @@ -241,6 +241,9 @@ function EditClass:Draw(viewPort, noTooltip) SetDrawColor(0.33, 0.33, 0.33) elseif mOver then SetDrawColor(1, 1, 1) + elseif self.borderFunc then + r, g, b = self.borderFunc() + SetDrawColor(r, g, b) else SetDrawColor(0.5, 0.5, 0.5) end diff --git a/src/Modules/ConfigOptions.lua b/src/Modules/ConfigOptions.lua index 099ab96ed8..57a2e454e6 100644 --- a/src/Modules/ConfigOptions.lua +++ b/src/Modules/ConfigOptions.lua @@ -1800,7 +1800,7 @@ Huge sets the radius to 11. end modList:NewMod("BossSkillActive", "FLAG", true, "Config") - + -- boss specific mods if val == "Atziri Flameblast" and isUber then enemyModList:NewMod("Damage", "INC", 60, "Alluring Abyss Map Mod") @@ -1829,7 +1829,7 @@ Huge sets the radius to 11. -- Section: Custom mods { section = "Custom Modifiers", col = 1 }, - { var = "customMods", type = "text", label = "", + { var = "customMods", type = "text", label = "", doNotHighlight = true, apply = function(val, modList, enemyModList, build) for line in val:gmatch("([^\n]*)\n?") do local strippedLine = StripEscapes(line):gsub("^[%s?]+", ""):gsub("[%s?]+$", "")