Mercurial > wow > skeletonkey
comparison SkeletonKey/ActionTemplates.lua @ 67:ecd6c6116b9c
make item bindings great again
| author | Nenue |
|---|---|
| date | Sat, 10 Sep 2016 20:56:19 -0400 |
| parents | 41f367b832a2 |
| children |
comparison
equal
deleted
inserted
replaced
| 66:41f367b832a2 | 67:ecd6c6116b9c |
|---|---|
| 95 atype['battlepet'] = function(id, name) | 95 atype['battlepet'] = function(id, name) |
| 96 return CLICK_KEYBINDER_MACRO, 'battlepet_' .. tostring(name), SLASH_SUMMON_BATTLE_PET1 .. " " .. tostring(name) | 96 return CLICK_KEYBINDER_MACRO, 'battlepet_' .. tostring(name), SLASH_SUMMON_BATTLE_PET1 .. " " .. tostring(name) |
| 97 end | 97 end |
| 98 | 98 |
| 99 atype['item'] = function(id, name) | 99 atype['item'] = function(id, name) |
| 100 return CLICK_KEYBINDER_KEY, 'item_' .. tostring(name), id | 100 return CLICK_KEYBINDER_KEY, tostring(name), id |
| 101 end | 101 end |
| 102 | 102 |
| 103 | 103 |
| 104 --- Resolves the SecureActionButton attribute names used for the given action | 104 --- Resolves the SecureActionButton attribute names used for the given action |
| 105 kb.RegisterAction = function(actionType, id, name) | 105 kb.RegisterAction = function(actionType, id, name) |
| 135 local bindings = kb.bindings | 135 local bindings = kb.bindings |
| 136 local key, macro = KeyBinderKey, KeyBinderMacro | 136 local key, macro = KeyBinderKey, KeyBinderMacro |
| 137 kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText ) | 137 kb.LoadBinding = function(command, name, icon, actionType, actionID, macroName, macroText ) |
| 138 | 138 |
| 139 local indexKey = actionType..'_'..actionID | 139 local indexKey = actionType..'_'..actionID |
| 140 local buttonTypeKey, buttonTypeValue = "*type-"..name, actionType | 140 local buttonTypeSuffix, buttonType = name, actionType |
| 141 local buttonActionKey, buttonActionValue = "*"..actionType.."-"..name, actionID | 141 local actionKey, actionValue = "*"..actionType.."-"..name, actionID |
| 142 local button = key | 142 local button = key |
| 143 if actionType == 'spell' then | 143 if actionType == 'spell' then |
| 144 buttonTypeKey = name | 144 buttonTypeSuffix = name |
| 145 buttonTypeValue = actionType | 145 buttonType = actionType |
| 146 buttonActionKey = "*"..actionType.."-"..name | 146 actionValue = name |
| 147 buttonActionValue = name | |
| 148 elseif actionType == 'item' then | 147 elseif actionType == 'item' then |
| 149 buttonTypeKey = name | 148 buttonTypeSuffix = name |
| 150 buttonTypeValue = actionType | 149 buttonType = actionType |
| 151 buttonActionKey = "*"..actionType.."-"..name | 150 actionValue = name |
| 152 buttonActionValue = actionID | |
| 153 elseif actionType == 'macro' then | |
| 154 button = macro | |
| 155 buttonTypeKey = macroName | |
| 156 buttonTypeValue = "macro" | |
| 157 buttonActionKey = "*macro-" .. macroName | |
| 158 buttonActionValue = name | |
| 159 else | 151 else |
| 160 button = macro | 152 button = macro |
| 161 buttonTypeKey = macroName | 153 buttonTypeSuffix = macroName |
| 162 buttonTypeValue = macroText | 154 buttonType = 'macro' |
| 163 buttonActionKey = nil | 155 if actionType == 'macro' then |
| 164 end | 156 actionKey = "*macro-" .. macroName |
| 165 | 157 actionValue = name |
| 166 --cprint(actionType, actionID, name) | 158 else |
| 167 kb.SecureAttribute(button, "*type-"..buttonTypeKey, buttonTypeValue) | 159 actionKey = '*macrotext-'..macroName |
| 168 if buttonActionKey then | 160 actionValue = macroText |
| 169 --cprint(button:GetName(), buttonActionKey,'=', buttonActionValue) | 161 end |
| 170 kb.SecureAttribute(button, buttonActionKey, buttonActionValue) | 162 end |
| 171 end | 163 |
| 164 kb.SecureAttribute(button, "*type-"..buttonTypeSuffix, buttonType) | |
| 165 kb.SecureAttribute(button, actionKey, actionValue) | |
| 172 | 166 |
| 173 kb.bindings[indexKey] = kb.bindings[indexKey] or {} | 167 kb.bindings[indexKey] = kb.bindings[indexKey] or {} |
| 174 kb.bindings[command] = kb.bindings[indexKey] | 168 kb.bindings[command] = kb.bindings[indexKey] |
| 175 commandActions[command] = indexKey | 169 commandActions[command] = indexKey |
| 176 return bindings[indexKey], actionID | 170 return bindings[indexKey], actionID |
