Mercurial > wow > skeletonkey
diff SkeletonKey/ActionTypes.lua @ 21:564015ef0317
- use pet spellbook subtext to categorize dynamic buttons
author | Nenue |
---|---|
date | Sat, 30 Jul 2016 20:28:15 -0400 |
parents | 67db6b712bf3 |
children | f6dd297cb812 |
line wrap: on
line diff
--- a/SkeletonKey/ActionTypes.lua Sat Jul 30 19:09:36 2016 -0400 +++ b/SkeletonKey/ActionTypes.lua Sat Jul 30 20:28:15 2016 -0400 @@ -3,13 +3,22 @@ -- Created: 7/29/2016 9:14 PM -- %file-revision% -- -local kb, print, wrap = LibStub('LibKraken').register(KeyBinder) +local tostring, tonumber, pairs, ipairs = tostring, tonumber, pairs, ipairs +local unpack, SetBinding = unpack, SetBinding +local tinsert, tContains, select, wipe = tinsert, tContains, select, table.wipe +local GetSpellBookItemInfo, GetSpellBookItemName, GetSpellInfo = GetSpellBookItemInfo, GetSpellBookItemName, GetSpellInfo +local GetSpecialization, GetSpecializationInfo, IsPassiveSpell, IsTalentSpell = GetSpecialization, GetSpecializationInfo, IsPassiveSpell, IsTalentSpell +local PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells = PetHasSpellbook, PetHasActionBar, GetPetActionInfo, HasPetSpells +local GetProfessions, GetProfessionInfo, GetTalentInfo = GetProfessions, GetProfessionInfo, GetTalentInfo +local GetNumBindings, GetBinding = GetNumBindings, GetBinding + +local kb, print, wrap = LibStub('LibKraken').register(KeyBinder, 'Info') local cprint = DEVIAN_WORKSPACE and function(...) _G.print('Cfg', ...) end or function() end -local SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544 local CLICK_KEYBINDER_MACRO = "CLICK KeyBinderMacro:" local CLICK_KEYBINDER_KEY = "CLICK KeyBinderKey:" - +local PET_BASIC_SUBTEXT = 'Basic Attack' +local PET_SPECIAL_SUBTEXT = 'Special Ability' local PETACTION_SCRIPT = { [PET_ACTION_MOVE_TO] = {SLASH_PET_MOVE_TO1, 'pet_move_to'}, [PET_ACTION_ATTACK] = {SLASH_PET_ATTACK1, 'pet_attack'}, @@ -20,9 +29,22 @@ [PET_MODE_PASSIVE] = {SLASH_PET_PASSIVE1, 'pet_passive'}, [PET_MODE_ASSIST] = {SLASH_PET_ASSIST1, 'pet_assist'}, } +local SECONDARY_PROFESSIONS = { + [5] = 3, + [7] = 4, + [9] = 5, + [10] = 6 +} +local SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544 kb.ActionTypes = {} -kb.PetCache = {} +kb.PetCache = { + spell = {}, + spellslot = {}, + action = {}, + special = {}, + subtext = {} +} kb.TalentCache = {} kb.ProfessionCache = {} @@ -59,7 +81,7 @@ if PETACTION_SCRIPT[name] then attributeValue, attributeName = unpack(PETACTION_SCRIPT[name]) elseif kb.PetCache.special[name] then - attributeName = "petaction_special" .. tonumber(kb.PetCache.special[name][2]) + attributeName = "petaction_"..kb.PetCache.special[name][3].."_" .. tonumber(kb.PetCache.special[name][6]) end return CLICK_KEYBINDER_MACRO, attributeName, attributeValue end @@ -86,10 +108,10 @@ attributeName = baseName .. '_' .. iterative iterative = iterative + 1 end - if macroName ~= baseName then - print(' * Creating|cFF00FF00', macroName) + if attributeName ~= baseName then + print(' * Creating|cFF00FF00', attributeName) else - print(' * Re-using|cFF00FF00', macroName) + print(' * Re-using|cFF00FF00', attributeName) end kb.macros[attributeName] = {attributeValue, command} @@ -179,7 +201,7 @@ end kb.ApplyAllBindings =function () - table.wipe(kb.TalentBindings) + wipe(kb.TalentBindings) -- reflect action key settings @@ -203,29 +225,17 @@ end -local PET_SPECIAL_SUBTEXT = 'Special Ability' -local SECONDARY_PROFESSIONS = { - [5] = 3, - [7] = 4, - [9] = 5, - [10] = 6 -} - -kb.TalentCache = {} -kb.ProfessionCache = {} -kb.PetCache = {} kb.specInfo = {} kb.UpdateSpecInfo = function() kb.specInfo.id = GetSpecialization() kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) - print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations()) end kb.UpdateTalentInfo = function() if kb.talentsPushed then return end - table.wipe(kb.TalentCache) + wipe(kb.TalentCache) for row =1, MAX_TALENT_TIERS do for col = 1, NUM_TALENT_COLUMNS do local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1) @@ -248,7 +258,7 @@ end kb.UpdateProfessionInfo = function() - table.wipe(kb.ProfessionCache) + wipe(kb.ProfessionCache) local profs = {GetProfessions() } local primaryNum = 0 for i, index in ipairs(profs) do @@ -291,30 +301,33 @@ kb.UpdatePetInfo = function() - kb.PetCache.spell = kb.PetCache.spell or {} - kb.PetCache.spellslot = kb.PetCache.spellslot or {} - kb.PetCache.action = kb.PetCache.action or {} - kb.PetCache.special = kb.PetCache.action or {} local hasPetSpells, petType = HasPetSpells() if PetHasSpellbook() then print('PET SPELLBOOK') local i = 1 - local specialNum = 0 + local specialNum = {} repeat local spellType, spellID = GetSpellBookItemInfo(i, BOOKTYPE_PET) local spellName, subText = GetSpellBookItemName(i, BOOKTYPE_PET) + local texture = GetSpellBookItemTexture(i, BOOKTYPE_PET) local isPassive = IsPassiveSpell(i, BOOKTYPE_PET) if not isPassive then if spellName then - kb.PetCache.spellslot[spellName] = {i, spellName, subText} + kb.PetCache.spellslot[spellName] = {i, spellName, subText, spellID, texture} print('|cFF00FF88spellslot['..spellName..']|r', '=>', i, subText) - if subText == PET_SPECIAL_SUBTEXT then - specialNum = specialNum + 1 - kb.PetCache.special[spellName] = {i, specialNum, spellID, subText } - print('|cFF00FFFFspecial['..spellName..']|r', '=>', i, specialNum, spellID, subText) - KeyBinderMacro:SetAttribute("*macrotext-pet_special_"..specialNum, "/cast "..spellName) + if subText then + kb.PetCache.subtext[subText] = kb.PetCache.subtext[subText] or {} + specialNum[subText] = (specialNum[subText] or 0) + 1 + + local entry = {i, spellName, subText, spellID, texture, specialNum[subText]} + + kb.PetCache.special[spellName] = entry + kb.PetCache.subtext[subText][specialNum[subText]] = entry + KeyBinderMacro:SetAttribute("*macrotext-petaction_"..subText.."_"..specialNum[subText], "/cast "..spellName) + + print('|cFF00FFFFspecial['..spellName..']|r', '\n','|cFF00FFFFsubtext['..subText..']['..specialNum[subText]..']|r', '=>', i, spellName, subText, spellID, texture, specialNum[subText]) end if spellID then @@ -330,8 +343,8 @@ until spellType == nil else print('NO PET SPELLBOOK') - table.wipe(kb.PetCache.spell) - table.wipe(kb.PetCache.spellslot) + wipe(kb.PetCache.spell) + wipe(kb.PetCache.spellslot) end if PetHasActionBar() then @@ -349,7 +362,7 @@ end else print('NO PET ACTION BAR') - table.wipe(kb.PetCache.action) + wipe(kb.PetCache.action) end kb.UpdateDynamicButtons('petaction') @@ -357,7 +370,7 @@ end kb.UpdateSystemBinds = function() - table.wipe(kb.SystemBindings) + wipe(kb.SystemBindings) local n = GetNumBindings() for i=1, n do local command, key1, key2 = GetBinding(i)