changeset 57:9eebce04e69b

- Prevent bind settings from being updated in combat. - Close the UI during combat. - Resolve conflicting keybinds and inform the user of any results. - Resolve conflicts for talents, but only when they are active.
author Nenue
date Mon, 22 Aug 2016 09:24:02 -0400
parents 2a95f4010c5a
children 39cfd8e142f9
files LibKraken/LibKraken.lua SkeletonKey/ActionTemplates.lua SkeletonKey/BindingsFrame.lua SkeletonKey/Events.lua SkeletonKey/HotKey.lua
diffstat 5 files changed, 50 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/LibKraken/LibKraken.lua	Sun Aug 21 07:19:01 2016 -0400
+++ b/LibKraken/LibKraken.lua	Mon Aug 22 09:24:02 2016 -0400
@@ -281,15 +281,15 @@
     end
   end
 
+  local debugFunc = emptyFunc
+  --@debug@
   local debugID = isModule and name or handler
-  local debugFunc = emptyFunc
   if (handler.DEVIAN_PNAME and DEVIAN_PNAME == handler.DEVIAN_PNAME) or ((not handler.DEVIAN_PNAME) and DEVIAN_WORKSPACE) then
     debuggers[debugID] = debuggers[debugID] or function(...) _G.print(name, ...) end
     debugFunc = debuggers[debugID]
   end
-
   print(loadedName)
-
+  --@end-debug@
   return handler, debugFunc, KT.wrap
 end
 
--- a/SkeletonKey/ActionTemplates.lua	Sun Aug 21 07:19:01 2016 -0400
+++ b/SkeletonKey/ActionTemplates.lua	Mon Aug 22 09:24:02 2016 -0400
@@ -328,23 +328,21 @@
           spellCache[k] = v
         end
       end
-      petSpellCache = spellCache
     end
+    petSpellCache = spellCache
     if petSubtextCache then
       for k,v in pairs(petSubtextCache) do
         if not subtextCache[k] then
           subtextCache[k] = v
         end
       end
-      petSubtextCache = subtextCache
     end
+    petSubtextCache = subtextCache
   else
     petSpellCache = {}
     petSubtextCache = {}
   end
 
-
-
   if PetHasSpellbook() then
     print('PET SPELLBOOK')
     local i = 1
--- a/SkeletonKey/BindingsFrame.lua	Sun Aug 21 07:19:01 2016 -0400
+++ b/SkeletonKey/BindingsFrame.lua	Mon Aug 22 09:24:02 2016 -0400
@@ -51,6 +51,7 @@
 local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
 local GetBindingAction, GetBindingKey, GetCurrentBindingSet = GetBindingAction, GetBindingKey, GetCurrentBindingSet
 local SetBinding, SaveBindings = SetBinding, SaveBindings
+local GetSpellInfo, InCombatLockdown = GetSpellInfo, InCombatLockdown
 
 kb.ProcessInput = function(key)
   if key == 'ESCAPE' then
@@ -499,6 +500,12 @@
   if not self.command then
     return
   end
+  if InCombatLockdown() then
+    kb:print(L('Bindings cannot be changed during combat.'))
+    return
+  end
+
+
   print('|cFFFFFF00received|cFFFFFF00', self:GetID(), '|cFF00FFFF', key)
 
   local modifier = ''
@@ -544,7 +551,8 @@
   for i, key in ipairs(currentHotKeys) do
     if key == binding then
       found = true
-      kb:print('hotkey already assigned')
+      print('|cFFFF4400key already bound to this')
+      return true
     end
   end
   if not found then
@@ -552,6 +560,34 @@
     kb.UpdateBindingsCache(self.actionType, self.actionID, currentHotKeys)
   end
 
+  -- scour profile data for any conflicting binds
+  local currentAction = GetBindingAction(binding)
+  if match(currentAction, 'KeyBinder') then
+    if currentAction ~= self.command then
+      print('|cFFFF4400removing bindings for:', currentAction)
+      for profileID, profileData in ipairs(kb.loadedProfiles) do
+        local buttonID = profileData.commands[currentAction]
+        if buttonID then
+          local buttonAction = profileData.buttons[buttonID][2]
+          if buttonAction then
+            local talentInfo = profileData.talents[buttonAction]
+            if talentInfo and GetSpellInfo(buttonAction) then
+              for i = #talentInfo, 5, -1  do
+                if binding == talentInfo[i] then
+                  tremove(talentInfo, i)
+                end
+              end
+              kb:print(L('Overwrote talent |cFF88FF00%s|r in |cFF00FFFF%s|r', buttonAction, kb.configHeaders[profileID]))
+            else
+
+              kb:print(L('Overwrote |cFFFFFF00%s|r in |cFF00FFFF%s|r', buttonAction, kb.configHeaders[profileID]))
+            end
+            profileData.bindings[binding] = nil
+          end
+        end
+      end
+    end
+  end
 
 
   print('SetBinding', binding, self.command)
@@ -588,8 +624,9 @@
     end
   end
 
+
   kb:print(L('BINDING_ASSIGNED', self.binding, self.actionName, kb.currentHeader))
-  kb.UpdateSlot(self, true)
+  kb.ui()
   return true
 end
 
--- a/SkeletonKey/Events.lua	Sun Aug 21 07:19:01 2016 -0400
+++ b/SkeletonKey/Events.lua	Mon Aug 22 09:24:02 2016 -0400
@@ -25,7 +25,7 @@
 end
 
 kb.PLAYER_REGEN_DISABLED = function()
-  kb.ui()
+  kb:Hide()
 end
 
 kb.UNIT_PORTRAIT_UPDATE = function()
--- a/SkeletonKey/HotKey.lua	Sun Aug 21 07:19:01 2016 -0400
+++ b/SkeletonKey/HotKey.lua	Mon Aug 22 09:24:02 2016 -0400
@@ -111,7 +111,7 @@
   if bindings[indexKey] then
     --print('|cFFFFFF00'..frame:GetName(), actionType, actionID, hasAction)
     local binds = bindings[indexKey]
-    if binds  then
+    if binds and (not frame.HotKey:IsVisible()) then
       if hasAction then
         local bindingsText = kb.BindingString(unpack(binds))
 
@@ -121,6 +121,10 @@
           hotkeyText[frame]:SetFont(frame.HotKey:GetFont())
           hotkeyText[frame]:SetTextColor(frame.HotKey:GetTextColor())
           hotkeyText[frame]:SetPoint('TOPRIGHT', frame.HotKey, 'TOPRIGHT')
+
+          hooksecurefunc(frame.HotKey, 'SetVertexColor', function(self, r,g,b,a)
+            hotkeyText[frame]:SetTextColor(r,g,b,a)
+          end)
         end
 
         hotkeyText[frame]:SetText(bindingsText)