Mercurial > wow > skeletonkey
changeset 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 | 91398d284a99 |
children | 5250877895ae |
files | .pkgmeta LibKraken/LibKraken-1.0.xml SkeletonKey/ActionTypes.lua SkeletonKey/BindingsUI.lua SkeletonKey/DynamicTypes.lua SkeletonKey/KeySlot.lua SkeletonKey/SkeletonKey.lua SkeletonKey/SkeletonKey.toc SkeletonKey/SkeletonKey.xml |
diffstat | 9 files changed, 363 insertions(+), 300 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.pkgmeta Sat Jul 30 19:08:11 2016 -0400 @@ -0,0 +1,12 @@ +externals: + libs/LibStub: + url: svn://svn.wowace.com/wow/libstub/mainline/trunk + tag: latest +move-folders: + LibKraken: libs/LibKraken-1.0 +ignore: + .idea + SkeletonKey.iml + +package-as: SkeletonKey +enable-nolib-creation: no \ No newline at end of file
--- a/LibKraken/LibKraken-1.0.xml Sat Jul 30 03:33:09 2016 -0400 +++ b/LibKraken/LibKraken-1.0.xml Sat Jul 30 19:08:11 2016 -0400 @@ -7,7 +7,7 @@ <Color a="1" r="1" g="1" b="1" /> </Font> - <Font name="KTHeaderFont" height="18" justifyH="LEFT" justifyV="TOP" virtual="true" inherits="NumberFont_Outline_Huge" /> + <Font name="KTHeaderFont" height="18" font="Fonts\skurri.ttf" outline="NORMAL" justifyH="LEFT" justifyV="TOP" virtual="true" inherits="NumberFont_Outline_Huge" /> <Font name="KTHeader2Font" height="14" font="Fonts\skurri.ttf" outline="NORMAL" justifyH="LEFT" justifyV="TOP" virtual="true" /> <Font name="KTUIPanelFont" justifyH="LEFT" virtual="true" inherits="NumberFontNormal" /> <Font name="KTMacroButtonFont" height="12" font="Fonts\ARIALN.TTF" justifyH="LEFT" virtual="true" >
--- a/SkeletonKey/ActionTypes.lua Sat Jul 30 03:33:09 2016 -0400 +++ b/SkeletonKey/ActionTypes.lua Sat Jul 30 19:08:11 2016 -0400 @@ -21,42 +21,54 @@ [PET_MODE_ASSIST] = {SLASH_PET_ASSIST1, 'pet_assist'}, } +kb.ActionTypes = {} +kb.PetCache = {} +kb.TalentCache = {} +kb.ProfessionCache = {} + +local atype = kb.ActionTypes + --- Caps Lock -local ACTION_HANDLERS = {} -ACTION_HANDLERS['mount'] = function(id, name) +atype['mount'] = function(id, name) if id == SUMMON_RANDOM_FAVORITE_MOUNT_SPELL then return 'mount_random', "/script C_MountJournal.SummonByID(0)", CLICK_KEYBINDER_MACRO else return 'mount_'..id, "/script C_MountJournal.SummonByID("..id..")", CLICK_KEYBINDER_MACRO end end -ACTION_HANDLERS['macro'] = function(id, name) + +atype['macro'] = function(id, name) return CLICK_KEYBINDER_MACRO, 'macro_' .. tostring(name), id end -ACTION_HANDLERS['equipset'] = function(id, name) + +atype['equipset'] = function(id, name) return CLICK_KEYBINDER_MACRO, 'equipset_'..tostring(name), "/script UseEquipmentSet("..tostring(id)..")" end -ACTION_HANDLERS['spell'] = function(id, name) + +atype['spell'] = function(id, name) local attributeName = name if kb.ProfessionCache[id] then attributeName = "profession_".. kb.ProfessionCache[id].profOffset .. '_' .. kb.ProfessionCache[id].spellNum end return CLICK_KEYBINDER_KEY, attributeName, name end -ACTION_HANDLERS['petaction'] = function(_, name) + +atype['petaction'] = function(_, name) -- ID doesn't exist for basic commands, even though they can be picked up local attributeName, attributeValue = "petaction_" .. tostring(name), "/cast "..tostring(name) if PETACTION_SCRIPT[name] then attributeValue, attributeName = unpack(PETACTION_SCRIPT[name]) + elseif kb.PetCache.special[name] then + attributeName = "petaction_special" .. tonumber(kb.PetCache.special[name][2]) end - return CLICK_KEYBINDER_MACRO, attributeName, attributeValue end -ACTION_HANDLERS['battlepet'] = function(id, name) +atype['battlepet'] = function(id, name) return CLICK_KEYBINDER_MACRO, 'battlepet_' .. tostring(name), SLASH_SUMMON_BATTLE_PET1 .. " " .. tostring(name) end -ACTION_HANDLERS['item'] = function(id, name) + +atype['item'] = function(id, name) return CLICK_KEYBINDER_KEY, 'item_' .. tostring(name), id end @@ -64,8 +76,8 @@ --- Resolves the SecureActionButton attribute names used for the given action kb.RegisterAction = function(actionType, id, name) - assert(ACTION_HANDLERS[actionType], 'Missing actionType handler for `'..tostring(actionType)..'`') - local target, attributeName, attributeValue = ACTION_HANDLERS[actionType](id, name) + assert(atype[actionType], 'Missing actionType handler for `'..tostring(actionType)..'`') + local target, attributeName, attributeValue = atype[actionType](id, name) local command = target .. attributeName local baseName, iterative = attributeName, 1 @@ -89,7 +101,6 @@ -kb.inactiveTalentBindings = {} kb.ApplyTalentBinding = function(talentInfo, cache) for i = 5, #talentInfo do local command = CLICK_KEYBINDER_KEY.. talentInfo[2] @@ -101,9 +112,9 @@ kb.CacheTalentBinding = function(talentInfo, cache) local spellID = talentInfo[4] - kb.inactiveTalentBindings[spellID] = kb.inactiveTalentBindings[spellID] or {} - kb.inactiveTalentBindings[spellID] = {select(5,unpack(talentInfo)) } - --cprint(spellID, unpack(kb.inactiveTalentBindings[spellID])) + cache[spellID] = cache[spellID] or {} + cache[spellID] = {select(5,unpack(talentInfo)) } + --cprint(spellID, unpack(kb.TalentBindings[spellID])) end do @@ -150,7 +161,7 @@ for spellName, talentInfo in pairs(profile.talents) do local dummy = GetSpellInfo(spellName) local func = kb.CacheTalentBinding - local dest = kb.inactiveTalentBindings + local dest = kb.TalentBindings if dummy then cprint('|cFFBBFF00Active:|r', dummy) local macroName, spellName, actionType, actionID = unpack(talentInfo) @@ -168,7 +179,7 @@ end kb.ApplyAllBindings =function () - table.wipe(kb.inactiveTalentBindings) + table.wipe(kb.TalentBindings) -- reflect action key settings @@ -189,4 +200,180 @@ SaveBindings(GetCurrentBindingSet()) end +end + + +local PET_SPECIAL_SUBTEXT = 'Special Ability' +local SECONDARY_PROFESSIONS = { + [5] = 3, + [7] = 4, + [9] = 5, + [10] = 6 +} + +kb.TalentCache = {} +kb.ProfessionCache = {} +kb.PetCache = {} +kb.specInfo = {} +kb.UpdateSpecInfo = function() + kb.specInfo.id = GetSpecialization() + kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) + print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations()) +end + +kb.UpdateTalentInfo = function() + if kb.talentsPushed then + return + end + table.wipe(kb.TalentCache) + 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 {} + talentInfo.row = 1 + talentInfo.col = col + talentInfo.name = talentName + talentInfo.talentID = talentID + talentInfo.selected = selected + talentInfo.available = available + talentInfo.spellID = spellID + kb.TalentCache[spellID] = talentInfo + kb.TalentCache[talentName] = talentInfo + print('Talent ', row, col, spellID, talentName) + end + end + kb.talentsPushed = true + + kb.UpdateDynamicButtons('talent') +end + +kb.UpdateProfessionInfo = function() + table.wipe(kb.ProfessionCache) + local profs = {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 + + + kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {} + + 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 + } + KeyBinderKey:SetAttribute("*type-profession_"..i .. '_' ..j, "spell") + KeyBinderKey:SetAttribute("*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) + end + + end + + kb.UpdateDynamicButtons('profession') +end + + + +kb.UpdatePetInfo = function() + kb.PetCache.spell = kb.PetCache.spell or {} + kb.PetCache.spellslot = kb.PetCache.spellslot or {} + kb.PetCache.action = kb.PetCache.action or {} + kb.PetCache.special = kb.PetCache.action or {} + local hasPetSpells, petType = HasPetSpells() + if PetHasSpellbook() then + print('PET SPELLBOOK') + local i = 1 + local specialNum = 0 + repeat + + local spellType, spellID = GetSpellBookItemInfo(i, BOOKTYPE_PET) + local spellName, subText = GetSpellBookItemName(i, BOOKTYPE_PET) + local isPassive = IsPassiveSpell(i, BOOKTYPE_PET) + if not isPassive then + if spellName then + kb.PetCache.spellslot[spellName] = {i, spellName, subText} + print('|cFF00FF88spellslot['..spellName..']|r', '=>', i, subText) + + if subText == PET_SPECIAL_SUBTEXT then + specialNum = specialNum + 1 + kb.PetCache.special[spellName] = {i, specialNum, spellID, subText } + print('|cFF00FFFFspecial['..spellName..']|r', '=>', i, specialNum, spellID, subText) + KeyBinderMacro:SetAttribute("*macrotext-pet_special_"..specialNum, "/cast "..spellName) + end + + if spellID then + kb.PetCache.spell[i] = {spellID, spellName, subText} + print('|cFF0088FFspell['..i..']|r', '=>', spellID, spellName, subText) + end + end + + + end + + i = i + 1 + until spellType == nil + else + print('NO PET SPELLBOOK') + table.wipe(kb.PetCache.spell) + table.wipe(kb.PetCache.spellslot) + end + + if PetHasActionBar() then + print('PET ACTION BAR') + for i = 1, 10 do + + + local name, subtext, texture, isToken, isActive = GetPetActionInfo(i) + if name then + kb.PetCache.action[i] = {name, subtext, texture, isToken, isActive } + + + end + print('|cFFFFFF00action['..i..']|r', name, subtext, texture) + end + else + print('NO PET ACTION BAR') + table.wipe(kb.PetCache.action) + end + + kb.UpdateDynamicButtons('petaction') + +end + +kb.UpdateSystemBinds = function() + table.wipe(kb.SystemBindings) + local n = GetNumBindings() + for i=1, n do + local command, key1, key2 = GetBinding(i) + if key1 then + kb.SystemBindings[key1] = command + end + if key2 then + kb.SystemBindings[key2] = command + end + end +end + +kb.UpdateDynamicButtons = function(dynamicType) + for i, button in ipairs(kb.buttons) do + if button.isDynamic == dynamicType then + kb.UpdateSlot(button, true) + end + end end \ No newline at end of file
--- a/SkeletonKey/BindingsUI.lua Sat Jul 30 03:33:09 2016 -0400 +++ b/SkeletonKey/BindingsUI.lua Sat Jul 30 19:08:11 2016 -0400 @@ -37,24 +37,29 @@ local saveButton local KeyButton_OnKeyDown = function(self, key) + if key == 'ESCAPE' or key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then + return + end + kb.saveTarget.border:SetColorTexture(1,1,1,1) end local KeyButton_OnKeyUp = function(self, key) if key == 'ESCAPE' then kb.DeactivateSlot(kb.saveTarget) - else + kb.ui() + return + end - if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then - return + if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then + return + end + + if kb.SaveSlot(kb.saveTarget, key) then + if not (kb.db.stickyMode or kb.db.hoverInput) then + + kb.DeactivateSlot(kb.saveTarget) end - kb.SaveSlot(kb.saveTarget, key) - - if not kb.stickyMode then - kb:SetScript('OnKeyUp', nil) - kb:SetScript('OnKeyDown', nil) - kb.saveTarget = nil - end + kb.ui() end - kb.ui() end local KeyButton_OnClick = function(self, click) @@ -65,12 +70,8 @@ kb.DropToSlot(self) else if IsShiftKeyDown() then - kb.stickyMode = true + kb.db.stickyMode = true KeyBinderStickyMode:SetChecked(true) - - kb.saveTarget = button - kb:SetScript('OnKeyUp', KeyButton_OnKeyUp) - kb:SetScript('OnKeyDown', KeyButton_OnKeyDown) end kb.ActivateSlot(self) @@ -145,10 +146,10 @@ end else - if self.active then + if self.active and kb.db.hoverInput then self.active = nil - kb.DeactivateSlot(self) - kb.ui() + --kb.DeactivateSlot(self) + --kb.ui() end end end @@ -177,18 +178,41 @@ kb.ui(true) end -local CheckButton_OnEnter = function(self) - if self.tooltip then - GameTooltip:SetOwner(self) - GameTooltip:SetText(self.tooltip) - GameTooltip:Show() +local KeyBinder_CheckButton = function(frame ,enableText, disableText, dbKey, tooltipText, callback) + if kb.db[dbKey] then + frame:SetChecked(true) end -end -local CheckButton_OnLeave = function(self) - if self.tooltip and GameTooltip:GetOwner() == self then - GameTooltip:Hide() - end + frame.label:SetText(kb.db[dbKey] and enableText or disableText) + frame:SetWidth(frame.label:GetStringWidth()+8) + frame:SetScript('OnClick', function(self) + if callback then + callback(self) + end + kb.db[dbKey] = self:GetChecked() + if not kb.db[dbKey] then + if kb.saveTarget then + kb.DeactivateSlot(kb.saveTarget) + end + end + self.label:SetText(kb.db[dbKey] and enableText or disableText) + self:SetWidth(self.label:GetStringWidth()+8) + kb.ui() + end) + + frame:SetScript('OnEnter', function(self) + if tooltipText then + GameTooltip:SetOwner(self) + GameTooltip:SetText(tooltipText) + GameTooltip:Show() + end + end) + + frame:SetScript('OnLeave', function(self) + if tooltipText and GameTooltip:GetOwner() == self then + GameTooltip:Hide() + end + end) end local KeyBinder_OnHide = function() @@ -292,28 +316,8 @@ function() OpenAllBags() end, "Interface\\BUTTONS\\UI-MicroButtonCharacter-Up", {0, 1, .4, 1}) - KeyBinderStickyMode.tooltip = 'Keep input active after receiving a key.' - KeyBinderStickyMode:SetScript('OnClick', function(self) - kb.db.stickyMode = self:GetChecked() - if not kb.db.stickyMode then - if kb.saveTarget then - kb.DeactivateSlot(kb.saveTarget) - end - end - kb.ui() - end) - if kb.db.stickyMode then - KeyBinderStickyMode:SetChecked(true) - end - - KeyBinderHoverInput.tooltip = 'Enable key input when the cursor is over a binding slot.' - KeyBinderHoverInput:SetScript('OnClick', function(self) - kb.db.hoverInput = self:GetChecked() - kb.ui() - end) - if kb.db.hoverInput then - KeyBinderHoverInput:SetChecked(true) - end + KeyBinder_CheckButton(KeyBinderStickyMode, 'Enabled', 'Disabled', 'stickyMode', 'Keep input active after receiving a key.') + KeyBinder_CheckButton(KeyBinderHoverInput, 'MouseOver', 'Click', 'hoverInput', 'Enable key input when the cursor is over a binding slot.') KeyBinderUnbindButton:SetScript('OnClick', function() @@ -323,10 +327,6 @@ kb.ui() end) - KeyBinderStickyMode:SetScript('OnEnter', CheckButton_OnEnter) - KeyBinderHoverInput:SetScript('OnEnter', CheckButton_OnEnter) - KeyBinderStickyMode:SetScript('OnLeave', CheckButton_OnLeave) - KeyBinderHoverInput:SetScript('OnLeave', CheckButton_OnLeave) kb.info:SetPoint('TOPLEFT', kb.UIPanels[1], 'BOTTOMLEFT', 0, -BUTTON_SPACING) HEADER_OFFSET = kb.UIPanels[1]:GetHeight() + BUTTON_PADDING @@ -434,15 +434,12 @@ if kb.saveTarget then KeyBinderUnbindButton:SetParent(kb.saveTarget) - KeyBinderUnbindButton:SetPoint('TOPRIGHT', kb.saveTarget, 'TOPLEFT', -2,0) + KeyBinderUnbindButton:SetPoint('TOPLEFT', kb.saveTarget, 'BOTTOMLEFT', 0, -1) KeyBinderUnbindButton:Show() else KeyBinderUnbindButton:Hide() end - KeyBinderStickyMode.label:SetText(kb.db.stickyMode and 'Sticky' or 'Normal') - KeyBinderHoverInput.label:SetText(kb.db.hoverInput and 'MouseOver' or 'Manual') - -- Reset this so talent cache can be rebuilt kb.talentsPushed = nil end
--- a/SkeletonKey/DynamicTypes.lua Sat Jul 30 03:33:09 2016 -0400 +++ b/SkeletonKey/DynamicTypes.lua Sat Jul 30 19:08:11 2016 -0400 @@ -4,179 +4,3 @@ -- %file-revision% -- Logic related to dynamic handlers local kb, print = LibStub('LibKraken').register(KeyBinder, 'PlayerInfo') - -local PET_SPECIAL_SUBTEXT = 'Special Ability' -local SECONDARY_PROFESSIONS = { - [5] = 3, - [7] = 4, - [9] = 5, - [10] = 6 -} - -kb.TalentCache = {} -kb.ProfessionCache = {} -kb.PetCache = {} -kb.specInfo = {} -kb.UpdateSpecInfo = function() - kb.specInfo.id = GetSpecialization() - kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) - print('|cFF00FF00current spec:|r', kb.specInfo.id, 'of', GetNumSpecializations()) -end - -kb.UpdateTalentInfo = function() - if kb.talentsPushed then - return - end - table.wipe(kb.TalentCache) - 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 {} - talentInfo.row = 1 - talentInfo.col = col - talentInfo.name = talentName - talentInfo.talentID = talentID - talentInfo.selected = selected - talentInfo.available = available - talentInfo.spellID = spellID - kb.TalentCache[spellID] = talentInfo - kb.TalentCache[talentName] = talentInfo - print('Talent ', row, col, spellID, talentName) - end - end - kb.talentsPushed = true - - kb.UpdateDynamicButtons('talent') -end - -kb.UpdateProfessionInfo = function() - table.wipe(kb.ProfessionCache) - local profs = {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 - - - kb.ProfessionCache[profNum] = kb.ProfessionCache[i] or {} - - 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 - } - KeyBinderKey:SetAttribute("*type-profession_"..i .. '_' ..j, "spell") - KeyBinderKey:SetAttribute("*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) - end - - end - - kb.UpdateDynamicButtons('profession') -end - - - -kb.UpdatePetInfo = function() - kb.PetCache.spell = kb.PetCache.spell or {} - kb.PetCache.spellslot = kb.PetCache.spellslot or {} - kb.PetCache.action = kb.PetCache.action or {} - kb.PetCache.special = kb.PetCache.action or {} - local hasPetSpells, petType = HasPetSpells() - if PetHasSpellbook() then - print('PET SPELLBOOK') - local i = 1 - local specialNum = 0 - repeat - - local spellType, spellID = GetSpellBookItemInfo(i, BOOKTYPE_PET) - local spellName, subText = GetSpellBookItemName(i, BOOKTYPE_PET) - local isPassive = IsPassiveSpell(i, BOOKTYPE_PET) - if not isPassive then - if spellName then - kb.PetCache.spellslot[spellName] = {i, spellName, subText} - print('|cFF00FF88spellslot['..spellName..']|r', '=>', i, subText) - - if subText == PET_SPECIAL_SUBTEXT then - specialNum = specialNum + 1 - kb.PetCache.special[spellName] = {i, specialNum, spellID, subText } - print('|cFF00FFFFspecial['..spellName..']|r', '=>', i, specialNum, spellID, subText) - end - - if spellID then - kb.PetCache.spell[i] = {spellID, spellName, subText} - print('|cFF0088FFspell['..i..']|r', '=>', spellID, spellName, subText) - end - end - - - end - - i = i + 1 - until spellType == nil - else - print('NO PET SPELLBOOK') - table.wipe(kb.PetCache.spell) - table.wipe(kb.PetCache.spellslot) - end - - if PetHasActionBar() then - print('PET ACTION BAR') - for i = 1, 10 do - - - local name, subtext, texture, isToken, isActive = GetPetActionInfo(i) - if name then - kb.PetCache.action[i] = {name, subtext, texture, isToken, isActive } - - - end - print('|cFFFFFF00action['..i..']|r', name, subtext, texture) - end - else - print('NO PET ACTION BAR') - table.wipe(kb.PetCache.action) - end - - kb.UpdateDynamicButtons('petaction') - -end - -kb.SystemBinds = {} -kb.UpdateSystemBinds = function() - table.wipe(kb.SystemBinds) - local n = GetNumBindings() - for i=1, n do - local command, key1, key2 = GetBinding(i) - if key1 then - kb.SystemBinds[key1] = command - end - if key2 then - kb.SystemBinds[key2] = command - end - end - -end - -kb.UpdateDynamicButtons = function(dynamicType) - for i, button in ipairs(kb.buttons) do - if button.isDynamic == dynamicType then - kb.UpdateSlot(button, true) - end - end -end \ No newline at end of file
--- a/SkeletonKey/KeySlot.lua Sat Jul 30 03:33:09 2016 -0400 +++ b/SkeletonKey/KeySlot.lua Sat Jul 30 19:08:11 2016 -0400 @@ -236,24 +236,21 @@ if key == 'ESCAPE' then else - if kb.SystemBinds[binding] then - kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', binding, kb.SystemBinds[binding])) + if kb.SystemBindings[binding] then + kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', binding, kb.SystemBindings[binding])) return end if self.command then - local previousKeys local previousAction = GetBindingAction(binding) - local binding1, binding2, new1, new2 - print(type(previousAction), previousAction) if previousAction ~= "" and previousAction ~= self.command then if kb.SystemBindings[binding] then -- bounce out if trying to use a protected key kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, GetBindingAction(binding))) kb.bindingstext:SetText(nil) - return + return false else kb:print('Discarding keybind for', previousAction) -- todo: sort out retcon'd talent spells @@ -298,6 +295,7 @@ end end kb.UpdateSlot(self, true) + return true end @@ -369,14 +367,19 @@ if self.isAvailable then self.bindingText = kb.BindingString(GetBindingKey(self.command)) else - if kb.inactiveTalentBindings[self.actionID] then - print(self.actionID, #kb.inactiveTalentBindings[self.actionID]) - self.bindingText= kb.BindingString(unpack(kb.inactiveTalentBindings[self.actionID])) + if kb.TalentBindings[self.actionID] then + print(self.actionID, #kb.TalentBindings[self.actionID]) + self.bindingText= kb.BindingString(unpack(kb.TalentBindings[self.actionID])) end end - elseif self.isDynamic == 'petaction' and self.command:match("special") then - self.statusText = '|cFF00FF00Pet Special|r' + elseif self.isDynamic == 'petaction' then + local specialNum = self.command:match("special(%d)") + if specialNum then + self.statusText = L('Pet Special %%d'):format(specialNum) + else + self.statusText = L('Pet Action') + end self.bindingText = kb.BindingString(GetBindingKey(self.command)) else self.statusText = '|cFF00FF00'.. (BUTTON_HEADERS[self.actionType] and BUTTON_HEADERS[self.actionType] or self.actionType) .. '|r' @@ -535,14 +538,30 @@ actionID = actionID or 0 self:EnableKeyboard(true) print(' |cFF00FF00kb.currentProfile.buttons['..slot..'] |cFF00FFFF=|r |cFF00FFFF"'.. command.. '"|r |cFF00FF00"'.. name.. '"|r |cFFFFFF00icon:'.. tostring(icon) .. '|r |cFFFF8800"'.. actionType, '"|r |cFFFF0088id:'.. actionID ..'|r |cFF00FF00"'.. macroName .. '"|r') - kb.currentProfile.buttons[slot] = {command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook} + kb.currentProfile.buttons[slot] = {command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook } + -- Clean up conflicting entries for loaded button local previous = kb.currentProfile.commands[command] if previous ~= slot and kb.buttons[previous] then kb.ReleaseSlot(kb.buttons[previous]) end + + if not (kb.IsCommandBound(self, command) or kb.currentProfile.bound[command]) then + + local binds = {GetBindingKey(command) } + if #binds >= 1 then + kb:print('Recovered key binding for', name) + for i, key in ipairs(binds) do + kb.currentProfile.bindings[key] = command + kb.currentProfile.bound[command] = true + end + end + end + + kb.currentProfile.commands[command] = slot + end self.isAvailable = isAvailable
--- a/SkeletonKey/SkeletonKey.lua Sat Jul 30 03:33:09 2016 -0400 +++ b/SkeletonKey/SkeletonKey.lua Sat Jul 30 19:08:11 2016 -0400 @@ -43,8 +43,10 @@ } +kb.SystemBindings = {} +kb.ActionTypes = {} +kb.TalentBindings = {} -kb.inactiveTalentBindings = {} kb.configHeaders = {} kb.loadedProfiles = {} kb.orderedProfiles = {}
--- a/SkeletonKey/SkeletonKey.toc Sat Jul 30 03:33:09 2016 -0400 +++ b/SkeletonKey/SkeletonKey.toc Sat Jul 30 19:08:11 2016 -0400 @@ -7,10 +7,10 @@ ## X-Category: Interface Enhancements ## DefaultState: Enabled ## LoadOnDemand: 0 -## OptionalDeps: LibStub, libKT +## OptionalDeps: LibStub, LibKraken, Devian -LibStub\LibStub.lua -libKT-1.0\libKT-1.0.xml +libs\LibStub\LibStub.lua +libs\LibKraken-1.0\LibKraken-1.0.xml SkeletonKey.xml SkeletonKey.lua ActionTypes.lua
--- a/SkeletonKey/SkeletonKey.xml Sat Jul 30 03:33:09 2016 -0400 +++ b/SkeletonKey/SkeletonKey.xml Sat Jul 30 19:08:11 2016 -0400 @@ -69,11 +69,12 @@ </Texture> </Layer> </Layers> - <HighlightTexture file="Interface\BUTTONS\UI-Button-Outline" alphaMode="ADD"> + <HighlightTexture alphaMode="ADD"> <Anchors> - <Anchor point="TOPLEFT" x="-13" y="13" /> - <Anchor point="BOTTOMRIGHT" x="13" y="-13" /> + <Anchor point="TOPLEFT" x="2" y="-2" /> + <Anchor point="BOTTOMRIGHT" x="-2" y="2" /> </Anchors> + <Color a="1" r="0.15" g="0.15" b="0.15" /> </HighlightTexture> </CheckButton> @@ -203,37 +204,37 @@ </Button> <Button name="$parentUnbindButton" hidden="true"> - <Size x="50" y="20" /> - <NormalTexture> - <Color a="1" r="1" g="0.4" b="0" /> - </NormalTexture> - <HighlightTexture> - - <Color a="1" r="1" g="0.6" b=".1" /> - </HighlightTexture> - <NormalFont style="KTUIPanelFont" /> + <Size x="60" y="24" /> + <Anchors> + <Anchor point="CENTER" /> + </Anchors> <Layers> <Layer level="OVERLAY"> <FontString inherits="KTUIPanelFont" text="Unbind" /> </Layer> </Layers> + <NormalTexture> + <Color a="1" r="1" g="0.4" b="0" /> + </NormalTexture> + <HighlightTexture alphaMode="ADD"> + + <Color a="1" r=".15" g="0.15" b=".15" /> + </HighlightTexture> </Button> <CheckButton name="KeyBinderStickyMode" text="Receiving"> - <Size y="28" /> + <Size y="28" x="72" /> <Anchors> - <Anchor point="BOTTOMLEFT" x="0" y="12" /> - <Anchor point="RIGHT" relativeKey="$parent.sourcesbg" /> + <Anchor point="TOPRIGHT" x="-4" y="-48" relativeKey="$parent.headerbg" /> </Anchors> - <NormalTexture> - <Color a=".5" r=".3" g="0.5" b="0.2" /> - </NormalTexture> - <CheckedTexture> - <Color a="1" r=".3" g="0.9" b=".2" /> - </CheckedTexture> <Layers> <Layer level="OVERLAY"> + <FontString inherits="KTLogString" text="Sticky Mode:"> + <Anchors> + <Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT" x="4" y="4" /> + </Anchors> + </FontString> <FontString parentKey="label" inherits="KTUIPanelFont" text="STICKY_MODE"> <Anchors> <Anchor point="LEFT" x="4" /> @@ -241,20 +242,22 @@ </FontString> </Layer> </Layers> + <NormalTexture> + <Color a=".5" r=".3" g="0.5" b="0.2" /> + </NormalTexture> + <CheckedTexture> + <Color a="1" r=".3" g="0.9" b=".2" /> + </CheckedTexture> + <HighlightTexture alphaMode="ADD"> + <Color a="1" r="0.2" g="0.2" b="0.2" /> + </HighlightTexture> </CheckButton> <CheckButton name="KeyBinderHoverInput"> - <Size y="28" /> + <Size y="28" x="72" /> <Anchors> - <Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT" x="0" y="12" relativeTo="$parentStickyMode" /> - <Anchor point="RIGHT" relativeKey="$parent.sourcesbg" /> + <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" x="-4" y="0" relativeTo="KeyBinderStickyMode" /> </Anchors> - <NormalTexture> - <Color a=".7" r=".5" g=".15" b=".1" /> - </NormalTexture> - <CheckedTexture> - <Color a="1" r="1" g=".3" b=".2" /> - </CheckedTexture> <Layers> <Layer level="OVERLAY"> @@ -262,9 +265,28 @@ <Anchors> <Anchor point="LEFT" x="4" /> </Anchors> - </FontString> + </FontString> + <FontString inherits="KTLogString" text="Bind on:"> + <Anchors> + <Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT" x="4" y="4" /> + </Anchors> + </FontString> + <FontString inherits="KTHeaderFont" text="Options"> + <Anchors> + <Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT" x="4" y="24" /> + </Anchors> + </FontString> </Layer> </Layers> + <NormalTexture> + <Color a=".7" r=".5" g=".15" b=".1" /> + </NormalTexture> + <CheckedTexture> + <Color a="1" r="1" g=".3" b=".2" /> + </CheckedTexture> + <HighlightTexture alphaMode="ADD"> + <Color a="1" r="0.2" g="0.2" b="0.2" /> + </HighlightTexture> </CheckButton> </Frames> </Frame>