changeset 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 8f8917d111c9
children 82170735e67c
files SkeletonKey/Cache.lua SkeletonKey/HotKey.lua SkeletonKey/KeyBinds.lua SkeletonKey/UI.lua
diffstat 4 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/SkeletonKey/Cache.lua	Thu Jul 28 17:45:17 2016 -0400
+++ b/SkeletonKey/Cache.lua	Thu Jul 28 18:20:32 2016 -0400
@@ -55,6 +55,7 @@
       talentInfo.available = available
       talentInfo.spellID = spellID
       kb.TalentCache[spellID] = talentInfo
+      kb.TalentCache[talentName] = talentInfo
       print('Talent ', row, col, spellID, talentName)
     end
   end
--- a/SkeletonKey/HotKey.lua	Thu Jul 28 17:45:17 2016 -0400
+++ b/SkeletonKey/HotKey.lua	Thu Jul 28 18:20:32 2016 -0400
@@ -117,6 +117,11 @@
   hooksecurefunc("ActionBarButtonEventsFrame_RegisterFrame", hotkey.RegisterFrame)
 end
 
+hotkey.ui = function()
+  hotkey.player()
+  hotkey.pet()
+end
+
 hotkey.world = function()
   hotkeyEvents["UPDATE_BINDINGS"] = {"actionbar"}
   hotkey.UPDATE_BINDINGS = hotkey.UpdateFromEvent
@@ -131,10 +136,9 @@
 
 -- requires all these arguments since non-actionbar buttons don't have all of said methods
 hotkey.UpdateSkeletonKeyText = function(frame, actionType, actionID, hasAction)
+  bindings = kb.GetBindings()
+  print(frame, actionType, actionID, hasAction)
   if bindings[actionType] then
-    if actionType == 'macro' then
-      actionID = GetMacroInfo(actionID)
-    end
     --print('|cFFFFFF00'..frame:GetName(), actionType, actionID, hasAction)
     local binds = bindings[actionType][actionID]
     if binds  then
--- 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]
--- a/SkeletonKey/UI.lua	Thu Jul 28 17:45:17 2016 -0400
+++ b/SkeletonKey/UI.lua	Thu Jul 28 18:20:32 2016 -0400
@@ -323,7 +323,6 @@
 
         isAvailable = GetSpellInfo(name)
       end
-      actionID = name
     elseif actionType == 'macro' then
       if not actionID then
         actionID = GetMacroIndexByName(name)
@@ -340,7 +339,7 @@
 
     if isAvailable then
       local oldCommand = command
-      macroName, macroText, command = kb.RegisterAction(actionType, actionID)
+      macroName, macroText, command = kb.RegisterAction(actionType, actionID, name)
       if oldCommand ~= command then
         print('|cFFFF4400fixing command string', actionType, actionID, name)
         kb.currentProfile.bound[oldCommand] = nil