Files
community_bridge/modules/menu/_qb-menu.lua
T
cityparadise 8c4c170e64 Added Accessibility Module w/ Misc Fix
-- Added new accessibility module
-- Added multiple colour convert functions (rgb to hex, rgb to hsl, hsl to rgb, hex to rgb)
-- Added adjusment function for colours
-- Added check for colourbliness alteration
-- Added colourblindness command uses `accessibility.cb_command` as command string
-- Added menu option to change colourblind options.
-- Added multiple accessibility locale enteries within en.json
-- Added multiple accessibility locale enteries within pt.json (translated via google translate)
-- Fixed disabled not showing up when using qb-menu.
-- Updated init.lua and fxmanifest.lua to include new module entry
2025-04-03 08:52:47 +01: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
--print("Loading QB Menu")
--- 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