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