Skip to content

Commit

Permalink
Highlight borders for changed config options in config tab (PathOfBui…
Browse files Browse the repository at this point in the history
…ldingCommunity#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 <slusnucky@gmail.com>
  • Loading branch information
deathbeam authored and Dullson committed Dec 6, 2023
1 parent 1565ae5 commit 5c40d86
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 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 @@ -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]
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
4 changes: 2 additions & 2 deletions src/Modules/ConfigOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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?]+$", "")
Expand Down

0 comments on commit 5c40d86

Please sign in to comment.