Mercurial > wow > reaction
view Options.lua @ 182:55c2fc0c8d55
Collect options in one file
clean up ReAction.lua a bit
remove AceConsole-3.0
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Thu, 21 Oct 2010 22:07:11 +0000 |
parents | |
children | 1ee86bbb05a0 |
line wrap: on
line source
local addonName, addonTable = ... local ReAction = addonTable.ReAction local L = ReAction.L local InCombatLockdown = InCombatLockdown local configID = "ReAction" local configProfileID = "ReAction_Profile" local function SlashHandler(option) if option == "config" or option == "options" then ReAction:ShowOptions() elseif option == "edit" then ReAction:ShowEditor() elseif option == "unlock" then ReAction:SetConfigMode(true) elseif option == "lock" then ReAction:SetConfigMode(false) elseif option == "kb" then ReAction:SetKeybindMode(true) else print(("%3.1f"):format(version)) print("/rxn config") print("/rxn edit") print("/rxn lock") print("/rxn unlock") print("/rxn kb") end end function ReAction:GetOptions() if not self.options then self.options = { type = "group", name = "ReAction", args = { _desc = { type = "description", name = L["Customizable replacement for Blizzard's Action Bars"], order = 1, }, unlock = { type = "toggle", name = L["Unlock Bars"], desc = L["Unlock bars for dragging and resizing with the mouse"], handler = self, get = "GetConfigMode", set = function(info, value) self:SetConfigMode(value) end, width = "full", disabled = InCombatLockdown, order = 2, }, hide = { type = "toggle", name = L["Hide Blizzard Action Bars"], desc = L["Hide the default main bar and extra action bars"], handler = self:GetModule("HideBlizzard"), get = "IsHidden", set = "SetHidden", disabled = "OptionDisabled", width = "full", order = 3, }, hideVehicle = { type = "toggle", name = L["Hide Blizzard Vehicle Bar"], desc = L["Hide the default vechicle action bar"], handler = self:GetModule("HideBlizzard"), get = "IsHidden", set = "SetHidden", disabled = "OptionDisabled", width = "full", order = 4, }, edit = { type = "execute", name = L["Edit Bars..."], desc = L["Show the ReAction Bar Editor dialogue"], handler = self:GetModule("ConfigUI"), func = "OptionShowEditor", order = 5, }, _closeThis = { type = "toggle", name = L["Close on Launch"], desc = L["Close the Interface Options window when launching the ReAction Bar Editor"], handler = self:GetModule("ConfigUI"), get = "OptionGetCloseThis", set = "OptionSetCloseThis", order = 6, cmdHidden = true, dropdownHidden = true, }, keybind = { type = "execute", name = L["Key Bindings"], desc = L["Show the keybinding dialogue"], func = function() self:SetKeybindMode(true) end, order = 7, }, skipProfileWarning = { type = "toggle", name = L["Skip profile keybind warning"], desc = L["Don't show a warning about updating keybinds when switching profiles"], get = function() return ReAction.db.global.skipKeybindWarning end, set = function(info, value) ReAction.db.global.skipKeybindWarning = value end, width = "double", order = 8, }, } } end return self.options end function ReAction:GetProfileOptions() if not self.profileOptions then self.profileOptions = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) end return self.profileOptions end function ReAction:InitializeOptions() local AceConfigReg = LibStub("AceConfigRegistry-3.0") local AceConfigDialog = LibStub("AceConfigDialog-3.0") AceConfigReg:RegisterOptionsTable(configID,ReAction:GetOptions()) AceConfigReg:RegisterOptionsTable(configProfileID,ReAction:GetProfileOptions()) self.configFrame = AceConfigDialog:AddToBlizOptions(configID, L["ReAction"]) self.configProfileFrame = AceConfigDialog:AddToBlizOptions(configProfileID, L["Profiles"], configID) self.configFrame.obj:SetCallback("default", function() self.db:ResetProfile() AceConfigReg:NotifyChange(configID) end ) self.db.RegisterCallback(self,"OnProfileChanged") self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged") self.db.RegisterCallback(self,"OnProfileCopied","OnProfileChanged") SlashCmdList["REACTION"] = SlashHandler _G["SLASH_REACTION1"] = "/reaction" _G["SLASH_REACTION2"] = "/rxn" StaticPopupDialogs["REACTION_KB_WARN"] = { text = L["ReAction profile changed: check your keybinds, they may need to be updated."], button1 = L["OK"], hideOnEscape = true, enterClicksFirstButton = true, timeout = 0, showAlert = true, whileDead = true, } end function ReAction:ShowOptions() InterfaceOptionsFrame_OpenToCategory(configID) end function ReAction:PopKeybindWarning() if not self.db.global.skipKeybindWarning then StaticPopup_Show("REACTION_KB_WARN") end end function ReAction:OnProfileChanged() self:Disable() self:Enable() self:PopKeybindWarning() end -- export to LDB LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject( "ReAction", { type = "launcher", icon = "Interface\\Icons\\INV_Qiraj_JewelEncased", OnClick = function( frame, button ) if not InCombatLockdown() then if IsAltKeyDown() then ReAction:SetKeybindMode( not ReAction:GetKeybindMode() ) elseif IsShiftKeyDown() then ReAction:SetConfigMode( not ReAction:GetConfigMode() ) elseif button == "RightButton" then ReAction:ShowEditor() else ReAction:ShowOptions() end else ReAction:UserError(L["ReAction: can't configure in combat"]) end end, -- this isn't included in the 'launcher' type LDB spec but it seems all launcher displays use it OnTooltipShow = function( tooltip ) tooltip:AddLine(format("|cffffffff%s|r %s",L["Click"],L["for options"])) tooltip:AddLine(format("|cffffd200%s|r %s",L["Right-click"],L["for bar editor dialog"])) tooltip:AddLine(format("|cff00ff00%s|r %s",L["Shift-click"],L["to unlock bars"])) tooltip:AddLine(format("|cff00cccc%s|r %s",L["Alt-click"],L["for keybind mode"])) end, } )