Files
community_bridge/modules/menu/wasabi_uikit/client.lua
T
MrNewb 343af95794 Remove example scripts and update core logic
Deleted all files in the examples directory to clean up unused or test scripts. Updated fxmanifest.lua to enable ox_lib initialization. Improved error handling and entity tracking in utility functions, added prop removal, and made minor localization and code style adjustments throughout the codebase. Significant reword of inventory module, notification module, and framework module. Added support for wasabi_uikit, added support for keep-progressbars,
2025-12-14 16:22:35 -05:00

58 lines
1.8 KiB
Lua

local resourceName = "wasabi_uikit"
local configValue = BridgeClientConfig.MenuSystem
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Menus = Menus or {}
---Converts a QB menu to an Wasabi menu.
---@param id string The menu ID.
---@param menu table The QB menu data.
---@return table The Wasabi menu data.
local function QBToWasabiMenu(id, menu)
local wasabiMenu = {
id = id,
title = "",
canClose = true,
options = {},
}
for i, v in pairs(menu) do
if v.isMenuHeader then
if wasabiMenu.title == "" then
wasabiMenu.title = v.header
end
else
local option = {
title = v.header,
description = v.txt,
icon = v.icon,
args = v.params.args,
onSelect = v.action or function(selected, secondary, args)
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(wasabiMenu.options, option)
end
end
return wasabiMenu
end
function OpenMenu(id, data, useQBinput)
if useQBinput then
data = QBToWasabiMenu(id, data)
end
exports.wasabi_uikit:RegisterContextMenu(data)
exports.wasabi_uikit:OpenContextMenu(id)
return data
end
GetMenuResourceName = function()
return resourceName
end