Mercurial > wow > reaction
comparison modules/ReAction_Action/ReAction_Action.lua @ 102:ad49739d110d
Added feature to lock buttons (per-bar), with optional only-in-combat selector.
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Sun, 26 Oct 2008 02:26:31 +0000 |
parents | 567a885cdfad |
children | b2fb8f7dc780 |
comparison
equal
deleted
inserted
replaced
101:3699d7dad312 | 102:ad49739d110d |
---|---|
148 type = "toggle", | 148 type = "toggle", |
149 width = "double", | 149 width = "double", |
150 get = "GetHideEmpty", | 150 get = "GetHideEmpty", |
151 set = "SetHideEmpty", | 151 set = "SetHideEmpty", |
152 }, | 152 }, |
153 lockButtons = { | |
154 name = L["Lock Buttons"], | |
155 desc = L["Prevents picking up/dragging actions.|nNOTE: This setting is overridden by the global setting in Blizzard's Action Buttons tab"], | |
156 order = 2, | |
157 type = "toggle", | |
158 disabled = "LockButtonsDisabled", | |
159 get = "GetLockButtons", | |
160 set = "SetLockButtons", | |
161 }, | |
162 lockOnlyCombat = { | |
163 name = L["Only in Combat"], | |
164 desc = L["Only lock the buttons when in combat"], | |
165 order = 3, | |
166 type = "toggle", | |
167 disabled = "LockButtonsCombatDisabled", | |
168 get = "GetLockButtonsCombat", | |
169 set = "SetLockButtonsCombat", | |
170 }, | |
153 pages = { | 171 pages = { |
154 name = L["# Pages"], | 172 name = L["# Pages"], |
155 desc = L["Use the Dynamic State tab to specify page transitions"], | 173 desc = L["Use the Dynamic State tab to specify page transitions"], |
156 order = 2, | 174 order = 4, |
157 type = "range", | 175 type = "range", |
158 min = 1, | 176 min = 1, |
159 max = 10, | 177 max = 10, |
160 step = 1, | 178 step = 1, |
161 get = "GetNumPages", | 179 get = "GetNumPages", |
162 set = "SetNumPages", | 180 set = "SetNumPages", |
163 }, | 181 }, |
164 mindcontrol = { | 182 mindcontrol = { |
165 name = L["Mind Control Support"], | 183 name = L["Mind Control Support"], |
166 desc = L["When possessing a target (e.g. via Mind Control), map the first 12 buttons of this bar to the possessed target's actions."], | 184 desc = L["When possessing a target (e.g. via Mind Control), map the first 12 buttons of this bar to the possessed target's actions."], |
167 order = 3, | 185 order = 5, |
168 type = "toggle", | 186 type = "toggle", |
169 width = "double", | 187 width = "double", |
170 set = "SetMindControl", | 188 set = "SetMindControl", |
171 get = "GetMindControl", | 189 get = "GetMindControl", |
172 }, | 190 }, |
173 actions = { | 191 actions = { |
174 name = L["Edit Action IDs"], | 192 name = L["Edit Action IDs"], |
175 order = 4, | 193 order = 6, |
176 type = "group", | 194 type = "group", |
177 inline = true, | 195 inline = true, |
178 args = { | 196 args = { |
179 method = { | 197 method = { |
180 name = L["Assign"], | 198 name = L["Assign"], |
288 self.btns[i] = nil | 306 self.btns[i] = nil |
289 btnCfg[i] = nil | 307 btnCfg[i] = nil |
290 end | 308 end |
291 end | 309 end |
292 end | 310 end |
311 local f = self.bar:GetFrame() | |
293 for _, b in ipairs(self.btns) do | 312 for _, b in ipairs(self.btns) do |
294 b:Refresh() | 313 b:Refresh() |
295 end | 314 end |
296 local f = self.bar:GetFrame() | |
297 f:SetAttribute("mindcontrol",self.config.mindcontrol) | 315 f:SetAttribute("mindcontrol",self.config.mindcontrol) |
298 f:Execute( | 316 f:Execute( |
299 [[ | 317 [[ |
300 doMindControl = self:GetAttribute("mindcontrol") | 318 doMindControl = self:GetAttribute("mindcontrol") |
301 control:ChildUpdate() | 319 control:ChildUpdate() |
305 -- function _onstate-mindcontrol(self, stateid, newstate) | 323 -- function _onstate-mindcontrol(self, stateid, newstate) |
306 [[ | 324 [[ |
307 control:ChildUpdate() | 325 control:ChildUpdate() |
308 ]]) | 326 ]]) |
309 RegisterStateDriver(f, "mindcontrol", "[bonusbar:5] mc; none") | 327 RegisterStateDriver(f, "mindcontrol", "[bonusbar:5] mc; none") |
328 self:UpdateButtonLock() | |
310 end | 329 end |
311 | 330 |
312 function Handle:Destroy() | 331 function Handle:Destroy() |
313 for _,b in pairs(self.btns) do | 332 for _,b in pairs(self.btns) do |
314 if b then | 333 if b then |
326 | 345 |
327 function Handle:ShowGrid(show) | 346 function Handle:ShowGrid(show) |
328 for _, b in pairs(self.btns) do | 347 for _, b in pairs(self.btns) do |
329 b:ShowGrid(show) | 348 b:ShowGrid(show) |
330 end | 349 end |
350 end | |
351 | |
352 function Handle:UpdateButtonLock() | |
353 local f = self.bar:GetFrame() | |
354 f:SetAttribute("lockbuttons",self.config.lockButtons) | |
355 f:SetAttribute("lockbuttonscombat",self.config.lockButtonsCombat) | |
356 f:Execute( | |
357 [[ | |
358 lockButtons = self:GetAttribute("lockbuttons") | |
359 lockButtonsCombat = self:GetAttribute("lockbuttonscombat") | |
360 ]]) | |
331 end | 361 end |
332 | 362 |
333 function Handle:SetKeybindMode(mode) | 363 function Handle:SetKeybindMode(mode) |
334 for _, b in pairs(self.btns) do | 364 for _, b in pairs(self.btns) do |
335 if mode then | 365 if mode then |
358 } | 388 } |
359 end | 389 end |
360 | 390 |
361 function Handle:SetHideEmpty(info, value) | 391 function Handle:SetHideEmpty(info, value) |
362 if value ~= self.config.hideEmpty then | 392 if value ~= self.config.hideEmpty then |
363 for b in self.bar:IterateButtons() do | |
364 b:ShowGrid(not value) | |
365 end | |
366 self.config.hideEmpty = value | 393 self.config.hideEmpty = value |
394 self:ShowGrid(not value) | |
367 end | 395 end |
368 end | 396 end |
369 | 397 |
370 function Handle:GetHideEmpty() | 398 function Handle:GetHideEmpty() |
371 return self.config.hideEmpty | 399 return self.config.hideEmpty |
400 end | |
401 | |
402 function Handle:GetLockButtons() | |
403 return LOCK_ACTIONBAR == "1" or self.config.lockButtons | |
404 end | |
405 | |
406 function Handle:SetLockButtons(info, value) | |
407 self.config.lockButtons = value | |
408 self:UpdateButtonLock() | |
409 end | |
410 | |
411 function Handle:LockButtonsDisabled() | |
412 return LOCK_ACTIONBAR == "1" | |
413 end | |
414 | |
415 function Handle:GetLockButtonsCombat() | |
416 return self.config.lockButtonsCombat | |
417 end | |
418 | |
419 function Handle:SetLockButtonsCombat(info, value) | |
420 self.config.lockButtonsCombat = value | |
421 self:UpdateButtonLock() | |
422 end | |
423 | |
424 function Handle:LockButtonsCombatDisabled() | |
425 return LOCK_ACTIONBAR == "1" or not self.config.lockButtons | |
372 end | 426 end |
373 | 427 |
374 function Handle:GetNumPages() | 428 function Handle:GetNumPages() |
375 return self.config.nPages | 429 return self.config.nPages |
376 end | 430 end |
896 end | 950 end |
897 local value = self:GetAttribute(action) | 951 local value = self:GetAttribute(action) |
898 self:SetAttribute("action",value) | 952 self:SetAttribute("action",value) |
899 ]]) | 953 ]]) |
900 | 954 |
955 -- install drag wrappers to lock buttons | |
956 bar:GetFrame():WrapScript(f, "OnDragStart", | |
957 -- OnDragStart(self, button, kind, value, ...) | |
958 [[ | |
959 if lockButtons and (PlayerInCombat() or not lockButtonsCombat) and not IsModifiedClick("PICKUPACTION") then | |
960 return "clear" | |
961 end | |
962 ]]) | |
963 | |
901 self.frame = f | 964 self.frame = f |
902 self.normalTexture = getglobal(format("%sNormalTexture",f:GetName())) | 965 self.normalTexture = getglobal(format("%sNormalTexture",f:GetName())) |
903 | 966 |
904 -- initialize the hide state | 967 -- initialize the hide state |
905 f:SetAttribute("showgrid",0) | 968 f:SetAttribute("showgrid",0) |