Mercurial > wow > skeletonkey
comparison SkeletonKey/KeyBinds.lua @ 13:eeec4a600064
- kb.bindings carries the exact values needed for matching GetActionInfo() outputs
| author | Nenue |
|---|---|
| date | Thu, 28 Jul 2016 18:20:32 -0400 |
| parents | e7977b336bf7 |
| children |
comparison
equal
deleted
inserted
replaced
| 12:8f8917d111c9 | 13:eeec4a600064 |
|---|---|
| 201 actionID = subData | 201 actionID = subData |
| 202 name, _, icon = GetSpellInfo(actionID) | 202 name, _, icon = GetSpellInfo(actionID) |
| 203 | 203 |
| 204 elseif actionType == 'macro' then | 204 elseif actionType == 'macro' then |
| 205 name, icon = GetMacroInfo(actionID) | 205 name, icon = GetMacroInfo(actionID) |
| 206 actionID = name | |
| 207 elseif actionType == 'petaction' then | 206 elseif actionType == 'petaction' then |
| 208 if not (CURSOR_SPELLSLOT and CURSOR_BOOKTYPE) then | 207 if not (CURSOR_SPELLSLOT and CURSOR_BOOKTYPE) then |
| 209 | 208 |
| 210 ClearCursor() | 209 ClearCursor() |
| 211 ResetCursor() | 210 ResetCursor() |
| 213 | 212 |
| 214 local bookType, spellID = GetSpellBookItemInfo(CURSOR_SPELLSLOT, CURSOR_BOOKTYPE) | 213 local bookType, spellID = GetSpellBookItemInfo(CURSOR_SPELLSLOT, CURSOR_BOOKTYPE) |
| 215 pickupID = CURSOR_SPELLSLOT | 214 pickupID = CURSOR_SPELLSLOT |
| 216 pickupBook = CURSOR_BOOKTYPE | 215 pickupBook = CURSOR_BOOKTYPE |
| 217 name, _, icon = GetSpellInfo(spellID) | 216 name, _, icon = GetSpellInfo(spellID) |
| 218 actionID = name | |
| 219 | |
| 220 elseif actionType == 'mount' then | 217 elseif actionType == 'mount' then |
| 221 if subType == 0 then | 218 if subType == 0 then |
| 222 name, _, icon = GetSpellInfo(SUMMON_RANDOM_FAVORITE_MOUNT_SPELL) | 219 name, _, icon = GetSpellInfo(SUMMON_RANDOM_FAVORITE_MOUNT_SPELL) |
| 223 actionID = 0 | 220 actionID = 0 |
| 224 else | 221 else |
| 233 local speciesID, customName, level, xp, maxXp, displayID, isFavorite, petName, petIcon, petType, creatureID = C_PetJournal.GetPetInfoByPetID(detail); | 230 local speciesID, customName, level, xp, maxXp, displayID, isFavorite, petName, petIcon, petType, creatureID = C_PetJournal.GetPetInfoByPetID(detail); |
| 234 name = customName or petName | 231 name = customName or petName |
| 235 icon = petIcon | 232 icon = petIcon |
| 236 | 233 |
| 237 end | 234 end |
| 238 macroName, macroText, command = kb.RegisterAction(actionType, actionID) | 235 macroName, macroText, command = kb.RegisterAction(actionType, actionID, name) |
| 239 | 236 |
| 240 | 237 |
| 241 local isAssigned, isBound, assignedBy, boundBy = kb.IsCommandBound(self, command) | 238 local isAssigned, isBound, assignedBy, boundBy = kb.IsCommandBound(self, command) |
| 242 if isAssigned then | 239 if isAssigned then |
| 243 local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] | 240 local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] |
| 282 end | 279 end |
| 283 end | 280 end |
| 284 | 281 |
| 285 | 282 |
| 286 --- Resolve the appropriate command and macroText for the given action parameters | 283 --- Resolve the appropriate command and macroText for the given action parameters |
| 287 kb.RegisterAction = function(type, id) | 284 kb.RegisterAction = function(type, id, name) |
| 288 local macroText, macroName, command = '', '', '' | 285 local macroText, macroName, command = '', '', '' |
| 289 | 286 |
| 290 if type == 'spell' then | 287 if type == 'spell' then |
| 291 if kb.ProfessionCache[id] then | 288 if kb.ProfessionCache[id] then |
| 292 command = CLICK_KEYBINDER_KEY .. "profession_".. kb.ProfessionCache[id].profOffset .. '_' .. kb.ProfessionCache[id].spellNum | 289 command = CLICK_KEYBINDER_KEY .. "profession_".. kb.ProfessionCache[id].profOffset .. '_' .. kb.ProfessionCache[id].spellNum |
| 293 else | 290 else |
| 294 command = CLICK_KEYBINDER_KEY ..id | 291 command = CLICK_KEYBINDER_KEY ..name |
| 295 end | 292 end |
| 296 else | 293 else |
| 297 macroName = type .. ' ' .. id | 294 macroName = type .. ' ' .. name |
| 298 macroText = ACTION_SCRIPT[type]:format(id) | 295 macroText = ACTION_SCRIPT[type]:format(name) |
| 299 local baseName, iterative = macroName, 1 | 296 local baseName, iterative = macroName, 1 |
| 300 while (macros[macroName] and macros[macroName][1] ~= macroText) do | 297 while (macros[macroName] and macros[macroName][1] ~= macroText) do |
| 301 print(' * cannot use|cFF00FF00', macroName, '|r"'.. (macros[macroName][1] or '') .. '"') | 298 print(' * cannot use|cFF00FF00', macroName, '|r"'.. (macros[macroName][1] or '') .. '"') |
| 302 macroName = baseName .. '_' .. iterative | 299 macroName = baseName .. '_' .. iterative |
| 303 iterative = iterative + 1 | 300 iterative = iterative + 1 |
| 449 --cprint(spellID, unpack(kb.inactiveTalentBindings[spellID])) | 446 --cprint(spellID, unpack(kb.inactiveTalentBindings[spellID])) |
| 450 end | 447 end |
| 451 | 448 |
| 452 kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText ) | 449 kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText ) |
| 453 | 450 |
| 454 | |
| 455 | |
| 456 if actionType == 'spell' then | 451 if actionType == 'spell' then |
| 457 KeyBinderKey:SetAttribute("*type-"..name, actionType) | 452 KeyBinderKey:SetAttribute("*type-"..name, actionType) |
| 458 KeyBinderKey:SetAttribute("*"..actionType.."-"..name, name) | 453 KeyBinderKey:SetAttribute("*"..actionType.."-"..name, name) |
| 454 | |
| 459 elseif actionType == 'item' then | 455 elseif actionType == 'item' then |
| 460 KeyBinderKey:SetAttribute("*type-"..name, actionType) | 456 KeyBinderKey:SetAttribute("*type-"..name, actionType) |
| 461 KeyBinderKey:SetAttribute("*"..actionType.."-"..name, name) | 457 KeyBinderKey:SetAttribute("*"..actionType.."-"..name, name) |
| 462 elseif actionType == 'macro' then | 458 elseif actionType == 'macro' then |
| 463 KeyBinderMacro:SetAttribute("*macro-"..macroName, actionID) | 459 KeyBinderMacro:SetAttribute("*macro-"..macroName, actionID) |
| 464 else | 460 else |
| 465 KeyBinderMacro:SetAttribute("*macrotext-"..macroName, macroText) | 461 KeyBinderMacro:SetAttribute("*macrotext-"..macroName, macroText) |
| 466 end | 462 end |
| 463 | |
| 464 cprint('Loading binding', actionType, actionID) | |
| 467 bindings[actionType] = bindings[actionType] or {} | 465 bindings[actionType] = bindings[actionType] or {} |
| 468 bindings[actionType][actionID] = bindings[actionType][actionID] or {} | 466 bindings[actionType][actionID] = bindings[actionType][actionID] or {} |
| 469 bindings[command] = bindings[actionType][actionID] | 467 bindings[command] = bindings[actionType][actionID] |
| 470 return bindings[actionType], actionID | 468 return bindings[actionType], actionID |
| 471 end | 469 end |
