Skip to content

Commit

Permalink
Highlight borders for changed config options in config tab
Browse files Browse the repository at this point in the history
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 <slusnucky@gmail.com>
  • Loading branch information
deathbeam committed Feb 27, 2023
1 parent 347e750 commit a8312d2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Classes/CheckBoxControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,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]
Expand Down
3 changes: 3 additions & 0 deletions src/Classes/DropDownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/Classes/EditControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/ConfigOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ Uber Pinnacle Boss adds the following modifiers:

-- Section: Custom mods
{ section = "Custom Modifiers", col = 1 },
{ var = "customMods", type = "text", label = "", apply = function(val, modList, enemyModList)
{ var = "customMods", type = "text", label = "", doNotHighlight = true, apply = function(val, modList, enemyModList)
for line in val:gmatch("([^\n]*)\n?") do
local mods, extra = modLib.parseMod(line)

Expand Down

0 comments on commit a8312d2

Please sign in to comment.