diff SkeletonKey/Cache.lua @ 6:f6d1c192afc6

Refactored file layout: - frame display logic in UI.lua - player data in Cache.lua - event responses in Events.lua a lot of local tables are now stored members of KeyBinder for that to work
author Nenue
date Thu, 28 Jul 2016 16:45:56 -0400
parents
children eeec4a600064
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SkeletonKey/Cache.lua	Thu Jul 28 16:45:56 2016 -0400
@@ -0,0 +1,107 @@
+-- KrakTool
+-- Cache.lua
+-- Created: 7/28/2016 3:28 PM
+-- %file-revision%
+-- Cached data regarding talent options, pet spells, etc.
+local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo')
+
+local BINDING_TYPE_SPECIALIZATION = 3
+local BINDING_TYPE_CHARACTER = 2
+local BINDING_TYPE_GLOBAL = 1
+local professionMappings = {
+  [5] = 3,
+  [7] = 4,
+  [9] = 5,
+  [10] = 6
+}
+
+kb.TalentCache = {}
+kb.ProfessionCache = {}
+kb.PetCache = {}
+kb.specInfo = {}
+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.bindMode]
+  print('|cFF00FF00bindMode:|r', kb.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
+
+kb.UpdateTalentInfo = function()
+  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)
+      local talentInfo = kb.TalentCache[spellID] or {}
+      talentInfo.row = 1
+      talentInfo.col = col
+      talentInfo.name = talentName
+      talentInfo.talentID = talentID
+      talentInfo.selected = selected
+      talentInfo.available = available
+      talentInfo.spellID = spellID
+      kb.TalentCache[spellID] = talentInfo
+      print('Talent ', row, col, spellID, talentName)
+    end
+  end
+  kb.talentsPushed = true
+end
+
+kb.UpdateProfessionInfo = function()
+  table.wipe(kb.ProfessionCache)
+  local profs = {GetProfessions() }
+  local primaryNum = 0
+  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
+      primaryNum = primaryNum + 1
+    end
+    local profNum = professionMappings[index] or primaryNum
+
+
+    kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {}
+
+    for j = 1, numSpells do
+      local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION)
+
+      local profInfo = {
+        spellName = spellName,
+        spellID = spellID,
+        icon = icon,
+        profOffset = i,
+        profIndex = index,
+        spellOffset = (spellOffset+j),
+        spellNum = j
+      }
+      KeyBinderKey:SetAttribute("*type-profession_"..i .. '_' ..j, "spell")
+      KeyBinderKey:SetAttribute("*spell-profession_"..i .. '_' ..j, spellName)
+
+      kb.ProfessionCache[i .. '_' .. j] = profInfo
+      kb.ProfessionCache[spellName] = profInfo
+      kb.ProfessionCache[spellID] = profInfo
+      print('  |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j)
+    end
+
+  end
+
+end
+
+
+kb.UpdatePetInfo = function()
+
+end
\ No newline at end of file