mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
feat(client/radial): refresh menu when current menu is removed
Possibly weird.
This commit is contained in:
@@ -106,18 +106,54 @@ end
|
|||||||
---Removes an item from the global radial menu with the given id.
|
---Removes an item from the global radial menu with the given id.
|
||||||
---@param id string
|
---@param id string
|
||||||
function lib.removeRadialItem(id)
|
function lib.removeRadialItem(id)
|
||||||
|
local menuItem
|
||||||
|
|
||||||
for i = 1, #menuItems do
|
for i = 1, #menuItems do
|
||||||
local item = menuItems[i]
|
menuItem = menuItems[i]
|
||||||
if item.id == id then
|
|
||||||
|
if menuItem.id == id then
|
||||||
table.remove(menuItems, i)
|
table.remove(menuItems, i)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if isOpen and not currentRadial then
|
|
||||||
SendNUIMessage({
|
if isOpen then
|
||||||
action = 'refreshItems',
|
if currentRadial then
|
||||||
data = menuItems
|
local refresh
|
||||||
})
|
|
||||||
|
-- Top level submenu
|
||||||
|
if menuItem.menu == currentRadial.id then
|
||||||
|
refresh = true
|
||||||
|
else
|
||||||
|
-- Nested submenu
|
||||||
|
for i = 1, #menuHistory do
|
||||||
|
local subMenuId = menuHistory[i]
|
||||||
|
|
||||||
|
if subMenuId == menuItem.menu then
|
||||||
|
refresh = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if refresh then
|
||||||
|
table.wipe(menuHistory)
|
||||||
|
|
||||||
|
currentRadial = nil
|
||||||
|
|
||||||
|
SendNUIMessage({
|
||||||
|
action = 'openRadialMenu',
|
||||||
|
data = {
|
||||||
|
items = menuItems
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
SendNUIMessage({
|
||||||
|
action = 'refreshItems',
|
||||||
|
data = menuItems
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user