Mercurial > wow > skeletonkey
comparison 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 |
comparison
equal
deleted
inserted
replaced
16:cdd387d39137 | 17:500f9b2bd9ac |
---|---|
4 -- %file-revision% | 4 -- %file-revision% |
5 -- Logic related to dynamic handlers | 5 -- Logic related to dynamic handlers |
6 local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo') | 6 local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo') |
7 | 7 |
8 local PET_SPECIAL_SUBTEXT = 'Special Ability' | 8 local PET_SPECIAL_SUBTEXT = 'Special Ability' |
9 local BINDING_TYPE_SPECIALIZATION = 3 | 9 local SECONDARY_PROFESSIONS = { |
10 local BINDING_TYPE_CHARACTER = 2 | |
11 local BINDING_TYPE_GLOBAL = 1 | |
12 local professionMappings = { | |
13 [5] = 3, | 10 [5] = 3, |
14 [7] = 4, | 11 [7] = 4, |
15 [9] = 5, | 12 [9] = 5, |
16 [10] = 6 | 13 [10] = 6 |
17 } | 14 } |
21 kb.PetCache = {} | 18 kb.PetCache = {} |
22 kb.specInfo = {} | 19 kb.specInfo = {} |
23 kb.UpdateSpecInfo = function() | 20 kb.UpdateSpecInfo = function() |
24 kb.specInfo.id = GetSpecialization() | 21 kb.specInfo.id = GetSpecialization() |
25 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) | 22 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) |
26 kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id] = kb.InitProfile(kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id], { | |
27 specID = kb.specInfo.id}) | |
28 | |
29 kb.configHeaders[BINDING_TYPE_SPECIALIZATION] = kb.configTitle[BINDING_TYPE_SPECIALIZATION]:format(kb.specInfo.name) | |
30 kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION] = kb.loadedProfiles[BINDING_TYPE_CHARACTER][kb.specInfo.id] | |
31 kb.currentProfile = kb.loadedProfiles[kb.db.bindMode] | |
32 print('|cFF00FF00bindMode:|r', kb.db.bindMode) | |
33 | |
34 kb.profileOrder = {kb.loadedProfiles[BINDING_TYPE_GLOBAL], kb.loadedProfiles[BINDING_TYPE_CHARACTER], kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION]} | |
35 | |
36 print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations()) | 23 print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations()) |
37 end | 24 end |
38 | 25 |
39 kb.UpdateTalentInfo = function() | 26 kb.UpdateTalentInfo = function() |
40 if kb.talentsPushed then | 27 if kb.talentsPushed then |
41 return | 28 return |
42 end | 29 end |
43 | |
44 | |
45 table.wipe(kb.TalentCache) | 30 table.wipe(kb.TalentCache) |
46 | |
47 for row =1, MAX_TALENT_TIERS do | 31 for row =1, MAX_TALENT_TIERS do |
48 for col = 1, NUM_TALENT_COLUMNS do | 32 for col = 1, NUM_TALENT_COLUMNS do |
49 local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1) | 33 local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1) |
50 local talentInfo = kb.TalentCache[spellID] or {} | 34 local talentInfo = kb.TalentCache[spellID] or {} |
51 talentInfo.row = 1 | 35 talentInfo.row = 1 |
59 kb.TalentCache[talentName] = talentInfo | 43 kb.TalentCache[talentName] = talentInfo |
60 print('Talent ', row, col, spellID, talentName) | 44 print('Talent ', row, col, spellID, talentName) |
61 end | 45 end |
62 end | 46 end |
63 kb.talentsPushed = true | 47 kb.talentsPushed = true |
48 | |
49 kb.UpdateDynamicButtons('talent') | |
64 end | 50 end |
65 | 51 |
66 kb.UpdateProfessionInfo = function() | 52 kb.UpdateProfessionInfo = function() |
67 table.wipe(kb.ProfessionCache) | 53 table.wipe(kb.ProfessionCache) |
68 local profs = {GetProfessions() } | 54 local profs = {GetProfessions() } |
69 local primaryNum = 0 | 55 local primaryNum = 0 |
70 for i, index in ipairs(profs) do | 56 for i, index in ipairs(profs) do |
71 local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index) | 57 local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index) |
72 print(i, index, profName, numSpells, spellOffset) | 58 print(i, index, profName, numSpells, spellOffset) |
73 if not professionMappings[index] then | 59 if not SECONDARY_PROFESSIONS[index] then |
74 primaryNum = primaryNum + 1 | 60 primaryNum = primaryNum + 1 |
75 end | 61 end |
76 local profNum = professionMappings[index] or primaryNum | 62 local profNum = SECONDARY_PROFESSIONS[index] or primaryNum |
77 | 63 |
78 | 64 |
79 kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {} | 65 kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {} |
80 | 66 |
81 for j = 1, numSpells do | 67 for j = 1, numSpells do |
99 print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) | 85 print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) |
100 end | 86 end |
101 | 87 |
102 end | 88 end |
103 | 89 |
90 kb.UpdateDynamicButtons('profession') | |
104 end | 91 end |
105 | 92 |
106 | 93 |
107 | 94 |
108 kb.UpdatePetInfo = function() | 95 kb.UpdatePetInfo = function() |
164 else | 151 else |
165 print('NO PET ACTION BAR') | 152 print('NO PET ACTION BAR') |
166 table.wipe(kb.PetCache.action) | 153 table.wipe(kb.PetCache.action) |
167 end | 154 end |
168 | 155 |
169 kb.UpdateCacheButtons(kb.petFrames) | 156 kb.UpdateDynamicButtons('petaction') |
170 | 157 |
171 end | 158 end |
172 | 159 |
173 kb.SystemBinds = {} | 160 kb.SystemBinds = {} |
174 kb.UpdateSystemBinds = function() | 161 kb.UpdateSystemBinds = function() |
184 end | 171 end |
185 end | 172 end |
186 | 173 |
187 end | 174 end |
188 | 175 |
189 do | 176 kb.UpdateDynamicButtons = function(dynamicType) |
190 local garbage = {} | 177 for i, button in ipairs(kb.buttons) do |
191 kb.UpdateCacheButtons = function(pending) | 178 if button.isDynamic == dynamicType then |
192 for i, button in ipairs(pending) do | 179 kb.UpdateSlot(button, true) |
193 if button.isDynamic then | |
194 print('flushing button', button:GetID()) | |
195 kb.UpdateSlot(button, true) | |
196 end | |
197 end | 180 end |
198 end | 181 end |
199 end | 182 end |
200 | |
201 | |
202 kb.RemoveCacheButton = function(pending, button) | |
203 local found | |
204 for index, frame in ipairs(pending) do | |
205 if button == frame then | |
206 found = index | |
207 break | |
208 end | |
209 end | |
210 if found then | |
211 print('|cFFFF4400pruning', button:GetName(), 'from update queue') | |
212 tremove(pending, found) | |
213 end | |
214 | |
215 end |