diff SkeletonKey/SkeletonKey.lua @ 16:cdd387d39137

filename refactor
author Nenue
date Fri, 29 Jul 2016 21:18:15 -0400
parents 32d64e42ec9b
children 500f9b2bd9ac
line wrap: on
line diff
--- a/SkeletonKey/SkeletonKey.lua	Fri Jul 29 03:27:15 2016 -0400
+++ b/SkeletonKey/SkeletonKey.lua	Fri Jul 29 21:18:15 2016 -0400
@@ -36,37 +36,6 @@
 local BINDING_TYPE_SPECIALIZATION = 3
 local BINDING_TYPE_CHARACTER = 2
 local BINDING_TYPE_GLOBAL = 1
-
-
---- Caps Lock derivatives
-local ACTION_SCRIPT = {
-  ['mount'] = "/script C_MountJournal.SummonByID(%d)",
-  ['macro'] = "%s",
-  ['equipset'] = "/script UseEquipmentSet(%d)",
-  ['spell'] = "/cast %s",
-  ['petaction'] = "/cast %s",
-  ['battlepet'] = SLASH_SUMMON_BATTLE_PET1 .. " %s",
-  ['item'] = "/use %s"
-}
-
-
-local PETACTION_SCRIPT = {
-  [PET_ACTION_MOVE_TO] = SLASH_PET_MOVE_TO1,
-  [PET_ACTION_ATTACK] = SLASH_PET_ATTACK1,
-  [PET_ACTION_FOLLOW] = SLASH_PET_FOLLOW1,
-  [PET_ACTION_WAIT] = SLASH_PET_STAY1,
-  [PET_MODE_AGGRESSIVE] = SLASH_PET_AGGRESSIVE1,
-  [PET_MODE_DEFENSIVE] = SLASH_PET_DEFENSIVE1,
-  [PET_MODE_PASSIVE] = SLASH_PET_PASSIVE1,
-  [PET_MODE_ASSIST] = SLASH_PET_ASSIST1,
-}
-
-local professionMappings = {
-  [5] = 3,
-  [7] = 4,
-  [9] = 5,
-  [10] = 6
-}
 kb.configTitle = {
   [BINDING_TYPE_GLOBAL] = 'Global Binds',
   [BINDING_TYPE_CHARACTER] = 'Character: %s',
@@ -179,152 +148,8 @@
 end
 
 
---- Resolve the appropriate command and macroText for the given action parameters
-kb.RegisterAction = function(type, id, name)
-  local macroText, macroName, command = '', '', ''
 
-  if type == 'spell' then
-    if kb.ProfessionCache[id] then
-      command = CLICK_KEYBINDER_KEY .. "profession_".. kb.ProfessionCache[id].profOffset .. '_' .. kb.ProfessionCache[id].spellNum
-    else
-      command = CLICK_KEYBINDER_KEY ..name
-    end
-  else
-    macroName = type .. ' ' .. name
-    macroText = ACTION_SCRIPT[type]:format(name)
-    local baseName, iterative = macroName, 1
-    while (macros[macroName] and macros[macroName][1] ~= macroText) do
-      print(' * cannot use|cFF00FF00', macroName, '|r"'.. (macros[macroName][1] or '') .. '"')
-      macroName = baseName .. '_' .. iterative
-      iterative = iterative + 1
-    end
-    if macroName ~= baseName then
-      print(' * Creating|cFF00FF00', macroName)
-    else
-      print(' * Re-using|cFF00FF00', macroName)
-    end
-    command = 'CLICK KeyBinderMacro:'.. macroName
-    macros[macroName] = {macroText, command }
-  end
 
-  print('RegisterAction', type, id, '->', command , macroText)
-  return macroName, macroText, command
-end
-
---- Updates the current KeyBinding for the button's command
-kb.StoreBinding = function(self, key)
-
-  if not self.command then
-    return
-  end
-
-  if key:match('[RL]SHIFT') or key:match('[RL]ALT') or key:match('[RL]CTRL') then
-    return
-  end
-  print('|cFFFFFF00received|cFFFFFF00', self:GetID(), '|cFF00FFFF', key)
-
-  local modifier = ''
-  if IsAltKeyDown() then
-    modifier = 'ALT-'
-  end
-  if IsControlKeyDown() then
-    modifier = modifier.. 'CTRL-'
-  end
-  if IsShiftKeyDown() then
-    modifier = modifier..'SHIFT-'
-  end
-  local binding = modifier..key
-
-  if key == 'ESCAPE' then
-    local keys = {GetBindingKey(self.command) }
-    --print('detected', #keys, 'bindings')
-    for i, key in pairs(keys) do
-      --print('clearing', key)
-      SetBinding(key, nil)
-      SaveBindings(GetCurrentBindingSet())
-      if kb.currentProfile.bindings[key] then
-        kb:print(L('BINDING_REMOVED', self.actionName, kb.configHeaders[db.bindMode]))
-        kb.currentProfile.bindings[key] = nil
-      end
-      if kb.currentProfile.talents[self.actionName] then
-        kb.currentProfile.talents[self.actionName] = nil
-      end
-      bindings[self.actionType][self.actionID] = nil
-    end
-    if kb.currentProfile.bound[self.command] then
-      kb.currentProfile.bound[self.command] = nil
-      --kb:print(BINDING_REMOVED:format(self.actionName, configHeaders[db.bindMode]))
-    end
-
-    bindsCommitted = false
-    self.active = false
-  else
-    if kb.SystemBinds[binding] then
-      kb.statustext:SetText(L('BINDING_FAILED_PROTECTED', key, kb.SystemBinds[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 protected[previousAction] 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
-        else
-          kb:print('Discarding keybind for', previousAction)
-          -- todo: sort out retcon'd talent spells
-        end
-      end
-
-      self.pending = true
-      self.binding = binding
-
-      bindsCommitted = false
-      SetBinding(self.binding, self.command)
-      SaveBindings(GetCurrentBindingSet())
-
-      local talentInfo
-      if self.actionType == 'spell' and kb.TalentCache[self.actionID] then
-        print('conditional binding (talent = "'..self.actionName..'")')
-        talentInfo = {self.macroName, self.actionName, self.actionType, self.actionID}
-        local bindings = {GetBindingKey(self.command) }
-        for i, key in ipairs(bindings) do
-          tinsert(talentInfo, key)
-        end
-      end
-
-      for level, profile in ipairs(kb.orderedProfiles) do
-        if (level == db.bindMode) then
-          profile.bound[self.command] = true
-          if talentInfo then
-            profile.bindings[self.binding] = nil
-          else
-            profile.bindings[self.binding] = self.command
-          end
-          profile.talents[self.actionName] = talentInfo
-        else
-          profile.bindings[self.binding] = nil
-          profile.bound[self.command] = nil
-          kb.currentProfile.talents[self.actionName] = nil
-        end
-        if kb.currentProfile.talents[self.actionID] then
-          kb.currentProfile.talents[self.actionID] = nil
-        end
-      end
-
-      kb:print(L('BINDING_ASSIGNED', self.binding, self.actionName, kb.configHeaders[db.bindMode]))
-    end
-  end
-  kb.UpdateSlot(self, true)
-  KeyBinderSaveButton:Enable()
-end
 
 
 kb.inactiveTalentBindings = {}