2025-03-04 22:15:29 -05:00
|
|
|
local resourceName = "ox_lib"
|
|
|
|
|
local configValue = BridgeClientConfig.MenuSystem
|
|
|
|
|
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
|
2025-01-16 00:53:51 -06:00
|
|
|
Menus = Menus or {}
|
2025-06-07 22:50:13 -04:00
|
|
|
|
|
|
|
|
---Converts a QB menu to an Ox menu.
|
2025-01-14 09:44:30 -06:00
|
|
|
---@param id string The menu ID.
|
|
|
|
|
---@param menu table The QB menu data.
|
|
|
|
|
---@return table The Ox menu data.
|
|
|
|
|
local function QBToOxMenu(id, menu)
|
|
|
|
|
local oxMenu = {
|
|
|
|
|
id = id,
|
|
|
|
|
title = "",
|
|
|
|
|
canClose = true,
|
|
|
|
|
options = {},
|
|
|
|
|
}
|
|
|
|
|
for i, v in pairs(menu) do
|
|
|
|
|
if v.isMenuHeader then
|
|
|
|
|
if oxMenu.title == "" then
|
|
|
|
|
oxMenu.title = v.header
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
local option = {
|
|
|
|
|
title = v.header,
|
|
|
|
|
description = v.txt,
|
|
|
|
|
icon = v.icon,
|
|
|
|
|
args = v.params.args,
|
2025-07-29 05:22:55 -05:00
|
|
|
onSelect = v.action or function(selected, secondary, args)
|
2025-01-14 09:44:30 -06:00
|
|
|
local params = menu[id]?.options?[selected]?.params
|
|
|
|
|
if not params then return end
|
|
|
|
|
local event = params.event
|
|
|
|
|
local isServer = params.isServer
|
|
|
|
|
if not event then return end
|
|
|
|
|
if isServer then
|
|
|
|
|
return TriggerServerEvent(event, args)
|
|
|
|
|
end
|
|
|
|
|
return TriggerEvent(event, args)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
table.insert(oxMenu.options, option)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return oxMenu
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-08 09:44:53 -04:00
|
|
|
function OpenMenu(id, data, useQBinput)
|
2025-02-20 15:10:42 -05:00
|
|
|
if useQBinput then
|
2025-01-14 09:44:30 -06:00
|
|
|
data = QBToOxMenu(id, data)
|
2025-02-20 15:10:42 -05:00
|
|
|
end
|
2025-02-15 21:16:44 -06:00
|
|
|
lib.registerContext(data)
|
2025-01-16 00:53:51 -06:00
|
|
|
lib.showContext(id)
|
2025-01-14 12:30:29 -06:00
|
|
|
return data
|
2025-07-08 09:44:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
GetMenuResourceName = function()
|
|
|
|
|
return resourceName
|
2025-06-07 22:50:13 -04:00
|
|
|
end
|