Mercurial > wow > skeletonkey
comparison SkeletonKey/BindingsUI.lua @ 16:cdd387d39137
filename refactor
author | Nenue |
---|---|
date | Fri, 29 Jul 2016 21:18:15 -0400 |
parents | 32d64e42ec9b |
children | 500f9b2bd9ac |
comparison
equal
deleted
inserted
replaced
15:32d64e42ec9b | 16:cdd387d39137 |
---|---|
1 -- KrakTool | 1 -- KrakTool |
2 -- BindingsUI.lua | 2 -- BindingsUI.lua |
3 -- Created: 7/28/2016 3:39 PM | 3 -- Created: 7/28/2016 3:39 PM |
4 -- %file-revision% | 4 -- %file-revision% |
5 -- | 5 -- Code piecing the interface together |
6 | 6 |
7 local kb, print = LibStub("LibKraken").register(KeyBinder, 'KeySlot') | 7 local kb, print = LibStub("LibKraken").register(KeyBinder, 'KeySlot') |
8 local BINDS_PER_ROW = 2 | 8 local BINDS_PER_ROW = 2 |
9 local BUTTON_HSPACING = 128 | 9 local BUTTON_HSPACING = 128 |
10 local BUTTON_SPACING = 4 | 10 local BUTTON_SPACING = 4 |
36 | 36 |
37 local restingAlpha = 0.7 | 37 local restingAlpha = 0.7 |
38 local fadeTime, fadeDelay = .30, 0.15 | 38 local fadeTime, fadeDelay = .30, 0.15 |
39 local numButtons = BINDS_PER_ROW * 8 | 39 local numButtons = BINDS_PER_ROW * 8 |
40 local saveButton | 40 local saveButton |
41 local KeyButton_OnKeyDown = function(self, key) | 41 local KeyButton_OnKey = function(self, key) |
42 kb.StoreBinding(self, key) | 42 kb.StoreBinding(self.saveTarget, key) |
43 end | 43 kb:SetScript('OnKeyUp', nil) |
44 kb:SetScript('OnKeyDown', nil) | |
45 end | |
46 | |
44 local KeyButton_OnClick = function(self, click) | 47 local KeyButton_OnClick = function(self, click) |
45 print(self:GetName(), 'OnMouseDown', click) | 48 print(self:GetName(), 'OnMouseDown', click) |
49 local cursorType = GetCursorInfo() | |
46 if click == 'LeftButton' then | 50 if click == 'LeftButton' then |
47 kb.DropToSlot(self) | 51 if cursorType then |
52 kb.DropToSlot(self) | |
53 else | |
54 kb.ActivateSlot(self) | |
55 end | |
48 elseif click == 'RightButton' then | 56 elseif click == 'RightButton' then |
49 kb.ReleaseSlot(self) | 57 kb.ReleaseSlot(self) |
50 else | |
51 kb.StoreBinding(self, click:upper()) | |
52 end | 58 end |
53 end | 59 end |
54 | 60 |
55 local KeyButton_OnDragStart = function(self) | 61 local KeyButton_OnDragStart = function(self) |
56 kb.PickupSlot(self) | 62 kb.PickupSlot(self) |
101 if self:IsMouseOver() then | 107 if self:IsMouseOver() then |
102 kb.elapsed = 0 | 108 kb.elapsed = 0 |
103 if not self.active then | 109 if not self.active then |
104 -- only set this handler when the button is activated/mouseOver | 110 -- only set this handler when the button is activated/mouseOver |
105 self.active = true | 111 self.active = true |
106 self:SetScript('OnKeyDown', KeyButton_OnKeyDown) | |
107 | |
108 kb.statustext:SetText(self.statusText .. ': '..self.actionName) | 112 kb.statustext:SetText(self.statusText .. ': '..self.actionName) |
109 kb.bindingstext:SetText(self.bindingText) | 113 kb.bindingstext:SetText(self.bindingText) |
110 kb.fadeStep = 0 | 114 kb.fadeStep = 0 |
111 kb.throttle = 0 | 115 kb.throttle = 0 |
112 kb:SetScript('OnUpdate', KeyBinder_OnUpdate) | 116 kb:SetScript('OnUpdate', KeyBinder_OnUpdate) |
258 end | 262 end |
259 return kb.buttons[index] | 263 return kb.buttons[index] |
260 end | 264 end |
261 end | 265 end |
262 | 266 |
267 | |
268 kb.ActivateSlot = function(self) | |
269 kb.saveTarget = self | |
270 kb:SetScript('OnKeyUp', KeyButton_OnKey) | |
271 kb.bg:SetColorTexture(0,.5,0,1) | |
272 end | |
263 | 273 |
264 --- push current information into living UI | 274 --- push current information into living UI |
265 kb.ui = function(force) | 275 kb.ui = function(force) |
266 for i, module in ipairs(kb.modules) do | 276 for i, module in ipairs(kb.modules) do |
267 if module.ui then | 277 if module.ui then |