Mercurial > wow > skeletonkey
comparison SkeletonKey/SkeletonKey.lua @ 15:32d64e42ec9b
- resolve pet bar actions for binding slots
- detect type of petaction (can be spell, stance, or 'PETACTION')
- keep track of displayed pet ability slots and update them alongside pet cache refreshes
| author | Nenue |
|---|---|
| date | Fri, 29 Jul 2016 03:27:15 -0400 |
| parents | 82170735e67c |
| children | cdd387d39137 |
comparison
equal
deleted
inserted
replaced
| 14:82170735e67c | 15:32d64e42ec9b |
|---|---|
| 47 ['petaction'] = "/cast %s", | 47 ['petaction'] = "/cast %s", |
| 48 ['battlepet'] = SLASH_SUMMON_BATTLE_PET1 .. " %s", | 48 ['battlepet'] = SLASH_SUMMON_BATTLE_PET1 .. " %s", |
| 49 ['item'] = "/use %s" | 49 ['item'] = "/use %s" |
| 50 } | 50 } |
| 51 | 51 |
| 52 | |
| 53 local PETACTION_SCRIPT = { | |
| 54 [PET_ACTION_MOVE_TO] = SLASH_PET_MOVE_TO1, | |
| 55 [PET_ACTION_ATTACK] = SLASH_PET_ATTACK1, | |
| 56 [PET_ACTION_FOLLOW] = SLASH_PET_FOLLOW1, | |
| 57 [PET_ACTION_WAIT] = SLASH_PET_STAY1, | |
| 58 [PET_MODE_AGGRESSIVE] = SLASH_PET_AGGRESSIVE1, | |
| 59 [PET_MODE_DEFENSIVE] = SLASH_PET_DEFENSIVE1, | |
| 60 [PET_MODE_PASSIVE] = SLASH_PET_PASSIVE1, | |
| 61 [PET_MODE_ASSIST] = SLASH_PET_ASSIST1, | |
| 62 } | |
| 63 | |
| 52 local professionMappings = { | 64 local professionMappings = { |
| 53 [5] = 3, | 65 [5] = 3, |
| 54 [7] = 4, | 66 [7] = 4, |
| 55 [9] = 5, | 67 [9] = 5, |
| 56 [10] = 6 | 68 [10] = 6 |
| 72 kb.configHeaders = {} | 84 kb.configHeaders = {} |
| 73 kb.loadedProfiles = {} | 85 kb.loadedProfiles = {} |
| 74 kb.orderedProfiles = {} | 86 kb.orderedProfiles = {} |
| 75 kb.buttons = {} | 87 kb.buttons = {} |
| 76 kb.macros = {} | 88 kb.macros = {} |
| 89 kb.petFrames = {} -- pet data is slightly delayed, their buttons are indexed here so they can be refreshed | |
| 90 kb.talentFrames = {} | |
| 91 kb.professionFrames = {} | |
| 77 | 92 |
| 78 -- these are sent to plugin | 93 -- these are sent to plugin |
| 79 | 94 |
| 80 local bindings = {} | 95 local bindings = {} |
| 81 local macros = {} | 96 local macros = {} |
| 205 | 220 |
| 206 if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then | 221 if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then |
| 207 return | 222 return |
| 208 end | 223 end |
| 209 print('|cFFFFFF00received|cFFFFFF00', self:GetID(), '|cFF00FFFF', key) | 224 print('|cFFFFFF00received|cFFFFFF00', self:GetID(), '|cFF00FFFF', key) |
| 225 | |
| 226 local modifier = '' | |
| 227 if IsAltKeyDown() then | |
| 228 modifier = 'ALT-' | |
| 229 end | |
| 230 if IsControlKeyDown() then | |
| 231 modifier = modifier.. 'CTRL-' | |
| 232 end | |
| 233 if IsShiftKeyDown() then | |
| 234 modifier = modifier..'SHIFT-' | |
| 235 end | |
| 236 local binding = modifier..key | |
| 210 | 237 |
| 211 if key == 'ESCAPE' then | 238 if key == 'ESCAPE' then |
| 212 local keys = {GetBindingKey(self.command) } | 239 local keys = {GetBindingKey(self.command) } |
| 213 --print('detected', #keys, 'bindings') | 240 --print('detected', #keys, 'bindings') |
| 214 for i, key in pairs(keys) do | 241 for i, key in pairs(keys) do |
| 230 end | 257 end |
| 231 | 258 |
| 232 bindsCommitted = false | 259 bindsCommitted = false |
| 233 self.active = false | 260 self.active = false |
| 234 else | 261 else |
| 235 | 262 if kb.SystemBinds[binding] then |
| 236 local modifier = '' | 263 kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, kb.SystemBinds[binding])) |
| 237 if IsAltKeyDown() then | 264 return |
| 238 modifier = 'ALT-' | |
| 239 end | |
| 240 if IsControlKeyDown() then | |
| 241 modifier = modifier.. 'CTRL-' | |
| 242 end | |
| 243 if IsShiftKeyDown() then | |
| 244 modifier = modifier..'SHIFT-' | |
| 245 end | 265 end |
| 246 | 266 |
| 247 | 267 |
| 248 if self.command then | 268 if self.command then |
| 249 self.binding = modifier..key | |
| 250 | 269 |
| 251 local previousKeys | 270 local previousKeys |
| 252 local previousAction = GetBindingAction(self.binding) | 271 local previousAction = GetBindingAction(binding) |
| 253 local binding1, binding2, new1, new2 | 272 local binding1, binding2, new1, new2 |
| 254 print(type(previousAction), previousAction) | 273 print(type(previousAction), previousAction) |
| 255 if previousAction ~= "" and previousAction ~= self.command then | 274 if previousAction ~= "" and previousAction ~= self.command then |
| 256 if protected[previousAction] then | 275 if protected[previousAction] then |
| 257 -- bounce out if trying to use a protected key | 276 -- bounce out if trying to use a protected key |
| 258 kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, GetBindingAction(previousAction))) | 277 kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, GetBindingAction(binding))) |
| 259 kb.bindingstext:SetText(nil) | 278 kb.bindingstext:SetText(nil) |
| 260 return | 279 return |
| 261 else | 280 else |
| 262 kb:print('Discarding keybind for', previousAction) | 281 kb:print('Discarding keybind for', previousAction) |
| 263 -- todo: sort out retcon'd talent spells | 282 -- todo: sort out retcon'd talent spells |
| 264 end | 283 end |
| 265 end | 284 end |
| 266 | 285 |
| 267 self.pending = true | 286 self.pending = true |
| 287 self.binding = binding | |
| 268 | 288 |
| 269 bindsCommitted = false | 289 bindsCommitted = false |
| 270 SetBinding(self.binding, self.command) | 290 SetBinding(self.binding, self.command) |
| 271 SaveBindings(GetCurrentBindingSet()) | 291 SaveBindings(GetCurrentBindingSet()) |
| 272 | 292 |
| 385 end | 405 end |
| 386 | 406 |
| 387 kb.ApplyAllBindings =function () | 407 kb.ApplyAllBindings =function () |
| 388 table.wipe(kb.inactiveTalentBindings) | 408 table.wipe(kb.inactiveTalentBindings) |
| 389 | 409 |
| 410 | |
| 390 -- reflect action key settings | 411 -- reflect action key settings |
| 391 if GetCVarBool("ActionButtonUseKeyDown") then | 412 if GetCVarBool("ActionButtonUseKeyDown") then |
| 392 KeyBinderMacro:RegisterForClicks("AnyDown") | 413 KeyBinderMacro:RegisterForClicks("AnyDown") |
| 393 KeyBinderKey:RegisterForClicks("AnyDown") | 414 KeyBinderKey:RegisterForClicks("AnyDown") |
| 394 else | 415 else |
| 491 --- Mutable skills data | 512 --- Mutable skills data |
| 492 kb.UpdateSpecInfo() | 513 kb.UpdateSpecInfo() |
| 493 kb.UpdateTalentInfo() | 514 kb.UpdateTalentInfo() |
| 494 | 515 |
| 495 kb.orderedProfiles = {kb.loadedProfiles[BINDING_TYPE_GLOBAL], kb.loadedProfiles[BINDING_TYPE_CHARACTER], kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION]} | 516 kb.orderedProfiles = {kb.loadedProfiles[BINDING_TYPE_GLOBAL], kb.loadedProfiles[BINDING_TYPE_CHARACTER], kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION]} |
| 496 if db.bindMode and (not kb.configTitle[db.bindMode]) then | 517 if (not db.bindMode) or (not kb.configTitle[db.bindMode]) then |
| 497 print('fixing bad bindMode value, was', db.bindMode) | 518 print('fixing bad bindMode value, was', db.bindMode) |
| 498 db.bindMode = defaultMode | 519 db.bindMode = defaultMode |
| 499 end | 520 end |
| 500 | 521 |
| 501 | 522 |
| 525 kb.RevertBindings = function() | 546 kb.RevertBindings = function() |
| 526 -- todo: reversion code | 547 -- todo: reversion code |
| 527 end | 548 end |
| 528 | 549 |
| 529 kb.ConfirmBindings = function() | 550 kb.ConfirmBindings = function() |
| 530 SaveBindings(GetCurrentBindingSet()) | |
| 531 bindsCommitted = true | |
| 532 for i, button in ipairs(buttons) do | |
| 533 button.pending = false | |
| 534 end | |
| 535 kb.ApplyAllBindings() | 551 kb.ApplyAllBindings() |
| 536 | |
| 537 kb.ui() | 552 kb.ui() |
| 538 kb:print('Keybinds saved.') | |
| 539 end | 553 end |
| 540 | 554 |
| 541 | 555 |
| 542 | 556 |
| 543 | 557 |
| 551 db = kb.db | 565 db = kb.db |
| 552 | 566 |
| 553 kb.SelectProfileSet(kb.profileName) | 567 kb.SelectProfileSet(kb.profileName) |
| 554 -- todo: redo import checking | 568 -- todo: redo import checking |
| 555 | 569 |
| 556 | 570 kb.UpdateSystemBinds() |
| 557 | |
| 558 kb.ApplyAllBindings() | 571 kb.ApplyAllBindings() |
| 559 | 572 |
| 560 kb.ui(true) | 573 kb.ui(true) |
| 561 end | 574 end |
| 562 | 575 |
