Nenue@70
|
1 -- SkeletonKey
|
Nenue@70
|
2 -- ActionTemplates.lua
|
Nenue@70
|
3 -- Created: 7/29/2016 9:14 PM
|
Nenue@70
|
4 -- %file-revision%
|
Nenue@70
|
5 -- Code dealing with the implementation of action hotkeys
|
Nenue@70
|
6
|
Nenue@70
|
7 local tostring, tonumber, pairs, ipairs = tostring, tonumber, pairs, ipairs
|
Nenue@70
|
8 local unpack, SetBinding = unpack, SetBinding
|
Nenue@70
|
9 local tinsert, tContains, select, wipe = tinsert, tContains, select, table.wipe
|
Nenue@70
|
10 local GetSpellBookItemInfo, GetSpellBookItemName, GetSpellInfo = GetSpellBookItemInfo, GetSpellBookItemName, GetSpellInfo
|
Nenue@70
|
11 local GetSpecialization, GetSpecializationInfo, IsPassiveSpell, IsTalentSpell = GetSpecialization, GetSpecializationInfo, IsPassiveSpell, IsTalentSpell
|
Nenue@70
|
12 local PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells = PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells
|
Nenue@70
|
13 local GetProfessions, GetProfessionInfo, GetTalentInfo = GetProfessions, GetProfessionInfo, GetTalentInfo
|
Nenue@70
|
14 local GetNumBindings, GetBinding = GetNumBindings, GetBinding
|
Nenue@70
|
15
|
Nenue@70
|
16 local _, kb = ...
|
Nenue@93
|
17 local print = (DEVIAN_PNAME == 'SkeletonKey') and function(...) print('AT', ...) end or nop
|
Nenue@70
|
18 local cprint = (DEVIAN_PNAME == 'SkeletonKey') and function(...) _G.print('Cfg', ...) end or nop
|
Nenue@70
|
19
|
Nenue@70
|
20 local CLICK_KEYBINDER_MACRO = "CLICK SkeletonKeyMacro:"
|
Nenue@70
|
21 local CLICK_KEYBINDER_KEY = "CLICK SkeletonKeyKey:"
|
Nenue@70
|
22 local PET_BASIC_SUBTEXT = 'Basic Attack'
|
Nenue@70
|
23 local PET_SPECIAL_SUBTEXT = 'Special Ability'
|
Nenue@70
|
24 local PETACTION_SCRIPT = {
|
Nenue@70
|
25 [PET_ACTION_MOVE_TO] = {'pet_move_to', SLASH_PET_MOVE_TO1},
|
Nenue@70
|
26 [PET_ACTION_ATTACK] = {'pet_attack', SLASH_PET_ATTACK1},
|
Nenue@70
|
27 [PET_ACTION_FOLLOW] = {'pet_follow', SLASH_PET_FOLLOW1},
|
Nenue@70
|
28 [PET_ACTION_WAIT] = {'pet_stay', SLASH_PET_STAY1 },
|
Nenue@70
|
29 [PET_MODE_AGGRESSIVE] = {'pet_aggressive', SLASH_PET_AGGRESSIVE1 },
|
Nenue@70
|
30 [PET_MODE_DEFENSIVE] = { 'pet_defensive', SLASH_PET_DEFENSIVE1},
|
Nenue@70
|
31 [PET_MODE_PASSIVE] = { 'pet_passive', SLASH_PET_PASSIVE1},
|
Nenue@70
|
32 [PET_MODE_ASSIST] = {'pet_assist', SLASH_PET_ASSIST1},
|
Nenue@70
|
33 }
|
Nenue@70
|
34 local SECONDARY_PROFESSIONS = {
|
Nenue@70
|
35 [5] = 3,
|
Nenue@70
|
36 [7] = 4,
|
Nenue@70
|
37 [9] = 5,
|
Nenue@70
|
38 [10] = 6
|
Nenue@70
|
39 }
|
Nenue@81
|
40
|
Nenue@81
|
41
|
Nenue@70
|
42 local petSpellCache,petSubtextCache
|
Nenue@70
|
43 local SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544
|
Nenue@70
|
44
|
Nenue@70
|
45
|
Nenue@70
|
46 local atype = kb.ActionTypes
|
Nenue@70
|
47
|
Nenue@70
|
48 --- Caps Lock
|
Nenue@70
|
49 atype['mount'] = function(id, name)
|
Nenue@70
|
50 if id == SUMMON_RANDOM_FAVORITE_MOUNT_SPELL then
|
Nenue@70
|
51 return CLICK_KEYBINDER_MACRO, 'mount_random', "/script C_MountJournal.SummonByID(0)", SkeletonKeyMacro
|
Nenue@70
|
52 else
|
Nenue@70
|
53 return CLICK_KEYBINDER_MACRO, 'mount_'..id, "/script C_MountJournal.SummonByID("..id..")", SkeletonKeyMacro
|
Nenue@70
|
54 end
|
Nenue@70
|
55 end
|
Nenue@70
|
56
|
Nenue@70
|
57 atype['macro'] = function(id, name)
|
Nenue@70
|
58 local _, _, text = GetMacroInfo(id)
|
Nenue@70
|
59 return CLICK_KEYBINDER_MACRO, 'macro_' .. tostring(name), name, SkeletonKeyMacro
|
Nenue@70
|
60 end
|
Nenue@70
|
61
|
Nenue@70
|
62 atype['equipset'] = function(id, name)
|
Nenue@70
|
63 return CLICK_KEYBINDER_MACRO, 'equipset_'..tostring(name), "/script UseEquipmentSet("..tostring(id)..")", SkeletonKeyMacro
|
Nenue@70
|
64 end
|
Nenue@70
|
65
|
Nenue@70
|
66 atype['spell'] = function(id, name)
|
Nenue@70
|
67 local attributeName = name
|
Nenue@78
|
68 local profInfo = kb.DynamicSpells.profession[id]
|
Nenue@78
|
69 if profInfo then
|
Nenue@78
|
70 attributeName = "profession_".. profInfo.dynamicIndex .. '_' .. profInfo.dynamicSubIndex
|
Nenue@70
|
71 end
|
Nenue@70
|
72 return CLICK_KEYBINDER_KEY, attributeName, name, SkeletonKeyKey
|
Nenue@70
|
73 end
|
Nenue@70
|
74
|
Nenue@70
|
75 atype['petaction'] = function(_, name)
|
Nenue@93
|
76 print('|cFF00FF00atype:petaction|r', name)
|
Nenue@70
|
77 -- ID doesn't exist for basic commands, even though they can be picked up
|
Nenue@93
|
78 local attributeName, attributeValue = "petaction_" .. tostring(name), "/use "..tostring(name)
|
Nenue@70
|
79
|
Nenue@70
|
80 if not petSpellCache then
|
Nenue@70
|
81 kb.UpdatePetInfo()
|
Nenue@70
|
82 end
|
Nenue@70
|
83 -- Compose a multi-macro for subtext abilities
|
Nenue@70
|
84
|
Nenue@70
|
85 if PETACTION_SCRIPT[name] then
|
Nenue@70
|
86 attributeName, attributeValue = unpack(PETACTION_SCRIPT[name])
|
Nenue@93
|
87
|
Nenue@93
|
88 print(' scripts hit:', name, attributeName, attributeValue)
|
Nenue@70
|
89 end
|
Nenue@70
|
90 return CLICK_KEYBINDER_MACRO, attributeName, attributeValue, SkeletonKeyMacro
|
Nenue@70
|
91 end
|
Nenue@70
|
92
|
Nenue@70
|
93 atype['battlepet'] = function(id, name)
|
Nenue@70
|
94 return CLICK_KEYBINDER_MACRO, 'battlepet_' .. tostring(name), SLASH_SUMMON_BATTLE_PET1 .. " " .. tostring(name), SkeletonKeyMacro
|
Nenue@70
|
95 end
|
Nenue@70
|
96
|
Nenue@70
|
97 atype['item'] = function(id, name)
|
Nenue@75
|
98 return CLICK_KEYBINDER_KEY, tostring(name), tostring(name), SkeletonKeyKey
|
Nenue@70
|
99 end
|
Nenue@70
|
100
|
Nenue@70
|
101
|
Nenue@70
|
102 --- Resolves the SecureActionButton attribute names used for the given action
|
Nenue@70
|
103 kb.RegisterAction = function(actionType, id, name)
|
Nenue@83
|
104 if not atype[actionType]then
|
Nenue@83
|
105 kb.print('Missing actionType handler for `'..tostring(actionType)..'`')
|
Nenue@83
|
106 return
|
Nenue@83
|
107 end
|
Nenue@74
|
108 local prefix, attributeName, attributeValue, button = atype[actionType](id, name)
|
Nenue@74
|
109 local command = prefix .. attributeName
|
Nenue@74
|
110 return attributeName, attributeValue, command, prefix, button
|
Nenue@70
|
111 end
|
Nenue@70
|
112
|
Nenue@70
|
113
|
Nenue@74
|
114 local spells = {}
|
Nenue@74
|
115 local SkeletonKey_GetGenericSpell = function(spellName, spellID, icon)
|
Nenue@74
|
116 if not spells[spellID] then
|
Nenue@74
|
117 spells[spellID] = {}
|
Nenue@74
|
118 spells[spellID].actionType = 'spell'
|
Nenue@74
|
119 spells[spellID].actionID = spellID
|
Nenue@74
|
120 spells[spellID].actionName = spellName
|
Nenue@74
|
121 spells[spellID].iconPath = icon
|
Nenue@74
|
122 spells[spellID].statusText = '|cFFBBBBBBSpell|r'
|
Nenue@74
|
123 spells[spellID].dynamicType = nil
|
Nenue@74
|
124 end
|
Nenue@74
|
125 return spells[spellID]
|
Nenue@74
|
126 end
|
Nenue@74
|
127
|
Nick@80
|
128 -- verifies binding slot data
|
Nenue@74
|
129 local dynamicTypes = {['profession'] = 'ProfessionCache', ['talent'] = 'TalentCache', ['petaction'] = 'PetInfoCache'}
|
Nenue@74
|
130 kb.ResolveSpellSlot = function(self)
|
Nenue@74
|
131 local spellName, spellID, command, icon = self.actionName, self.actionID, self.command, self.iconPath
|
Nick@80
|
132
|
Nenue@74
|
133 --print(GetSpellInfo(spellName or spellID))
|
Nick@80
|
134 local internalName, _, internalIcon, _, _, _, _ = GetSpellInfo(spellID)
|
Nick@80
|
135 local replacerName, _, _, _, _, _, replacerID = GetSpellInfo(internalName)
|
Nick@80
|
136 print('Resolve Slot: id =', spellID, 'nameFromID =', internalName, 'nameFromName =', replacerName)
|
Nenue@74
|
137 local isAvailable = internalName and true
|
Nenue@74
|
138
|
Nick@80
|
139 -- keep current slotInfo if it's a spell that has been replaced by spec/talent
|
Nick@80
|
140 if internalName and (internalName ~= replacerName) then
|
Nick@80
|
141 print(' |cFFFF4400spell name is overridden by', replacerName, '(was', internalName,')')
|
Nenue@74
|
142 self.statusText = '|cFFFFFF00Spell|r'
|
Nenue@74
|
143 self.isAvailable = true
|
Nenue@74
|
144 return
|
Nenue@74
|
145 end
|
Nenue@74
|
146
|
Nick@80
|
147 -- resolve spell name
|
Nick@80
|
148 local info = kb.DynamicSpells[spellName]
|
Nenue@74
|
149 if not info then
|
Nenue@74
|
150 local dynamicType, dynamicIndex, dynamicSubIndex = command:match("(%a+)_(%S+)_(%S+)")
|
Nenue@74
|
151 if kb.DynamicSpells[dynamicType] then
|
Nenue@74
|
152 print('|cFFFF4400resolving dynamic type index:', internalName, spellName, command)
|
Nenue@74
|
153 dynamicIndex = tonumber(dynamicIndex)
|
Nenue@74
|
154 dynamicSubIndex = tonumber(dynamicSubIndex)
|
Nenue@74
|
155 local cache = kb.DynamicSpells[dynamicType]
|
Nenue@74
|
156 print('type:', dynamicType)
|
Nenue@74
|
157 if dynamicIndex and cache[dynamicIndex] then
|
Nenue@74
|
158 info = kb.DynamicSpells[dynamicType][dynamicIndex]
|
Nenue@74
|
159 print('index:', dynamicIndex)
|
Nenue@74
|
160 if dynamicSubIndex and info[dynamicSubIndex] then
|
Nenue@74
|
161 info = info[dynamicSubIndex]
|
Nenue@74
|
162 print('sub-index:', dynamicSubIndex)
|
Nenue@74
|
163 end
|
Nenue@74
|
164 isAvailable = true
|
Nenue@74
|
165 end
|
Nenue@74
|
166 end
|
Nenue@74
|
167 if not info then
|
Nenue@74
|
168 info = SkeletonKey_GetGenericSpell(spellName, spellID, internalIcon or icon)
|
Nenue@74
|
169 end
|
Nenue@74
|
170 end
|
Nenue@81
|
171
|
Nenue@81
|
172
|
Nenue@81
|
173
|
Nenue@74
|
174 info.isAvailable = isAvailable
|
Nenue@74
|
175
|
Nenue@74
|
176 print('|cFF00FF88Slot Details:|r', info.actionName, info.actionID, info.dynamicType, info.isAvailable)
|
Nenue@74
|
177 for k,v in pairs(info) do
|
Nenue@74
|
178 --cprint(' ',k,v)
|
Nenue@74
|
179 self[k] = v
|
Nenue@74
|
180 end
|
Nenue@74
|
181
|
Nenue@74
|
182 return info
|
Nenue@74
|
183 end
|
Nenue@70
|
184
|
Nenue@70
|
185 do
|
Nenue@76
|
186 local PROFILE_VERSION = 320
|
Nenue@70
|
187 local commandActions = {}
|
Nenue@70
|
188 local bindings = kb.bindings
|
Nenue@70
|
189 local key, macro = SkeletonKeyKey, SkeletonKeyMacro
|
Nenue@70
|
190 kb.LoadBinding = function( configTable)
|
Nenue@70
|
191 if configTable.command then
|
Nenue@70
|
192 configTable.command = configTable.command:gsub('KeyBinder', 'SkeletonKey')
|
Nenue@70
|
193 end
|
Nenue@70
|
194
|
Nenue@83
|
195 cprint('|cFF0088FFLoadBinding()|r', configTable.actionName, configTable.dynamicType)
|
Nenue@83
|
196 local isAvailable
|
Nenue@83
|
197 local dynamicType = configTable.dynamicType
|
Nenue@83
|
198 if dynamicType == 'profession' then
|
Nenue@83
|
199 local dynamicIndex, dynamicSubIndex = tonumber(configTable.dynamicIndex), tonumber(configTable.dynamicSubIndex)
|
Nenue@83
|
200 cprint(' |cFF00FFFFDynamicInfo:|r', dynamicType, dynamicIndex, dynamicSubIndex)
|
Nenue@83
|
201
|
Nenue@83
|
202 local extendedTable = kb.DynamicSpells[dynamicType][dynamicIndex]
|
Nenue@83
|
203
|
Nenue@83
|
204 if extendedTable then
|
Nenue@83
|
205 cprint(extendedTable)
|
Nenue@83
|
206 for k,v in pairs(extendedTable) do
|
Nenue@83
|
207 cprint(type(k), k)
|
Nenue@83
|
208 end
|
Nenue@83
|
209 local subTable = extendedTable[dynamicSubIndex]
|
Nenue@83
|
210
|
Nenue@83
|
211 if subTable then
|
Nenue@83
|
212 for k,v in pairs(subTable) do
|
Nenue@83
|
213 cprint(' override', k, '=', v, '(was', configTable[k])
|
Nenue@83
|
214 configTable[k] = subTable[k]
|
Nenue@83
|
215 end
|
Nenue@83
|
216 --isAvailable = configTable.isAvailabl
|
Nenue@83
|
217 --name, actionID = configTable.actionName, configTable.actionID
|
Nenue@83
|
218 cprint(subTable.actionName, subTable.actionID)
|
Nenue@83
|
219 isAvailable = true
|
Nenue@83
|
220 end
|
Nenue@83
|
221 end
|
Nenue@83
|
222 end
|
Nenue@83
|
223
|
Nenue@70
|
224 local command, name, icon, actionType, actionID, macroName, macroText =
|
Nenue@70
|
225 configTable.command, configTable.actionName, configTable.iconPath, configTable.actionType,
|
Nenue@70
|
226 configTable.actionID, configTable.macroName, configTable.macroText
|
Nenue@70
|
227
|
Nenue@83
|
228 local indexKey = tostring(actionType)..'_'..tostring(actionID)
|
Nenue@83
|
229 local actionPrefix = "*"..tostring(actionType).."-"
|
Nenue@70
|
230 local button = SkeletonKeyKey
|
Nenue@70
|
231 local specialButtonType
|
Nenue@70
|
232 if actionType == 'spell' then
|
Nick@80
|
233 local realName, _, _, _, _, _, realID = GetSpellInfo(name)
|
Nenue@83
|
234
|
Nenue@81
|
235 if realName then
|
Nenue@81
|
236 if (realName ~= name) then
|
Nenue@83
|
237 cprint(' *** "', name, '" is replaced by...', realName, realID)
|
Nick@80
|
238 --name, actionID = realName, realID
|
Nick@80
|
239 indexKey = actionType .. '_'.. realID
|
Nenue@81
|
240 end
|
Nenue@83
|
241 elseif dynamicType == 'talent' then
|
Nenue@83
|
242 cprint(' |cFF00FFFFDynamicInfo:|r', dynamicType, table.concat(configTable.assignedKeys, ','))
|
Nenue@83
|
243 cprint(' *** "', name, '" is a non-selected talent.')
|
Nenue@81
|
244 return
|
Nick@80
|
245 end
|
Nick@80
|
246
|
Nenue@83
|
247 if GetSpellInfo(realName or name) then
|
Nick@80
|
248
|
Nenue@76
|
249 isAvailable = true
|
Nenue@76
|
250
|
Nenue@70
|
251 end
|
Nenue@75
|
252 elseif actionType == 'item' then
|
Nenue@75
|
253 actionID = configTable.actionName
|
Nenue@75
|
254 isAvailable = true
|
Nenue@75
|
255 else
|
Nenue@71
|
256
|
Nenue@70
|
257 if actionType ~= 'macro' then
|
Nenue@70
|
258 actionPrefix = '*macrotext-'
|
Nenue@70
|
259 end
|
Nenue@70
|
260
|
Nenue@70
|
261 specialButtonType = 'macro'
|
Nenue@73
|
262 isAvailable = true
|
Nenue@70
|
263 end
|
Nenue@70
|
264
|
Nenue@72
|
265 if isAvailable then
|
Nenue@83
|
266 cprint(' available', actionType, actionID, name)
|
Nenue@70
|
267
|
Nenue@72
|
268 local attributeSuffix, attributeValue, command, target, button = kb.RegisterAction(actionType, actionID, name)
|
Nenue@83
|
269 local actionKey = tostring(actionPrefix) .. tostring(attributeSuffix)
|
Nenue@83
|
270
|
Nenue@83
|
271 if not attributeSuffix then
|
Nenue@83
|
272 cprint('failed to generate button attribute')
|
Nenue@83
|
273 return
|
Nenue@83
|
274 end
|
Nenue@83
|
275
|
Nenue@83
|
276
|
Nenue@83
|
277 cprint('|cFF00FF88 result:|r', button and button:GetName(), "*type-"..tostring(attributeSuffix), actionType, '|cFFFFFF00'..actionKey, attributeValue, isAvailable)
|
Nenue@70
|
278
|
Nenue@70
|
279
|
Nenue@70
|
280 kb.SecureAttribute(button, "*type-"..attributeSuffix, specialButtonType or actionType)
|
Nenue@70
|
281 kb.SecureAttribute(button, actionKey, attributeValue)
|
Nenue@72
|
282
|
Nenue@83
|
283 cprint(' |cFFFF4400add', name, isAvailable, indexKey, unpack(configTable.assignedKeys))
|
Nenue@70
|
284 kb.bindings[indexKey] = configTable.assignedKeys
|
Nenue@70
|
285 commandActions[command] = kb.bindings[indexKey]
|
Nenue@70
|
286 return command, kb.bindings[indexKey]
|
Nenue@70
|
287 else
|
Nenue@72
|
288 if kb.bindings[indexKey] then
|
Nenue@83
|
289 cprint(' |cFFFF4400remove', name, isAvailable, indexKey, unpack(configTable.assignedKeys))
|
Nenue@72
|
290 kb.bindings[indexKey] = nil
|
Nenue@72
|
291 end
|
Nenue@72
|
292
|
Nenue@70
|
293 return nil
|
Nenue@70
|
294 end
|
Nenue@70
|
295 end
|
Nenue@70
|
296
|
Nenue@71
|
297
|
Nenue@70
|
298 local usedSlots = {}
|
Nenue@71
|
299 kb.UpgradeProfile = function(profile)
|
Nenue@70
|
300 wipe(usedSlots)
|
Nenue@70
|
301 for slot, configTable in pairs(profile.buttons) do
|
Nenue@70
|
302
|
Nenue@71
|
303 -- convert old style table
|
Nenue@70
|
304 if #configTable >= 1 then
|
Nenue@70
|
305 local command, name, icon, actionType, actionID, macroName, macroText, spellbookSlot, spellbookType = unpack(configTable)
|
Nenue@70
|
306
|
Nenue@70
|
307 cprint('|CFFFF4400Fixing pad entry', slot, command, name)
|
Nenue@70
|
308 local assignedKeys = {GetBindingKey(command)}
|
Nenue@70
|
309 for k,v in pairs(profile.bindings) do
|
Nenue@70
|
310 if v == command then
|
Nenue@70
|
311 tinsert(assignedKeys, k)
|
Nenue@70
|
312 end
|
Nenue@70
|
313 end
|
Nenue@70
|
314
|
Nenue@70
|
315 configTable = {
|
Nenue@70
|
316 command = command,
|
Nenue@70
|
317 actionType = actionType,
|
Nenue@70
|
318 actionName = name,
|
Nenue@70
|
319 actionID = actionID,
|
Nenue@70
|
320 macroName = macroName,
|
Nenue@70
|
321 macroText = macroText,
|
Nenue@70
|
322 iconPath = icon,
|
Nenue@70
|
323 spellbookSlot = spellbookSlot,
|
Nenue@70
|
324 spellbookType = spellbookType,
|
Nenue@70
|
325 assignedKeys = assignedKeys
|
Nenue@70
|
326 }
|
Nenue@71
|
327
|
Nenue@71
|
328 local dynamic = kb.DynamicSpells[name]
|
Nenue@71
|
329 if dynamic then
|
Nenue@71
|
330 configTable.dynamicType = dynamic.dynamicType
|
Nenue@71
|
331 configTable.dynamicIndex = dynamic.dynamicIndex
|
Nenue@71
|
332 configTable.dynamicSubIndex = dynamic.dynamicSubIndex
|
Nenue@71
|
333 configTable.dynamicID = dynamic.dynamicID
|
Nenue@71
|
334 if configTable.dynamicType == 'talent' then
|
Nenue@71
|
335 profile.talents[name] = configTable
|
Nenue@71
|
336 end
|
Nenue@71
|
337 end
|
Nenue@71
|
338
|
Nenue@71
|
339
|
Nenue@70
|
340 kb.currentProfile.buttons[slot] = configTable
|
Nenue@70
|
341 end
|
Nenue@70
|
342 if not configTable.actionID then
|
Nenue@70
|
343 configTable.actionID = configTable.actionName
|
Nenue@70
|
344 end
|
Nenue@70
|
345 if not configTable.iconPath then
|
Nenue@70
|
346 print('corrected missing icon')
|
Nenue@70
|
347 configTable.iconPath = GetSpellTexture(configTable.actionName)
|
Nenue@70
|
348 end
|
Nenue@70
|
349
|
Nenue@70
|
350 usedSlots[configTable.actionName or configTable.actionID] = true
|
Nenue@70
|
351 usedSlots[configTable.command] = true
|
Nenue@70
|
352 end
|
Nenue@70
|
353
|
Nenue@70
|
354
|
Nenue@71
|
355 -- clean up legacy data
|
Nenue@70
|
356 for spellName, talentInfo in pairs(profile.talents) do
|
Nenue@70
|
357 if not usedSlots[spellName] then
|
Nenue@70
|
358 cprint('|cFFFF4400Unslotted talent', spellName)
|
Nenue@70
|
359 profile.talents[spellName] = nil
|
Nenue@70
|
360 end
|
Nenue@70
|
361 end
|
Nenue@70
|
362 for command in pairs(profile.bound) do
|
Nenue@70
|
363 if not usedSlots[command] then
|
Nenue@70
|
364 cprint('|cFFFF4400Unslotted bound entry', command)
|
Nenue@70
|
365 profile.bound[command] = nil
|
Nenue@70
|
366 profile.commands[command] = nil
|
Nenue@70
|
367 end
|
Nenue@70
|
368 end
|
Nenue@70
|
369 for command in pairs(profile.commands) do
|
Nenue@70
|
370 if not usedSlots[command] then
|
Nenue@70
|
371 cprint('|cFFFF4400Unslotted command entry', command)
|
Nenue@70
|
372 profile.commands[command] = nil
|
Nenue@70
|
373 end
|
Nenue@70
|
374 end
|
Nenue@76
|
375
|
Nenue@76
|
376 if profile.talents then
|
Nenue@76
|
377 profile.talents = nil
|
Nenue@76
|
378 end
|
Nenue@76
|
379
|
Nenue@76
|
380
|
Nenue@76
|
381 profile.versionID = PROFILE_VERSION
|
Nenue@71
|
382 end
|
Nenue@70
|
383
|
Nenue@71
|
384 kb.ApplyBindings = function (profile)
|
Nenue@71
|
385 cprint('|cFF0088FFApplyBindings()')
|
Nenue@71
|
386 --cprint('binding profile', profile)
|
Nenue@71
|
387
|
Nenue@71
|
388 local version = profile.versionID or 0
|
Nenue@76
|
389 if version < PROFILE_VERSION then
|
Nenue@71
|
390 kb.UpgradeProfile(profile)
|
Nenue@71
|
391 end
|
Nenue@71
|
392
|
Nenue@71
|
393
|
Nenue@71
|
394 -- then buttons
|
Nenue@71
|
395 for slot, configTable in pairs(profile.buttons) do
|
Nenue@71
|
396 -- convert old style table
|
Nenue@71
|
397 if kb.LoadBinding(configTable) then
|
Nenue@76
|
398
|
Nenue@71
|
399 if not configTable.assignedKeys then
|
Nenue@75
|
400 configTable.assignedKeys = {GetBindingKey(configTable.command)}
|
Nenue@71
|
401 end
|
Nenue@75
|
402 --if configTable.dynamicType == 'talent' then
|
Nenue@75
|
403 -- kb:print(table.concat(configTable.assignedKeys, ', ') .. ' bound to '.. configTable.actionName)
|
Nenue@75
|
404 --end
|
Nenue@74
|
405 for _, key in pairs(configTable.assignedKeys) do
|
Nenue@76
|
406 local command = configTable.command
|
Nenue@76
|
407 cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command)
|
Nenue@76
|
408 SetBinding(key, command)
|
Nenue@76
|
409 if commandActions[command] and not tContains(commandActions[command], key) then
|
Nenue@76
|
410 tinsert(commandActions[command], key)
|
Nenue@76
|
411 end
|
Nenue@74
|
412 end
|
Nenue@74
|
413
|
Nenue@71
|
414 end
|
Nenue@71
|
415 end
|
Nenue@70
|
416 end
|
Nenue@70
|
417
|
Nenue@70
|
418 kb.ApplyAllBindings =function ()
|
Nenue@74
|
419 print('|cFFFFFF00ApplyAllBindings()')
|
Nenue@70
|
420 wipe(kb.bindings)
|
Nenue@70
|
421 --kb:print('Loading binding profile', kb.profileName)
|
Nenue@70
|
422
|
Nenue@70
|
423 -- reflect action key settings
|
Nenue@70
|
424 if GetCVarBool("ActionButtonUseKeyDown") then
|
Nenue@70
|
425 SkeletonKeyMacro:RegisterForClicks("AnyDown")
|
Nenue@70
|
426 SkeletonKeyKey:RegisterForClicks("AnyDown")
|
Nenue@70
|
427 else
|
Nenue@70
|
428 SkeletonKeyMacro:RegisterForClicks("AnyUp")
|
Nenue@70
|
429 SkeletonKeyKey:RegisterForClicks("AnyUp")
|
Nenue@70
|
430 end
|
Nenue@70
|
431
|
Nenue@70
|
432 for i, profile in ipairs(kb.orderedProfiles) do
|
Nenue@70
|
433 kb.ApplyBindings(profile)
|
Nenue@70
|
434 end
|
Nenue@70
|
435 -- do this after to ensure that profession binds are properly overridden
|
Nenue@70
|
436 kb.UpdateProfessionInfo()
|
Nenue@70
|
437
|
Nenue@70
|
438 SaveBindings(GetCurrentBindingSet())
|
Nenue@72
|
439
|
Nenue@75
|
440
|
Nenue@70
|
441 end
|
Nenue@70
|
442 end
|
Nenue@70
|
443
|
Nenue@70
|
444
|
Nenue@78
|
445 local AddSpellInfo = function(id, name, icon, dynamicType, dynamicID, dynamicIndex, dynamicSubIndex, isAvailable)
|
Nenue@78
|
446 local spell = kb.DynamicSpells[id] or {}
|
Nenue@78
|
447 spell.actionName = name
|
Nenue@78
|
448 spell.dynamicType = dynamicType
|
Nenue@78
|
449 spell.dynamicID = dynamicID
|
Nenue@78
|
450 spell.iconPath = icon
|
Nenue@78
|
451 spell.dynamicIndex = dynamicIndex
|
Nenue@78
|
452 spell.dynamicSubIndex = dynamicSubIndex
|
Nenue@78
|
453 spell.isAvailable = isAvailable
|
Nenue@78
|
454 spell.actionType = 'spell'
|
Nenue@78
|
455 spell.spellbookType = BOOKTYPE_SPELL
|
Nenue@78
|
456 kb.DynamicSpells[name] = spell
|
Nenue@78
|
457
|
Nenue@78
|
458 local spellList = dynamicType and kb.DynamicSpells[dynamicType]
|
Nenue@78
|
459 if spellList then
|
Nenue@78
|
460 spellList[dynamicIndex] = spellList[dynamicIndex] or {}
|
Nenue@78
|
461 spellList[dynamicIndex][dynamicSubIndex] = spell
|
Nenue@78
|
462 end
|
Nenue@78
|
463
|
Nenue@78
|
464 cprint('|cFF00FFFFSpellInfo:|r', name, isAvailable, dynamicType or 'spell')
|
Nenue@78
|
465 end
|
Nenue@78
|
466
|
Nenue@70
|
467 kb.UpdateSpecInfo = function()
|
Nenue@70
|
468 kb.specInfo.id = GetSpecialization()
|
Nenue@70
|
469 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id)
|
Nenue@70
|
470 end
|
Nenue@70
|
471
|
Nenue@70
|
472 kb.UpdateMacroInfo = function()
|
Nenue@70
|
473 print('|cFFFFFF00kb.UpdateMacroInfo()|r')
|
Nenue@70
|
474 for index = 1, GetNumMacros() do
|
Nenue@70
|
475 local name = GetMacroInfo(index)
|
Nenue@70
|
476 kb.SecureAttribute(SkeletonKeyMacro, "*type-macro_"..tostring(name), 'macro')
|
Nenue@70
|
477 kb.SecureAttribute(SkeletonKeyMacro, "*macro-macro_"..tostring(name), index)
|
Nenue@70
|
478 end
|
Nenue@70
|
479 end
|
Nenue@70
|
480
|
Nenue@78
|
481
|
Nenue@70
|
482 kb.UpdateTalentInfo = function()
|
Nenue@78
|
483 print('|cFFFFFF00kb.UpdateSpells()|r')
|
Nenue@78
|
484 cprint('|cFFFFFF00kb.UpdateSpells()|r')
|
Nenue@70
|
485 if kb.talentsPushed then
|
Nenue@70
|
486 return
|
Nenue@70
|
487 end
|
Nenue@70
|
488 for row =1, MAX_TALENT_TIERS do
|
Nenue@70
|
489 for col = 1, NUM_TALENT_COLUMNS do
|
Nenue@70
|
490 local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1)
|
Nenue@78
|
491 local talentInfo = kb.DynamicSpells[spellID] or {}
|
Nenue@70
|
492 if spellID then
|
Nenue@78
|
493 AddSpellInfo(spellID, talentName, icon, 'talent', talentID, row, col, selected)
|
Nenue@70
|
494 end
|
Nenue@70
|
495
|
Nenue@70
|
496 end
|
Nenue@70
|
497 end
|
Nenue@70
|
498
|
Nenue@86
|
499 --[[
|
Nenue@70
|
500 for row = 1, MAX_PVP_TALENT_TIERS do
|
Nenue@70
|
501 for col = 1, MAX_PVP_TALENT_COLUMNS do
|
Nenue@78
|
502 local talentID, talentName, icon, selected, available, spellID, unlocked = GetPvpTalentInfo(row, col, 1)
|
Nenue@70
|
503 if spellID then
|
Nenue@78
|
504 AddSpellInfo(spellID, talentName, icon, 'talent', talentID, row, col, selected)
|
Nenue@70
|
505 end
|
Nenue@70
|
506 end
|
Nenue@70
|
507 end
|
Nenue@86
|
508 --]]
|
Nenue@70
|
509
|
Nenue@78
|
510 local numTabs = GetNumSpellTabs()
|
Nenue@78
|
511 for i = 1, numTabs do
|
Nenue@78
|
512 local name, texture, offset, numSpells = GetSpellTabInfo(i)
|
Nenue@78
|
513 for spellLine = offset+1, offset+numSpells do
|
Nenue@78
|
514 local skillType, spellID = GetSpellBookItemInfo(spellLine)
|
Nenue@78
|
515 if skillType == 'SPELL' then
|
Nenue@78
|
516 local name, _, icon = GetSpellInfo(spellID)
|
Nenue@78
|
517 AddSpellInfo(spellID, name, icon, nil, nil, nil, nil, true)
|
Nenue@78
|
518 elseif skillType == 'FLYOUT' then
|
Nenue@78
|
519 local flyoutID = GetFlyoutID(spellLine)
|
Nenue@78
|
520 local _, _, numSlots = GetFlyoutInfo(flyoutID)
|
Nenue@78
|
521 if numSlots then
|
Nenue@78
|
522 for slot = 1, numSlots do
|
Nenue@78
|
523 local spellID, isKnown = GetFlyoutSlotInfo(flyoutID, slot)
|
Nenue@78
|
524 local name, rank, icon = GetSpellInfo(spellID)
|
Nenue@78
|
525 AddSpellInfo(spellID, name, icon, nil, nil, nil, nil, true)
|
Nenue@78
|
526 end
|
Nenue@78
|
527 end
|
Nenue@78
|
528 end
|
Nenue@78
|
529 end
|
Nenue@78
|
530 end
|
Nenue@78
|
531
|
Nenue@78
|
532
|
Nenue@78
|
533
|
Nenue@70
|
534 kb.talentsPushed = true
|
Nenue@70
|
535 kb.UpdateDynamicButtons('talent')
|
Nenue@70
|
536 end
|
Nenue@78
|
537 kb.UpdateSpells = kb.UpdateTalentInfo
|
Nenue@70
|
538
|
Nenue@70
|
539 kb.UpdateProfessionInfo = function()
|
Nenue@70
|
540 wipe(kb.ProfessionCache)
|
Nenue@70
|
541 local profs = {GetProfessions() }
|
Nenue@70
|
542 --print(GetProfessions())
|
Nenue@70
|
543 local primaryNum = 0
|
Nenue@70
|
544 for i = 1, 6 do
|
Nenue@70
|
545 if profs[i] then
|
Nenue@70
|
546 local profID = profs[i]
|
Nenue@70
|
547 local profName, texture, _, _, numSpells, spellOffset = GetProfessionInfo(profID)
|
Nenue@70
|
548 cprint(i, profID, profName, numSpells, spellOffset)
|
Nenue@70
|
549 if not SECONDARY_PROFESSIONS[profID] then
|
Nenue@70
|
550 primaryNum = primaryNum + 1
|
Nenue@70
|
551 end
|
Nenue@70
|
552 local profNum = SECONDARY_PROFESSIONS[profID] or primaryNum
|
Nenue@70
|
553 cprint(i, profNum)
|
Nenue@70
|
554
|
Nenue@70
|
555
|
Nenue@70
|
556 for j = 1, numSpells do
|
Nenue@70
|
557 local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION)
|
Nenue@70
|
558 cprint(j, spellName)
|
Nenue@70
|
559 local profInfo = {
|
Nenue@70
|
560 actionType = 'spell',
|
Nenue@70
|
561 actionName = spellName,
|
Nenue@70
|
562 actionID = spellID,
|
Nenue@70
|
563 iconPath = icon,
|
Nenue@70
|
564 dynamicIndex = i,
|
Nenue@70
|
565 dynamicSubIndex = j,
|
Nenue@70
|
566 dynamicType = 'profession',
|
Nenue@70
|
567 spellbookOffset = (spellOffset+j),
|
Nenue@70
|
568 spellbookType = BOOKTYPE_PROFESSION,
|
Nenue@70
|
569 isAvailable = true,
|
Nenue@78
|
570 dynamicID = profID,
|
Nenue@70
|
571 }
|
Nenue@70
|
572
|
Nenue@70
|
573 kb.SecureAttribute(SkeletonKeyKey, "*type-profession_"..i .. '_' ..j, "spell")
|
Nenue@70
|
574 kb.SecureAttribute(SkeletonKeyKey, "*spell-profession_"..i .. '_' ..j, spellName)
|
Nenue@70
|
575
|
Nenue@70
|
576
|
Nenue@70
|
577 kb.DynamicSpells[spellName] = profInfo
|
Nenue@70
|
578 kb.DynamicSpells[spellID] = profInfo
|
Nenue@70
|
579
|
Nenue@78
|
580 kb.DynamicSpells.profession[spellName] = profInfo
|
Nenue@78
|
581 kb.DynamicSpells.profession[spellID] = profInfo
|
Nenue@70
|
582 kb.DynamicSpells.profession[i] = kb.DynamicSpells.profession[i] or {}
|
Nenue@70
|
583 kb.DynamicSpells.profession[i][j] = profInfo
|
Nenue@83
|
584 cprint(' |cFF0088FF['..i..']|r|cFFFF44BB['..j..']|r', spellName, "profession_"..i .. '_' ..j)
|
Nenue@70
|
585 end
|
Nenue@70
|
586 end
|
Nenue@70
|
587
|
Nenue@70
|
588 end
|
Nenue@70
|
589
|
Nenue@70
|
590 kb.UpdateDynamicButtons('profession')
|
Nenue@70
|
591 end
|
Nenue@70
|
592
|
Nenue@70
|
593
|
Nenue@70
|
594
|
Nenue@70
|
595 kb.UpdatePetInfo = function()
|
Nenue@93
|
596 print('|cFFFFFF00kb.UpdatePetInfo()')
|
Nenue@70
|
597 local hasPetSpells, petType = HasPetSpells()
|
Nenue@70
|
598
|
Nenue@70
|
599 -- reconcile saved data if it becomes available
|
Nenue@70
|
600 if kb.db then
|
Nenue@70
|
601 kb.db.petSpellsDB = kb.db.petSpellsDB or {}
|
Nenue@70
|
602 kb.db.petSpellsDB.subtext = kb.db.petSpellsDB.subtext or {}
|
Nenue@70
|
603 kb.db.petSpellsDB.spell = kb.db.petSpellsDB.spell or {}
|
Nenue@70
|
604 local spellCache = kb.db.petSpellsDB.spell
|
Nenue@70
|
605 local subtextCache = kb.db.petSpellsDB.subtext
|
Nenue@70
|
606 if petSpellCache then
|
Nenue@70
|
607 for k,v in pairs(petSpellCache) do
|
Nenue@70
|
608 if not spellCache[k] then
|
Nenue@70
|
609 spellCache[k] = v
|
Nenue@70
|
610 end
|
Nenue@70
|
611 end
|
Nenue@70
|
612 end
|
Nenue@70
|
613 petSpellCache = spellCache
|
Nenue@70
|
614 if petSubtextCache then
|
Nenue@70
|
615 for k,v in pairs(petSubtextCache) do
|
Nenue@70
|
616 if not subtextCache[k] then
|
Nenue@70
|
617 subtextCache[k] = v
|
Nenue@70
|
618 end
|
Nenue@70
|
619 end
|
Nenue@70
|
620 end
|
Nenue@70
|
621 petSubtextCache = subtextCache
|
Nenue@70
|
622 else
|
Nenue@70
|
623 petSpellCache = {}
|
Nenue@70
|
624 petSubtextCache = {}
|
Nenue@70
|
625 end
|
Nenue@70
|
626
|
Nenue@70
|
627 if PetHasSpellbook() then
|
Nenue@93
|
628 print('PET SPELLBOOK')
|
Nenue@70
|
629 local spellbookOffset = 1
|
Nenue@70
|
630 local specialNum = {}
|
Nenue@70
|
631 local newSubtextItems = false
|
Nenue@70
|
632
|
Nenue@70
|
633 repeat
|
Nenue@70
|
634
|
Nenue@70
|
635 local spellType, spellID = GetSpellBookItemInfo(spellbookOffset, BOOKTYPE_PET)
|
Nenue@70
|
636 local spellName, subText = GetSpellBookItemName(spellbookOffset, BOOKTYPE_PET)
|
Nenue@70
|
637 local texture = GetSpellBookItemTexture(spellbookOffset, BOOKTYPE_PET)
|
Nenue@93
|
638
|
Nenue@93
|
639
|
Nenue@93
|
640 if (spellType == 'PETACTION') and (not IsPassiveSpell(spellbookOffset, BOOKTYPE_PET)) then
|
Nenue@93
|
641
|
Nenue@93
|
642 print('|cFF00FF00#'..spellbookOffset..'|r', spellType, spellID, spellName, subText, texture)
|
Nenue@70
|
643 local info = kb.PetCache[spellName] or {}
|
Nenue@70
|
644 kb.PetCache.spellslot[spellName] = {spellbookOffset, spellName, subText, spellID, texture}
|
Nenue@93
|
645 print('|cFF00FF88spellslot['..spellName..']|r', '=>', spellName, spellID)
|
Nenue@70
|
646
|
Nenue@70
|
647 if subText then
|
Nenue@70
|
648 kb.PetCache.subtext[subText] = kb.PetCache.subtext[subText] or {}
|
Nenue@70
|
649 specialNum[subText] = (specialNum[subText] or 0) + 1
|
Nenue@70
|
650
|
Nenue@70
|
651 petSpellCache[spellName] = subText
|
Nenue@70
|
652
|
Nenue@93
|
653 --local entry = {spellbookOffset, spellName, subText, spellID, texture, specialNum[subText] }
|
Nenue@70
|
654
|
Nenue@70
|
655
|
Nenue@70
|
656 info.spellbookOffset = spellbookOffset
|
Nenue@70
|
657 info.spellbookType = BOOKTYPE_PET
|
Nenue@70
|
658 info.actionName = spellName
|
Nenue@70
|
659 info.spellID = spellID
|
Nenue@70
|
660 info.dynamicType = 'petaction'
|
Nenue@70
|
661 info.dynamicID = spellID
|
Nenue@70
|
662 info.dynamicIndex = subText
|
Nenue@70
|
663 info.dynamicSubIndex = specialNum[subText]
|
Nenue@70
|
664 info.isAvailable = true
|
Nenue@70
|
665
|
Nenue@70
|
666 kb.PetCache.special[spellName] = info
|
Nenue@70
|
667 kb.PetCache.subtext[subText][specialNum[subText]] = info
|
Nenue@78
|
668
|
Nenue@70
|
669 kb.DynamicSpells[spellName] = info
|
Nenue@70
|
670 kb.DynamicSpells[spellID] = info
|
Nenue@70
|
671
|
Nenue@70
|
672 end
|
Nenue@70
|
673
|
Nenue@70
|
674 if spellID then
|
Nenue@70
|
675 kb.PetCache.spell[spellbookOffset] = {spellID, spellName, subText}
|
Nenue@70
|
676 --print('|cFF0088FFspell['..i..']|r', '=>', spellID, spellName, subText)
|
Nenue@70
|
677 end
|
Nenue@70
|
678
|
Nenue@70
|
679 kb.PetCache[spellName] = info
|
Nenue@70
|
680 end
|
Nenue@70
|
681
|
Nenue@70
|
682 spellbookOffset = spellbookOffset + 1
|
Nenue@70
|
683 until spellType == nil
|
Nenue@70
|
684
|
Nenue@70
|
685
|
Nenue@70
|
686 else
|
Nenue@70
|
687 --print('NO PET SPELLBOOK')
|
Nenue@70
|
688 wipe(kb.PetCache.spell)
|
Nenue@70
|
689 wipe(kb.PetCache.spellslot)
|
Nenue@70
|
690 end
|
Nenue@70
|
691
|
Nenue@70
|
692 if PetHasActionBar() then
|
Nenue@93
|
693 print('PET ACTION BAR')
|
Nenue@70
|
694 for i = 1, 10 do
|
Nenue@93
|
695 local name, texture, _, _, _, _, spellId = GetPetActionInfo(i)
|
Nenue@93
|
696 if name then
|
Nenue@70
|
697
|
Nenue@70
|
698
|
Nenue@93
|
699 print(i, name, texture, spellId)
|
Nenue@93
|
700
|
Nenue@93
|
701 kb.PetCache.action[i] = {name, texture, spellId}
|
Nenue@70
|
702
|
Nenue@70
|
703
|
Nenue@70
|
704 end
|
Nenue@70
|
705 --print('|cFFFFFF00action['..i..']|r', name, subtext, texture)
|
Nenue@70
|
706 end
|
Nenue@70
|
707 else
|
Nenue@70
|
708 --print('NO PET ACTION BAR')
|
Nenue@70
|
709 wipe(kb.PetCache.action)
|
Nenue@70
|
710 end
|
Nenue@70
|
711
|
Nenue@70
|
712 kb.UpdateDynamicButtons('petaction')
|
Nenue@70
|
713
|
Nenue@70
|
714 end
|
Nenue@70
|
715
|
Nenue@70
|
716 kb.UpdateSystemBinds = function()
|
Nenue@70
|
717 wipe(kb.SystemBindings)
|
Nenue@70
|
718 local n = GetNumBindings()
|
Nenue@70
|
719 for i=1, n do
|
Nenue@70
|
720 local command, key1, key2 = GetBinding(i)
|
Nenue@70
|
721 if not command:match('ACTION.*%d+') then
|
Nenue@70
|
722 if key1 then
|
Nenue@70
|
723 kb.SystemBindings[key1] = command
|
Nenue@70
|
724 end
|
Nenue@70
|
725 if key2 then
|
Nenue@70
|
726 kb.SystemBindings[key2] = command
|
Nenue@70
|
727 end
|
Nenue@70
|
728 else
|
Nenue@70
|
729 --print('ignoring action button binding', command)
|
Nenue@70
|
730 end
|
Nenue@70
|
731 end
|
Nenue@70
|
732 end
|
Nenue@70
|
733
|
Nenue@70
|
734 kb.UpdateDynamicButtons = function(dynamicType)
|
Nenue@70
|
735 for i, button in ipairs(kb.buttons) do
|
Nenue@70
|
736 if button.isDynamic == dynamicType then
|
Nenue@70
|
737 kb.UpdateSlot(button, true)
|
Nenue@70
|
738 end
|
Nenue@70
|
739 end
|
Nenue@70
|
740 end
|
Nenue@70
|
741
|
Nenue@70
|
742 kb.pendingAttributes = {}
|
Nenue@70
|
743 kb.SecureAttribute = function(target, name, value)
|
Nenue@70
|
744 if InCombatLockdown() then
|
Nenue@70
|
745 if #kb.pendingAttributes == 0 then
|
Nenue@70
|
746 kb:print(kb.L('Key bindings will be applied when you exit combat.'))
|
Nenue@70
|
747 end
|
Nenue@70
|
748 tinsert(kb.pendingAttributes, {target, name, value})
|
Nenue@70
|
749 SkeletonKey:RegisterEvent('PLAYER_REGEN_ENABLED')
|
Nenue@70
|
750 else
|
Nenue@70
|
751 --cprint('|cFFFF4444' .. target:GetName()..'|r.|cFFFFFF00'.. tostring(name)..'|r = "'..tostring(value)..'"')
|
Nenue@70
|
752 target:SetAttribute(name, value)
|
Nenue@70
|
753 end
|
Nenue@70
|
754 end
|
Nenue@70
|
755
|
Nenue@70
|
756 kb.PLAYER_REGEN_ENABLED = function()
|
Nenue@70
|
757 if #kb.pendingAttributes >= 1 then
|
Nenue@70
|
758 local args = tremove(kb.pendingAttributes)
|
Nenue@70
|
759 while args do
|
Nenue@70
|
760 local target, name, value = unpack(args)
|
Nenue@70
|
761 --print(target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"')
|
Nenue@70
|
762 cprint('deferred', target:GetName(), 'attribute', '"'.. tostring(name)..'" = "'..tostring(value)..'"')
|
Nenue@70
|
763 target:SetAttribute(name, value)
|
Nenue@70
|
764 args = tremove(kb.pendingAttributes)
|
Nenue@70
|
765 end
|
Nenue@70
|
766 end
|
Nenue@70
|
767
|
Nenue@70
|
768 if #kb.pendingCalls >= 1 then
|
Nenue@70
|
769
|
Nenue@70
|
770 local func = tremove(kb.pendingCalls)
|
Nenue@70
|
771 while func do
|
Nenue@70
|
772 func()
|
Nenue@70
|
773 end
|
Nenue@70
|
774 end
|
Nenue@70
|
775 end
|
Nenue@70
|
776
|
Nenue@70
|
777 kb.UpdateBindingsCache = function(actionType, actionID, bindings)
|
Nenue@70
|
778 local indexKey = actionType .. '_' .. actionID
|
Nenue@70
|
779 kb.bindings[indexKey] = bindings
|
Nenue@70
|
780
|
Nenue@70
|
781 cprint('|cFF00FF00'..indexKey..'|r = {'.. table.concat(bindings,', ').. '}')
|
Nenue@70
|
782 tinsert(kb.ChangedBindings, {actionType, actionID})
|
Nenue@70
|
783 end |