diff SkeletonKey/DynamicTypes.lua @ 17:500f9b2bd9ac

- for RegisterAction, use a function table instead of that if/then rats nest - consequently pet bar actions work now - unlocalize bindings data - activate keyslot input manually instead of on mouse over - activate checkbox to keep input mode active - dynamic buttons update in real time for petaction/talent/profession spells
author Nenue
date Sat, 30 Jul 2016 00:08:00 -0400
parents cdd387d39137
children 67db6b712bf3
line wrap: on
line diff
--- a/SkeletonKey/DynamicTypes.lua	Fri Jul 29 21:18:15 2016 -0400
+++ b/SkeletonKey/DynamicTypes.lua	Sat Jul 30 00:08:00 2016 -0400
@@ -6,10 +6,7 @@
 local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo')
 
 local PET_SPECIAL_SUBTEXT = 'Special Ability'
-local BINDING_TYPE_SPECIALIZATION = 3
-local BINDING_TYPE_CHARACTER = 2
-local BINDING_TYPE_GLOBAL = 1
-local professionMappings = {
+local SECONDARY_PROFESSIONS = {
   [5] = 3,
   [7] = 4,
   [9] = 5,
@@ -23,16 +20,6 @@
 kb.UpdateSpecInfo = function()
   kb.specInfo.id = GetSpecialization()
   kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id)
-  kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id] = kb.InitProfile(kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id], {
-    specID = kb.specInfo.id})
-
-  kb.configHeaders[BINDING_TYPE_SPECIALIZATION] = kb.configTitle[BINDING_TYPE_SPECIALIZATION]:format(kb.specInfo.name)
-  kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION] = kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id]
-  kb.currentProfile = kb.loadedProfiles[kb.db.bindMode]
-  print('|cFF00FF00bindMode:|r', kb.db.bindMode)
-
-  kb.profileOrder = {kb.loadedProfiles[BINDING_TYPE_GLOBAL], kb.loadedProfiles[BINDING_TYPE_CHARACTER], kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION]}
-
   print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations())
 end
 
@@ -40,10 +27,7 @@
   if kb.talentsPushed then
     return
   end
-
-
   table.wipe(kb.TalentCache)
-
   for row =1, MAX_TALENT_TIERS do
     for col = 1, NUM_TALENT_COLUMNS do
       local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1)
@@ -61,6 +45,8 @@
     end
   end
   kb.talentsPushed = true
+
+  kb.UpdateDynamicButtons('talent')
 end
 
 kb.UpdateProfessionInfo = function()
@@ -70,10 +56,10 @@
   for i, index in ipairs(profs) do
     local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index)
     print(i, index, profName, numSpells, spellOffset)
-    if not professionMappings[index] then
+    if not SECONDARY_PROFESSIONS[index] then
       primaryNum = primaryNum + 1
     end
-    local profNum = professionMappings[index] or primaryNum
+    local profNum = SECONDARY_PROFESSIONS[index] or primaryNum
 
 
     kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {}
@@ -101,6 +87,7 @@
 
   end
 
+  kb.UpdateDynamicButtons('profession')
 end
 
 
@@ -166,7 +153,7 @@
     table.wipe(kb.PetCache.action)
   end
 
-  kb.UpdateCacheButtons(kb.petFrames)
+  kb.UpdateDynamicButtons('petaction')
 
 end
 
@@ -186,30 +173,10 @@
 
 end
 
-do
-  local garbage = {}
-  kb.UpdateCacheButtons = function(pending)
-    for i, button in ipairs(pending) do
-      if button.isDynamic then
-        print('flushing button', button:GetID())
-          kb.UpdateSlot(button, true)
-      end
+kb.UpdateDynamicButtons = function(dynamicType)
+  for i, button in ipairs(kb.buttons) do
+    if button.isDynamic == dynamicType then
+      kb.UpdateSlot(button, true)
     end
   end
-end
-
-
-kb.RemoveCacheButton = function(pending, button)
-  local found
-  for index, frame in ipairs(pending) do
-    if button == frame then
-      found = index
-      break
-    end
-  end
-  if found then
-    print('|cFFFF4400pruning', button:GetName(), 'from update queue')
-    tremove(pending, found)
-  end
-
 end
\ No newline at end of file