Mercurial > wow > skeletonkey
diff SkeletonKey/KeySlot.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 | 91398d284a99 |
children | 564015ef0317 |
line wrap: on
line diff
--- 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