local parent = InterfaceOptionsActionBarsPanel |
if not parent.userControls then |
parent.userControls = {} |
local function insecureChildrenUpdater(message) |
return function (frame) |
for control, input in pairs(frame.userControls) do |
local action = control[message] |
local inputType = type(input) |
if inputType == 'function' then |
action(control, input(control, message)) |
elseif inputType == 'table' then |
action(control, unpack(input)) |
else |
action(control, input) |
end |
end |
end |
end |
for _, message in ipairs{"okay", "cancel", "default", "refresh"} do |
hooksecurefunc(parent, message, insecureChildrenUpdater(message)) |
end |
end |
|
|
local function refresh(self) |
local parent = self:GetParent() |
self.value = parent.options[self:GetAttribute("option")] |
if self.setFunc then |
self.setFunc(self.value) |
end |
self:SetChecked(self.value) |
return self.value |
end |
|
local function default(self) |
local parent = self:GetParent() |
parent.options[self:GetAttribute("option")] = self:GetAttribute("default") |
return self:refresh() |
end |
|
local cancel = refresh |
|
local function okay(self) |
local parent = self:GetParent() |
local option = self:GetAttribute("option") |
parent.options[option] = self.value |
if self.setFunc then |
self.setFunc(self.value) |
end |
end |
|
function JustTheArtCheckBox_OnLoad(self) |
self.Text = _G[self:GetName().."Text"] |
self.Text:SetText(self:GetAttribute("text")) |
self.tooltipText = self:GetAttribute("tooltiptext") |
self.defaultValue = self:GetAttribute("default") |
-- BlizzardOptionsPanel_RegisterControl(self, self:GetParent():GetParent()) |
self:GetParent():GetParent().userControls[self] = true |
self.refresh = refresh |
self.default = default |
self.cancel = cancel |
self.okay = okay |
|
local dependsOn = self:GetAttribute("depends") |
if dependsOn then |
dependsOn = self:GetParent()[dependsOn]; |
if dependsOn then |
BlizzardOptionsPanel_SetupDependentControl(dependsOn, self) |
end |
end |
self:RegisterEvent("ADDON_LOADED") |
end |