Mercurial > wow > skeletonkey
comparison SkeletonKey/UI.lua @ 6:f6d1c192afc6
Refactored file layout:
- frame display logic in UI.lua
- player data in Cache.lua
- event responses in Events.lua
a lot of local tables are now stored members of KeyBinder for that to work
author | Nenue |
---|---|
date | Thu, 28 Jul 2016 16:45:56 -0400 |
parents | |
children | a2fc77fa4c73 |
comparison
equal
deleted
inserted
replaced
5:9ac29fe77455 | 6:f6d1c192afc6 |
---|---|
1 -- KrakTool | |
2 -- UI.lua | |
3 -- Created: 7/28/2016 3:39 PM | |
4 -- %file-revision% | |
5 -- | |
6 | |
7 local kb, print = LibStub("LibKraken").register(KeyBinder, 'KeySlot') | |
8 local BINDS_PER_ROW = 2 | |
9 local BUTTON_HSPACING = 128 | |
10 local BUTTON_SPACING = 4 | |
11 local BUTTON_PADDING = 12 | |
12 local BINDING_TYPE_SPECIALIZATION = 3 | |
13 local BINDING_TYPE_CHARACTER = 2 | |
14 local BINDING_TYPE_GLOBAL = 1 | |
15 local KEY_BUTTON_SIZE = 48 | |
16 local MIN_BIND_SLOTS = 32 | |
17 local TAB_OFFSET = 12 | |
18 local TAB_HEIGHT = 40 | |
19 local TAB_SPACING = 2 | |
20 local BORDER_UNASSIGNED = {0.2,0.2,0.2,1 } | |
21 local BORDER_ASSIGNED = {0.5,0.5,0.5,1 } | |
22 local BORDER_DYNAMIC = {1,1,0,1} | |
23 local BORDER_PENDING = {1,0.5,0,1 } | |
24 | |
25 local BUTTON_HEADERS = { | |
26 ['spell'] = SPELLS, | |
27 ['macro'] = MACRO, | |
28 ['petaction'] = PET, | |
29 ['mount'] = MOUNT, | |
30 ['battlepet'] = BATTLEPET, | |
31 | |
32 | |
33 [5] = PROFESSIONS_FIRST_AID, | |
34 [7] = PROFESSIONS_COOKING, | |
35 [9] = PROFESSIONS_FISHING, | |
36 [10] = PROFESSIONS_ARCHAEOLOGY, | |
37 | |
38 } | |
39 | |
40 local BINDING_SCHEME_COLOR = { | |
41 [BINDING_TYPE_GLOBAL] = {0,.125,.5,.5}, | |
42 [BINDING_TYPE_CHARACTER] = {0,0.25,0,0.5}, | |
43 [BINDING_TYPE_SPECIALIZATION] = {.25,0,0,0.5}, | |
44 } | |
45 local BINDING_SCHEME_VERTEX = { | |
46 [BINDING_TYPE_GLOBAL] = {0,.5,1,1}, | |
47 [BINDING_TYPE_CHARACTER] = {0,1,0,1}, | |
48 [BINDING_TYPE_SPECIALIZATION] = {1,1,1,1}, | |
49 } | |
50 local BINDING_SCHEME_TEXT = { | |
51 [BINDING_TYPE_SPECIALIZATION] = {0, 1, 1}, | |
52 [BINDING_TYPE_CHARACTER] = {0, 1, 0}, | |
53 [BINDING_TYPE_GLOBAL] = {0, 1, 1} | |
54 } | |
55 | |
56 local restingAlpha = 0.7 | |
57 local fadeTime, fadeDelay = .30, 0.15 | |
58 local numButtons = BINDS_PER_ROW * 8 | |
59 local saveButton | |
60 local KeyButton_OnKeyDown = function(self, key) | |
61 kb.StoreBinding(self, key) | |
62 end | |
63 local KeyButton_OnClick = function(self, click) | |
64 print(self:GetName(), 'OnMouseDown', click) | |
65 if click == 'LeftButton' then | |
66 kb.DropToSlot(self) | |
67 elseif click == 'RightButton' then | |
68 kb.ReleaseSlot(self) | |
69 else | |
70 kb.StoreBinding(self, click:upper()) | |
71 end | |
72 end | |
73 | |
74 local KeyButton_OnDragStart = function(self) | |
75 kb.PickupSlot(self) | |
76 end | |
77 | |
78 local KeyButton_OnReceiveDrag = function(self, ...) | |
79 kb.DropToSlot(self) | |
80 end | |
81 | |
82 | |
83 local KeyBinder_OnUpdate = function(self, elapsed) | |
84 self.elapsed = self.elapsed + elapsed | |
85 self.throttle = self.throttle + elapsed | |
86 | |
87 if (self.throttle >= 0.032) then | |
88 self.throttle = 0 | |
89 else | |
90 return | |
91 end | |
92 | |
93 local progress = 1 | |
94 if self.elapsed > fadeTime then | |
95 self.elapsed = 0 | |
96 self.fadeStep = 0 | |
97 --self.statustext:SetText(nil) | |
98 --self.bindingstext:SetText(nil) | |
99 self:SetScript('OnUpdate', nil) | |
100 else | |
101 if self.elapsed < fadeDelay then | |
102 progress = 0 | |
103 else | |
104 self.fadeStep = self.fadeStep + 1 | |
105 progress = (self.elapsed - fadeDelay) /(fadeTime - fadeDelay) | |
106 end | |
107 --print(self.fadeStep, format('%.02f/%.02f', (self.elapsed - fadeDelay) ,(fadeTime - fadeDelay)) , progress) | |
108 end | |
109 | |
110 local alpha = 1 - progress * (1- restingAlpha) | |
111 self.statustext:SetAlpha(alpha) | |
112 self.bindingstext:SetAlpha(alpha) | |
113 end | |
114 | |
115 local KeyButton_OnUpdate = function(self) | |
116 if not self.command then | |
117 return | |
118 end | |
119 | |
120 if self:IsMouseOver() then | |
121 kb.elapsed = 0 | |
122 if not self.active then | |
123 -- only set this handler when the button is activated/mouseOver | |
124 self.active = true | |
125 self:SetScript('OnKeyDown', KeyButton_OnKeyDown) | |
126 | |
127 kb.statustext:SetText(self.statusText .. ': '..self.actionName) | |
128 kb.bindingstext:SetText(self.bindingText) | |
129 kb.fadeStep = 0 | |
130 kb.throttle = 0 | |
131 kb:SetScript('OnUpdate', KeyBinder_OnUpdate) | |
132 | |
133 end | |
134 else | |
135 if self.active then | |
136 self.active = nil | |
137 self:SetScript('OnKeyDown', nil) | |
138 end | |
139 end | |
140 end | |
141 | |
142 local KeyBinder_OnMouseWheel = function(self, delta) | |
143 print(self, delta, self.scrollOffset, (self.scrollOffset <= 0)) | |
144 | |
145 | |
146 if IsControlKeyDown() then | |
147 KEY_BUTTON_SIZE = KEY_BUTTON_SIZE - delta | |
148 else | |
149 | |
150 | |
151 if (delta > 0) and (self.scrollOffset <= 0) then | |
152 return | |
153 elseif delta < 0 and kb.scrollOffset >= 42 then | |
154 return | |
155 end | |
156 kb.scrollOffset = ceil(kb.scrollOffset - (delta * BINDS_PER_ROW)) | |
157 end | |
158 | |
159 kb.ui(true) | |
160 end | |
161 | |
162 local KeyBinder_OnHide = function() | |
163 KeyBinderImportLog:Hide() | |
164 end | |
165 | |
166 local CloseButton_OnClick = function() | |
167 db.showUI = false | |
168 kb:Hide() | |
169 end | |
170 local CancelButton_OnClick = function() | |
171 kb.RevertBindings() | |
172 end | |
173 local SaveButton_OnClick = function() | |
174 kb.ConfirmBindings() | |
175 end | |
176 | |
177 local KeyBinder_Initialize = function() | |
178 | |
179 | |
180 kb.scrollOffset = 0 | |
181 kb.tabAnchor = {'TOPLEFT', kb.profilebg, 'TOPLEFT', BUTTON_PADDING, -BUTTON_SPACING} | |
182 kb.tabGrowth = {'TOPLEFT', nil,'TOPRIGHT', BUTTON_SPACING, 0} | |
183 kb.tabSize = {TAB_HEIGHT, TAB_HEIGHT } | |
184 kb.UIPanelAnchor = {'TOPLEFT', kb.sourcesbg, 'TOPLEFT', BUTTON_PADDING, -BUTTON_SPACING} | |
185 kb.UIPanelGrowth = {'TOPLEFT', nil, 'BOTTOMLEFT', 0, -2 } | |
186 kb.UIPanelSize = {84, 32 } | |
187 kb.UIPanelIcon = {24, 32, 'LEFT', -12, 0} | |
188 kb.controlsAnchor = {'BOTTOMLEFT', kb.footer, BUTTON_PADDING, BUTTON_PADDING } | |
189 kb.controlsGrowth = {'BOTTOMLEFT', nil, 'BOTTOMRIGHT', BUTTON_SPACING, 0} | |
190 | |
191 -- order of these is important | |
192 kb:tab('KeyBinderGlobalTab', | |
193 kb.configTitle[BINDING_TYPE_GLOBAL] .. '\n' .. kb.configDescription[BINDING_TYPE_GLOBAL], "Interface\\ICONS\\item_azereansphere", {0.15,.85,.15,.85}) | |
194 kb:tab('KeyBinderCharacterTab', | |
195 kb.configHeaders[BINDING_TYPE_CHARACTER] .. '\n' .. kb.configDescription[BINDING_TYPE_CHARACTER], nil) | |
196 kb:tab('KeyBinderSpecTab', | |
197 kb.configHeaders[BINDING_TYPE_SPECIALIZATION] .. '\n' .. kb.configDescription[BINDING_TYPE_SPECIALIZATION], kb.specInfo.texture) | |
198 KeyBinderCharacterTab.icon:SetTexCoord(0.15,.85,.15,.85) | |
199 | |
200 | |
201 | |
202 --portraitLayers[1] = KeyBinderCharacterTab.icon | |
203 | |
204 saveButton = kb:button('KeyBinderSaveButton', 'Save', 'Commit all changes.', SaveButton_OnClick) | |
205 --restoreButton = kb:button('KeyBinderRestoreButton', 'Discard', 'Revert all changes.', CancelButton_OnClick) | |
206 --clearButton = kb:button('KeyBinderClearButton', 'Clear Page', 'Release all buttons.', ResetButton_OnClick) | |
207 | |
208 kb:uibutton( | |
209 'KeyBinderSpellBookButton', 'SpellBook', nil, | |
210 function() ToggleSpellBook(BOOKTYPE_SPELL) end, | |
211 "Interface\\BUTTONS\\UI-MicroButton-Spellbook-Up", {0, 1, .4, 1}) | |
212 kb:uibutton( | |
213 'KeyBinderTalentFrameButton', TALENTS, SPECIALIZATION, | |
214 function() ToggleTalentFrame() end, | |
215 "Interface\\BUTTONS\\UI-MicroButton-Talents-Up", {0, 1, .4, 1}) | |
216 | |
217 kb:uibutton( | |
218 'KeyBinderMacroFrameButton', 'Macros', nil, | |
219 function() if MacroFrame and MacroFrame:IsVisible() then | |
220 HideUIPanel(MacroFrame) | |
221 else | |
222 ShowMacroFrame() end | |
223 end, | |
224 "Interface\\BUTTONS\\UI-MicroButton-Help-Up", {0, 1, .4, 1}) | |
225 | |
226 kb:uibutton( | |
227 'KeyBinderInventoryButton', 'Bags', nil, | |
228 function() OpenAllBags() end, | |
229 "Interface\\BUTTONS\\UI-MicroButtonCharacter-Up", {0, 1, .4, 1}) | |
230 | |
231 | |
232 | |
233 kb.info:SetPoint('TOPLEFT', kb.UIPanels[1], 'BOTTOMLEFT', 0, -BUTTON_SPACING) | |
234 HEADER_OFFSET = kb.UIPanels[1]:GetHeight() + BUTTON_PADDING | |
235 + kb.info:GetHeight() | |
236 FOOTER_OFFSET = saveButton:GetHeight() + BUTTON_PADDING | |
237 | |
238 kb:SetScript('OnHide', KeyBinder_OnHide) | |
239 kb:SetScript('OnMouseWheel', KeyBinder_OnMouseWheel) | |
240 kb.CloseButton:SetScript('OnClick', CloseButton_OnClick) | |
241 | |
242 end | |
243 | |
244 --- Resets button command | |
245 kb.ReleaseSlot = function(self) | |
246 local slot = self:GetID() | |
247 | |
248 | |
249 if kb.currentProfile.buttons[slot] then | |
250 kb.currentProfile.buttons[slot] = nil | |
251 end | |
252 if self.command then | |
253 kb.currentProfile.commands[self.command] = nil | |
254 end | |
255 if self.actionType == 'spell' and IsTalentSpell(self.actionName) then | |
256 if kb.currentProfile.talents[self.actionID] then | |
257 kb.currentProfile.talents[self.actionID] = nil | |
258 end | |
259 end | |
260 local droppedKeys = {} | |
261 | |
262 -- doing removal in second loop to avoid possible iterator shenanigans | |
263 for k,v in pairs(kb.currentProfile.bindings) do | |
264 if v == self.command then | |
265 tinsert(droppedKeys, k) | |
266 end | |
267 end | |
268 if #droppedKeys >=1 then | |
269 for i, k in ipairs(droppedKeys) do | |
270 kb.currentProfile.bindings[k] = nil | |
271 end | |
272 end | |
273 | |
274 self.isAvailable = nil | |
275 self.isDynamic = nil | |
276 self.bindingText = nil | |
277 self.statusText = nil | |
278 self.command = nil | |
279 self.actionType = nil | |
280 self.actionID = nil | |
281 self.actionName = nil | |
282 self.pickupSlot = nil | |
283 self.pickupBook = nil | |
284 self.macroName = nil | |
285 self.profile = nil | |
286 self.icon:SetTexture(nil) | |
287 self.border:SetColorTexture(unpack(BORDER_UNASSIGNED)) | |
288 self:EnableKeyboard(false) | |
289 self:SetScript('OnKeyDown', nil) | |
290 end | |
291 | |
292 kb.SetSlot = function(self, command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook) | |
293 local slot = self:GetID() | |
294 local isDynamic, isAvailable | |
295 | |
296 print('|cFFFFFF00SetSlot|r:', self:GetID()) | |
297 if command then | |
298 | |
299 if actionType == 'spell' then | |
300 local professionNum, spellNum = command:match("profession_(%d)_(%d)") | |
301 | |
302 if (professionNum and spellNum) then | |
303 isDynamic = 'profession' | |
304 local cacheInfo = kb.ProfessionCache[professionNum..'_'..spellNum] | |
305 if cacheInfo then | |
306 isAvailable = true | |
307 name = cacheInfo.spellName | |
308 icon = cacheInfo.icon | |
309 actionID = cacheInfo.spellID | |
310 self.profIndex = cacheInfo.profIndex | |
311 self.spellOffset = cacheInfo.spellOffset | |
312 end | |
313 print(' Special slot: |cFF00FFFFProfession|r', professionNum, spellNum, isDynamic, isAvailable) | |
314 | |
315 self.professionNum = tonumber(professionNum) | |
316 self.spellNum = tonumber(spellNum) | |
317 | |
318 else | |
319 if kb.TalentCache[actionID] then | |
320 isDynamic = 'talent' | |
321 print(' Special slot: |cFFBBFF00talent|r', name, isAvailable) | |
322 end | |
323 | |
324 isAvailable = GetSpellInfo(name) | |
325 end | |
326 actionID = name | |
327 elseif actionType == 'macro' then | |
328 if not actionID then | |
329 actionID = GetMacroIndexByName(name) | |
330 end | |
331 isAvailable = true | |
332 else | |
333 --- Journal selections | |
334 -- todo: consider using the deep end of blizzard action bar instead | |
335 if not actionID then | |
336 actionID = command:match("^KeyBinderMacro:(.+)") | |
337 end | |
338 isAvailable = true | |
339 end | |
340 | |
341 if isAvailable then | |
342 local oldCommand = command | |
343 macroName, macroText, command = kb.RegisterAction(actionType, actionID) | |
344 if oldCommand ~= command then | |
345 print('|cFFFF4400fixing command string', actionType, actionID, name) | |
346 kb.currentProfile.bound[oldCommand] = nil | |
347 kb.currentProfile.bound[command] = slot | |
348 for k,v in pairs(kb.currentProfile.bindings) do | |
349 if v == oldCommand then | |
350 kb.currentProfile.bindings[k] = command | |
351 end | |
352 end | |
353 end | |
354 kb.LoadBinding(command, name, icon, actionType, actionID, macroName, macroText) | |
355 end | |
356 | |
357 if actionType == 'petaction' then | |
358 self.pickupSlot = pickupSlot | |
359 self.pickupBook = pickupBook | |
360 else | |
361 self.pickupSlot = nil | |
362 self.pickupBook = nil | |
363 end | |
364 | |
365 actionID = actionID or 0 | |
366 self:EnableKeyboard(true) | |
367 print(' |cFF00FF00kb.currentProfile.buttons['..slot..'] |cFF00FFFF=|r |cFF00FFFF"'.. command.. '"|r |cFF00FF00"'.. name, '"|r |cFFFFFF00icon:'.. icon .. '|r |cFFFF8800"'.. actionType, '"|r |cFFFF0088id:'.. actionID ..'|r |cFF00FF00"'.. macroName .. '"|r') | |
368 kb.currentProfile.buttons[slot] = {command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook} | |
369 | |
370 -- Clean up conflicting entries for loaded button | |
371 local previous = kb.currentProfile.commands[command] | |
372 if previous ~= slot and kb.buttons[previous] then | |
373 kb.ReleaseSlot(kb.buttons[previous]) | |
374 end | |
375 kb.currentProfile.commands[command] = slot | |
376 end | |
377 | |
378 self.isAvailable = isAvailable | |
379 self.isDynamic = isDynamic | |
380 | |
381 self.macroText = macroText | |
382 self.macroName = macroName | |
383 self.actionType = actionType | |
384 self.actionID = actionID | |
385 self.actionName = name | |
386 self.command = command | |
387 self.icon:SetTexture(icon) | |
388 self.profile = kb.db.bindMode | |
389 self:RegisterForDrag('LeftButton') | |
390 end | |
391 | |
392 --- Retrieves button at index; creates said button and instates any stored parameters | |
393 local leftSlot, upSlot | |
394 local buttonsDepth = 0 | |
395 kb.GetSlot = function(index) | |
396 | |
397 local slot = index + kb.scrollOffset | |
398 | |
399 if not kb.buttons[index] then | |
400 local button = CreateFrame('CheckButton', 'KeyBinderSlot'..index, kb, 'KeyButton') | |
401 button:SetScript('OnClick', KeyButton_OnClick) | |
402 button:SetScript('OnUpdate', KeyButton_OnUpdate) | |
403 button:SetScript('OnDragStart', KeyButton_OnDragStart) | |
404 button:SetScript('OnReceiveDrag', KeyButton_OnReceiveDrag) | |
405 button:RegisterForClicks('AnyUp') | |
406 | |
407 | |
408 local newRow = (mod(index, BINDS_PER_ROW) == 1) | |
409 | |
410 if index == 1 then | |
411 button:SetPoint('TOPLEFT', kb.bg, 'TOPLEFT', BUTTON_PADDING, - BUTTON_PADDING) | |
412 upSlot = button | |
413 buttonsDepth = KEY_BUTTON_SIZE + BUTTON_PADDING * 2 | |
414 elseif newRow then | |
415 button:SetPoint('TOPLEFT', upSlot, 'BOTTOMLEFT', 0, -BUTTON_SPACING) | |
416 upSlot = button | |
417 buttonsDepth = buttonsDepth + KEY_BUTTON_SIZE + BUTTON_SPACING | |
418 else | |
419 button:SetPoint('TOPLEFT', leftSlot, 'TOPRIGHT', BUTTON_HSPACING, 0) | |
420 end | |
421 | |
422 button:SetSize(KEY_BUTTON_SIZE, KEY_BUTTON_SIZE) | |
423 button:Show() | |
424 kb.buttons[index] = button | |
425 leftSlot = button | |
426 end | |
427 return kb.buttons[index] | |
428 end | |
429 | |
430 --- Updates profile assignment and button contents | |
431 kb.UpdateSlot = function(self, force) | |
432 local slot = self:GetID() | |
433 | |
434 if force then | |
435 if kb.currentProfile.buttons[slot] then | |
436 kb.SetSlot(self, unpack(kb.currentProfile.buttons[slot])) | |
437 else | |
438 kb.ReleaseSlot(self) | |
439 end | |
440 end | |
441 | |
442 if self.command then | |
443 print('['..slot..'] =', self.command, GetBindingKey(self.command)) | |
444 | |
445 if self.pending then | |
446 self.border:SetColorTexture(unpack(BORDER_PENDING)) | |
447 elseif self.isDynamic then | |
448 self.border:SetColorTexture(unpack(BORDER_DYNAMIC)) | |
449 else | |
450 self.border:SetColorTexture(unpack(BORDER_ASSIGNED)) | |
451 end | |
452 | |
453 if self.actionType == 'macro' then | |
454 self.macro:Show() | |
455 else | |
456 self.macro:Hide() | |
457 if self.actionType == 'spell' then | |
458 local dummy = GetSpellInfo(self.actionName) | |
459 if not dummy then | |
460 self.icon:SetDesaturated(true) | |
461 else | |
462 self.icon:SetDesaturated(false) | |
463 end | |
464 | |
465 end | |
466 end | |
467 | |
468 if self.isDynamic then | |
469 print('|cFFFFBB00UpdateSlot|r: ', self.isDynamic, self.isAvailable, self.actionID) | |
470 end | |
471 | |
472 if self.isDynamic == 'profession' then | |
473 local profText = (self.spellNum == 1) and TRADE_SKILLS or (BUTTON_HEADERS[self.profIndex] or GetProfessionInfo(self.profIndex)) | |
474 if self.isAvailable then | |
475 print(self.profIndex, 'spnum', type(self.spellNum), (self.spellNum == 1)) | |
476 | |
477 self.statusText = '|cFFFFFF00'..profText..'|r' | |
478 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | |
479 else | |
480 self.statusText = '|cFFFF4400'..profText..'|r' | |
481 self.actionName = '(need to train profession #'..self.profNum..')' | |
482 self.bindingText ='?' | |
483 end | |
484 elseif self.isDynamic == 'talent' then | |
485 | |
486 self.statusText = '|cFF00FFFF'.. TALENT .. '|r' | |
487 if self.isAvailable then | |
488 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | |
489 else | |
490 if kb.inactiveTalentBindings[self.actionID] then | |
491 print(self.actionID, #kb.inactiveTalentBindings[self.actionID]) | |
492 self.bindingText= kb.BindingString(unpack(kb.inactiveTalentBindings[self.actionID])) | |
493 end | |
494 | |
495 end | |
496 else | |
497 self.statusText = '|cFF00FF00'.. (BUTTON_HEADERS[self.actionType] and BUTTON_HEADERS[self.actionType] or self.actionType) .. '|r' | |
498 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | |
499 end | |
500 | |
501 local locked, layer = kb.IsCommandBound(self) | |
502 if locked then | |
503 self.icon:SetAlpha(0.5) | |
504 else | |
505 self.icon:SetAlpha(1) | |
506 end | |
507 | |
508 if self.actionType == 'spell' then | |
509 self.icon:SetTexture(GetSpellTexture(self.actionID)) | |
510 end | |
511 end | |
512 | |
513 if not self.isAvailable then | |
514 self.bind:SetTextColor(0.7,0.7,0.7,1) | |
515 else | |
516 self.bind:SetTextColor(1,1,1,1) | |
517 end | |
518 | |
519 self.header:SetText(self.statusText) | |
520 self.bind:SetText(self.bindingText) | |
521 self.macro:SetText(self.macroName) | |
522 self.details:SetText(self.actionName) | |
523 end | |
524 | |
525 --- push current information into living UI | |
526 kb.ui = function(force) | |
527 for i, module in ipairs(kb.modules) do | |
528 if module.ui then | |
529 module.ui(force) | |
530 end | |
531 end | |
532 | |
533 if not kb.db.showUI then | |
534 print('---end of refresh') | |
535 return | |
536 end | |
537 if not kb.loaded then | |
538 KeyBinder_Initialize() | |
539 kb.loaded = true | |
540 end | |
541 for i = 1, numButtons do | |
542 local button = kb.GetSlot(i) | |
543 button:SetID(i+kb.scrollOffset) | |
544 kb.UpdateSlot(button, force) | |
545 end | |
546 | |
547 if kb.bindsCommitted then | |
548 KeyBinderSaveButton:Disable() | |
549 --KeyBinderRestoreButton:Disable() | |
550 else | |
551 KeyBinderSaveButton:Enable() | |
552 --KeyBinderRestoreButton:Enable() | |
553 end | |
554 | |
555 --- Frame Sizing | |
556 kb.profilebg:SetHeight(kb.tabSize[2] + BUTTON_PADDING * 2 + kb.profiletext:GetStringHeight()) | |
557 | |
558 kb.bg:SetWidth((KEY_BUTTON_SIZE + BUTTON_HSPACING + BUTTON_SPACING) * BINDS_PER_ROW + BUTTON_PADDING*2 - BUTTON_SPACING) | |
559 local numRows = numButtons/BINDS_PER_ROW | |
560 | |
561 kb.bg:SetHeight((KEY_BUTTON_SIZE + BUTTON_SPACING) * numRows + BUTTON_PADDING*2 - BUTTON_SPACING) | |
562 | |
563 kb:SetHeight(kb.headerbg:GetHeight() + kb.profilebg:GetHeight() + kb.bg:GetHeight() + kb.footer:GetHeight()) | |
564 kb:SetWidth((kb.sourcesbg:GetWidth() +(BINDS_PER_ROW * (KEY_BUTTON_SIZE + BUTTON_HSPACING) + (BINDS_PER_ROW - 1) * BUTTON_SPACING + BUTTON_PADDING * 2) )) | |
565 | |
566 kb.bg:SetColorTexture(unpack(BINDING_SCHEME_COLOR[kb.db.bindMode])) | |
567 for i, tab in ipairs(kb.tabButtons) do | |
568 local border = tab:GetNormalTexture() | |
569 local tabTexture = "Interface\\Buttons\\UI-Quickslot2" | |
570 local left, top, right, bottom = -12, 12, 13, -13 | |
571 if i == kb.db.bindMode then | |
572 tabTexture = "Interface\\Buttons\\CheckButtonGlow" | |
573 left, top, right, bottom = -14, 14, 15, -15 | |
574 tab.icon:SetDesaturated(false) | |
575 if tab.icon2 then tab.icon2:SetDesaturated(false) end | |
576 border:SetDesaturated(true) | |
577 border:SetVertexColor(1,1,1, 1) | |
578 else | |
579 tab.icon:SetDesaturated(true) | |
580 if tab.icon2 then tab.icon2:SetDesaturated(true) end | |
581 border:SetDesaturated(false) | |
582 border:SetVertexColor(1,1,1) | |
583 end | |
584 border:SetTexture(tabTexture) | |
585 border:SetPoint('TOPLEFT', tab, 'TOPLEFT', left, top) | |
586 border:SetPoint('BOTTOMRIGHT', tab, 'BOTTOMRIGHT', right, bottom) | |
587 end | |
588 | |
589 KeyBinderSpecTab.icon:SetTexture(kb.specInfo.texture) | |
590 | |
591 kb.profiletext:SetText(kb.configHeaders[kb.db.bindMode]) | |
592 print(kb.db.bindMode, kb.configHeaders[kb.db.bindMode], kb:GetSize()) | |
593 print(kb:GetPoint(1)) | |
594 | |
595 kb:Show() | |
596 | |
597 -- Reset this so talent cache can be rebuilt | |
598 kb.talentsPushed = nil | |
599 end | |
600 | |
601 kb.AcceptAssignment = function(self, ...) | |
602 local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] | |
603 local source = loadedProfiles[popup.oldProfile] | |
604 kb.SetSlot(popup.slot, unpack(popup.args)) | |
605 kb.UpdateSlot(popup.slot) | |
606 kb:SetScript('OnMouseWheel', KeyBinder_OnMouseWheel) -- re-enable scrolling | |
607 ClearCursor() | |
608 ResetCursor() | |
609 end | |
610 | |
611 | |
612 --- Add to blizzard interfaces | |
613 StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] = { | |
614 text = "Confirm moving an assigned command.", | |
615 button1 = OKAY, | |
616 button2 = CANCEL, | |
617 timeout = 0, | |
618 whileDead = 1, | |
619 showAlert = 1, | |
620 OnAccept = kb.AcceptAssignment, | |
621 OnCancel = function() kb:SetScript('OnMouseWheel', KeyBinder_OnMouseWheel) end | |
622 } |