# HG changeset patch # User Nenue # Date 1485480304 18000 # Node ID d4c100b0fd0168fcb567c1fd17aa240cd644d970 # Parent 4ca4cc031e99507e061bdf02540ca7db809af96f - Fixed an issue with talent bindings not loading between specialization changes. - Fixed action button text corruption that occurred after changing assignments on an inactive spell. diff -r 4ca4cc031e99 -r d4c100b0fd01 ActionTemplates.lua --- a/ActionTemplates.lua Mon Jan 23 20:09:08 2017 -0500 +++ b/ActionTemplates.lua Thu Jan 26 20:25:04 2017 -0500 @@ -40,8 +40,6 @@ local petSpellCache,petSubtextCache local SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544 ---kb.ChangedBindings = {} ---kb.ActionTypes = {} local atype = kb.ActionTypes @@ -65,8 +63,9 @@ atype['spell'] = function(id, name) local attributeName = name - if kb.ProfessionCache[id] then - attributeName = "profession_".. kb.ProfessionCache[id].dynamicIndex .. '_' .. kb.ProfessionCache[id].dynamicSubIndex + local profInfo = kb.DynamicSpells.profession[id] + if profInfo then + attributeName = "profession_".. profInfo.dynamicIndex .. '_' .. profInfo.dynamicSubIndex end return CLICK_KEYBINDER_KEY, attributeName, name, SkeletonKeyKey end @@ -178,25 +177,6 @@ return info end - -kb.ApplyTalentBinding = function(talentInfo, cache) - talentInfo.assignedKeys = talentInfo.assignedKeys or {} - for i , key in pairs(talentInfo.assignedKeys) do - local command = CLICK_KEYBINDER_KEY.. talentInfo.actionName - SetBinding(key, command) - cprint(' **', i, '->', command) - tinsert(cache, talentInfo) - end -end -kb.CacheTalentBinding = function(talentInfo, cache) - - local spellID = talentInfo.actionID - cache[spellID] = cache[spellID] or {} - cache[spellID] = talentInfo - cprint(spellID, unpack(kb.TalentBindings[spellID])) -end - - do local PROFILE_VERSION = 320 local commandActions = {} @@ -393,7 +373,6 @@ kb.ApplyAllBindings =function () print('|cFFFFFF00ApplyAllBindings()') - wipe(kb.TalentBindings) wipe(kb.bindings) --kb:print('Loading binding profile', kb.profileName) @@ -419,7 +398,28 @@ end -kb.specInfo = {} +local AddSpellInfo = function(id, name, icon, dynamicType, dynamicID, dynamicIndex, dynamicSubIndex, isAvailable) + local spell = kb.DynamicSpells[id] or {} + spell.actionName = name + spell.dynamicType = dynamicType + spell.dynamicID = dynamicID + spell.iconPath = icon + spell.dynamicIndex = dynamicIndex + spell.dynamicSubIndex = dynamicSubIndex + spell.isAvailable = isAvailable + spell.actionType = 'spell' + spell.spellbookType = BOOKTYPE_SPELL + kb.DynamicSpells[name] = spell + + local spellList = dynamicType and kb.DynamicSpells[dynamicType] + if spellList then + spellList[dynamicIndex] = spellList[dynamicIndex] or {} + spellList[dynamicIndex][dynamicSubIndex] = spell + end + + cprint('|cFF00FFFFSpellInfo:|r', name, isAvailable, dynamicType or 'spell') +end + kb.UpdateSpecInfo = function() kb.specInfo.id = GetSpecialization() kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) @@ -434,54 +434,61 @@ end end + kb.UpdateTalentInfo = function() - print('|cFFFFFF00kb.UpdateTalentInfo()|r') + print('|cFFFFFF00kb.UpdateSpells()|r') + cprint('|cFFFFFF00kb.UpdateSpells()|r') if kb.talentsPushed then return end 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) - local talentInfo = kb.TalentCache[spellID] or {} + local talentInfo = kb.DynamicSpells[spellID] or {} if spellID then - talentInfo.actionType = 'spell' - talentInfo.actionName = talentName - talentInfo.dynamicType = 'talent' - talentInfo.dynamicID = talentID - talentInfo.dynamicIndex = row - talentInfo.dynamicSubIndex = col - talentInfo.actionID = spellID - talentInfo.isAvailable = selected - kb.DynamicSpells[spellID] = talentInfo - kb.DynamicSpells[talentName] = talentInfo + AddSpellInfo(spellID, talentName, icon, 'talent', talentID, row, col, selected) end - --print('Talent ', row, col, spellID, talentName) end end for row = 1, MAX_PVP_TALENT_TIERS do for col = 1, MAX_PVP_TALENT_COLUMNS do - local id, name, icon, selected, available, spellID, unlocked = GetPvpTalentInfo(row, col, 1) + local talentID, talentName, icon, selected, available, spellID, unlocked = GetPvpTalentInfo(row, col, 1) if spellID then - local talentInfo = kb.TalentCache[spellID] or {} - talentInfo.actionType = 'spell' - talentInfo.actionName = name - talentInfo.dynamicType = 'talent' - talentInfo.dynamicID = id - talentInfo.dynamicIndex = row - talentInfo.dynamicSubIndex = col - talentInfo.actionID = spellID - talentInfo.isAvailable = selected - kb.DynamicSpells[spellID] = talentInfo - kb.DynamicSpells[name] = talentInfo + AddSpellInfo(spellID, talentName, icon, 'talent', talentID, row, col, selected) end end end + local numTabs = GetNumSpellTabs() + for i = 1, numTabs do + local name, texture, offset, numSpells = GetSpellTabInfo(i) + for spellLine = offset+1, offset+numSpells do + local skillType, spellID = GetSpellBookItemInfo(spellLine) + if skillType == 'SPELL' then + local name, _, icon = GetSpellInfo(spellID) + AddSpellInfo(spellID, name, icon, nil, nil, nil, nil, true) + elseif skillType == 'FLYOUT' then + local flyoutID = GetFlyoutID(spellLine) + local _, _, numSlots = GetFlyoutInfo(flyoutID) + if numSlots then + for slot = 1, numSlots do + local spellID, isKnown = GetFlyoutSlotInfo(flyoutID, slot) + local name, rank, icon = GetSpellInfo(spellID) + AddSpellInfo(spellID, name, icon, nil, nil, nil, nil, true) + end + end + end + end + end + + + kb.talentsPushed = true kb.UpdateDynamicButtons('talent') end +kb.UpdateSpells = kb.UpdateTalentInfo kb.UpdateProfessionInfo = function() wipe(kb.ProfessionCache) @@ -500,15 +507,12 @@ cprint(i, profNum) - kb.ProfessionCache[profNum] = kb.ProfessionCache[profNum] or {} - for j = 1, numSpells do local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION) cprint(j, spellName) local profInfo = { actionType = 'spell', actionName = spellName, - statusText = 'Profession ' .. i, actionID = spellID, iconPath = icon, dynamicIndex = i, @@ -517,19 +521,18 @@ spellbookOffset = (spellOffset+j), spellbookType = BOOKTYPE_PROFESSION, isAvailable = true, - -- need to check if necessary - uniqueID = profID, + dynamicID = profID, } kb.SecureAttribute(SkeletonKeyKey, "*type-profession_"..i .. '_' ..j, "spell") kb.SecureAttribute(SkeletonKeyKey, "*spell-profession_"..i .. '_' ..j, spellName) - kb.ProfessionCache[spellName] = profInfo - kb.ProfessionCache[spellID] = profInfo kb.DynamicSpells[spellName] = profInfo kb.DynamicSpells[spellID] = profInfo + kb.DynamicSpells.profession[spellName] = profInfo + kb.DynamicSpells.profession[spellID] = profInfo kb.DynamicSpells.profession[i] = kb.DynamicSpells.profession[i] or {} kb.DynamicSpells.profession[i][j] = profInfo --print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) @@ -621,6 +624,7 @@ kb.PetCache.special[spellName] = info kb.PetCache.subtext[subText][specialNum[subText]] = info + kb.DynamicSpells[spellName] = info kb.DynamicSpells[spellID] = info diff -r 4ca4cc031e99 -r d4c100b0fd01 BindingsFrame.lua --- a/BindingsFrame.lua Mon Jan 23 20:09:08 2017 -0500 +++ b/BindingsFrame.lua Thu Jan 26 20:25:04 2017 -0500 @@ -16,6 +16,7 @@ --]=] SkeletonKeyButtonMixin = {} +local skb = SkeletonKeyButtonMixin local _, kb = ... local print = (DEVIAN_PNAME == 'SkeletonKey') and function(...) _G.print('SKUI', ...) end or nop local gprint = (DEVIAN_PNAME == 'SkeletonKey') and function(...) _G.print('SK', ...) end or nop @@ -423,6 +424,64 @@ return true end +function ActionListPanel:UnbindSlot (button) + + local configTable = kb.currentProfile.buttons[button:GetID()] + local button = button or kb.saveTarget + if not button then + return + end + + local command = button.command + local actionType = button.actionType + local actionID = button.actionID + + + local talentName = button.actionName + if actionType == 'macro' then + local spellName, _, spellID = GetMacroSpell(actionID) + talentName = spellName + end + + local keys = {GetBindingKey(command) } + if configTable and configTable.assignedKeys then + for _, key in ipairs(configTable.assignedKeys) do + if not tContains(keys, key) then + tinsert(keys, key) + end + end + end + + -- only manipulate bindings if its an available ability + if button.isAvailable then + --print('detected', #keys, 'bindings') + + if #keys >= 1 then + kb.UpdateBindingsCache(actionType, actionID, {}) + end + + for i, key in pairs(keys) do + --print('clearing', key) + SetBinding(key, nil) + kb.bindings[tostring(actionType)..'_'..tostring(actionID)] = nil + end + SaveBindings(GetCurrentBindingSet()) + end + + + if configTable and configTable.assignedKeys then + table.wipe(configTable.assignedKeys) + end + + if kb.currentProfile.bound[command] then + kb.currentProfile.bound[command] = nil + --kb:print(BINDING_REMOVED:format(self.actionName, configHeaders[db.bindMode])) + end + kb.saveTarget = nil + button:UpdateSlot(true) + return true +end + function ActionListPanel:OnInput(key) if key == 'ESCAPE' then @@ -448,7 +507,7 @@ end --- Associate processed input with the given slot's metadata -function SkeletonKeyButtonMixin:SaveSlot (key) +function skb:SaveSlot (key) if not self.command then return @@ -505,7 +564,7 @@ SetBinding(binding, self.command) SaveBindings(GetCurrentBindingSet()) self.assignedKeys = {GetBindingKey(self.command) } - + kb.UpdateBindingsCache(self.actionType, self.actionID, self.assignedKeys) kb:print(L('BINDING_ASSIGNED', binding, self.actionName, kb.currentHeader)) else kb:print(L('UNSELECTED_TALENT_ASSIGNED', binding, self.actionName, kb.currentHeader)) @@ -515,7 +574,6 @@ tinsert(self.assignedKeys, 1, binding) end - for _, key in ipairs(self.assignedKeys) do if not kb.currentProfile.bindings[key] then kb.currentProfile.bindings[key] = self.command @@ -530,10 +588,7 @@ end end - kb.UpdateBindingsCache(self.actionType, self.actionID, self.assignedKeys) - self.binding = binding - return true end @@ -550,64 +605,6 @@ self:StopMovingOrSizing() end -function ActionListPanel:UnbindSlot (button) - - local configTable = kb.currentProfile.buttons[button:GetID()] - local button = button or kb.saveTarget - if not button then - return - end - - local command = button.command - local actionType = button.actionType - local actionID = button.actionID - - - local talentName = button.actionName - if actionType == 'macro' then - local spellName, _, spellID = GetMacroSpell(actionID) - talentName = spellName - end - - local keys = {GetBindingKey(command) } - if configTable and configTable.assignedKeys then - for _, key in ipairs(configTable.assignedKeys) do - if not tContains(keys, key) then - tinsert(keys, key) - end - end - end - - -- only manipulate bindings if its an available ability - if button.isAvailable then - --print('detected', #keys, 'bindings') - - if #keys >= 1 then - kb.UpdateBindingsCache(actionType, actionID, {}) - end - - for i, key in pairs(keys) do - --print('clearing', key) - SetBinding(key, nil) - kb.bindings[tostring(actionType)..'_'..tostring(actionID)] = nil - end - SaveBindings(GetCurrentBindingSet()) - end - - - if configTable and configTable.assignedKeys then - table.wipe(configTable.assignedKeys) - end - - if kb.currentProfile.bound[command] then - kb.currentProfile.bound[command] = nil - --kb:print(BINDING_REMOVED:format(self.actionName, configHeaders[db.bindMode])) - end - kb.saveTarget = nil - button:UpdateSlot(true) - return true -end - kb.AcceptAssignment = function(self, ...) local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] local source = kb. loadedProfiles[popup.oldProfile] diff -r 4ca4cc031e99 -r d4c100b0fd01 Events.lua --- a/Events.lua Mon Jan 23 20:09:08 2017 -0500 +++ b/Events.lua Thu Jan 26 20:25:04 2017 -0500 @@ -36,6 +36,7 @@ -- only need to respond to this for pet actions kb.PLAYER_SPECIALIZATION_CHANGED = function(self, event, unit) + kb.talentsPushed = nil kb.UpdateSpecInfo() kb.UpdateTalentInfo() kb.UpdatePetInfo() diff -r 4ca4cc031e99 -r d4c100b0fd01 KeyButton.lua --- a/KeyButton.lua Mon Jan 23 20:09:08 2017 -0500 +++ b/KeyButton.lua Thu Jan 26 20:25:04 2017 -0500 @@ -243,10 +243,6 @@ StaticPopup_Show('SKELETONKEY_CONFIRM_ASSIGN_SLOT') else kb.currentProfile.buttons[self:GetID()] = slotInfo - if #slotInfo.assignedKeys >= 1 then - kb:print('Obtained following hotkeys:', table.concat(slotInfo.assignedKeys, ', ')) - - end kb.LoadBinding(slotInfo) self:SetSlot(slotInfo) self:UpdateSlot() diff -r 4ca4cc031e99 -r d4c100b0fd01 SkeletonKey.lua --- a/SkeletonKey.lua Mon Jan 23 20:09:08 2017 -0500 +++ b/SkeletonKey.lua Thu Jan 26 20:25:04 2017 -0500 @@ -47,7 +47,7 @@ kb.ChangedBindings = {} kb.SystemBindings = {} kb.ActionTypes = {} -kb.TalentBindings = {} +-- pet spell categories kb.PetCache = { spell = {}, spellslot = {}, @@ -55,16 +55,18 @@ special = {}, subtext = {} } +-- general spell resolution kb.DynamicSpells = { profession = {}, petaction = {}, talent = {}, } -kb.TalentCache = {} + kb.ProfessionCache = {} + +kb.specInfo = {} kb.pendingCalls = {} kb.pendingAttributes = {} - kb.configHeaders = {} kb.loadedProfiles = {} kb.orderedProfiles = {}