refactor(addKeybind): consistency with defaultKey (#128)

This commit is contained in:
Dominic
2022-10-15 19:41:49 -06:00
committed by GitHub
parent a4d553cbb1
commit 63b8afa9ed

View File

@@ -2,7 +2,7 @@
---@field name string ---@field name string
---@field description string ---@field description string
---@field defaultKey? string ---@field defaultKey? string
---@field keybind string ---@field currentKey string
---@field disabled? boolean ---@field disabled? boolean
---@field disable? fun(self: CKeybind, toggle: boolean) ---@field disable? fun(self: CKeybind, toggle: boolean)
---@field onPressed? fun(self: CKeybind) ---@field onPressed? fun(self: CKeybind)
@@ -20,7 +20,7 @@ local IsPauseMenuActive = IsPauseMenuActive
---@return CKeybind ---@return CKeybind
function lib.addKeybind(data) function lib.addKeybind(data)
data.defaultKey = data.defaultKey or '' data.defaultKey = data.defaultKey or ''
data.keybind = GetControlInstructionalButton(0, joaat('+' .. data.name) | 0x80000000, true):sub(3) data.currentKey = GetControlInstructionalButton(0, joaat('+' .. data.name) | 0x80000000, true):sub(3)
data.disabled = data.disabled or false data.disabled = data.disabled or false
data.disable = disableKeybind data.disable = disableKeybind
@@ -34,7 +34,7 @@ function lib.addKeybind(data)
data:onReleased() data:onReleased()
end) end)
RegisterKeyMapping('+' .. data.name, data.description, 'keyboard', data.keybind) RegisterKeyMapping('+' .. data.name, data.description, 'keyboard', data.defaultKey)
SetTimeout(500, function() SetTimeout(500, function()
TriggerEvent('chat:removeSuggestion', ('/+%s'):format(data.name)) TriggerEvent('chat:removeSuggestion', ('/+%s'):format(data.name))