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