Nenue@6: -- KrakTool Nenue@16: -- DynamicTypes.lua Nenue@6: -- Created: 7/28/2016 3:28 PM Nenue@6: -- %file-revision% Nenue@16: -- Logic related to dynamic handlers Nenue@6: local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo') Nenue@32: Nenue@32: local PET_SPECIAL_SUBTEXT = 'Special Ability' Nenue@32: local SECONDARY_PROFESSIONS = { Nenue@32: [5] = 3, Nenue@32: [7] = 4, Nenue@32: [9] = 5, Nenue@32: [10] = 6 Nenue@32: } Nenue@32: Nenue@32: kb.TalentCache = {} Nenue@32: kb.ProfessionCache = {} Nenue@32: kb.PetCache = {} Nenue@32: kb.specInfo = {} Nenue@32: kb.UpdateSpecInfo = function() Nenue@32: kb.specInfo.id = GetSpecialization() Nenue@32: kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) Nenue@32: print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations()) Nenue@32: end Nenue@32: Nenue@32: kb.UpdateTalentInfo = function() Nenue@32: if kb.talentsPushed then Nenue@32: return Nenue@32: end Nenue@32: table.wipe(kb.TalentCache) Nenue@32: for row =1, MAX_TALENT_TIERS do Nenue@32: for col = 1, NUM_TALENT_COLUMNS do Nenue@32: local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1) Nenue@32: local talentInfo = kb.TalentCache[spellID] or {} Nenue@32: talentInfo.row = 1 Nenue@32: talentInfo.col = col Nenue@32: talentInfo.name = talentName Nenue@32: talentInfo.talentID = talentID Nenue@32: talentInfo.selected = selected Nenue@32: talentInfo.available = available Nenue@32: talentInfo.spellID = spellID Nenue@32: kb.TalentCache[spellID] = talentInfo Nenue@32: kb.TalentCache[talentName] = talentInfo Nenue@32: print('Talent ', row, col, spellID, talentName) Nenue@32: end Nenue@32: end Nenue@32: kb.talentsPushed = true Nenue@32: Nenue@32: kb.UpdateDynamicButtons('talent') Nenue@32: end Nenue@32: Nenue@32: kb.UpdateProfessionInfo = function() Nenue@32: table.wipe(kb.ProfessionCache) Nenue@32: local profs = {GetProfessions() } Nenue@32: local primaryNum = 0 Nenue@32: for i, index in ipairs(profs) do Nenue@32: local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index) Nenue@32: print(i, index, profName, numSpells, spellOffset) Nenue@32: if not SECONDARY_PROFESSIONS[index] then Nenue@32: primaryNum = primaryNum + 1 Nenue@32: end Nenue@32: local profNum = SECONDARY_PROFESSIONS[index] or primaryNum Nenue@32: Nenue@32: Nenue@32: kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {} Nenue@32: Nenue@32: for j = 1, numSpells do Nenue@32: local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION) Nenue@32: Nenue@32: local profInfo = { Nenue@32: spellName = spellName, Nenue@32: spellID = spellID, Nenue@32: icon = icon, Nenue@32: profOffset = i, Nenue@32: profIndex = index, Nenue@32: spellOffset = (spellOffset+j), Nenue@32: spellNum = j Nenue@32: } Nenue@32: KeyBinderKey:SetAttribute("*type-profession_"..i .. '_' ..j, "spell") Nenue@32: KeyBinderKey:SetAttribute("*spell-profession_"..i .. '_' ..j, spellName) Nenue@32: Nenue@32: kb.ProfessionCache[i .. '_' .. j] = profInfo Nenue@32: kb.ProfessionCache[spellName] = profInfo Nenue@32: kb.ProfessionCache[spellID] = profInfo Nenue@32: print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) Nenue@32: end Nenue@32: Nenue@32: end Nenue@32: Nenue@32: kb.UpdateDynamicButtons('profession') Nenue@32: end Nenue@32: Nenue@32: Nenue@32: Nenue@32: kb.UpdatePetInfo = function() Nenue@32: kb.PetCache.spell = kb.PetCache.spell or {} Nenue@32: kb.PetCache.spellslot = kb.PetCache.spellslot or {} Nenue@32: kb.PetCache.action = kb.PetCache.action or {} Nenue@32: kb.PetCache.special = kb.PetCache.action or {} Nenue@32: local hasPetSpells, petType = HasPetSpells() Nenue@32: if PetHasSpellbook() then Nenue@32: print('PET SPELLBOOK') Nenue@32: local i = 1 Nenue@32: local specialNum = 0 Nenue@32: repeat Nenue@32: Nenue@32: local spellType, spellID = GetSpellBookItemInfo(i, BOOKTYPE_PET) Nenue@32: local spellName, subText = GetSpellBookItemName(i, BOOKTYPE_PET) Nenue@32: local isPassive = IsPassiveSpell(i, BOOKTYPE_PET) Nenue@32: if not isPassive then Nenue@32: if spellName then Nenue@32: kb.PetCache.spellslot[spellName] = {i, spellName, subText} Nenue@32: print('|cFF00FF88spellslot['..spellName..']|r', '=>', i, subText) Nenue@32: Nenue@32: if subText == PET_SPECIAL_SUBTEXT then Nenue@32: specialNum = specialNum + 1 Nenue@32: kb.PetCache.special[spellName] = {i, specialNum, spellID, subText } Nenue@32: print('|cFF00FFFFspecial['..spellName..']|r', '=>', i, specialNum, spellID, subText) Nenue@32: end Nenue@32: Nenue@32: if spellID then Nenue@32: kb.PetCache.spell[i] = {spellID, spellName, subText} Nenue@32: print('|cFF0088FFspell['..i..']|r', '=>', spellID, spellName, subText) Nenue@32: end Nenue@32: end Nenue@32: Nenue@32: Nenue@32: end Nenue@32: Nenue@32: i = i + 1 Nenue@32: until spellType == nil Nenue@32: else Nenue@32: print('NO PET SPELLBOOK') Nenue@32: table.wipe(kb.PetCache.spell) Nenue@32: table.wipe(kb.PetCache.spellslot) Nenue@32: end Nenue@32: Nenue@32: if PetHasActionBar() then Nenue@32: print('PET ACTION BAR') Nenue@32: for i = 1, 10 do Nenue@32: Nenue@32: Nenue@32: local name, subtext, texture, isToken, isActive = GetPetActionInfo(i) Nenue@32: if name then Nenue@32: kb.PetCache.action[i] = {name, subtext, texture, isToken, isActive } Nenue@32: Nenue@32: Nenue@32: end Nenue@32: print('|cFFFFFF00action['..i..']|r', name, subtext, texture) Nenue@32: end Nenue@32: else Nenue@32: print('NO PET ACTION BAR') Nenue@32: table.wipe(kb.PetCache.action) Nenue@32: end Nenue@32: Nenue@32: kb.UpdateDynamicButtons('petaction') Nenue@32: Nenue@32: end Nenue@32: Nenue@32: kb.SystemBinds = {} Nenue@32: kb.UpdateSystemBinds = function() Nenue@32: table.wipe(kb.SystemBinds) Nenue@32: local n = GetNumBindings() Nenue@32: for i=1, n do Nenue@32: local command, key1, key2 = GetBinding(i) Nenue@32: if key1 then Nenue@32: kb.SystemBinds[key1] = command Nenue@32: end Nenue@32: if key2 then Nenue@32: kb.SystemBinds[key2] = command Nenue@32: end Nenue@32: end Nenue@32: Nenue@32: end Nenue@32: Nenue@32: kb.UpdateDynamicButtons = function(dynamicType) Nenue@32: for i, button in ipairs(kb.buttons) do Nenue@32: if button.isDynamic == dynamicType then Nenue@32: kb.UpdateSlot(button, true) Nenue@32: end Nenue@32: end Nenue@32: end