Nenue@6: -- KrakTool Nenue@6: -- Cache.lua Nenue@6: -- Created: 7/28/2016 3:28 PM Nenue@6: -- %file-revision% Nenue@6: -- Cached data regarding talent options, pet spells, etc. Nenue@6: local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo') Nenue@6: Nenue@6: local BINDING_TYPE_SPECIALIZATION = 3 Nenue@6: local BINDING_TYPE_CHARACTER = 2 Nenue@6: local BINDING_TYPE_GLOBAL = 1 Nenue@6: local professionMappings = { Nenue@6: [5] = 3, Nenue@6: [7] = 4, Nenue@6: [9] = 5, Nenue@6: [10] = 6 Nenue@6: } Nenue@6: Nenue@6: kb.TalentCache = {} Nenue@6: kb.ProfessionCache = {} Nenue@6: kb.PetCache = {} Nenue@6: kb.specInfo = {} Nenue@6: kb.UpdateSpecInfo = function() Nenue@6: kb.specInfo.id = GetSpecialization() Nenue@6: kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) Nenue@6: kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id] = kb.InitProfile(kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id], { Nenue@6: specID = kb.specInfo.id}) Nenue@6: Nenue@6: kb.configHeaders[BINDING_TYPE_SPECIALIZATION] = kb.configTitle[BINDING_TYPE_SPECIALIZATION]:format(kb.specInfo.name) Nenue@6: kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION] = kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id] Nenue@6: kb.currentProfile = kb.loadedProfiles[kb.bindMode] Nenue@6: print('|cFF00FF00bindMode:|r', kb.bindMode) Nenue@6: Nenue@6: kb.profileOrder = {kb.loadedProfiles[BINDING_TYPE_GLOBAL], kb.loadedProfiles[BINDING_TYPE_CHARACTER], kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION]} Nenue@6: Nenue@6: print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations()) Nenue@6: end Nenue@6: Nenue@6: kb.UpdateTalentInfo = function() Nenue@6: if kb.talentsPushed then Nenue@6: return Nenue@6: end Nenue@6: Nenue@6: Nenue@6: table.wipe(kb.TalentCache) Nenue@6: Nenue@6: for row =1, MAX_TALENT_TIERS do Nenue@6: for col = 1, NUM_TALENT_COLUMNS do Nenue@6: local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1) Nenue@6: local talentInfo = kb.TalentCache[spellID] or {} Nenue@6: talentInfo.row = 1 Nenue@6: talentInfo.col = col Nenue@6: talentInfo.name = talentName Nenue@6: talentInfo.talentID = talentID Nenue@6: talentInfo.selected = selected Nenue@6: talentInfo.available = available Nenue@6: talentInfo.spellID = spellID Nenue@6: kb.TalentCache[spellID] = talentInfo Nenue@13: kb.TalentCache[talentName] = talentInfo Nenue@6: print('Talent ', row, col, spellID, talentName) Nenue@6: end Nenue@6: end Nenue@6: kb.talentsPushed = true Nenue@6: end Nenue@6: Nenue@6: kb.UpdateProfessionInfo = function() Nenue@6: table.wipe(kb.ProfessionCache) Nenue@6: local profs = {GetProfessions() } Nenue@6: local primaryNum = 0 Nenue@6: for i, index in ipairs(profs) do Nenue@6: local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index) Nenue@6: print(i, index, profName, numSpells, spellOffset) Nenue@6: if not professionMappings[index] then Nenue@6: primaryNum = primaryNum + 1 Nenue@6: end Nenue@6: local profNum = professionMappings[index] or primaryNum Nenue@6: Nenue@6: Nenue@6: kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {} Nenue@6: Nenue@6: for j = 1, numSpells do Nenue@6: local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION) Nenue@6: Nenue@6: local profInfo = { Nenue@6: spellName = spellName, Nenue@6: spellID = spellID, Nenue@6: icon = icon, Nenue@6: profOffset = i, Nenue@6: profIndex = index, Nenue@6: spellOffset = (spellOffset+j), Nenue@6: spellNum = j Nenue@6: } Nenue@6: KeyBinderKey:SetAttribute("*type-profession_"..i .. '_' ..j, "spell") Nenue@6: KeyBinderKey:SetAttribute("*spell-profession_"..i .. '_' ..j, spellName) Nenue@6: Nenue@6: kb.ProfessionCache[i .. '_' .. j] = profInfo Nenue@6: kb.ProfessionCache[spellName] = profInfo Nenue@6: kb.ProfessionCache[spellID] = profInfo Nenue@6: print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) Nenue@6: end Nenue@6: Nenue@6: end Nenue@6: Nenue@6: end Nenue@6: Nenue@6: Nenue@6: kb.UpdatePetInfo = function() Nenue@6: Nenue@6: end