# HG changeset patch # User Nenue # Date 1470440478 14400 # Node ID b0e4d04d428a9a37d700e7d94f80776dafe0f48f # Parent bb160c04de882d6a8a7b83a6b98a0b504f3c08b2 - use a fixed loop to parse GetProfessions() result so unlearned secondaries don't break the cache - removed a bad varaible reference that was causing confirmation popup to barf diff -r bb160c04de88 -r b0e4d04d428a SkeletonKey/ActionTemplates.lua --- a/SkeletonKey/ActionTemplates.lua Fri Aug 05 12:25:18 2016 -0400 +++ b/SkeletonKey/ActionTemplates.lua Fri Aug 05 19:41:18 2016 -0400 @@ -254,38 +254,43 @@ kb.UpdateProfessionInfo = function() wipe(kb.ProfessionCache) local profs = {GetProfessions() } + print(GetProfessions()) local primaryNum = 0 - for i, index in ipairs(profs) do - local profName, texture, rank, maxRank, numSpells, spellOffset = GetProfessionInfo(index) - print(i, index, profName, numSpells, spellOffset) - if not SECONDARY_PROFESSIONS[index] then - primaryNum = primaryNum + 1 - end - local profNum = SECONDARY_PROFESSIONS[index] or primaryNum + for i = 1, 6 do + if profs[i] then + local index = profs[i] + local profName, texture, _, _, numSpells, spellOffset = GetProfessionInfo(index) + print(i, index, profName, numSpells, spellOffset) + if not SECONDARY_PROFESSIONS[index] then + primaryNum = primaryNum + 1 + end + local profNum = SECONDARY_PROFESSIONS[index] or primaryNum + print(i, profNum) - kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {} + kb.ProfessionCache[profNum] = kb.ProfessionCache[profNum] or {} - for j = 1, numSpells do - local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION) + for j = 1, numSpells do + local spellName, _, icon, _, _, _, spellID = GetSpellInfo(spellOffset+j, BOOKTYPE_PROFESSION) - local profInfo = { - spellName = spellName, - spellID = spellID, - icon = icon, - profOffset = i, - profIndex = index, - spellOffset = (spellOffset+j), - spellNum = j - } + local profInfo = { + spellName = spellName, + spellID = spellID, + icon = icon, + profOffset = i, + profIndex = index, + spellOffset = (spellOffset+j), + spellNum = j + } - kb.SecureAttribute(KeyBinderKey, "*type-profession_"..i .. '_' ..j, "spell") - kb.SecureAttribute(KeyBinderKey, "*spell-profession_"..i .. '_' ..j, spellName) + kb.SecureAttribute(KeyBinderKey, "*type-profession_"..i .. '_' ..j, "spell") + kb.SecureAttribute(KeyBinderKey, "*spell-profession_"..i .. '_' ..j, spellName) - kb.ProfessionCache[i .. '_' .. j] = profInfo - kb.ProfessionCache[spellName] = profInfo - kb.ProfessionCache[spellID] = profInfo - print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) + kb.ProfessionCache[i .. '_' .. j] = profInfo + kb.ProfessionCache[spellName] = profInfo + kb.ProfessionCache[spellID] = profInfo + print(' |cFF0088FF['..i..']|r|cFFFF44BB['..spellOffset+i..']|r', spellName, "profession_"..i .. '_' ..j) + end end end diff -r bb160c04de88 -r b0e4d04d428a SkeletonKey/BindingsFrame.lua --- a/SkeletonKey/BindingsFrame.lua Fri Aug 05 12:25:18 2016 -0400 +++ b/SkeletonKey/BindingsFrame.lua Fri Aug 05 19:41:18 2016 -0400 @@ -69,13 +69,16 @@ if cursorType then kb.DropToSlot(self) else - if IsShiftKeyDown() then - kb.db.stickyMode = true - KeyBinderStickyMode:SetChecked(true) + if self.command and self.isAvailable then + if IsShiftKeyDown() then + kb.db.stickyMode = true + KeyBinderStickyMode:SetChecked(true) + end + + kb.ActivateSlot(self) + kb.ui() end - kb.ActivateSlot(self) - kb.ui() end elseif click == 'RightButton' then kb.ReleaseSlot(self) @@ -446,7 +449,7 @@ kb.AcceptAssignment = function(self, ...) local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] - local source = loadedProfiles[popup.oldProfile] + local source = kb. loadedProfiles[popup.oldProfile] kb.SetSlot(popup.slot, unpack(popup.args)) kb.UpdateSlot(popup.slot) kb:SetScript('OnMouseWheel', KeyBinder_OnMouseWheel) -- re-enable scrolling diff -r bb160c04de88 -r b0e4d04d428a SkeletonKey/KeyButton.lua --- a/SkeletonKey/KeyButton.lua Fri Aug 05 12:25:18 2016 -0400 +++ b/SkeletonKey/KeyButton.lua Fri Aug 05 19:41:18 2016 -0400 @@ -27,6 +27,15 @@ } +local PROFESSION_HEADERS = { + [1] = 'Profession 1', + [2] = 'Profession 2', + [3] = 10, + [4] = 7, + [5] = 9, + [6] = 5 +} + -- This is needed to identify a spells that aren't reflected by GetCursorInfo() kb.OnPickupPetAction = function(slot, ...) local isPickup = GetCursorInfo() @@ -387,7 +396,7 @@ end if self.isDynamic == 'profession' then - if self.isAvailable then + if self.profIndex then local profText = (self.spellNum == 1) and TRADE_SKILLS or (BUTTON_HEADERS[self.profIndex] or GetProfessionInfo(self.profIndex)) print(self.profIndex, 'spnum', type(self.spellNum), (self.spellNum == 1)) @@ -396,7 +405,7 @@ self.bindingText = kb.BindingString(GetBindingKey(self.command)) else - self.statusText = '|cFFFF4400Profession|r' + self.statusText = '|cFFFF4400'..PROFESSION_HEADERS[self.professionNum]..'|r' self.actionName = '(#'..self.professionNum..')' self.bindingText ='?' end @@ -529,6 +538,16 @@ actionID = cacheInfo.spellID self.profIndex = cacheInfo.profIndex self.spellOffset = cacheInfo.spellOffset + else + print(professionNum, type(professionNum), PROFESSION_HEADERS[tonumber(professionNum)]) + local profID = PROFESSION_HEADERS[tonumber(professionNum)] + if type(profID) == 'number' then + local pname, texture, _, _, numSpells, spellOffset = GetProfessionInfo(profID) + self.profIndex = profID + else + name = profID + end + end print(' Special slot: |cFF00FFFFProfession|r', professionNum, spellNum, isDynamic, isAvailable) @@ -548,7 +567,7 @@ local specialType, specialNum = command:match(actionType..'_([%a%s]+)_(%d)') if kb.PetCache.subtext[specialType] and kb.PetCache.subtext[specialType][tonumber(specialNum)] then - print('***dynamic pet thign', specialType, specialNum) + print('***dynamic pet skill', specialType, specialNum) --[[ i, spellName, subText, spellID, texture, specialNum[subText ]] pickupSlot, name, specialType, actionID, icon, specialNum = unpack(kb.PetCache.subtext[specialType][tonumber(specialNum)]) pickupBook = BOOKTYPE_PET