Mercurial > wow > skeletonkey
comparison KeyButton.lua @ 72:c48913c5924c
- Dynamic bindings properly update between talent choices, and the hotkey text is also correctly reflected.
author | Nenue |
---|---|
date | Sat, 07 Jan 2017 12:47:41 -0500 |
parents | ca3118127e5e |
children | 9824d524a661 |
comparison
equal
deleted
inserted
replaced
71:ca3118127e5e | 72:c48913c5924c |
---|---|
310 | 310 |
311 local borderType = BORDER_UNASSIGNED | 311 local borderType = BORDER_UNASSIGNED |
312 | 312 |
313 if self.command then | 313 if self.command then |
314 | 314 |
315 print('|cFFFF4400', self.actionName, #self.assignedKeys, self.assignedKeys) | |
316 print(table.concat(self.assignedKeys, ',')) | |
317 print(self.actionID) | |
318 self.bindingText= kb.BindingString(unpack(self.assignedKeys)) | |
315 if not self.isAvailable then | 319 if not self.isAvailable then |
316 borderType = BORDER_DYNAMIC | 320 borderType = BORDER_DYNAMIC |
317 self.ignoreTexture:Show() | 321 self.ignoreTexture:Show() |
318 else | 322 else |
319 self.ignoreTexture:Hide() | 323 self.ignoreTexture:Hide() |
324 borderType = BORDER_DYNAMIC | 328 borderType = BORDER_DYNAMIC |
325 else | 329 else |
326 borderType = BORDER_ASSIGNED | 330 borderType = BORDER_ASSIGNED |
327 end | 331 end |
328 end | 332 end |
329 | |
330 | 333 |
331 if self.actionType == 'macro' then | 334 if self.actionType == 'macro' then |
332 self.macro:Show() | 335 self.macro:Show() |
333 else | 336 else |
334 self.macro:Hide() | 337 self.macro:Hide() |
344 end | 347 end |
345 | 348 |
346 | 349 |
347 if self.dynamicType == 'profession' then | 350 if self.dynamicType == 'profession' then |
348 if self.isAvailable then | 351 if self.isAvailable then |
349 | |
350 self.statusText = '|cFFFFFF00Profession|r' | 352 self.statusText = '|cFFFFFF00Profession|r' |
351 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | |
352 else | 353 else |
353 | 354 |
354 self.statusText = '|cFFFF4400'..PROFESSION_HEADERS[self.dynamicIndex]..'|r' | 355 self.statusText = '|cFFFF4400'..PROFESSION_HEADERS[self.dynamicIndex]..'|r' |
355 self.actionName = '(#'..self.dynamicIndex..')' | 356 self.actionName = '(#'..self.dynamicIndex..')' |
356 self.bindingText ='?' | |
357 end | 357 end |
358 elseif self.dynamicType == 'talent' then | 358 elseif self.dynamicType == 'talent' then |
359 self.statusText = '|cFF00FFFF'.. TALENT .. '|r' | 359 self.statusText = '|cFF00FFFF'.. TALENT .. '|r' |
360 if self.isAvailable then | |
361 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | |
362 else | |
363 | |
364 print('|cFFFF4400', self.actionName, #self.assignedKeys, self.assignedKeys) | |
365 print(self.actionID) | |
366 self.bindingText= kb.BindingString(self.assignedKeys) | |
367 end | |
368 elseif self.dynamicType == 'petaction' then | |
369 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | |
370 else | |
371 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | |
372 end | 360 end |
373 | 361 |
374 local locked, layer = kb.IsCommandBound(self) | 362 local locked, layer = kb.IsCommandBound(self) |
375 if locked then | 363 if locked then |
376 self.icon:SetAlpha(0.5) | 364 self.icon:SetAlpha(0.5) |
491 local SkeletonKey_GetSpellDetails = function(self) | 479 local SkeletonKey_GetSpellDetails = function(self) |
492 | 480 |
493 local spellName, spellID, command, icon = self.actionName, self.actionID, self.command, self.iconPath | 481 local spellName, spellID, command, icon = self.actionName, self.actionID, self.command, self.iconPath |
494 | 482 |
495 | 483 |
496 cprint(' In:', spellName, spellID, command) | 484 print(' In:', spellName, spellID, command) |
497 cprint(GetSpellInfo(spellName or spellID)) | 485 print(GetSpellInfo(spellName or spellID)) |
498 local internalName, _, internalIcon, _, _, _, _ = GetSpellInfo(spellName or spellID) | 486 local internalName, _, internalIcon, _, _, _, _ = GetSpellInfo(spellName or spellID) |
499 local isAvailable = internalName and true | 487 local isAvailable = internalName and true |
500 | 488 |
501 if internalName and (internalName ~= spellName) then | 489 if internalName and (internalName ~= spellName) then |
502 -- it's a binding for the originating spell, leave it as is | 490 -- it's a binding for the originating spell, leave it as is |
503 cprint(' |cFFFF4400spell is an override(', internalName, '~=', spellName,') leave the name info alone') | 491 print(' |cFFFF4400spell is an override(', internalName, '~=', spellName,') leave the name info alone') |
504 self.statusText = '|cFFFFFF00Spell|r' | 492 self.statusText = '|cFFFFFF00Spell|r' |
505 self.isAvailable = true | 493 self.isAvailable = true |
506 return | 494 return |
507 end | 495 end |
508 | 496 |
509 -- let's us match spells replaced by talents | 497 -- let's us match spells replaced by talents |
510 local info = kb.DynamicSpells[internalName or spellName] | 498 local info = kb.DynamicSpells[internalName or spellName] |
511 if not info then | 499 if not info then |
512 local dynamicType, dynamicIndex, dynamicSubIndex = command:match("(%a+)_(%S+)_(%S+)") | 500 local dynamicType, dynamicIndex, dynamicSubIndex = command:match("(%a+)_(%S+)_(%S+)") |
513 if kb.DynamicSpells[dynamicType] then | 501 if kb.DynamicSpells[dynamicType] then |
514 cprint('|cFFFF4400resolving dynamic type index:', internalName, spellName, command) | 502 print('|cFFFF4400resolving dynamic type index:', internalName, spellName, command) |
515 dynamicIndex = tonumber(dynamicIndex) | 503 dynamicIndex = tonumber(dynamicIndex) |
516 dynamicSubIndex = tonumber(dynamicSubIndex) | 504 dynamicSubIndex = tonumber(dynamicSubIndex) |
517 local cache = kb.DynamicSpells[dynamicType] | 505 local cache = kb.DynamicSpells[dynamicType] |
518 cprint('type:', dynamicType) | 506 print('type:', dynamicType) |
519 if dynamicIndex and cache[dynamicIndex] then | 507 if dynamicIndex and cache[dynamicIndex] then |
520 info = kb.DynamicSpells[dynamicType][dynamicIndex] | 508 info = kb.DynamicSpells[dynamicType][dynamicIndex] |
521 cprint('index:', dynamicIndex) | 509 print('index:', dynamicIndex) |
522 if dynamicSubIndex and info[dynamicSubIndex] then | 510 if dynamicSubIndex and info[dynamicSubIndex] then |
523 info = info[dynamicSubIndex] | 511 info = info[dynamicSubIndex] |
524 cprint('sub-index:', dynamicSubIndex) | 512 print('sub-index:', dynamicSubIndex) |
525 end | 513 end |
526 isAvailable = true | 514 isAvailable = true |
527 end | 515 end |
528 end | 516 end |
529 if not info then | 517 if not info then |
530 info = SkeletonKey_GetGenericSpell(spellName, spellID, internalIcon or icon) | 518 info = SkeletonKey_GetGenericSpell(spellName, spellID, internalIcon or icon) |
531 end | 519 end |
532 end | 520 end |
533 info.isAvailable = isAvailable | 521 info.isAvailable = isAvailable |
534 | 522 |
535 cprint('|cFF00FF88SpellDetails:|r', info.actionName, info.actionID, info.dynamicType, info.isAvailable) | 523 print('|cFF00FF88SpellDetails:|r', info.actionName, info.actionID, info.dynamicType, info.isAvailable) |
536 for k,v in pairs(info) do | 524 for k,v in pairs(info) do |
537 --cprint(' ',k,v) | 525 --cprint(' ',k,v) |
538 self[k] = v | 526 self[k] = v |
539 end | 527 end |
540 | 528 |
597 for i = 1, GetNumMacros() do | 585 for i = 1, GetNumMacros() do |
598 local searchName, _ , searchBody = GetMacroInfo(i) | 586 local searchName, _ , searchBody = GetMacroInfo(i) |
599 if (searchName == name) and (searchBody == macroText) then | 587 if (searchName == name) and (searchBody == macroText) then |
600 -- complete match | 588 -- complete match |
601 actionID = i | 589 actionID = i |
590 kb:print('Macro index changed: |cFFFFFF00', actionType, '|r', name, '(was '..tostring(prevIndex)..', now '..tostring(actionID)..')') | |
602 break | 591 break |
603 elseif (searchName == name) or (searchBody == macroText) then | 592 elseif (searchName == name) or (searchBody == macroText) then |
604 -- partial match, continue the search | 593 -- partial match, continue the search |
605 actionID = i | 594 actionID = i |
595 kb:print('Macro index changed: |cFFFFFF00', actionType, '|r', name, '(was '..tostring(prevIndex)..', now '..tostring(actionID)..')') | |
606 end | 596 end |
607 end | 597 end |
608 end | 598 end |
609 kb:print('Macro index changed: |cFFFFFF00', actionType, '|r', name, '(was '..tostring(prevIndex)..', now '..tostring(actionID)..')') | 599 |
610 end | 600 end |
611 else | 601 else |
612 actionID = GetMacroIndexByName(name) | 602 actionID = GetMacroIndexByName(name) |
613 end | 603 end |
614 self.statusText = 'Macro' | 604 self.statusText = 'Macro' |
619 end | 609 end |
620 self.isAvailable = true | 610 self.isAvailable = true |
621 end | 611 end |
622 | 612 |
623 if self.isAvailable then | 613 if self.isAvailable then |
624 local oldCommand = command | 614 --[[ |
625 command = kb.LoadBinding(self) | 615 local checkCommand = command |
626 if oldCommand ~= command then | 616 checkCommand = kb.LoadBinding(self) |
617 if checkCommand and (checkCommand ~= command) then | |
627 print('|cFFFF4400fixing command string', actionType, actionID, name) | 618 print('|cFFFF4400fixing command string', actionType, actionID, name) |
628 kb.currentProfile.bound[oldCommand] = nil | 619 kb.currentProfile.bound[command] = nil |
629 kb.currentProfile.bound[command] = slot | 620 kb.currentProfile.bound[checkCommand] = slot |
630 for k,v in pairs(kb.currentProfile.bindings) do | 621 for k,v in pairs(kb.currentProfile.bindings) do |
631 if v == oldCommand then | 622 if v == command then |
632 kb.currentProfile.bindings[k] = command | 623 kb.currentProfile.bindings[k] = checkCommand |
633 end | 624 end |
634 end | 625 end |
635 end | 626 end |
627 --]] | |
636 end | 628 end |
637 | 629 |
638 | 630 |
639 actionID = actionID or 0 | 631 actionID = actionID or 0 |
640 self:EnableKeyboard(true) | 632 self:EnableKeyboard(true) |