Skip to content

Commit 87f2da1

Browse files
InfusOnWoWStanzilla
authored andcommitted
Fix Slider max >= min check
By doing the same check that AceGui does and fixing it up if we detect a problem. Noteably that means soft overrides normal, and fallbacks to 0 and 100 respectively. Fixes: #3799
1 parent bad8758 commit 87f2da1

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

WeakAurasOptions/AuthorOptions.lua

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,18 @@ typeControlAdders = {
676676
bigStep = option.bigStep
677677
min = option.min
678678
max = option.max
679-
if max and min then
680-
max = math.max(min, max)
679+
local effectiveMin = softMin or min or 0
680+
local effectiveMax = softMax or max or 100
681+
if (effectiveMin > effectiveMax) then
682+
-- This will cause a error inside the slider
683+
-- Fix up either softMax or max, depending on which one is the effective one
684+
if softMax then
685+
softMax = effectiveMin
686+
elseif max then
687+
max = effectiveMin
688+
else
689+
softMax = effectiveMin
690+
end
681691
end
682692
step = option.step
683693
args[prefix .. "default"] = {
@@ -2223,13 +2233,23 @@ local function addUserModeOption(options, args, data, order, prefix, i)
22232233
userOption.get = getUserNumAsString(option)
22242234
userOption.set = setUserNum(data, option)
22252235
elseif optionType == "range" then
2226-
userOption.softMax = option.softMax
2236+
userOption.softMax = option.softMax or 20
22272237
userOption.softMin = option.softMin
22282238
userOption.bigStep = option.bigStep
22292239
userOption.min = option.min
22302240
userOption.max = option.max
2231-
if userOption.max and userOption.min then
2232-
userOption.max = max(userOption.min, userOption.max)
2241+
local effectiveMin = userOption.softMin or userOption.min or 0
2242+
local effectiveMax = userOption.softMax or userOption.max or 100
2243+
if (effectiveMin > effectiveMax) then
2244+
-- This will cause a error inside the slider
2245+
-- Fix up either softMax or max, depending on which one is the effective one
2246+
if userOption.softMax then
2247+
userOption.softMax = effectiveMin
2248+
elseif userOption.max then
2249+
userOption.max = effectiveMin
2250+
else
2251+
userOption.softMax = effectiveMin
2252+
end
22332253
end
22342254
userOption.step = option.step
22352255
elseif optionType == "color" then

0 commit comments

Comments
 (0)