annotate SkeletonKey/DynamicTypes.lua @ 42:c77b355a0366

Added tag v7.0.3-10-release for changeset 0877063fd03b
author Nenue
date Tue, 16 Aug 2016 11:34:46 -0400
parents 34a2e8d93448
children
rev   line source
Nenue@6 1 -- KrakTool
Nenue@16 2 -- DynamicTypes.lua
Nenue@6 3 -- Created: 7/28/2016 3:28 PM
Nenue@6 4 -- %file-revision%
Nenue@16 5 -- Logic related to dynamic handlers
Nenue@6 6 local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo')
Nenue@32 7
Nenue@32 8 local PET_SPECIAL_SUBTEXT = 'Special Ability'
Nenue@32 9 local SECONDARY_PROFESSIONS = {
Nenue@32 10 [5] = 3,
Nenue@32 11 [7] = 4,
Nenue@32 12 [9] = 5,
Nenue@32 13 [10] = 6
Nenue@32 14 }
Nenue@32 15
Nenue@32 16 kb.TalentCache = {}
Nenue@32 17 kb.ProfessionCache = {}
Nenue@32 18 kb.PetCache = {}
Nenue@32 19 kb.specInfo = {}
Nenue@32 20 kb.UpdateSpecInfo = function()
Nenue@32 21 kb.specInfo.id = GetSpecialization()
Nenue@32 22 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id)
Nenue@32 23 print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations())
Nenue@32 24 end
Nenue@32 25
Nenue@32 26 kb.UpdateTalentInfo = function()
Nenue@32 27 if kb.talentsPushed then
Nenue@32 28 return
Nenue@32 29 end
Nenue@32 30 table.wipe(kb.TalentCache)
Nenue@32 31 for row =1, MAX_TALENT_TIERS do
Nenue@32 32 for col = 1, NUM_TALENT_COLUMNS do
Nenue@32 33 local talentID, talentName, icon, selected, available, spellID = GetTalentInfo(row, col, 1)
Nenue@32 34 local talentInfo = kb.TalentCache[spellID] or {}
Nenue@32 35 talentInfo.row = 1
Nenue@32 36 talentInfo.col = col
Nenue@32 37 talentInfo.name = talentName
Nenue@32 38 talentInfo.talentID = talentID
Nenue@32 39 talentInfo.selected = selected
Nenue@32 40 talentInfo.available = available
Nenue@32 41 talentInfo.spellID = spellID
Nenue@32 42 kb.TalentCache[spellID] = talentInfo
Nenue@32 43 kb.TalentCache[talentName] = talentInfo
Nenue@32 44 print('Talent ', row, col, spellID, talentName)
Nenue@32 45 end
Nenue@32 46 end
Nenue@32 47 kb.talentsPushed = true
Nenue@32 48
Nenue@32 49 kb.UpdateDynamicButtons('talent')
Nenue@32 50 end
Nenue@32 51
Nenue@32 52 kb.UpdateProfessionInfo = function()
Nenue@32 53 table.wipe(kb.ProfessionCache)
Nenue@32 54 local profs = {GetProfessions() }
Nenue@32 55 local primaryNum = 0
Nenue@32 56 for i, index in ipairs(profs) do
Nenue@32 57 local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index)
Nenue@32 58 print(i, index, profName, numSpells, spellOffset)
Nenue@32 59 if not SECONDARY_PROFESSIONS[index] then
Nenue@32 60 primaryNum = primaryNum + 1
Nenue@32 61 end
Nenue@32 62 local profNum = SECONDARY_PROFESSIONS[index] or primaryNum
Nenue@32 63
Nenue@32 64
Nenue@32 65 kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {}
Nenue@32 66
Nenue@32 67 for j = 1, numSpells do
Nenue@32 68 local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION)
Nenue@32 69
Nenue@32 70 local profInfo = {
Nenue@32 71 spellName = spellName,
Nenue@32 72 spellID = spellID,
Nenue@32 73 icon = icon,
Nenue@32 74 profOffset = i,
Nenue@32 75 profIndex = index,
Nenue@32 76 spellOffset = (spellOffset+j),
Nenue@32 77 spellNum = j
Nenue@32 78 }
Nenue@32 79 KeyBinderKey:SetAttribute("*type-profession_"..i .. '_' ..j, "spell")
Nenue@32 80 KeyBinderKey:SetAttribute("*spell-profession_"..i .. '_' ..j, spellName)
Nenue@32 81
Nenue@32 82 kb.ProfessionCache[i .. '_' .. j] = profInfo
Nenue@32 83 kb.ProfessionCache[spellName] = profInfo
Nenue@32 84 kb.ProfessionCache[spellID] = profInfo
Nenue@32 85 print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j)
Nenue@32 86 end
Nenue@32 87
Nenue@32 88 end
Nenue@32 89
Nenue@32 90 kb.UpdateDynamicButtons('profession')
Nenue@32 91 end
Nenue@32 92
Nenue@32 93
Nenue@32 94
Nenue@32 95 kb.UpdatePetInfo = function()
Nenue@32 96 kb.PetCache.spell = kb.PetCache.spell or {}
Nenue@32 97 kb.PetCache.spellslot = kb.PetCache.spellslot or {}
Nenue@32 98 kb.PetCache.action = kb.PetCache.action or {}
Nenue@32 99 kb.PetCache.special = kb.PetCache.action or {}
Nenue@32 100 local hasPetSpells, petType = HasPetSpells()
Nenue@32 101 if PetHasSpellbook() then
Nenue@32 102 print('PET SPELLBOOK')
Nenue@32 103 local i = 1
Nenue@32 104 local specialNum = 0
Nenue@32 105 repeat
Nenue@32 106
Nenue@32 107 local spellType, spellID = GetSpellBookItemInfo(i, BOOKTYPE_PET)
Nenue@32 108 local spellName, subText = GetSpellBookItemName(i, BOOKTYPE_PET)
Nenue@32 109 local isPassive = IsPassiveSpell(i, BOOKTYPE_PET)
Nenue@32 110 if not isPassive then
Nenue@32 111 if spellName then
Nenue@32 112 kb.PetCache.spellslot[spellName] = {i, spellName, subText}
Nenue@32 113 print('|cFF00FF88spellslot['..spellName..']|r', '=>', i, subText)
Nenue@32 114
Nenue@32 115 if subText == PET_SPECIAL_SUBTEXT then
Nenue@32 116 specialNum = specialNum + 1
Nenue@32 117 kb.PetCache.special[spellName] = {i, specialNum, spellID, subText }
Nenue@32 118 print('|cFF00FFFFspecial['..spellName..']|r', '=>', i, specialNum, spellID, subText)
Nenue@32 119 end
Nenue@32 120
Nenue@32 121 if spellID then
Nenue@32 122 kb.PetCache.spell[i] = {spellID, spellName, subText}
Nenue@32 123 print('|cFF0088FFspell['..i..']|r', '=>', spellID, spellName, subText)
Nenue@32 124 end
Nenue@32 125 end
Nenue@32 126
Nenue@32 127
Nenue@32 128 end
Nenue@32 129
Nenue@32 130 i = i + 1
Nenue@32 131 until spellType == nil
Nenue@32 132 else
Nenue@32 133 print('NO PET SPELLBOOK')
Nenue@32 134 table.wipe(kb.PetCache.spell)
Nenue@32 135 table.wipe(kb.PetCache.spellslot)
Nenue@32 136 end
Nenue@32 137
Nenue@32 138 if PetHasActionBar() then
Nenue@32 139 print('PET ACTION BAR')
Nenue@32 140 for i = 1, 10 do
Nenue@32 141
Nenue@32 142
Nenue@32 143 local name, subtext, texture, isToken, isActive = GetPetActionInfo(i)
Nenue@32 144 if name then
Nenue@32 145 kb.PetCache.action[i] = {name, subtext, texture, isToken, isActive }
Nenue@32 146
Nenue@32 147
Nenue@32 148 end
Nenue@32 149 print('|cFFFFFF00action['..i..']|r', name, subtext, texture)
Nenue@32 150 end
Nenue@32 151 else
Nenue@32 152 print('NO PET ACTION BAR')
Nenue@32 153 table.wipe(kb.PetCache.action)
Nenue@32 154 end
Nenue@32 155
Nenue@32 156 kb.UpdateDynamicButtons('petaction')
Nenue@32 157
Nenue@32 158 end
Nenue@32 159
Nenue@32 160 kb.SystemBinds = {}
Nenue@32 161 kb.UpdateSystemBinds = function()
Nenue@32 162 table.wipe(kb.SystemBinds)
Nenue@32 163 local n = GetNumBindings()
Nenue@32 164 for i=1, n do
Nenue@32 165 local command, key1, key2 = GetBinding(i)
Nenue@32 166 if key1 then
Nenue@32 167 kb.SystemBinds[key1] = command
Nenue@32 168 end
Nenue@32 169 if key2 then
Nenue@32 170 kb.SystemBinds[key2] = command
Nenue@32 171 end
Nenue@32 172 end
Nenue@32 173
Nenue@32 174 end
Nenue@32 175
Nenue@32 176 kb.UpdateDynamicButtons = function(dynamicType)
Nenue@32 177 for i, button in ipairs(kb.buttons) do
Nenue@32 178 if button.isDynamic == dynamicType then
Nenue@32 179 kb.UpdateSlot(button, true)
Nenue@32 180 end
Nenue@32 181 end
Nenue@32 182 end