comparison SkeletonKey/SkeletonKey.lua @ 50:1aba8a6fd4a9

- fix kb.bindings content and define a generic function for constructing its keystrings - handle hotkey text for actions placed in multiple slots -- hotkey.actionbar generates a cache table for use during binding changes
author Nenue
date Fri, 19 Aug 2016 01:12:56 -0400
parents 73df13211b22
children 81a7c71c4483
comparison
equal deleted inserted replaced
49:9a9d7f2a7c07 50:1aba8a6fd4a9
70 70
71 -- these are sent to plugin 71 -- these are sent to plugin
72 72
73 73
74 local db 74 local db
75 local bindHeader, currentHeader = '', '' 75 local _G = _G
76 local specID, specGlobalID, specName, specDesc, specTexture, characterHeader = 0, 0, 'SPEC_NAME', 'SPEC_DESCRIPTION', 'Interface\\ICONS\\INV_Misc_QuestionMark', 'PLAYER_NAME' 76 local UnitName, SelectedRealmName, InCombatLockdown, UnitClass = UnitName, SelectedRealmName, InCombatLockdown, UnitClass
77 local tostring, select, tinsert, pairs = tostring, select, tinsert, pairs
78 local concat, wipe = table.concat, table.wipe
77 local classHeader, className, classID = '', '', 0 79 local classHeader, className, classID = '', '', 0
78 local bindsCommitted = true
79 local forceButtonUpdate = false
80 80
81 --- Control handles 81 --- Control handles
82 local saveButton, restoreButton, clearButton 82 local saveButton, restoreButton, clearButton
83 83
84 --- Returns conflicting assignment and binding profiles for use in displaying confirmations 84 --- Returns conflicting assignment and binding profiles for use in displaying confirmations
137 local key = select(i, ...) 137 local key = select(i, ...)
138 stack[i] = key:gsub('SHIFT', 's'):gsub('ALT', 'a'):gsub('CTRL', 'c'):gsub('SPACE', 'Sp'):gsub('BUTTON', 'M '):gsub('NUMPAD', '# ') 138 stack[i] = key:gsub('SHIFT', 's'):gsub('ALT', 'a'):gsub('CTRL', 'c'):gsub('SPACE', 'Sp'):gsub('BUTTON', 'M '):gsub('NUMPAD', '# ')
139 end 139 end
140 140
141 if #stack >= 1 then 141 if #stack >= 1 then
142 return table.concat(stack, ',') 142 return concat(stack, ',')
143 else 143 else
144 return nil 144 return nil
145 end 145 end
146 end 146 end
147 147
195 return profile 195 return profile
196 end 196 end
197 197
198 kb.ResetProfile = function(profile, prototype) 198 kb.ResetProfile = function(profile, prototype)
199 if profile == kb.currentProfile then 199 if profile == kb.currentProfile then
200 for i, button in pairs(buttons) do 200 for i, button in pairs(kb.buttons) do
201 kb.ReleaseSlot(button) 201 kb.ReleaseSlot(button)
202 end 202 end
203 end 203 end
204 table.wipe(profile) 204 wipe(profile)
205 kb.InitProfile(profile, prototype) 205 kb.InitProfile(profile, prototype)
206 end 206 end
207 207
208 208
209 209
282 kb.ConfirmBindings = function() 282 kb.ConfirmBindings = function()
283 kb.ApplyAllBindings() 283 kb.ApplyAllBindings()
284 kb.ui() 284 kb.ui()
285 end 285 end
286 286
287
288
289
290 --- post ADDON_LOADED 287 --- post ADDON_LOADED
291 kb.variables = function() 288 kb.variables = function()
292 SkeletonKeyDB = kb.InitProfile(SkeletonKeyDB, {}) 289 _G.SkeletonKeyDB = kb.InitProfile(_G.SkeletonKeyDB, {})
293 kb.db = SkeletonKeyDB 290 kb.db = _G.SkeletonKeyDB
294 kb.playerName = UnitName('player') 291 kb.playerName = UnitName('player')
295 kb.playerRealm = SelectedRealmName() 292 kb.playerRealm = SelectedRealmName()
296 kb.profileName = kb.playerRealm .. '_' .. kb.playerName 293 kb.profileName = kb.playerRealm .. '_' .. kb.playerName
297 db = kb.db 294 db = kb.db
298 295
320 kb.modules = kb.modules or {} 317 kb.modules = kb.modules or {}
321 tinsert(kb.modules, module) 318 tinsert(kb.modules, module)
322 end 319 end
323 320
324 -- Volatiles Access 321 -- Volatiles Access
322 kb.FormatActionID = function(actionType, actionID) return tostring(actionType) .. '_' .. tostring(actionID) end
325 kb.GetBindings = function() return kb.bindings end 323 kb.GetBindings = function() return kb.bindings end
326 kb.GetButtons = function() return kb.buttons end 324 kb.GetButtons = function() return kb.buttons end
327 kb.GetCharacterProfile = function () return kb.loadedProfiles[BINDING_TYPE_CHARACTER] end 325 kb.GetCharacterProfile = function () return kb.loadedProfiles[BINDING_TYPE_CHARACTER] end
328 kb.GetGlobalProfile = function () return kb.loadedProfiles[BINDING_TYPE_GLOBAL] end 326 kb.GetGlobalProfile = function () return kb.loadedProfiles[BINDING_TYPE_GLOBAL] end
329 kb.GetSpecProfile = function () return kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION] end 327 kb.GetSpecProfile = function () return kb.loadedProfiles[BINDING_TYPE_SPECIALIZATION] end