--[[ PowerAurasButtons Module: ButtonsConfig --]] -- Create module frames. local CoreFrame = PowerAurasButtons; local ModuleFrame = CoreFrame:RegisterModule("ButtonsConfig", { "Buttons", "Config" }); local Modules = CoreFrame.Modules; --[[ ---------------------------------------------------------------------------------------------------- OnCreateConfigurationFrame Creates the configuration frame for the Config module. ---------------------------------------------------------------------------------------------------- --]] function ModuleFrame:OnCreateConfigurationFrame(name) -- Only do this if the name matches the module name. if(name ~= ModuleFrame.Name and name) then return; end -- Make the parent frame. local ActionEditor = CreateFrame("Frame", nil, UIParent); ActionEditor:SetHeight(51); -- Label. ActionEditor.DisplayLabel = Modules.Config:CreateHeaderWidget("Module: Buttons", ActionEditor, 0); -- Display glows? ActionEditor.DisplayGlow = Modules.Config:CreateButtonWidget(ActionEditor, "Display Glow"); ActionEditor.DisplayGlow:SetPoint("TOP", ActionEditor, "TOP", 0, -25); ActionEditor.DisplayGlow:SetScript("OnClick", function(self) -- Toggle self. if(self.Selected) then self:Deselect(); Modules.Config:UpdateActionData("glow", nil); else self:Select(); Modules.Config:UpdateActionData("glow", true); end end); -- Tooltips (localization handled by the config module) Modules.Config:RegisterConfigTooltip(ActionEditor.DisplayGlow, { title = "Display Glow", text = "Displays the shiny glow on the button when this aura is active." }); -- Add the necessary functions. ActionEditor.UpdateAction = function(self, actionData) if(actionData["glow"]) then ActionEditor.DisplayGlow:Select(); else ActionEditor.DisplayGlow:Deselect(); end end; -- Done. Modules.Config:RegisterActionConfigFrame(ActionEditor, 2); end --[[ ---------------------------------------------------------------------------------------------------- OnCreateInterfaceOptionsFrame Creates the interface options configuration frame for the Config module. ---------------------------------------------------------------------------------------------------- --]] function ModuleFrame:OnCreateInterfaceOptionsFrame(name) -- Only do this if the name matches the module name. if(name ~= ModuleFrame.Name and name) then return; end -- Base frame. local InterfaceOptions = Modules.Config:RegisterInterfaceOptionsFrame("Module: Buttons"); -- Two things needed: Slider, checkbutton. Slider first. InterfaceOptions.ThrottleSlider = CreateFrame("Slider", "PowerAurasButtons_ButtonsThrottle", InterfaceOptions, "OptionsSliderTemplate"); InterfaceOptions.ThrottleSlider:SetPoint("TOPLEFT", InterfaceOptions, "TOPLEFT", 20, -80); InterfaceOptions.ThrottleSlider:SetMinMaxValues(0.05, 1); InterfaceOptions.ThrottleSlider:SetValue(CoreFrame:GetModuleSetting("Buttons", "Throttle")); InterfaceOptions.ThrottleSlider:SetValueStep(0.05); InterfaceOptions.ThrottleSlider:SetWidth(250); PowerAurasButtons_ButtonsThrottleLow:SetText("0.05"); PowerAurasButtons_ButtonsThrottleHigh:SetText("1"); PowerAurasButtons_ButtonsThrottleText:SetText(CoreFrame.L["Update Throttle"] .. " (" .. CoreFrame:GetModuleSetting("Buttons", "Throttle") .. " " .. CoreFrame.L["Seconds"] .. ")"); -- Update on value change. InterfaceOptions.ThrottleSlider:SetScript("OnValueChanged", function(self) -- Set it. CoreFrame:SetModuleSetting("Buttons", "Throttle", tonumber(string.format("%.2f", self:GetValue()), 10)); -- Update label too. PowerAurasButtons_ButtonsThrottleText:SetText(CoreFrame.L["Update Throttle"] .. " (" .. tonumber(string.format("%.2f", self:GetValue()), 10) .. " " .. CoreFrame.L["Seconds"] .. ")"); end); -- Checkbutton. InterfaceOptions.Blizz = CreateFrame("CheckButton", "PowerAurasButtons_ButtonsBlizz", InterfaceOptions, "ChatConfigCheckButtonTemplate"); InterfaceOptions.Blizz:SetPoint("TOPLEFT", InterfaceOptions, "TOPLEFT", 10, -115); PowerAurasButtons_ButtonsBlizzText:SetText(CoreFrame.L["Register Blizzard Buttons"]); InterfaceOptions.Blizz:SetChecked( CoreFrame:GetModuleSetting("Buttons", "RegisterBlizzardButtons")); -- Save on click. InterfaceOptions.Blizz:SetScript("OnClick", function(self) -- Requires a reload to take effect, so get a glowbox ready and running. Modules.Config:CreateGlowBoxWidget(InterfaceOptions); -- Save. CoreFrame:SetModuleSetting("Buttons", "RegisterBlizzardButtons", self:GetChecked()); end); -- One more checkbutton. InterfaceOptions.SGlow = CreateFrame("CheckButton", "PowerAurasButtons_ButtonsShowBlizzGlows", InterfaceOptions, "ChatConfigCheckButtonTemplate"); InterfaceOptions.SGlow:SetPoint("TOPLEFT", InterfaceOptions, "TOPLEFT", 10, -140); PowerAurasButtons_ButtonsShowBlizzGlowsText:SetText(CoreFrame.L["Show Blizzard Glows"]); InterfaceOptions.SGlow:SetChecked( CoreFrame:GetModuleSetting("Buttons", "ShowBlizzardGlows")); -- Save on click. InterfaceOptions.SGlow:SetScript("OnClick", function(self) -- Save. CoreFrame:SetModuleSetting("Buttons", "ShowBlizzardGlows", self:GetChecked()); end); -- Tooltips. Modules.Config:RegisterConfigTooltip(InterfaceOptions.ThrottleSlider, { title = "Update Throttle", text = "Controls the throttle for mass button updates. This affects both " .. "performance and responsiveness, so leaving it at around 0.05 to 0.1 is a good idea." }); Modules.Config:RegisterConfigTooltip(InterfaceOptions.Blizz, { title = "Register Blizzard Buttons", text = "Select this if you want Blizzard's default action buttons to be included. " .. "If you are using another addon like Bartender or Dominos, you can disable this." }); Modules.Config:RegisterConfigTooltip(InterfaceOptions.SGlow, { title = "Show Blizzard Glows |cFFFF0000*BETA*|r", text = "Select this if you want Blizzard's default action button glows to be displayed." }); end --[[ ---------------------------------------------------------------------------------------------------- OnInitialize Fired by the module handler. Put all the loading code into here. ---------------------------------------------------------------------------------------------------- --]] function ModuleFrame:OnInitialize() -- Register module events for config frames. CoreFrame:RegisterModuleEventListener("OnCreateConfigurationFrame", ModuleFrame); CoreFrame:RegisterModuleEventListener("OnCreateInterfaceOptionsFrame", ModuleFrame); -- Done. return true; end