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