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@182: local configProfileID = "ReAction_Profile" flickerstreak@182: flickerstreak@182: local function SlashHandler(option) flickerstreak@182: if option == "config" or option == "options" then flickerstreak@182: ReAction:ShowOptions() flickerstreak@182: elseif option == "edit" then flickerstreak@182: ReAction:ShowEditor() flickerstreak@182: elseif option == "unlock" then flickerstreak@182: ReAction:SetConfigMode(true) flickerstreak@182: elseif option == "lock" then flickerstreak@182: ReAction:SetConfigMode(false) flickerstreak@182: elseif option == "kb" then flickerstreak@182: ReAction:SetKeybindMode(true) flickerstreak@182: else flickerstreak@182: print(("%3.1f"):format(version)) flickerstreak@182: print("/rxn config") flickerstreak@182: print("/rxn edit") flickerstreak@182: print("/rxn lock") flickerstreak@182: print("/rxn unlock") flickerstreak@182: print("/rxn kb") flickerstreak@182: end flickerstreak@182: end flickerstreak@182: flickerstreak@182: flickerstreak@182: function ReAction:GetOptions() flickerstreak@182: if not self.options then flickerstreak@182: self.options = { flickerstreak@182: type = "group", flickerstreak@182: name = "ReAction", flickerstreak@182: args = { flickerstreak@182: _desc = { flickerstreak@182: type = "description", flickerstreak@182: name = L["Customizable replacement for Blizzard's Action Bars"], flickerstreak@182: order = 1, flickerstreak@182: }, flickerstreak@182: unlock = { flickerstreak@182: type = "toggle", flickerstreak@182: name = L["Unlock Bars"], flickerstreak@182: desc = L["Unlock bars for dragging and resizing with the mouse"], flickerstreak@182: handler = self, flickerstreak@182: get = "GetConfigMode", flickerstreak@182: set = function(info, value) self:SetConfigMode(value) end, flickerstreak@182: width = "full", flickerstreak@182: disabled = InCombatLockdown, flickerstreak@182: order = 2, flickerstreak@182: }, flickerstreak@182: hide = { flickerstreak@182: type = "toggle", flickerstreak@182: name = L["Hide Blizzard Action Bars"], flickerstreak@182: desc = L["Hide the default main bar and extra action bars"], flickerstreak@182: handler = self:GetModule("HideBlizzard"), flickerstreak@182: get = "IsHidden", flickerstreak@182: set = "SetHidden", flickerstreak@182: disabled = "OptionDisabled", flickerstreak@182: width = "full", flickerstreak@182: order = 3, flickerstreak@182: }, flickerstreak@182: hideVehicle = { flickerstreak@182: type = "toggle", flickerstreak@182: name = L["Hide Blizzard Vehicle Bar"], flickerstreak@182: desc = L["Hide the default vechicle action bar"], flickerstreak@182: handler = self:GetModule("HideBlizzard"), flickerstreak@182: get = "IsHidden", flickerstreak@182: set = "SetHidden", flickerstreak@182: disabled = "OptionDisabled", flickerstreak@182: width = "full", flickerstreak@182: order = 4, flickerstreak@182: }, flickerstreak@182: edit = { flickerstreak@182: type = "execute", flickerstreak@182: name = L["Edit Bars..."], flickerstreak@182: desc = L["Show the ReAction Bar Editor dialogue"], flickerstreak@182: handler = self:GetModule("ConfigUI"), flickerstreak@182: func = "OptionShowEditor", flickerstreak@182: order = 5, flickerstreak@182: }, flickerstreak@182: _closeThis = { flickerstreak@182: type = "toggle", flickerstreak@182: name = L["Close on Launch"], flickerstreak@182: desc = L["Close the Interface Options window when launching the ReAction Bar Editor"], flickerstreak@182: handler = self:GetModule("ConfigUI"), flickerstreak@182: get = "OptionGetCloseThis", flickerstreak@182: set = "OptionSetCloseThis", flickerstreak@182: order = 6, flickerstreak@182: cmdHidden = true, flickerstreak@182: dropdownHidden = true, flickerstreak@182: }, flickerstreak@182: keybind = { flickerstreak@182: type = "execute", flickerstreak@182: name = L["Key Bindings"], flickerstreak@182: desc = L["Show the keybinding dialogue"], flickerstreak@182: func = function() self:SetKeybindMode(true) end, flickerstreak@182: order = 7, flickerstreak@182: }, flickerstreak@182: skipProfileWarning = { flickerstreak@182: type = "toggle", flickerstreak@182: name = L["Skip profile keybind warning"], flickerstreak@182: desc = L["Don't show a warning about updating keybinds when switching profiles"], flickerstreak@182: get = function() return ReAction.db.global.skipKeybindWarning end, flickerstreak@182: set = function(info, value) ReAction.db.global.skipKeybindWarning = value end, flickerstreak@182: width = "double", flickerstreak@182: order = 8, flickerstreak@182: }, flickerstreak@182: } flickerstreak@182: } flickerstreak@182: end flickerstreak@182: return self.options flickerstreak@182: end flickerstreak@182: flickerstreak@182: flickerstreak@182: function ReAction:GetProfileOptions() flickerstreak@182: if not self.profileOptions then flickerstreak@182: self.profileOptions = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) flickerstreak@182: end flickerstreak@182: return self.profileOptions flickerstreak@182: end flickerstreak@182: flickerstreak@182: flickerstreak@182: function ReAction:InitializeOptions() flickerstreak@182: local AceConfigReg = LibStub("AceConfigRegistry-3.0") flickerstreak@182: local AceConfigDialog = LibStub("AceConfigDialog-3.0") flickerstreak@182: flickerstreak@182: AceConfigReg:RegisterOptionsTable(configID,ReAction:GetOptions()) flickerstreak@182: AceConfigReg:RegisterOptionsTable(configProfileID,ReAction:GetProfileOptions()) flickerstreak@182: flickerstreak@182: self.configFrame = AceConfigDialog:AddToBlizOptions(configID, L["ReAction"]) flickerstreak@182: self.configProfileFrame = AceConfigDialog:AddToBlizOptions(configProfileID, L["Profiles"], configID) flickerstreak@182: flickerstreak@182: self.configFrame.obj:SetCallback("default", flickerstreak@182: function() flickerstreak@182: self.db:ResetProfile() flickerstreak@182: AceConfigReg:NotifyChange(configID) flickerstreak@182: end ) 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@182: SlashCmdList["REACTION"] = SlashHandler 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@182: function ReAction:PopKeybindWarning() 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@182: function ReAction:OnProfileChanged() flickerstreak@182: self:Disable() flickerstreak@182: self:Enable() flickerstreak@182: self:PopKeybindWarning() flickerstreak@182: end flickerstreak@182: flickerstreak@182: flickerstreak@182: -- export to LDB flickerstreak@182: LibStub:GetLibrary("LibDataBroker-1.1"):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@182: } flickerstreak@182: )