Mercurial > wow > skeletonkey
comparison SkeletonKey/BindingsUI.lua @ 19:67db6b712bf3
- option checkbutton literals are stored by enclosure
- detect and save any old keybindings when a slot is assigned (anything that begins with 'CLICK KeyBinder*' is ours)
- mouseover mode key input will stay active after leaving a button
- button border flashes when a non-modifier key is pressed
author | Nenue |
---|---|
date | Sat, 30 Jul 2016 19:08:11 -0400 |
parents | 91398d284a99 |
children |
comparison
equal
deleted
inserted
replaced
18:91398d284a99 | 19:67db6b712bf3 |
---|---|
35 local restingAlpha = 0.7 | 35 local restingAlpha = 0.7 |
36 local fadeTime, fadeDelay = .30, 0.15 | 36 local fadeTime, fadeDelay = .30, 0.15 |
37 local saveButton | 37 local saveButton |
38 | 38 |
39 local KeyButton_OnKeyDown = function(self, key) | 39 local KeyButton_OnKeyDown = function(self, key) |
40 if key == 'ESCAPE' or key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then | |
41 return | |
42 end | |
43 kb.saveTarget.border:SetColorTexture(1,1,1,1) | |
40 end | 44 end |
41 local KeyButton_OnKeyUp = function(self, key) | 45 local KeyButton_OnKeyUp = function(self, key) |
42 if key == 'ESCAPE' then | 46 if key == 'ESCAPE' then |
43 kb.DeactivateSlot(kb.saveTarget) | 47 kb.DeactivateSlot(kb.saveTarget) |
44 else | 48 kb.ui() |
45 | 49 return |
46 if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then | 50 end |
47 return | 51 |
48 end | 52 if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then |
49 kb.SaveSlot(kb.saveTarget, key) | 53 return |
50 | 54 end |
51 if not kb.stickyMode then | 55 |
52 kb:SetScript('OnKeyUp', nil) | 56 if kb.SaveSlot(kb.saveTarget, key) then |
53 kb:SetScript('OnKeyDown', nil) | 57 if not (kb.db.stickyMode or kb.db.hoverInput) then |
54 kb.saveTarget = nil | 58 |
55 end | 59 kb.DeactivateSlot(kb.saveTarget) |
56 end | 60 end |
57 kb.ui() | 61 kb.ui() |
62 end | |
58 end | 63 end |
59 | 64 |
60 local KeyButton_OnClick = function(self, click) | 65 local KeyButton_OnClick = function(self, click) |
61 print(self:GetName(), 'OnMouseDown', click) | 66 print(self:GetName(), 'OnMouseDown', click) |
62 local cursorType = GetCursorInfo() | 67 local cursorType = GetCursorInfo() |
63 if click == 'LeftButton' then | 68 if click == 'LeftButton' then |
64 if cursorType then | 69 if cursorType then |
65 kb.DropToSlot(self) | 70 kb.DropToSlot(self) |
66 else | 71 else |
67 if IsShiftKeyDown() then | 72 if IsShiftKeyDown() then |
68 kb.stickyMode = true | 73 kb.db.stickyMode = true |
69 KeyBinderStickyMode:SetChecked(true) | 74 KeyBinderStickyMode:SetChecked(true) |
70 | |
71 kb.saveTarget = button | |
72 kb:SetScript('OnKeyUp', KeyButton_OnKeyUp) | |
73 kb:SetScript('OnKeyDown', KeyButton_OnKeyDown) | |
74 end | 75 end |
75 | 76 |
76 kb.ActivateSlot(self) | 77 kb.ActivateSlot(self) |
77 kb.ui() | 78 kb.ui() |
78 end | 79 end |
143 kb.ui() | 144 kb.ui() |
144 end | 145 end |
145 | 146 |
146 end | 147 end |
147 else | 148 else |
148 if self.active then | 149 if self.active and kb.db.hoverInput then |
149 self.active = nil | 150 self.active = nil |
150 kb.DeactivateSlot(self) | 151 --kb.DeactivateSlot(self) |
151 kb.ui() | 152 --kb.ui() |
152 end | 153 end |
153 end | 154 end |
154 end | 155 end |
155 | 156 |
156 local KeyBinder_OnMouseWheel = function(self, delta) | 157 local KeyBinder_OnMouseWheel = function(self, delta) |
175 end | 176 end |
176 | 177 |
177 kb.ui(true) | 178 kb.ui(true) |
178 end | 179 end |
179 | 180 |
180 local CheckButton_OnEnter = function(self) | 181 local KeyBinder_CheckButton = function(frame ,enableText, disableText, dbKey, tooltipText, callback) |
181 if self.tooltip then | 182 if kb.db[dbKey] then |
182 GameTooltip:SetOwner(self) | 183 frame:SetChecked(true) |
183 GameTooltip:SetText(self.tooltip) | 184 end |
184 GameTooltip:Show() | 185 frame.label:SetText(kb.db[dbKey] and enableText or disableText) |
185 end | 186 frame:SetWidth(frame.label:GetStringWidth()+8) |
186 end | 187 |
187 local CheckButton_OnLeave = function(self) | 188 frame:SetScript('OnClick', function(self) |
188 if self.tooltip and GameTooltip:GetOwner() == self then | 189 if callback then |
189 GameTooltip:Hide() | 190 callback(self) |
190 end | 191 end |
191 | 192 kb.db[dbKey] = self:GetChecked() |
193 if not kb.db[dbKey] then | |
194 if kb.saveTarget then | |
195 kb.DeactivateSlot(kb.saveTarget) | |
196 end | |
197 end | |
198 self.label:SetText(kb.db[dbKey] and enableText or disableText) | |
199 self:SetWidth(self.label:GetStringWidth()+8) | |
200 kb.ui() | |
201 end) | |
202 | |
203 frame:SetScript('OnEnter', function(self) | |
204 if tooltipText then | |
205 GameTooltip:SetOwner(self) | |
206 GameTooltip:SetText(tooltipText) | |
207 GameTooltip:Show() | |
208 end | |
209 end) | |
210 | |
211 frame:SetScript('OnLeave', function(self) | |
212 if tooltipText and GameTooltip:GetOwner() == self then | |
213 GameTooltip:Hide() | |
214 end | |
215 end) | |
192 end | 216 end |
193 | 217 |
194 local KeyBinder_OnHide = function() | 218 local KeyBinder_OnHide = function() |
195 KeyBinderImportLog:Hide() | 219 KeyBinderImportLog:Hide() |
196 end | 220 end |
290 kb:uibutton( | 314 kb:uibutton( |
291 'KeyBinderInventoryButton', 'Bags', nil, | 315 'KeyBinderInventoryButton', 'Bags', nil, |
292 function() OpenAllBags() end, | 316 function() OpenAllBags() end, |
293 "Interface\\BUTTONS\\UI-MicroButtonCharacter-Up", {0, 1, .4, 1}) | 317 "Interface\\BUTTONS\\UI-MicroButtonCharacter-Up", {0, 1, .4, 1}) |
294 | 318 |
295 KeyBinderStickyMode.tooltip = 'Keep input active after receiving a key.' | 319 KeyBinder_CheckButton(KeyBinderStickyMode, 'Enabled', 'Disabled', 'stickyMode', 'Keep input active after receiving a key.') |
296 KeyBinderStickyMode:SetScript('OnClick', function(self) | 320 KeyBinder_CheckButton(KeyBinderHoverInput, 'MouseOver', 'Click', 'hoverInput', 'Enable key input when the cursor is over a binding slot.') |
297 kb.db.stickyMode = self:GetChecked() | |
298 if not kb.db.stickyMode then | |
299 if kb.saveTarget then | |
300 kb.DeactivateSlot(kb.saveTarget) | |
301 end | |
302 end | |
303 kb.ui() | |
304 end) | |
305 if kb.db.stickyMode then | |
306 KeyBinderStickyMode:SetChecked(true) | |
307 end | |
308 | |
309 KeyBinderHoverInput.tooltip = 'Enable key input when the cursor is over a binding slot.' | |
310 KeyBinderHoverInput:SetScript('OnClick', function(self) | |
311 kb.db.hoverInput = self:GetChecked() | |
312 kb.ui() | |
313 end) | |
314 if kb.db.hoverInput then | |
315 KeyBinderHoverInput:SetChecked(true) | |
316 end | |
317 | 321 |
318 | 322 |
319 KeyBinderUnbindButton:SetScript('OnClick', function() | 323 KeyBinderUnbindButton:SetScript('OnClick', function() |
320 if kb.saveTarget then | 324 if kb.saveTarget then |
321 kb.UnbindSlot(kb.saveTarget) | 325 kb.UnbindSlot(kb.saveTarget) |
322 end | 326 end |
323 kb.ui() | 327 kb.ui() |
324 end) | 328 end) |
325 | 329 |
326 KeyBinderStickyMode:SetScript('OnEnter', CheckButton_OnEnter) | |
327 KeyBinderHoverInput:SetScript('OnEnter', CheckButton_OnEnter) | |
328 KeyBinderStickyMode:SetScript('OnLeave', CheckButton_OnLeave) | |
329 KeyBinderHoverInput:SetScript('OnLeave', CheckButton_OnLeave) | |
330 | 330 |
331 kb.info:SetPoint('TOPLEFT', kb.UIPanels[1], 'BOTTOMLEFT', 0, -BUTTON_SPACING) | 331 kb.info:SetPoint('TOPLEFT', kb.UIPanels[1], 'BOTTOMLEFT', 0, -BUTTON_SPACING) |
332 HEADER_OFFSET = kb.UIPanels[1]:GetHeight() + BUTTON_PADDING | 332 HEADER_OFFSET = kb.UIPanels[1]:GetHeight() + BUTTON_PADDING |
333 + kb.info:GetHeight() | 333 + kb.info:GetHeight() |
334 FOOTER_OFFSET = saveButton:GetHeight() + BUTTON_PADDING | 334 FOOTER_OFFSET = saveButton:GetHeight() + BUTTON_PADDING |
432 | 432 |
433 kb:Show() | 433 kb:Show() |
434 | 434 |
435 if kb.saveTarget then | 435 if kb.saveTarget then |
436 KeyBinderUnbindButton:SetParent(kb.saveTarget) | 436 KeyBinderUnbindButton:SetParent(kb.saveTarget) |
437 KeyBinderUnbindButton:SetPoint('TOPRIGHT', kb.saveTarget, 'TOPLEFT', -2,0) | 437 KeyBinderUnbindButton:SetPoint('TOPLEFT', kb.saveTarget, 'BOTTOMLEFT', 0, -1) |
438 KeyBinderUnbindButton:Show() | 438 KeyBinderUnbindButton:Show() |
439 else | 439 else |
440 KeyBinderUnbindButton:Hide() | 440 KeyBinderUnbindButton:Hide() |
441 end | 441 end |
442 | |
443 KeyBinderStickyMode.label:SetText(kb.db.stickyMode and 'Sticky' or 'Normal') | |
444 KeyBinderHoverInput.label:SetText(kb.db.hoverInput and 'MouseOver' or 'Manual') | |
445 | 442 |
446 -- Reset this so talent cache can be rebuilt | 443 -- Reset this so talent cache can be rebuilt |
447 kb.talentsPushed = nil | 444 kb.talentsPushed = nil |
448 end | 445 end |
449 | 446 |