diff KeyButton.lua @ 80:b9a53385462c

- Fixed Demon Hunter Vengeance bindings, along with other spells that are replaced by specialization variants. - Spells replaced by a specialization now display the replacing name along with the original name in their binding slot.
author Nick@Zahhak
date Tue, 21 Mar 2017 02:23:23 -0400
parents d4c100b0fd01
children 9a206b105ea5
line wrap: on
line diff
--- a/KeyButton.lua	Thu Jan 26 20:27:06 2017 -0500
+++ b/KeyButton.lua	Tue Mar 21 02:23:23 2017 -0400
@@ -22,7 +22,8 @@
 local BORDER_UNASSIGNED = {0.6,0.6,0.6,1}
 local BORDER_ASSIGNED = {1,1,1,1}
 local BORDER_DYNAMIC = {1,1,0,1}
-local BORDER_PENDING = {1,0.5,0,1 }
+local BORDER_PENDING = {1,0.5,0,1}
+local BORDER_REPLACED = {0,1,.5,1}
 local BUTTON_HEADERS = {
   ['spell'] = SPELLS,
   ['macro'] = MACRO,
@@ -144,7 +145,7 @@
   elseif click == 'RightButton' then
     self:ReleaseSlot()
   else
-    kb.ProcessInput(strupper(click))
+    SkeletonKey:ProcessInput(strupper(click))
   end
   SkeletonKey:Update()
 end
@@ -174,9 +175,8 @@
     local pickupID, pickupBook
 
     if actionType == 'spell' then
-      actionID = subData
-      name, _, icon = GetSpellInfo(actionID)
-
+      local realName = GetSpellInfo(subData)
+      name, _, icon, _, _, _, actionID = GetSpellInfo(subData)
     elseif actionType == 'macro' then
       name, icon, macroText = GetMacroInfo(actionID)
       macroName = name
@@ -311,13 +311,16 @@
   end
 
   local borderType = BORDER_UNASSIGNED
-
+  local displayName = self.actionName
+  local displayTexture = self.iconPath
+  local altName, altTexture
   if self.command then
 
-    print('|cFFFF4400', self.actionName, #self.assignedKeys, table.concat(self.assignedKeys, ','))
-    print(self.isAvailable)
-    print(self.actionID)
+    print('|cFFFF4400:', self.actionName, #self.assignedKeys, table.concat(self.assignedKeys, ','))
+    print('|cFF00FF88:', self.isAvailable, self.actionID)
+
     self.bindingText= kb.BindingString(unpack(self.assignedKeys))
+
     if not self.isAvailable then
       borderType = BORDER_DYNAMIC
       self.ignoreTexture:Show()
@@ -338,7 +341,14 @@
     else
       self.macro:Hide()
       if self.actionType == 'spell' then
-        self.isAvailable = GetSpellInfo(self.actionName) and true or false
+        altName, _, altTexture = GetSpellInfo(self.actionName)
+        self.isAvailable = displayName and true or false
+        if altName and (altName ~= self.actionName) then
+          displayName = '|cFFFFFF00'..altName..'|r ('..self.actionName..')'
+          displayTexture = altTexture
+          borderType = BORDER_REPLACED
+        end
+
       end
     end
 
@@ -363,14 +373,7 @@
     end
 
 
-    if self.actionType == 'spell' then
-      self.icon:SetTexture(GetSpellTexture(self.actionID))
-    end
     print('|cFF00BBFFUpdateSlot|r:', '['..slot..'] =', self.command, self.bindingText, self.dynamicType, self.isAvailable, self.actionID)
-  else
-    if kb.saveTarget == self then
-      kb.DeactivateSlot(self)
-    end
 
   end
 
@@ -394,18 +397,23 @@
 
   --self.alert:SetShown(self.command and not self.isBound)
 
-  self.icon:SetTexture(self.iconPath)
+  self.icon:SetTexture(displayTexture)
 
   self.border:SetColorTexture(unpack(borderType))
   self.header:SetText(self.statusText)
   self.bind:SetText(self.bindingText)
-  self.details:SetText(self.actionName)
+  self.details:SetText(displayName)
 end
 
 --- Resets button command
 function skb:ReleaseSlot ()
   local slot = self:GetID()
 
+  -- keep right click from deleting an assignment during bind mode
+  if kb.saveTarget == self then
+    self:GetParent():DeactivateSlot(self)
+    return
+  end
 
   if kb.currentProfile.buttons[slot] then
     kb.currentProfile.buttons[slot] = nil
@@ -597,9 +605,14 @@
     self:EnableKeyboard(true)
 
     -- this is done to keep legacy key-values from breaking algorithm assumptions
-    print(slotInfo.assignedKeys)
-    print(GetBindingKey(command))
-    self.assignedKeys = slotInfo.assignedKeys or {GetBindingKey(command)}
+    print('assigned', table.concat(slotInfo.assignedKeys,', '))
+
+    if #slotInfo.assignedKeys == 0 then
+      print('updating assigned table to:', GetBindingKey(command))
+      slotInfo.assignedKeys = {GetBindingKey(command) }
+    end
+
+    self.assignedKeys = slotInfo.assignedKeys
 
     local slotInfo = {
       command = command,