diff SkeletonKey/KeyBinds.lua @ 13:eeec4a600064

- kb.bindings carries the exact values needed for matching GetActionInfo() outputs
author Nenue
date Thu, 28 Jul 2016 18:20:32 -0400
parents e7977b336bf7
children
line wrap: on
line diff
--- a/SkeletonKey/KeyBinds.lua	Thu Jul 28 17:45:17 2016 -0400
+++ b/SkeletonKey/KeyBinds.lua	Thu Jul 28 18:20:32 2016 -0400
@@ -203,7 +203,6 @@
 
     elseif actionType == 'macro' then
       name, icon = GetMacroInfo(actionID)
-      actionID = name
     elseif actionType == 'petaction' then
       if not (CURSOR_SPELLSLOT and CURSOR_BOOKTYPE) then
 
@@ -215,8 +214,6 @@
       pickupID = CURSOR_SPELLSLOT
       pickupBook = CURSOR_BOOKTYPE
       name, _, icon = GetSpellInfo(spellID)
-      actionID = name
-
     elseif actionType == 'mount' then
       if subType == 0 then
         name, _, icon = GetSpellInfo(SUMMON_RANDOM_FAVORITE_MOUNT_SPELL)
@@ -235,7 +232,7 @@
       icon = petIcon
 
     end
-    macroName, macroText, command = kb.RegisterAction(actionType, actionID)
+    macroName, macroText, command = kb.RegisterAction(actionType, actionID, name)
 
 
     local isAssigned, isBound, assignedBy, boundBy = kb.IsCommandBound(self, command)
@@ -284,18 +281,18 @@
 
 
 --- Resolve the appropriate command and macroText for the given action parameters
-kb.RegisterAction = function(type, id)
+kb.RegisterAction = function(type, id, name)
   local macroText, macroName, command = '', '', ''
 
   if type == 'spell' then
     if kb.ProfessionCache[id] then
       command = CLICK_KEYBINDER_KEY .. "profession_".. kb.ProfessionCache[id].profOffset .. '_' .. kb.ProfessionCache[id].spellNum
     else
-      command = CLICK_KEYBINDER_KEY ..id
+      command = CLICK_KEYBINDER_KEY ..name
     end
   else
-    macroName = type .. ' ' .. id
-    macroText = ACTION_SCRIPT[type]:format(id)
+    macroName = type .. ' ' .. name
+    macroText = ACTION_SCRIPT[type]:format(name)
     local baseName, iterative = macroName, 1
     while (macros[macroName] and macros[macroName][1] ~= macroText) do
       print(' * cannot use|cFF00FF00', macroName, '|r"'.. (macros[macroName][1] or '') .. '"')
@@ -451,11 +448,10 @@
 
 kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText )
 
-
-
   if actionType == 'spell' then
     KeyBinderKey:SetAttribute("*type-"..name, actionType)
     KeyBinderKey:SetAttribute("*"..actionType.."-"..name, name)
+
   elseif actionType == 'item' then
     KeyBinderKey:SetAttribute("*type-"..name, actionType)
     KeyBinderKey:SetAttribute("*"..actionType.."-"..name, name)
@@ -464,6 +460,8 @@
   else
     KeyBinderMacro:SetAttribute("*macrotext-"..macroName, macroText)
   end
+
+  cprint('Loading binding', actionType, actionID)
   bindings[actionType] = bindings[actionType] or {}
   bindings[actionType][actionID] = bindings[actionType][actionID] or {}
   bindings[command] = bindings[actionType][actionID]