Merge pull request #12 from overextended/feat/ui

Feat/UI
This commit is contained in:
Linden
2022-04-11 13:55:23 +10:00
committed by GitHub
27 changed files with 12763 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
local contextMenus = {}
function lib.showContext(id)
local data = contextMenus[id]
SetNuiFocus(true, true)
SendNUIMessage({
action = 'showContext',
data = {
title = data.title,
menu = data.menu,
options = data.options
}
})
end
function lib.registerContext(context)
for k, v in pairs(context) do
if type(k) == 'number' then
contextMenus[v.id] = v
else
contextMenus[context.id] = context
break
end
end
end
RegisterNUICallback('openContext', function(id)
lib.showContext(id)
end)
RegisterNUICallback('clickContext', function(data)
if data.event then TriggerEvent(data.event, data.args) end
if data.serverEvent then TriggerServerEvent(data.serverEvent, data.args) end
SetNuiFocus(false, false)
SendNUIMessage({
action = 'hideContext'
})
end)
RegisterNUICallback('closeContext', function()
SetNuiFocus(false, false)
end)

View File

@@ -0,0 +1,19 @@
--[[```lua
{
id?: string
title?: string
description: string
duration?: number
position?: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left'
style?: table
icon?: string
iconColor?: string
}
```]]
---@param data table
function lib.notify(data)
SendNUIMessage({
action = 'customNotify',
data = data
})
end