comparison ActionTemplates.lua @ 83:1605319122ce

- Added a list of special-cases for replaced abilities that can't be detected internally (Carve, Blink, etc.)
author Nenue
date Sun, 28 May 2017 12:45:32 -0400
parents 9a206b105ea5
children b80e78f4a17b
comparison
equal deleted inserted replaced
82:cc082ee22c4c 83:1605319122ce
104 end 104 end
105 105
106 106
107 --- Resolves the SecureActionButton attribute names used for the given action 107 --- Resolves the SecureActionButton attribute names used for the given action
108 kb.RegisterAction = function(actionType, id, name) 108 kb.RegisterAction = function(actionType, id, name)
109 assert(atype[actionType], 'Missing actionType handler for `'..tostring(actionType)..'`') 109 if not atype[actionType]then
110 kb.print('Missing actionType handler for `'..tostring(actionType)..'`')
111 return
112 end
110 local prefix, attributeName, attributeValue, button = atype[actionType](id, name) 113 local prefix, attributeName, attributeValue, button = atype[actionType](id, name)
111 local command = prefix .. attributeName 114 local command = prefix .. attributeName
112 return attributeName, attributeValue, command, prefix, button 115 return attributeName, attributeValue, command, prefix, button
113 end 116 end
114 117
192 kb.LoadBinding = function( configTable) 195 kb.LoadBinding = function( configTable)
193 if configTable.command then 196 if configTable.command then
194 configTable.command = configTable.command:gsub('KeyBinder', 'SkeletonKey') 197 configTable.command = configTable.command:gsub('KeyBinder', 'SkeletonKey')
195 end 198 end
196 199
200 cprint('|cFF0088FFLoadBinding()|r', configTable.actionName, configTable.dynamicType)
201 local isAvailable
202 local dynamicType = configTable.dynamicType
203 if dynamicType == 'profession' then
204 local dynamicIndex, dynamicSubIndex = tonumber(configTable.dynamicIndex), tonumber(configTable.dynamicSubIndex)
205 cprint(' |cFF00FFFFDynamicInfo:|r', dynamicType, dynamicIndex, dynamicSubIndex)
206
207 local extendedTable = kb.DynamicSpells[dynamicType][dynamicIndex]
208
209 if extendedTable then
210 cprint(extendedTable)
211 for k,v in pairs(extendedTable) do
212 cprint(type(k), k)
213 end
214 local subTable = extendedTable[dynamicSubIndex]
215
216 if subTable then
217 for k,v in pairs(subTable) do
218 cprint(' override', k, '=', v, '(was', configTable[k])
219 configTable[k] = subTable[k]
220 end
221 --isAvailable = configTable.isAvailabl
222 --name, actionID = configTable.actionName, configTable.actionID
223 cprint(subTable.actionName, subTable.actionID)
224 isAvailable = true
225 end
226 end
227 end
228
197 local command, name, icon, actionType, actionID, macroName, macroText = 229 local command, name, icon, actionType, actionID, macroName, macroText =
198 configTable.command, configTable.actionName, configTable.iconPath, configTable.actionType, 230 configTable.command, configTable.actionName, configTable.iconPath, configTable.actionType,
199 configTable.actionID, configTable.macroName, configTable.macroText 231 configTable.actionID, configTable.macroName, configTable.macroText
200 232
201 233 local indexKey = tostring(actionType)..'_'..tostring(actionID)
202 local indexKey = actionType..'_'..actionID 234 local actionPrefix = "*"..tostring(actionType).."-"
203 local actionPrefix = "*"..actionType.."-"
204 local button = SkeletonKeyKey 235 local button = SkeletonKeyKey
205 local isAvailable
206 local specialButtonType 236 local specialButtonType
207 if actionType == 'spell' then 237 if actionType == 'spell' then
208 local realName, _, _, _, _, _, realID = GetSpellInfo(name) 238 local realName, _, _, _, _, _, realID = GetSpellInfo(name)
239
209 if realName then 240 if realName then
210 if (realName ~= name) then 241 if (realName ~= name) then
211 print(' *** "', name, '" is replaced by...', realName, realID) 242 cprint(' *** "', name, '" is replaced by...', realName, realID)
212 --name, actionID = realName, realID 243 --name, actionID = realName, realID
213 indexKey = actionType .. '_'.. realID 244 indexKey = actionType .. '_'.. realID
214 end 245 end
215 elseif configTable.dynamicType == 'talent' then 246 elseif dynamicType == 'talent' then
216 print(' *** "', name, '" is a non-selected talent.') 247 cprint(' |cFF00FFFFDynamicInfo:|r', dynamicType, table.concat(configTable.assignedKeys, ','))
248 cprint(' *** "', name, '" is a non-selected talent.')
217 return 249 return
218 end 250 end
219 251
220 252 if GetSpellInfo(realName or name) then
221 253
222 local dynamicInfo = kb.DynamicSpells[name]
223 if dynamicInfo then
224 configTable.assignedKeys = configTable.assignedKeys or {GetBindingKey(configTable.command) }
225
226 cprint('|cFF00FFFFDynamicInfo:|r', dynamicInfo.dynamicType, table.concat(configTable.assignedKeys, ','))
227 for k, v in pairs(dynamicInfo) do
228 --cprint(' --', k, v)
229 configTable[k] = v
230 end
231 isAvailable = configTable.isAvailable
232 elseif GetSpellInfo(actionID) then
233 isAvailable = true 254 isAvailable = true
234 255
235 end 256 end
236 elseif actionType == 'item' then 257 elseif actionType == 'item' then
237 actionID = configTable.actionName 258 actionID = configTable.actionName
245 specialButtonType = 'macro' 266 specialButtonType = 'macro'
246 isAvailable = true 267 isAvailable = true
247 end 268 end
248 269
249 if isAvailable then 270 if isAvailable then
271 cprint(' available', actionType, actionID, name)
250 272
251 local attributeSuffix, attributeValue, command, target, button = kb.RegisterAction(actionType, actionID, name) 273 local attributeSuffix, attributeValue, command, target, button = kb.RegisterAction(actionType, actionID, name)
252 local actionKey = actionPrefix .. attributeSuffix 274 local actionKey = tostring(actionPrefix) .. tostring(attributeSuffix)
253 cprint('|cFF00FF88LoadBinding()|r', button:GetName(), "*type-"..attributeSuffix, actionType, '|cFFFFFF00'..actionKey, attributeValue, isAvailable) 275
276 if not attributeSuffix then
277 cprint('failed to generate button attribute')
278 return
279 end
280
281
282 cprint('|cFF00FF88 result:|r', button and button:GetName(), "*type-"..tostring(attributeSuffix), actionType, '|cFFFFFF00'..actionKey, attributeValue, isAvailable)
254 283
255 284
256 kb.SecureAttribute(button, "*type-"..attributeSuffix, specialButtonType or actionType) 285 kb.SecureAttribute(button, "*type-"..attributeSuffix, specialButtonType or actionType)
257 kb.SecureAttribute(button, actionKey, attributeValue) 286 kb.SecureAttribute(button, actionKey, attributeValue)
258 287
259 cprint('|cFFFF4400add', name, isAvailable, indexKey, unpack(configTable.assignedKeys)) 288 cprint(' |cFFFF4400add', name, isAvailable, indexKey, unpack(configTable.assignedKeys))
260 kb.bindings[indexKey] = configTable.assignedKeys 289 kb.bindings[indexKey] = configTable.assignedKeys
261 commandActions[command] = kb.bindings[indexKey] 290 commandActions[command] = kb.bindings[indexKey]
262 return command, kb.bindings[indexKey] 291 return command, kb.bindings[indexKey]
263 else 292 else
264 if kb.bindings[indexKey] then 293 if kb.bindings[indexKey] then
265 cprint('|cFFFF4400remove', name, isAvailable, indexKey, unpack(configTable.assignedKeys)) 294 cprint(' |cFFFF4400remove', name, isAvailable, indexKey, unpack(configTable.assignedKeys))
266 kb.bindings[indexKey] = nil 295 kb.bindings[indexKey] = nil
267 end 296 end
268 297
269 return nil 298 return nil
270 end 299 end
553 582
554 kb.DynamicSpells.profession[spellName] = profInfo 583 kb.DynamicSpells.profession[spellName] = profInfo
555 kb.DynamicSpells.profession[spellID] = profInfo 584 kb.DynamicSpells.profession[spellID] = profInfo
556 kb.DynamicSpells.profession[i] = kb.DynamicSpells.profession[i] or {} 585 kb.DynamicSpells.profession[i] = kb.DynamicSpells.profession[i] or {}
557 kb.DynamicSpells.profession[i][j] = profInfo 586 kb.DynamicSpells.profession[i][j] = profInfo
558 --print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) 587 cprint(' |cFF0088FF['..i..']|r|cFFFF44BB['..j..']|r', spellName, "profession_"..i .. '_' ..j)
559 end 588 end
560 end 589 end
561 590
562 end 591 end
563 592