Files
community_bridge/modules/menu/_qb-menu.lua
T
MrNewb c71a261115 chore(intellisense): improve parameter annotations and add missing comments
Touched up incorrect or missing Intellisense parameter annotations across several functions. Added some missing descriptions to improve editor support. Still more to do, but this is a small step forward for overall developer workflow. Also small fix in picklexp
2025-06-07 22:50:13 -04:00

43 lines
1.2 KiB
Lua

local resourceName = "qb-menu"
local configValue = BridgeClientConfig.MenuSystem
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
---Converts an Ox menu to a QB menu.
---@param id string The menu ID.
---@param menu table The Ox menu data.
---@return table The QB menu data.
function OxToQBMenu(id, menu)
local qbMenu = {
{
header = menu.title,
isMenuHeader = true,
}
}
for i, v in pairs(menu.options) do
local button = {
header = v.title,
txt = v.description,
icon = v.icon,
disabled = v.disabled,
}
if v.onSelect then
button.params = {
event = "community_bridge:client:MenuCallback",
args = {id = id, selected = i, args = v.args, onSelect = v.onSelect},
}
end
table.insert(qbMenu, button)
end
return qbMenu
end
OpenMenu = function(id, data, useQBinput)
if not useQBinput then
data = OxToQBMenu(id, data)
end
exports['qb-menu']:openMenu(data)
return data
end