Quantcast
WoWInterface - View Single Post - AceConfig-3.0 Options: Inherit "disabled" from parent group explicitly?
View Single Post
12-29-20, 05:05 PM   #4
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Assuming you are not using the passed info table in your other disabled functions (and not using handlers) then you could use:
Lua Code:
  1. local function GetInheritedDisabledStatus(info)
  2.     local option, options = info.options, { }
  3.     local disabled = option.disabled
  4.     for index = 1, #info - 1 do
  5.         option = option.args[info[index]]
  6.         options[index] = option
  7.     end
  8.     for index = #options, 1, -1 do
  9.         if options[index].disabled ~= nil then
  10.             disabled = options[index].disabled
  11.             break
  12.         end
  13.     end
  14.     if type(disabled) == "function" then
  15.         disabled = disabled()
  16.     end
  17.     return disabled
  18. end
  19.  
  20. local function CreateSliderResetButton(order, forSituations, index1, index2)
  21.   return {
  22.     type = "execute",
  23.     name = "Reset",
  24.     order = order,
  25.       func =
  26.         function()
  27.           DynamicCam:SetSettingsDefault(forSituations, index1, index2)
  28.         end,
  29.       disabled =
  30.         function(info)
  31.           return DynamicCam:GetSettingsValue(forSituations, index1, index2) == DynamicCam:GetSettingsDefault(index1, index2) or GetInheritedDisabledStatus(info)
  32.       end,
  33.   }
  34. end
  Reply With Quote