diff 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
line wrap: on
line diff
--- a/KeyButton.lua	Fri Jan 06 16:21:49 2017 -0500
+++ b/KeyButton.lua	Sat Jan 07 12:47:41 2017 -0500
@@ -312,6 +312,10 @@
 
   if self.command then
 
+    print('|cFFFF4400', self.actionName, #self.assignedKeys, self.assignedKeys)
+    print(table.concat(self.assignedKeys, ','))
+    print(self.actionID)
+    self.bindingText= kb.BindingString(unpack(self.assignedKeys))
     if not self.isAvailable then
       borderType = BORDER_DYNAMIC
       self.ignoreTexture:Show()
@@ -327,7 +331,6 @@
       end
     end
 
-
     if self.actionType == 'macro' then
       self.macro:Show()
     else
@@ -346,29 +349,14 @@
 
     if self.dynamicType == 'profession'  then
       if self.isAvailable then
-
         self.statusText = '|cFFFFFF00Profession|r'
-        self.bindingText = kb.BindingString(GetBindingKey(self.command))
       else
 
         self.statusText = '|cFFFF4400'..PROFESSION_HEADERS[self.dynamicIndex]..'|r'
         self.actionName = '(#'..self.dynamicIndex..')'
-        self.bindingText ='?'
       end
     elseif self.dynamicType == 'talent' then
       self.statusText = '|cFF00FFFF'.. TALENT .. '|r'
-      if self.isAvailable then
-        self.bindingText = kb.BindingString(GetBindingKey(self.command))
-      else
-
-        print('|cFFFF4400', self.actionName, #self.assignedKeys, self.assignedKeys)
-        print(self.actionID)
-        self.bindingText= kb.BindingString(self.assignedKeys)
-      end
-    elseif self.dynamicType == 'petaction' then
-      self.bindingText = kb.BindingString(GetBindingKey(self.command))
-    else
-      self.bindingText = kb.BindingString(GetBindingKey(self.command))
     end
 
     local locked, layer = kb.IsCommandBound(self)
@@ -493,14 +481,14 @@
   local spellName, spellID, command, icon = self.actionName, self.actionID, self.command, self.iconPath
 
 
-  cprint(' In:', spellName, spellID, command)
-  cprint(GetSpellInfo(spellName or spellID))
+  print(' In:', spellName, spellID, command)
+  print(GetSpellInfo(spellName or spellID))
   local internalName, _, internalIcon, _, _, _, _ = GetSpellInfo(spellName or spellID)
   local isAvailable = internalName and true
 
   if internalName and (internalName ~= spellName) then
     -- it's a binding for the originating spell, leave it as is
-    cprint('  |cFFFF4400spell is an override(', internalName, '~=', spellName,') leave the name info alone')
+    print('  |cFFFF4400spell is an override(', internalName, '~=', spellName,') leave the name info alone')
     self.statusText = '|cFFFFFF00Spell|r'
     self.isAvailable = true
     return
@@ -511,17 +499,17 @@
   if not info then
     local dynamicType, dynamicIndex, dynamicSubIndex = command:match("(%a+)_(%S+)_(%S+)")
     if kb.DynamicSpells[dynamicType] then
-      cprint('|cFFFF4400resolving dynamic type index:', internalName, spellName, command)
+      print('|cFFFF4400resolving dynamic type index:', internalName, spellName, command)
       dynamicIndex = tonumber(dynamicIndex)
       dynamicSubIndex = tonumber(dynamicSubIndex)
       local cache = kb.DynamicSpells[dynamicType]
-      cprint('type:', dynamicType)
+      print('type:', dynamicType)
       if dynamicIndex and cache[dynamicIndex] then
         info = kb.DynamicSpells[dynamicType][dynamicIndex]
-        cprint('index:', dynamicIndex)
+        print('index:', dynamicIndex)
         if dynamicSubIndex and info[dynamicSubIndex] then
           info = info[dynamicSubIndex]
-          cprint('sub-index:', dynamicSubIndex)
+          print('sub-index:', dynamicSubIndex)
         end
         isAvailable = true
       end
@@ -532,7 +520,7 @@
   end
   info.isAvailable = isAvailable
 
-  cprint('|cFF00FF88SpellDetails:|r', info.actionName, info.actionID, info.dynamicType, info.isAvailable)
+  print('|cFF00FF88SpellDetails:|r', info.actionName, info.actionID, info.dynamicType, info.isAvailable)
   for k,v in pairs(info) do
     --cprint(' ',k,v)
     self[k] = v
@@ -599,14 +587,16 @@
               if (searchName == name) and (searchBody == macroText) then
                 -- complete match
                 actionID = i
+                kb:print('Macro index changed: |cFFFFFF00', actionType, '|r', name, '(was '..tostring(prevIndex)..', now '..tostring(actionID)..')')
                 break
               elseif (searchName == name) or (searchBody == macroText) then
                 -- partial match, continue the search
                 actionID = i
+                kb:print('Macro index changed: |cFFFFFF00', actionType, '|r', name, '(was '..tostring(prevIndex)..', now '..tostring(actionID)..')')
               end
             end
           end
-          kb:print('Macro index changed: |cFFFFFF00', actionType, '|r', name, '(was '..tostring(prevIndex)..', now '..tostring(actionID)..')')
+
         end
       else
         actionID = GetMacroIndexByName(name)
@@ -621,18 +611,20 @@
     end
 
     if self.isAvailable then
-      local oldCommand = command
-      command = kb.LoadBinding(self)
-      if oldCommand ~= command then
+      --[[
+      local checkCommand = command
+      checkCommand = kb.LoadBinding(self)
+      if checkCommand and (checkCommand ~= command) then
         print('|cFFFF4400fixing command string', actionType, actionID, name)
-        kb.currentProfile.bound[oldCommand] = nil
-        kb.currentProfile.bound[command] = slot
+        kb.currentProfile.bound[command] = nil
+        kb.currentProfile.bound[checkCommand] = slot
         for k,v in pairs(kb.currentProfile.bindings) do
-          if v == oldCommand then
-            kb.currentProfile.bindings[k] = command
+          if v == command then
+            kb.currentProfile.bindings[k] = checkCommand
           end
         end
       end
+      --]]
     end