annotate SkeletonKey/Cache.lua @ 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 f6d1c192afc6
children 82170735e67c
rev   line source
Nenue@6 1 -- KrakTool
Nenue@6 2 -- Cache.lua
Nenue@6 3 -- Created: 7/28/2016 3:28 PM
Nenue@6 4 -- %file-revision%
Nenue@6 5 -- Cached data regarding talent options, pet spells, etc.
Nenue@6 6 local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo')
Nenue@6 7
Nenue@6 8 local BINDING_TYPE_SPECIALIZATION = 3
Nenue@6 9 local BINDING_TYPE_CHARACTER = 2
Nenue@6 10 local BINDING_TYPE_GLOBAL = 1
Nenue@6 11 local professionMappings = {
Nenue@6 12 [5] = 3,
Nenue@6 13 [7] = 4,
Nenue@6 14 [9] = 5,
Nenue@6 15 [10] = 6
Nenue@6 16 }
Nenue@6 17
Nenue@6 18 kb.TalentCache = {}
Nenue@6 19 kb.ProfessionCache = {}
Nenue@6 20 kb.PetCache = {}
Nenue@6 21 kb.specInfo = {}
Nenue@6 22 kb.UpdateSpecInfo = function()
Nenue@6 23 kb.specInfo.id = GetSpecialization()
Nenue@6 24 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id)
Nenue@6 25 kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id] = kb.InitProfile(kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id], {
Nenue@6 26 specID = kb.specInfo.id})
Nenue@6 27
Nenue@6 28 kb.configHeaders[BINDING_TYPE_SPECIALIZATION] = kb.configTitle[BINDING_TYPE_SPECIALIZATION]:format(kb.specInfo.name)
Nenue@6 29 kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION] = kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id]
Nenue@6 30 kb.currentProfile = kb.loadedProfiles[kb.bindMode]
Nenue@6 31 print('|cFF00FF00bindMode:|r', kb.bindMode)
Nenue@6 32
Nenue@6 33 kb.profileOrder = {kb.loadedProfiles[BINDING_TYPE_GLOBAL], kb.loadedProfiles[BINDING_TYPE_CHARACTER], kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION]}
Nenue@6 34
Nenue@6 35 print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations())
Nenue@6 36 end
Nenue@6 37
Nenue@6 38 kb.UpdateTalentInfo = function()
Nenue@6 39 if kb.talentsPushed then
Nenue@6 40 return
Nenue@6 41 end
Nenue@6 42
Nenue@6 43
Nenue@6 44 table.wipe(kb.TalentCache)
Nenue@6 45
Nenue@6 46 for row =1, MAX_TALENT_TIERS do
Nenue@6 47 for col = 1, NUM_TALENT_COLUMNS do
Nenue@6 48 local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1)
Nenue@6 49 local talentInfo = kb.TalentCache[spellID] or {}
Nenue@6 50 talentInfo.row = 1
Nenue@6 51 talentInfo.col = col
Nenue@6 52 talentInfo.name = talentName
Nenue@6 53 talentInfo.talentID = talentID
Nenue@6 54 talentInfo.selected = selected
Nenue@6 55 talentInfo.available = available
Nenue@6 56 talentInfo.spellID = spellID
Nenue@6 57 kb.TalentCache[spellID] = talentInfo
Nenue@13 58 kb.TalentCache[talentName] = talentInfo
Nenue@6 59 print('Talent ', row, col, spellID, talentName)
Nenue@6 60 end
Nenue@6 61 end
Nenue@6 62 kb.talentsPushed = true
Nenue@6 63 end
Nenue@6 64
Nenue@6 65 kb.UpdateProfessionInfo = function()
Nenue@6 66 table.wipe(kb.ProfessionCache)
Nenue@6 67 local profs = {GetProfessions() }
Nenue@6 68 local primaryNum = 0
Nenue@6 69 for i, index in ipairs(profs) do
Nenue@6 70 local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index)
Nenue@6 71 print(i, index, profName, numSpells, spellOffset)
Nenue@6 72 if not professionMappings[index] then
Nenue@6 73 primaryNum = primaryNum + 1
Nenue@6 74 end
Nenue@6 75 local profNum = professionMappings[index] or primaryNum
Nenue@6 76
Nenue@6 77
Nenue@6 78 kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {}
Nenue@6 79
Nenue@6 80 for j = 1, numSpells do
Nenue@6 81 local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION)
Nenue@6 82
Nenue@6 83 local profInfo = {
Nenue@6 84 spellName = spellName,
Nenue@6 85 spellID = spellID,
Nenue@6 86 icon = icon,
Nenue@6 87 profOffset = i,
Nenue@6 88 profIndex = index,
Nenue@6 89 spellOffset = (spellOffset+j),
Nenue@6 90 spellNum = j
Nenue@6 91 }
Nenue@6 92 KeyBinderKey:SetAttribute("*type-profession_"..i .. '_' ..j, "spell")
Nenue@6 93 KeyBinderKey:SetAttribute("*spell-profession_"..i .. '_' ..j, spellName)
Nenue@6 94
Nenue@6 95 kb.ProfessionCache[i .. '_' .. j] = profInfo
Nenue@6 96 kb.ProfessionCache[spellName] = profInfo
Nenue@6 97 kb.ProfessionCache[spellID] = profInfo
Nenue@6 98 print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j)
Nenue@6 99 end
Nenue@6 100
Nenue@6 101 end
Nenue@6 102
Nenue@6 103 end
Nenue@6 104
Nenue@6 105
Nenue@6 106 kb.UpdatePetInfo = function()
Nenue@6 107
Nenue@6 108 end