Mercurial > wow > reaction
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 181:c8777ae7d460 | 182:55c2fc0c8d55 |
|---|---|
| 1 local addonName, addonTable = ... | |
| 2 local ReAction = addonTable.ReAction | |
| 3 local L = ReAction.L | |
| 4 local InCombatLockdown = InCombatLockdown | |
| 5 | |
| 6 | |
| 7 local configID = "ReAction" | |
| 8 local configProfileID = "ReAction_Profile" | |
| 9 | |
| 10 local function SlashHandler(option) | |
| 11 if option == "config" or option == "options" then | |
| 12 ReAction:ShowOptions() | |
| 13 elseif option == "edit" then | |
| 14 ReAction:ShowEditor() | |
| 15 elseif option == "unlock" then | |
| 16 ReAction:SetConfigMode(true) | |
| 17 elseif option == "lock" then | |
| 18 ReAction:SetConfigMode(false) | |
| 19 elseif option == "kb" then | |
| 20 ReAction:SetKeybindMode(true) | |
| 21 else | |
| 22 print(("%3.1f"):format(version)) | |
| 23 print("/rxn config") | |
| 24 print("/rxn edit") | |
| 25 print("/rxn lock") | |
| 26 print("/rxn unlock") | |
| 27 print("/rxn kb") | |
| 28 end | |
| 29 end | |
| 30 | |
| 31 | |
| 32 function ReAction:GetOptions() | |
| 33 if not self.options then | |
| 34 self.options = { | |
| 35 type = "group", | |
| 36 name = "ReAction", | |
| 37 args = { | |
| 38 _desc = { | |
| 39 type = "description", | |
| 40 name = L["Customizable replacement for Blizzard's Action Bars"], | |
| 41 order = 1, | |
| 42 }, | |
| 43 unlock = { | |
| 44 type = "toggle", | |
| 45 name = L["Unlock Bars"], | |
| 46 desc = L["Unlock bars for dragging and resizing with the mouse"], | |
| 47 handler = self, | |
| 48 get = "GetConfigMode", | |
| 49 set = function(info, value) self:SetConfigMode(value) end, | |
| 50 width = "full", | |
| 51 disabled = InCombatLockdown, | |
| 52 order = 2, | |
| 53 }, | |
| 54 hide = { | |
| 55 type = "toggle", | |
| 56 name = L["Hide Blizzard Action Bars"], | |
| 57 desc = L["Hide the default main bar and extra action bars"], | |
| 58 handler = self:GetModule("HideBlizzard"), | |
| 59 get = "IsHidden", | |
| 60 set = "SetHidden", | |
| 61 disabled = "OptionDisabled", | |
| 62 width = "full", | |
| 63 order = 3, | |
| 64 }, | |
| 65 hideVehicle = { | |
| 66 type = "toggle", | |
| 67 name = L["Hide Blizzard Vehicle Bar"], | |
| 68 desc = L["Hide the default vechicle action bar"], | |
| 69 handler = self:GetModule("HideBlizzard"), | |
| 70 get = "IsHidden", | |
| 71 set = "SetHidden", | |
| 72 disabled = "OptionDisabled", | |
| 73 width = "full", | |
| 74 order = 4, | |
| 75 }, | |
| 76 edit = { | |
| 77 type = "execute", | |
| 78 name = L["Edit Bars..."], | |
| 79 desc = L["Show the ReAction Bar Editor dialogue"], | |
| 80 handler = self:GetModule("ConfigUI"), | |
| 81 func = "OptionShowEditor", | |
| 82 order = 5, | |
| 83 }, | |
| 84 _closeThis = { | |
| 85 type = "toggle", | |
| 86 name = L["Close on Launch"], | |
| 87 desc = L["Close the Interface Options window when launching the ReAction Bar Editor"], | |
| 88 handler = self:GetModule("ConfigUI"), | |
| 89 get = "OptionGetCloseThis", | |
| 90 set = "OptionSetCloseThis", | |
| 91 order = 6, | |
| 92 cmdHidden = true, | |
| 93 dropdownHidden = true, | |
| 94 }, | |
| 95 keybind = { | |
| 96 type = "execute", | |
| 97 name = L["Key Bindings"], | |
| 98 desc = L["Show the keybinding dialogue"], | |
| 99 func = function() self:SetKeybindMode(true) end, | |
| 100 order = 7, | |
| 101 }, | |
| 102 skipProfileWarning = { | |
| 103 type = "toggle", | |
| 104 name = L["Skip profile keybind warning"], | |
| 105 desc = L["Don't show a warning about updating keybinds when switching profiles"], | |
| 106 get = function() return ReAction.db.global.skipKeybindWarning end, | |
| 107 set = function(info, value) ReAction.db.global.skipKeybindWarning = value end, | |
| 108 width = "double", | |
| 109 order = 8, | |
| 110 }, | |
| 111 } | |
| 112 } | |
| 113 end | |
| 114 return self.options | |
| 115 end | |
| 116 | |
| 117 | |
| 118 function ReAction:GetProfileOptions() | |
| 119 if not self.profileOptions then | |
| 120 self.profileOptions = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) | |
| 121 end | |
| 122 return self.profileOptions | |
| 123 end | |
| 124 | |
| 125 | |
| 126 function ReAction:InitializeOptions() | |
| 127 local AceConfigReg = LibStub("AceConfigRegistry-3.0") | |
| 128 local AceConfigDialog = LibStub("AceConfigDialog-3.0") | |
| 129 | |
| 130 AceConfigReg:RegisterOptionsTable(configID,ReAction:GetOptions()) | |
| 131 AceConfigReg:RegisterOptionsTable(configProfileID,ReAction:GetProfileOptions()) | |
| 132 | |
| 133 self.configFrame = AceConfigDialog:AddToBlizOptions(configID, L["ReAction"]) | |
| 134 self.configProfileFrame = AceConfigDialog:AddToBlizOptions(configProfileID, L["Profiles"], configID) | |
| 135 | |
| 136 self.configFrame.obj:SetCallback("default", | |
| 137 function() | |
| 138 self.db:ResetProfile() | |
| 139 AceConfigReg:NotifyChange(configID) | |
| 140 end ) | |
| 141 | |
| 142 self.db.RegisterCallback(self,"OnProfileChanged") | |
| 143 self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged") | |
| 144 self.db.RegisterCallback(self,"OnProfileCopied","OnProfileChanged") | |
| 145 | |
| 146 SlashCmdList["REACTION"] = SlashHandler | |
| 147 _G["SLASH_REACTION1"] = "/reaction" | |
| 148 _G["SLASH_REACTION2"] = "/rxn" | |
| 149 | |
| 150 StaticPopupDialogs["REACTION_KB_WARN"] = { | |
| 151 text = L["ReAction profile changed: check your keybinds, they may need to be updated."], | |
| 152 button1 = L["OK"], | |
| 153 hideOnEscape = true, | |
| 154 enterClicksFirstButton = true, | |
| 155 timeout = 0, | |
| 156 showAlert = true, | |
| 157 whileDead = true, | |
| 158 } | |
| 159 end | |
| 160 | |
| 161 | |
| 162 function ReAction:ShowOptions() | |
| 163 InterfaceOptionsFrame_OpenToCategory(configID) | |
| 164 end | |
| 165 | |
| 166 | |
| 167 function ReAction:PopKeybindWarning() | |
| 168 if not self.db.global.skipKeybindWarning then | |
| 169 StaticPopup_Show("REACTION_KB_WARN") | |
| 170 end | |
| 171 end | |
| 172 | |
| 173 function ReAction:OnProfileChanged() | |
| 174 self:Disable() | |
| 175 self:Enable() | |
| 176 self:PopKeybindWarning() | |
| 177 end | |
| 178 | |
| 179 | |
| 180 -- export to LDB | |
| 181 LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject( "ReAction", | |
| 182 { | |
| 183 type = "launcher", | |
| 184 icon = "Interface\\Icons\\INV_Qiraj_JewelEncased", | |
| 185 | |
| 186 OnClick = function( frame, button ) | |
| 187 if not InCombatLockdown() then | |
| 188 if IsAltKeyDown() then | |
| 189 ReAction:SetKeybindMode( not ReAction:GetKeybindMode() ) | |
| 190 elseif IsShiftKeyDown() then | |
| 191 ReAction:SetConfigMode( not ReAction:GetConfigMode() ) | |
| 192 elseif button == "RightButton" then | |
| 193 ReAction:ShowEditor() | |
| 194 else | |
| 195 ReAction:ShowOptions() | |
| 196 end | |
| 197 else | |
| 198 ReAction:UserError(L["ReAction: can't configure in combat"]) | |
| 199 end | |
| 200 end, | |
| 201 | |
| 202 -- this isn't included in the 'launcher' type LDB spec but it seems all launcher displays use it | |
| 203 OnTooltipShow = function( tooltip ) | |
| 204 tooltip:AddLine(format("|cffffffff%s|r %s",L["Click"],L["for options"])) | |
| 205 tooltip:AddLine(format("|cffffd200%s|r %s",L["Right-click"],L["for bar editor dialog"])) | |
| 206 tooltip:AddLine(format("|cff00ff00%s|r %s",L["Shift-click"],L["to unlock bars"])) | |
| 207 tooltip:AddLine(format("|cff00cccc%s|r %s",L["Alt-click"],L["for keybind mode"])) | |
| 208 end, | |
| 209 | |
| 210 } | |
| 211 ) |
