diff SkeletonKey/SkeletonKey.lua @ 15:32d64e42ec9b

- resolve pet bar actions for binding slots - detect type of petaction (can be spell, stance, or 'PETACTION') - keep track of displayed pet ability slots and update them alongside pet cache refreshes
author Nenue
date Fri, 29 Jul 2016 03:27:15 -0400
parents 82170735e67c
children cdd387d39137
line wrap: on
line diff
--- a/SkeletonKey/SkeletonKey.lua	Thu Jul 28 23:58:53 2016 -0400
+++ b/SkeletonKey/SkeletonKey.lua	Fri Jul 29 03:27:15 2016 -0400
@@ -49,6 +49,18 @@
   ['item'] = "/use %s"
 }
 
+
+local PETACTION_SCRIPT = {
+  [PET_ACTION_MOVE_TO] = SLASH_PET_MOVE_TO1,
+  [PET_ACTION_ATTACK] = SLASH_PET_ATTACK1,
+  [PET_ACTION_FOLLOW] = SLASH_PET_FOLLOW1,
+  [PET_ACTION_WAIT] = SLASH_PET_STAY1,
+  [PET_MODE_AGGRESSIVE] = SLASH_PET_AGGRESSIVE1,
+  [PET_MODE_DEFENSIVE] = SLASH_PET_DEFENSIVE1,
+  [PET_MODE_PASSIVE] = SLASH_PET_PASSIVE1,
+  [PET_MODE_ASSIST] = SLASH_PET_ASSIST1,
+}
+
 local professionMappings = {
   [5] = 3,
   [7] = 4,
@@ -74,6 +86,9 @@
 kb.orderedProfiles = {}
 kb.buttons = {}
 kb.macros = {}
+kb.petFrames = {} -- pet data is slightly delayed, their buttons are indexed here so they can be refreshed
+kb.talentFrames = {}
+kb.professionFrames = {}
 
 -- these are sent to plugin
 
@@ -208,6 +223,18 @@
   end
   print('|cFFFFFF00received|cFFFFFF00', self:GetID(), '|cFF00FFFF', key)
 
+  local modifier = ''
+  if IsAltKeyDown() then
+    modifier = 'ALT-'
+  end
+  if IsControlKeyDown() then
+    modifier = modifier.. 'CTRL-'
+  end
+  if IsShiftKeyDown() then
+    modifier = modifier..'SHIFT-'
+  end
+  local binding = modifier..key
+
   if key == 'ESCAPE' then
     local keys = {GetBindingKey(self.command) }
     --print('detected', #keys, 'bindings')
@@ -232,30 +259,22 @@
     bindsCommitted = false
     self.active = false
   else
-
-    local modifier = ''
-    if IsAltKeyDown() then
-      modifier = 'ALT-'
-    end
-    if IsControlKeyDown() then
-      modifier = modifier.. 'CTRL-'
-    end
-    if IsShiftKeyDown() then
-      modifier = modifier..'SHIFT-'
+    if kb.SystemBinds[binding] then
+      kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, kb.SystemBinds[binding]))
+      return
     end
 
 
     if self.command then
-      self.binding = modifier..key
 
       local previousKeys
-      local previousAction = GetBindingAction(self.binding)
+      local previousAction = GetBindingAction(binding)
       local binding1, binding2, new1, new2
       print(type(previousAction), previousAction)
       if previousAction ~= "" and previousAction ~= self.command then
         if protected[previousAction] then
           -- bounce out if trying to use a protected key
-          kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, GetBindingAction(previousAction)))
+          kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, GetBindingAction(binding)))
           kb.bindingstext:SetText(nil)
           return
         else
@@ -265,6 +284,7 @@
       end
 
       self.pending = true
+      self.binding = binding
 
       bindsCommitted = false
       SetBinding(self.binding, self.command)
@@ -387,6 +407,7 @@
 kb.ApplyAllBindings =function ()
   table.wipe(kb.inactiveTalentBindings)
 
+
   -- reflect action key settings
   if GetCVarBool("ActionButtonUseKeyDown") then
     KeyBinderMacro:RegisterForClicks("AnyDown")
@@ -493,7 +514,7 @@
   kb.UpdateTalentInfo()
 
   kb.orderedProfiles = {kb.loadedProfiles[BINDING_TYPE_GLOBAL], kb.loadedProfiles[BINDING_TYPE_CHARACTER], kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION]}
-  if db.bindMode and (not kb.configTitle[db.bindMode]) then
+  if (not db.bindMode) or (not kb.configTitle[db.bindMode]) then
     print('fixing bad bindMode value, was', db.bindMode)
     db.bindMode = defaultMode
   end
@@ -527,15 +548,8 @@
 end
 
 kb.ConfirmBindings = function()
-  SaveBindings(GetCurrentBindingSet())
-  bindsCommitted = true
-  for i, button in ipairs(buttons) do
-    button.pending = false
-  end
   kb.ApplyAllBindings()
-
   kb.ui()
-  kb:print('Keybinds saved.')
 end
 
 
@@ -553,8 +567,7 @@
   kb.SelectProfileSet(kb.profileName)
   -- todo: redo import checking
 
-
-
+  kb.UpdateSystemBinds()
   kb.ApplyAllBindings()
 
   kb.ui(true)