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