Mercurial > wow > reaction
comparison ReAction.lua @ 116:fb48811a8736
Convert to standard keybindings
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 23 Jan 2009 23:44:55 +0000 |
parents | d39cfbdde301 |
children | a2d2f23137c8 |
comparison
equal
deleted
inserted
replaced
115:af0172ed7037 | 116:fb48811a8736 |
---|---|
55 local L = LibStub("AceLocale-3.0"):GetLocale("ReAction") | 55 local L = LibStub("AceLocale-3.0"):GetLocale("ReAction") |
56 ReAction.L = L | 56 ReAction.L = L |
57 | 57 |
58 ------ PRIVATE ------ | 58 ------ PRIVATE ------ |
59 local weak = {__mode="k"} | 59 local weak = {__mode="k"} |
60 local private = { | 60 local private = { } |
61 allKB = setmetatable({}, weak), | |
62 kbHooked = setmetatable({}, weak), | |
63 } | |
64 local bars = {} | 61 local bars = {} |
65 local defaultBarConfig = {} | 62 local defaultBarConfig = {} |
66 local barOptionGenerators = { } | 63 local barOptionGenerators = { } |
67 local options = { | 64 local options = { |
68 type = "group", | 65 type = "group", |
84 name = L["Unlock Bars"], | 81 name = L["Unlock Bars"], |
85 desc = L["Unlock bars for dragging and resizing with the mouse"], | 82 desc = L["Unlock bars for dragging and resizing with the mouse"], |
86 handler = ReAction, | 83 handler = ReAction, |
87 get = "GetConfigMode", | 84 get = "GetConfigMode", |
88 set = function(info, value) ReAction:SetConfigMode(value) end, | 85 set = function(info, value) ReAction:SetConfigMode(value) end, |
86 width = "double", | |
89 disabled = InCombatLockdown, | 87 disabled = InCombatLockdown, |
90 order = 1 | 88 order = 1 |
89 }, | |
90 skipProfileWarning = { | |
91 type = "toggle", | |
92 name = L["Skip profile keybind warning"], | |
93 desc = L["Don't show a warning about updating keybinds when switching profiles"], | |
94 get = function() return ReAction.db.global.skipKeybindWarning end, | |
95 set = function(info, value) ReAction.db.global.skipKeybindWarning = value end, | |
96 width = "double", | |
97 order = 2, | |
91 }, | 98 }, |
92 }, | 99 }, |
93 plugins = { }, | 100 plugins = { }, |
94 order = 2, | 101 order = 2, |
95 }, | 102 }, |
105 }, | 112 }, |
106 plugins = { } | 113 plugins = { } |
107 } | 114 } |
108 ReAction.options = options | 115 ReAction.options = options |
109 | 116 |
110 local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy, CallModuleMethod, SlashHandler, KBAttach | 117 -- insert an entry into the WoW static popup dialogs list |
118 StaticPopupDialogs["REACTION_KB_WARN"] = { | |
119 text = L["ReAction profile changed: check your keybinds, they may need to be updated."], | |
120 button1 = L["OK"], | |
121 hideOnEscape = true, | |
122 enterClicksFirstButton = true, | |
123 timeout = 0, | |
124 showAlert = true, | |
125 whileDead = true, | |
126 } | |
127 | |
128 local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy, CallModuleMethod, SlashHandler | |
111 do | 129 do |
112 local pcall = pcall | 130 local pcall = pcall |
113 local geterrorhandler = geterrorhandler | 131 local geterrorhandler = geterrorhandler |
114 local self = ReAction | 132 local self = ReAction |
115 local inited = false | 133 local inited = false |
116 | |
117 local function kb_onEnter( self ) | |
118 if ReAction:GetKeybindMode() then | |
119 KB:Set(self) | |
120 end | |
121 end | |
122 | 134 |
123 function SelectBar(x) | 135 function SelectBar(x) |
124 local bar, name | 136 local bar, name |
125 if type(x) == "string" then | 137 if type(x) == "string" then |
126 name = x | 138 name = x |
210 self:Print("/rxn config") | 222 self:Print("/rxn config") |
211 self:Print("/rxn edit") | 223 self:Print("/rxn edit") |
212 self:Print("/rxn lock") | 224 self:Print("/rxn lock") |
213 self:Print("/rxn unlock") | 225 self:Print("/rxn unlock") |
214 self:Print("/rxn kb") | 226 self:Print("/rxn kb") |
215 end | |
216 end | |
217 | |
218 function KBAttach( frame ) | |
219 if not private.kbHooked[frame] then | |
220 -- avoid taint, particularly with SecureAnchorEnterTemplate | |
221 -- don't hook scripts multiple times, there isn't any unhook! | |
222 frame:HookScript("OnEnter",kb_onEnter) | |
223 private.kbHooked[frame] = true | |
224 end | 227 end |
225 end | 228 end |
226 | 229 |
227 end | 230 end |
228 | 231 |
261 end | 264 end |
262 | 265 |
263 function ReAction:OnProfileChanged() | 266 function ReAction:OnProfileChanged() |
264 TearDownBars() | 267 TearDownBars() |
265 InitializeBars() | 268 InitializeBars() |
269 self:PopKeybindWarning() | |
266 end | 270 end |
267 | 271 |
268 function ReAction:PLAYER_REGEN_DISABLED() | 272 function ReAction:PLAYER_REGEN_DISABLED() |
269 if private.configMode == true then | 273 if private.configMode == true then |
270 self:UserError(L["ReAction config mode disabled during combat."]) | 274 self:UserError(L["ReAction config mode disabled during combat."]) |
499 end | 503 end |
500 | 504 |
501 function ReAction:SetKeybindMode( mode ) | 505 function ReAction:SetKeybindMode( mode ) |
502 if mode ~= private.kbMode then | 506 if mode ~= private.kbMode then |
503 if mode then | 507 if mode then |
504 for f in pairs(private.allKB) do | |
505 KBAttach(f) | |
506 end | |
507 KB:Activate() | 508 KB:Activate() |
508 else | 509 else |
509 KB:Deactivate() | 510 KB:Deactivate() |
510 end | 511 end |
511 private.kbMode = KB:IsShown() or false | 512 private.kbMode = KB:IsShown() or false |
514 | 515 |
515 function ReAction:GetKeybindMode( mode ) | 516 function ReAction:GetKeybindMode( mode ) |
516 return private.kbMode | 517 return private.kbMode |
517 end | 518 end |
518 | 519 |
519 function ReAction:RegisterKeybindFrame( f ) | 520 function ReAction:PopKeybindWarning() |
520 private.allKB[f] = true | 521 if not self.db.global.skipKeybindWarning then |
521 if private.kbMode then | 522 StaticPopup_Show("REACTION_KB_WARN") |
522 KBAttach(f) | 523 end |
523 end | 524 end |
524 end | |
525 | |
526 function ReAction:FreeOverrideHotkey( key ) | |
527 for f in pairs(private.allKB) do | |
528 if f.GetBindings then | |
529 for i = 1, select('#', f:GetBindings()) do | |
530 if select(i, f:GetBindings()) == key then | |
531 if f.FreeKey then | |
532 return f:FreeKey(key) | |
533 else | |
534 local action = f.GetActionName and f:GetActionName() or f:GetName() | |
535 SetOverrideBinding(f, false, key, nil) | |
536 return action | |
537 end | |
538 end | |
539 end | |
540 end | |
541 end | |
542 end |