changeset 93:f9df7cd7bfd6 tip

revert pet spell subText collation remove an empty script handler
author Nenue
date Tue, 04 Sep 2018 23:00:21 -0400
parents c1c9dd6063a8
children
files ActionTemplates.lua Events.lua KeyButton.lua SkeletonKey.xml SystemBindings.lua SystemBindings.xml
diffstat 5 files changed, 90 insertions(+), 146 deletions(-) [+]
line wrap: on
line diff
--- a/ActionTemplates.lua	Tue Jul 17 20:48:19 2018 -0400
+++ b/ActionTemplates.lua	Tue Sep 04 23:00:21 2018 -0400
@@ -14,7 +14,7 @@
 local GetNumBindings, GetBinding = GetNumBindings, GetBinding
 
 local _, kb = ...
-local print = (DEVIAN_PNAME == 'SkeletonKey') and function(...) print('SK', ...) end or nop
+local print = (DEVIAN_PNAME == 'SkeletonKey') and function(...) print('AT', ...) end or nop
 local cprint = (DEVIAN_PNAME == 'SkeletonKey') and function(...) _G.print('Cfg', ...) end or nop
 
 local CLICK_KEYBINDER_MACRO = "CLICK SkeletonKeyMacro:"
@@ -73,24 +73,19 @@
 end
 
 atype['petaction'] = function(_, name)
+  print('|cFF00FF00atype:petaction|r', name)
   -- ID doesn't exist for basic commands, even though they can be picked up
-  local attributeName, attributeValue = "petaction_" .. tostring(name), "/cast "..tostring(name)
+  local attributeName, attributeValue = "petaction_" .. tostring(name), "/use "..tostring(name)
 
   if not petSpellCache then
     kb.UpdatePetInfo()
   end
   -- Compose a multi-macro for subtext abilities
-  if petSpellCache[name] then
-    attributeValue = ""
-    for spellName, enabled in pairs(petSubtextCache[petSpellCache[name]]) do
-      attributeValue = attributeValue .. "/cast " .. spellName .. "\n"
-    end
-  end
 
   if PETACTION_SCRIPT[name] then
     attributeName, attributeValue = unpack(PETACTION_SCRIPT[name])
-  elseif kb.PetCache.special[name] then
-    attributeName = "petaction_"..kb.PetCache.special[name][3].."_" .. tonumber(kb.PetCache.special[name][6])
+
+    print('  scripts hit:', name, attributeName, attributeValue)
   end
   return CLICK_KEYBINDER_MACRO, attributeName, attributeValue, SkeletonKeyMacro
 end
@@ -598,6 +593,7 @@
 
 
 kb.UpdatePetInfo = function()
+  print('|cFFFFFF00kb.UpdatePetInfo()')
   local hasPetSpells, petType = HasPetSpells()
 
   -- reconcile saved data if it becomes available
@@ -629,7 +625,7 @@
   end
 
   if PetHasSpellbook() then
-    --print('PET SPELLBOOK')
+    print('PET SPELLBOOK')
     local spellbookOffset = 1
     local specialNum = {}
     local newSubtextItems = false
@@ -639,28 +635,22 @@
       local spellType, spellID = GetSpellBookItemInfo(spellbookOffset, BOOKTYPE_PET)
       local spellName, subText = GetSpellBookItemName(spellbookOffset, BOOKTYPE_PET)
       local texture = GetSpellBookItemTexture(spellbookOffset, BOOKTYPE_PET)
-      if (spellType == 'SPELL') and (not IsPassiveSpell(spellbookOffset, BOOKTYPE_PET)) then
+
+
+      if (spellType == 'PETACTION') and (not IsPassiveSpell(spellbookOffset, BOOKTYPE_PET)) then
+
+        print('|cFF00FF00#'..spellbookOffset..'|r', spellType, spellID, spellName, subText, texture)
         local info = kb.PetCache[spellName] or {}
         kb.PetCache.spellslot[spellName] = {spellbookOffset, spellName, subText, spellID, texture}
-        --print('|cFF00FF88spellslot['..spellName..']|r', '=>', i, subText)
+        print('|cFF00FF88spellslot['..spellName..']|r', '=>', spellName, spellID)
 
         if subText then
           kb.PetCache.subtext[subText] = kb.PetCache.subtext[subText] or {}
           specialNum[subText] = (specialNum[subText] or 0) + 1
 
           petSpellCache[spellName] = subText
-          petSubtextCache[subText] = petSubtextCache[subText] or {}
 
-          -- add to the list
-          if not petSubtextCache[subText][spellName] then
-            petSubtextCache[subText][spellName] = true
-            newSubtextItems = true
-            --print('|cFF00FFFFspecial['..spellName..']|r', '\n','|cFF00FFFFsubtext['..subText..']['..specialNum[subText]..']|r', '=>', i, spellName, subText, spellID,  texture, specialNum[subText])
-          end
-
-
-
-          local entry = {spellbookOffset, spellName, subText, spellID,  texture, specialNum[subText] }
+          --local entry = {spellbookOffset, spellName, subText, spellID,  texture, specialNum[subText] }
 
 
           info.spellbookOffset = spellbookOffset
@@ -692,19 +682,6 @@
       spellbookOffset = spellbookOffset + 1
     until spellType == nil
 
-    if newSubtextItems then
-
-      local macrotext = ""
-      for subText, spells in pairs(petSubtextCache) do
-        if specialNum[subText] then
-          for spellName, enabled in pairs(spells) do
-            macrotext = macrotext .. "/cast " .. spellName .. "\n"
-          end
-          kb.SecureAttribute(SkeletonKeyMacro, "*macrotext-petaction_"..subText.."_"..specialNum[subText], macrotext)
-        end
-      end
-    end
-
 
   else
     --print('NO PET SPELLBOOK')
@@ -713,13 +690,15 @@
   end
 
   if PetHasActionBar() then
-    --print('PET ACTION BAR')
+    print('PET ACTION BAR')
     for i = 1, 10 do
+      local name, texture, _, _, _, _, spellId = GetPetActionInfo(i)
+      if name then
 
 
-      local name, subtext, texture, isToken, isActive = GetPetActionInfo(i)
-      if name then
-        kb.PetCache.action[i] = {name, subtext, texture, isToken, isActive }
+        print(i, name, texture, spellId)
+
+        kb.PetCache.action[i] = {name, texture, spellId}
 
 
       end
--- a/Events.lua	Tue Jul 17 20:48:19 2018 -0400
+++ b/Events.lua	Tue Sep 04 23:00:21 2018 -0400
@@ -36,6 +36,9 @@
 
 -- only need to respond to this for pet actions
 kb.PLAYER_SPECIALIZATION_CHANGED = function(self, event, unit)
+end
+
+kb.SPELLS_CHANGED = function()
   kb.talentsPushed = nil
   kb.UpdateSpecInfo()
   kb.UpdateTalentInfo()
@@ -45,10 +48,6 @@
   SkeletonKey:Update(true)
 end
 
-kb.SPELLS_CHANGED = function()
-  SkeletonKey:Update()
-end
-
 kb.UPDATE_MACROS = function()
   kb.UpdateMacroInfo()
 end
--- a/KeyButton.lua	Tue Jul 17 20:48:19 2018 -0400
+++ b/KeyButton.lua	Tue Sep 04 23:00:21 2018 -0400
@@ -77,34 +77,16 @@
 }
 
 
--- This is needed to identify a spells that aren't reflected by GetCursorInfo()
+-- This is needed to identify spells that aren't reflected by GetCursorInfo()
 kb.OnPickupPetAction = function(slot, ...)
-  local isPickup = GetCursorInfo()
-  print(slot, ...)
-  if kb.PetCache.action[slot] then
-    if isPickup then
-      local key, _, texture = unpack(kb.PetCache.action[slot])
-      local spellName = _G[key] or key
-      if spellName and kb.PetCache.spellslot[spellName] then
-        CURSOR_SPELLSLOT = kb.PetCache.spellslot[spellName][1]
-        CURSOR_BOOKTYPE = BOOKTYPE_PET
-        CURSOR_TEXTURE = _G[texture] or texture
-      end
-    else
-      CURSOR_SPELLSLOT = nil
-      CURSOR_BOOKTYPE = nil
-      CURSOR_TEXTURE = nil
-    end
-    print('|cFFFF4400PickupPetAction|r', isPickup, CURSOR_PETACTION)
-  end
+  local pickupType, texture, slot = GetCursorInfo()
+  print('|cFFFF4400PickupPetAction|r', GetCursorInfo())
 
-  local name, subtext, texture, isToken = GetPetActionInfo(slot)
-  if name then
-    kb.PetCache.action[slot] = {name, subtext, texture, isToken}
-  end
+  CURSOR_SPELLSLOT = slot
+  CURSOR_BOOKTYPE = 'pet'
+  CURSOR_TEXTURE = texture
 
-
-  print('current cursor info', CURSOR_SPELLSLOT, CURSOR_BOOKTYPE, CURSOR_TEXTURE)
+  print('[cursor book]', CURSOR_BOOKTYPE, CURSOR_SPELLSLOT, 'texture:', CURSOR_TEXTURE)
 
 end
 
@@ -113,7 +95,7 @@
   CURSOR_SPELLSLOT = slot
   CURSOR_BOOKTYPE = bookType
   CURSOR_TEXTURE = GetSpellBookItemTexture(slot, bookType)
-  print('current cursor info', CURSOR_SPELLSLOT, CURSOR_BOOKTYPE, CURSOR_TEXTURE)
+  print('[cursor book]', CURSOR_BOOKTYPE, CURSOR_SPELLSLOT, 'texture:', CURSOR_TEXTURE)
 end
 
 kb.CreateHooks = function()
@@ -153,8 +135,6 @@
   end
 end
 
-function skb:OnUpdate()
-end
 function skb:OnClick(click)
   print(self:GetName(), 'OnMouseDown', click)
   local cursorType = GetCursorInfo()
@@ -187,12 +167,13 @@
 end
 
 function skb:DropToSlot ()
-  print(self:GetName(),'|cFF0088FFreceived|r')
   local actionType, actionID, subType, subData = GetCursorInfo()
-  print('GetCursorInfo', GetCursorInfo())
+  print(self:GetName(),'|cFF0088FFDropToSlot|r', actionType, actionID, subType, subData)
   if actionType then
+    print('##', actionType)
 
     if actionType == 'flyout' then
+      print('## flyout button, abort')
       ClearCursor()
       ResetCursor()
       return
@@ -202,70 +183,71 @@
     local name, icon, _, macroName, macroText
     local pickupID, pickupBook
 
-      if actionType == 'spell' then
-        local realName = GetSpellInfo(subData)
-        name, _, icon, _, _, _, actionID = GetSpellInfo(subData)
+    if actionType == 'spell' then
+      local realName = GetSpellInfo(subData)
+      name, _, icon, _, _, _, actionID = GetSpellInfo(subData)
 
-        if TALENT_SPELLS[actionID] then
-          name = TALENT_SPELLS[actionID].actionName
-          actionID  = TALENT_SPELLS[actionID].actionID
-          icon = TALENT_SPELLS[actionID].icon
-      elseif actionType == 'macro' then
-        name, icon, macroText = GetMacroInfo(actionID)
-        macroName = name
-      elseif actionType == 'petaction' then
-        if CURSOR_SPELLSLOT and CURSOR_BOOKTYPE then
+      if TALENT_SPELLS[actionID] then
+        name = TALENT_SPELLS[actionID].actionName
+        actionID  = TALENT_SPELLS[actionID].actionID
+        icon = TALENT_SPELLS[actionID].icon
+      end
 
-          local spellType, spellID = GetSpellBookItemInfo(CURSOR_SPELLSLOT, CURSOR_BOOKTYPE)
-          local spellName, spellText = GetSpellBookItemName(CURSOR_SPELLSLOT, CURSOR_BOOKTYPE)
-          if spellType == 'PETACTION' then
-            name = spellName
-            actionID = spellText
-            icon = CURSOR_TEXTURE
-          else
-            name, _, icon = GetSpellInfo(spellID)
-            actionID = spellID
-          end
+    elseif actionType == 'macro' then
+      name, icon, macroText = GetMacroInfo(actionID)
+      macroName = name
+    elseif actionType == 'petaction' then
 
-          pickupID = CURSOR_SPELLSLOT
-          pickupBook = CURSOR_BOOKTYPE
-        else
 
 
-        end
+        --local spellType, spellID = GetSpellBookItemInfo(actionID, BOOKTYPE_PET)
+        local spellName, spellText = GetSpellBookItemName(actionID, BOOKTYPE_PET)
 
-      elseif actionType == 'mount' then
-        if subType == 0 then
-          name, _, icon = GetSpellInfo(SUMMON_RANDOM_FAVORITE_MOUNT_SPELL)
-          actionID = 0
-        else
-          name, _, icon = GetMountInfoByID(actionID)
-        end
-      elseif actionType == 'item' then
-        name = GetItemInfo(actionID)
-        icon = GetItemIcon(actionID)
-      elseif actionType == 'battlepet' then
+      if subType then
+        actionID = subType
+      end
 
-        local speciesID, customName, level, xp, maxXp, displayID, isFavorite, petName, petIcon, petType, creatureID = GetPetInfoByPetID(actionID)
-        name = customName or petName
-        icon = petIcon
 
+
+      print('##PET', actionID, '=>',  spellName, spellText)
+      pickupID = actionID
+      name = GetSpellBookItemName(actionID, BOOKTYPE_PET)
+      icon = GetSpellBookItemTexture(actionID, BOOKTYPE_PET)
+      actionID = name
+      pickupBook = BOOKTYPE_PET
+
+    elseif actionType == 'mount' then
+      if subType == 0 then
+        name, _, icon = GetSpellInfo(SUMMON_RANDOM_FAVORITE_MOUNT_SPELL)
+        actionID = 0
+      else
+        name, _, icon = GetMountInfoByID(actionID)
       end
-      local _, macroBody, command = kb.RegisterAction(actionType, actionID, name)
-      local slotInfo = {
-        command = command,
-        actionName = name,
-        iconPath = icon,
-        actionType = actionType,
-        actionID = actionID,
-        macroName = macroName,
-        macroText = macroText or macroBody,
-        spellbookSlot = pickupID,
-        spellbookType = pickupBook,
-        assignedKeys = {GetBindingKey(command)}
-      }
+    elseif actionType == 'item' then
+      name = GetItemInfo(actionID)
+      icon = GetItemIcon(actionID)
+    elseif actionType == 'battlepet' then
 
-      local isAssigned, isBound, assignedBy, boundBy = kb.IsCommandBound(self, command)
+      local speciesID, customName, level, xp, maxXp, displayID, isFavorite, petName, petIcon, petType, creatureID = GetPetInfoByPetID(actionID)
+      name = customName or petName
+      icon = petIcon
+
+    end
+    local _, macroBody, command = kb.RegisterAction(actionType, actionID, name)
+    local slotInfo = {
+      command = command,
+      actionName = name,
+      iconPath = icon,
+      actionType = actionType,
+      actionID = actionID,
+      macroName = macroName,
+      macroText = macroText or macroBody,
+      spellbookSlot = pickupID,
+      spellbookType = pickupBook,
+      assignedKeys = {GetBindingKey(command)}
+    }
+
+    local isAssigned, isBound, assignedBy, boundBy = kb.IsCommandBound(self, command)
       if isAssigned then
         local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"]
         popup.slot = self
@@ -284,7 +266,6 @@
         ResetCursor()
       end
     end
-  end
 end
 
 
--- a/SkeletonKey.xml	Tue Jul 17 20:48:19 2018 -0400
+++ b/SkeletonKey.xml	Tue Sep 04 23:00:21 2018 -0400
@@ -235,11 +235,9 @@
     <Scripts>
       <OnLoad method="OnLoad" />
       <OnClick method="OnClick" />
-      <OnUpdate method="OnUpdate" />
-      <OnKeyDown method="OnKeyDown" />
       <OnDragStart method="OnDragStart" />
       <OnReceiveDrag method="OnReceiveDrag" />
-      <OnKeyUp method="OnKeyUp" />
+
       <OnEnter method="OnEnter" />
       <OnLeave method="OnLeave" />
     </Scripts>
--- a/SystemBindings.xml	Tue Jul 17 20:48:19 2018 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
-..\FrameXML\UI.xsd">
-  <Script file="SystemBindings.lua" />
-
-  <Frame name="$parentSystemBindings" parent="SkeletonKey" mixin="SkeletonKeySystemBindingsMixin">
-    <Layers>
-      <Layer level="BACKGROUND">
-        <Texture parentKey="Background">
-          <Color a="1" r="1" g="0" b="0" />
-        </Texture>
-      </Layer>
-    </Layers>
-  </Frame>
-  </Ui>
\ No newline at end of file