flickerstreak@182: local addonName, addonTable = ... flickerstreak@182: local ReAction = addonTable.ReAction flickerstreak@182: local L = ReAction.L flickerstreak@182: local InCombatLockdown = InCombatLockdown flickerstreak@182: flickerstreak@182: flickerstreak@182: local configID = "ReAction" flickerstreak@184: local displayName = L["ReAction"] flickerstreak@182: flickerstreak@182: flickerstreak@182: function ReAction:InitializeOptions() flickerstreak@184: local AceConfigReg = LibStub("AceConfigRegistry-3.0") flickerstreak@182: local AceConfigDialog = LibStub("AceConfigDialog-3.0") flickerstreak@182: flickerstreak@184: local options = { flickerstreak@184: type = "group", flickerstreak@184: name = displayName, flickerstreak@184: handler = self, flickerstreak@184: args = { flickerstreak@184: general = { flickerstreak@184: type = "group", flickerstreak@184: name = displayName, flickerstreak@184: args = { flickerstreak@184: _desc = { flickerstreak@184: type = "description", flickerstreak@184: name = L["Customizable replacement for Blizzard's Action Bars"], flickerstreak@184: order = 1, flickerstreak@184: }, flickerstreak@184: unlock = { flickerstreak@184: type = "toggle", flickerstreak@184: name = L["Unlock Bars"], flickerstreak@184: desc = L["Unlock bars for dragging and resizing with the mouse"], flickerstreak@184: get = "GetConfigMode", flickerstreak@184: set = "OptionSetConfigMode", flickerstreak@184: width = "full", flickerstreak@184: disabled = InCombatLockdown, flickerstreak@184: order = 2, flickerstreak@184: }, flickerstreak@184: hide = { flickerstreak@184: type = "toggle", flickerstreak@184: name = L["Hide Blizzard Action Bars"], flickerstreak@184: desc = L["Hide the default main bar and extra action bars"], flickerstreak@184: handler = self:GetModule("HideBlizzard"), flickerstreak@184: get = "IsHidden", flickerstreak@184: set = "SetHidden", flickerstreak@184: disabled = "OptionDisabled", flickerstreak@184: width = "full", flickerstreak@184: order = 3, flickerstreak@184: }, flickerstreak@184: hideVehicle = { flickerstreak@184: type = "toggle", flickerstreak@184: name = L["Hide Blizzard Vehicle Bar"], flickerstreak@184: desc = L["Hide the default vechicle action bar"], flickerstreak@184: handler = self:GetModule("HideBlizzard"), flickerstreak@184: get = "IsHidden", flickerstreak@184: set = "SetHidden", flickerstreak@184: disabled = "OptionDisabled", flickerstreak@184: width = "full", flickerstreak@184: order = 4, flickerstreak@184: }, flickerstreak@184: edit = { flickerstreak@184: type = "execute", flickerstreak@184: name = L["Edit Bars..."], flickerstreak@184: desc = L["Show the ReAction Bar Editor dialogue"], flickerstreak@184: func = "OptionShowEditor", flickerstreak@184: order = 5, flickerstreak@184: }, flickerstreak@184: _closeThis = { flickerstreak@184: type = "toggle", flickerstreak@184: name = L["Close on Launch"], flickerstreak@184: desc = L["Close the Interface Options window when launching the ReAction Bar Editor"], flickerstreak@184: get = "OptionGetCloseThis", flickerstreak@184: set = "OptionSetCloseThis", flickerstreak@184: order = 6, flickerstreak@184: cmdHidden = true, flickerstreak@184: dropdownHidden = true, flickerstreak@184: }, flickerstreak@184: keybind = { flickerstreak@184: type = "execute", flickerstreak@184: name = L["Key Bindings"], flickerstreak@184: desc = L["Show the keybinding dialogue"], flickerstreak@184: func = "OptionLaunchKeybindMode", flickerstreak@184: order = 7, flickerstreak@184: }, flickerstreak@184: skipProfileWarning = { flickerstreak@184: type = "toggle", flickerstreak@184: name = L["Skip profile keybind warning"], flickerstreak@184: desc = L["Don't show a warning about updating keybinds when switching profiles"], flickerstreak@184: get = "OptionGetSkipKeybindWarning", flickerstreak@184: set = "OptionSetSkipKeybindWarning", flickerstreak@184: width = "double", flickerstreak@184: order = 8, flickerstreak@184: }, flickerstreak@184: } flickerstreak@184: }, flickerstreak@184: profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db), flickerstreak@184: } flickerstreak@184: } flickerstreak@182: flickerstreak@184: AceConfigReg:RegisterOptionsTable(configID,options) flickerstreak@182: flickerstreak@184: local f = AceConfigDialog:AddToBlizOptions(configID, displayName, nil, "general") flickerstreak@184: flickerstreak@184: if f and f.obj then flickerstreak@184: f.obj:SetCallback("default", flickerstreak@184: function() flickerstreak@184: self.db:ResetProfile() flickerstreak@184: AceConfigReg:NotifyChange(configID) flickerstreak@184: end ) flickerstreak@184: end flickerstreak@184: flickerstreak@184: AceConfigDialog:AddToBlizOptions(configID, options.args.profiles.name, configID, "profiles") flickerstreak@182: flickerstreak@182: self.db.RegisterCallback(self,"OnProfileChanged") flickerstreak@182: self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged") flickerstreak@182: self.db.RegisterCallback(self,"OnProfileCopied","OnProfileChanged") flickerstreak@182: flickerstreak@184: SlashCmdList["REACTION"] = function(option) flickerstreak@184: option = string.match(option or "", "^%s*(%S+)") flickerstreak@184: if option == "config" or option == "options" then flickerstreak@184: ReAction:ShowOptions() flickerstreak@184: elseif option == "edit" then flickerstreak@184: ReAction:ShowEditor() flickerstreak@184: elseif option == "unlock" then flickerstreak@184: ReAction:SetConfigMode(true) flickerstreak@184: elseif option == "lock" then flickerstreak@184: ReAction:SetConfigMode(false) flickerstreak@184: elseif option == "kb" then flickerstreak@184: ReAction:SetKeybindMode(true) flickerstreak@184: else flickerstreak@185: print(("%s %s %s"):format(L["ReAction"], ReAction.version, L["Usage:"])) flickerstreak@184: print("/rxn config") flickerstreak@184: print("/rxn edit") flickerstreak@184: print("/rxn lock") flickerstreak@184: print("/rxn unlock") flickerstreak@184: print("/rxn kb") flickerstreak@184: end flickerstreak@184: end flickerstreak@184: flickerstreak@182: _G["SLASH_REACTION1"] = "/reaction" flickerstreak@182: _G["SLASH_REACTION2"] = "/rxn" flickerstreak@182: flickerstreak@182: StaticPopupDialogs["REACTION_KB_WARN"] = { flickerstreak@182: text = L["ReAction profile changed: check your keybinds, they may need to be updated."], flickerstreak@182: button1 = L["OK"], flickerstreak@182: hideOnEscape = true, flickerstreak@182: enterClicksFirstButton = true, flickerstreak@182: timeout = 0, flickerstreak@182: showAlert = true, flickerstreak@182: whileDead = true, flickerstreak@182: } flickerstreak@182: end flickerstreak@182: flickerstreak@182: flickerstreak@182: function ReAction:ShowOptions() flickerstreak@182: InterfaceOptionsFrame_OpenToCategory(configID) flickerstreak@182: end flickerstreak@182: flickerstreak@182: flickerstreak@184: function ReAction:OnProfileChanged() flickerstreak@184: self:RebuildAll() flickerstreak@182: if not self.db.global.skipKeybindWarning then flickerstreak@182: StaticPopup_Show("REACTION_KB_WARN") flickerstreak@182: end flickerstreak@182: end flickerstreak@182: flickerstreak@184: flickerstreak@184: function ReAction:OptionSetConfigMode(info, value) flickerstreak@184: self:SetConfigMode(value) flickerstreak@182: end flickerstreak@182: flickerstreak@182: flickerstreak@184: function ReAction:OptionShowEditor() flickerstreak@184: self:ShowEditor() flickerstreak@184: if self.db.profile.closeOptionsOnEditorLaunch then flickerstreak@184: InterfaceOptionsFrame:Hide() flickerstreak@184: end flickerstreak@184: end flickerstreak@184: flickerstreak@184: flickerstreak@184: function ReAction:OptionGetCloseThis() flickerstreak@184: return self.db.profile.closeOptionsOnEditorLaunch flickerstreak@184: end flickerstreak@184: flickerstreak@184: flickerstreak@184: function ReAction:OptionSetCloseThis(info,val) flickerstreak@184: self.db.profile.closeOptionsOnEditorLaunch = val flickerstreak@184: end flickerstreak@184: flickerstreak@184: flickerstreak@184: function ReAction:OptionLaunchKeybindMode() flickerstreak@184: self:SetKeybindMode(true) flickerstreak@184: end flickerstreak@184: flickerstreak@184: flickerstreak@184: function ReAction:OptionGetSkipKeybindWarning() flickerstreak@184: return self.db.global.skipKeybindWarning flickerstreak@184: end flickerstreak@184: flickerstreak@184: flickerstreak@184: function ReAction:OptionSetSkipKeybindWarning(info, value) flickerstreak@184: self.db.global.skipKeybindWarning = value flickerstreak@184: end flickerstreak@184: flickerstreak@184: flickerstreak@182: -- export to LDB flickerstreak@184: local LDB = LibStub:GetLibrary("LibDataBroker-1.1") flickerstreak@184: if LDB then flickerstreak@184: LDB:NewDataObject( "ReAction", flickerstreak@182: { flickerstreak@182: type = "launcher", flickerstreak@182: icon = "Interface\\Icons\\INV_Qiraj_JewelEncased", flickerstreak@182: flickerstreak@182: OnClick = function( frame, button ) flickerstreak@182: if not InCombatLockdown() then flickerstreak@182: if IsAltKeyDown() then flickerstreak@182: ReAction:SetKeybindMode( not ReAction:GetKeybindMode() ) flickerstreak@182: elseif IsShiftKeyDown() then flickerstreak@182: ReAction:SetConfigMode( not ReAction:GetConfigMode() ) flickerstreak@182: elseif button == "RightButton" then flickerstreak@182: ReAction:ShowEditor() flickerstreak@182: else flickerstreak@182: ReAction:ShowOptions() flickerstreak@182: end flickerstreak@182: else flickerstreak@182: ReAction:UserError(L["ReAction: can't configure in combat"]) flickerstreak@182: end flickerstreak@182: end, flickerstreak@182: flickerstreak@182: -- this isn't included in the 'launcher' type LDB spec but it seems all launcher displays use it flickerstreak@182: OnTooltipShow = function( tooltip ) flickerstreak@182: tooltip:AddLine(format("|cffffffff%s|r %s",L["Click"],L["for options"])) flickerstreak@182: tooltip:AddLine(format("|cffffd200%s|r %s",L["Right-click"],L["for bar editor dialog"])) flickerstreak@182: tooltip:AddLine(format("|cff00ff00%s|r %s",L["Shift-click"],L["to unlock bars"])) flickerstreak@182: tooltip:AddLine(format("|cff00cccc%s|r %s",L["Alt-click"],L["for keybind mode"])) flickerstreak@182: end, flickerstreak@182: flickerstreak@184: }) flickerstreak@184: end