Mercurial > wow > skeletonkey
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 18:91398d284a99 | 19:67db6b712bf3 |
|---|---|
| 234 end | 234 end |
| 235 local binding = modifier..key | 235 local binding = modifier..key |
| 236 | 236 |
| 237 if key == 'ESCAPE' then | 237 if key == 'ESCAPE' then |
| 238 else | 238 else |
| 239 if kb.SystemBinds[binding] then | 239 if kb.SystemBindings[binding] then |
| 240 kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', binding, kb.SystemBinds[binding])) | 240 kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', binding, kb.SystemBindings[binding])) |
| 241 return | 241 return |
| 242 end | 242 end |
| 243 | 243 |
| 244 | 244 |
| 245 if self.command then | 245 if self.command then |
| 246 | 246 |
| 247 local previousKeys | |
| 248 local previousAction = GetBindingAction(binding) | 247 local previousAction = GetBindingAction(binding) |
| 249 local binding1, binding2, new1, new2 | |
| 250 print(type(previousAction), previousAction) | |
| 251 if previousAction ~= "" and previousAction ~= self.command then | 248 if previousAction ~= "" and previousAction ~= self.command then |
| 252 if kb.SystemBindings[binding] then | 249 if kb.SystemBindings[binding] then |
| 253 -- bounce out if trying to use a protected key | 250 -- bounce out if trying to use a protected key |
| 254 kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, GetBindingAction(binding))) | 251 kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, GetBindingAction(binding))) |
| 255 kb.bindingstext:SetText(nil) | 252 kb.bindingstext:SetText(nil) |
| 256 return | 253 return false |
| 257 else | 254 else |
| 258 kb:print('Discarding keybind for', previousAction) | 255 kb:print('Discarding keybind for', previousAction) |
| 259 -- todo: sort out retcon'd talent spells | 256 -- todo: sort out retcon'd talent spells |
| 260 end | 257 end |
| 261 end | 258 end |
| 296 | 293 |
| 297 kb:print(L('BINDING_ASSIGNED', self.binding, self.actionName, kb.currentHeader)) | 294 kb:print(L('BINDING_ASSIGNED', self.binding, self.actionName, kb.currentHeader)) |
| 298 end | 295 end |
| 299 end | 296 end |
| 300 kb.UpdateSlot(self, true) | 297 kb.UpdateSlot(self, true) |
| 298 return true | |
| 301 end | 299 end |
| 302 | 300 |
| 303 | 301 |
| 304 --- Updates profile assignment and button contents | 302 --- Updates profile assignment and button contents |
| 305 kb.UpdateSlot = function(self, force) | 303 kb.UpdateSlot = function(self, force) |
| 367 | 365 |
| 368 self.statusText = '|cFF00FFFF'.. TALENT .. '|r' | 366 self.statusText = '|cFF00FFFF'.. TALENT .. '|r' |
| 369 if self.isAvailable then | 367 if self.isAvailable then |
| 370 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | 368 self.bindingText = kb.BindingString(GetBindingKey(self.command)) |
| 371 else | 369 else |
| 372 if kb.inactiveTalentBindings[self.actionID] then | 370 if kb.TalentBindings[self.actionID] then |
| 373 print(self.actionID, #kb.inactiveTalentBindings[self.actionID]) | 371 print(self.actionID, #kb.TalentBindings[self.actionID]) |
| 374 self.bindingText= kb.BindingString(unpack(kb.inactiveTalentBindings[self.actionID])) | 372 self.bindingText= kb.BindingString(unpack(kb.TalentBindings[self.actionID])) |
| 375 end | 373 end |
| 376 | 374 |
| 377 end | 375 end |
| 378 elseif self.isDynamic == 'petaction' and self.command:match("special") then | 376 elseif self.isDynamic == 'petaction' then |
| 379 self.statusText = '|cFF00FF00Pet Special|r' | 377 local specialNum = self.command:match("special(%d)") |
| 378 if specialNum then | |
| 379 self.statusText = L('Pet Special %%d'):format(specialNum) | |
| 380 else | |
| 381 self.statusText = L('Pet Action') | |
| 382 end | |
| 380 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | 383 self.bindingText = kb.BindingString(GetBindingKey(self.command)) |
| 381 else | 384 else |
| 382 self.statusText = '|cFF00FF00'.. (BUTTON_HEADERS[self.actionType] and BUTTON_HEADERS[self.actionType] or self.actionType) .. '|r' | 385 self.statusText = '|cFF00FF00'.. (BUTTON_HEADERS[self.actionType] and BUTTON_HEADERS[self.actionType] or self.actionType) .. '|r' |
| 383 self.bindingText = kb.BindingString(GetBindingKey(self.command)) | 386 self.bindingText = kb.BindingString(GetBindingKey(self.command)) |
| 384 end | 387 end |
| 533 | 536 |
| 534 | 537 |
| 535 actionID = actionID or 0 | 538 actionID = actionID or 0 |
| 536 self:EnableKeyboard(true) | 539 self:EnableKeyboard(true) |
| 537 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') | 540 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') |
| 538 kb.currentProfile.buttons[slot] = {command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook} | 541 kb.currentProfile.buttons[slot] = {command, name, icon, actionType, actionID, macroName, macroText, pickupSlot, pickupBook } |
| 542 | |
| 539 | 543 |
| 540 -- Clean up conflicting entries for loaded button | 544 -- Clean up conflicting entries for loaded button |
| 541 local previous = kb.currentProfile.commands[command] | 545 local previous = kb.currentProfile.commands[command] |
| 542 if previous ~= slot and kb.buttons[previous] then | 546 if previous ~= slot and kb.buttons[previous] then |
| 543 kb.ReleaseSlot(kb.buttons[previous]) | 547 kb.ReleaseSlot(kb.buttons[previous]) |
| 544 end | 548 end |
| 549 | |
| 550 if not (kb.IsCommandBound(self, command) or kb.currentProfile.bound[command]) then | |
| 551 | |
| 552 local binds = {GetBindingKey(command) } | |
| 553 if #binds >= 1 then | |
| 554 kb:print('Recovered key binding for', name) | |
| 555 for i, key in ipairs(binds) do | |
| 556 kb.currentProfile.bindings[key] = command | |
| 557 kb.currentProfile.bound[command] = true | |
| 558 end | |
| 559 end | |
| 560 end | |
| 561 | |
| 562 | |
| 545 kb.currentProfile.commands[command] = slot | 563 kb.currentProfile.commands[command] = slot |
| 564 | |
| 546 end | 565 end |
| 547 | 566 |
| 548 self.isAvailable = isAvailable | 567 self.isAvailable = isAvailable |
| 549 self.isDynamic = isDynamic | 568 self.isDynamic = isDynamic |
| 550 | 569 |
