From 2eb0bad018b6f19094807e882b7701d0c455a504 Mon Sep 17 00:00:00 2001 From: Taavi <97351942+Taavi-AU@users.noreply.github.com> Date: Mon, 7 Nov 2022 19:04:28 +0800 Subject: [PATCH] context implementation --- [esx_addons]/esx_animations/client/main.lua | 49 ++++++++++----------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/[esx_addons]/esx_animations/client/main.lua b/[esx_addons]/esx_animations/client/main.lua index 7d5ef10e..5f8e1715 100644 --- a/[esx_addons]/esx_animations/client/main.lua +++ b/[esx_addons]/esx_animations/client/main.lua @@ -18,20 +18,20 @@ function startScenario(anim) end function OpenAnimationsMenu() - local elements = {} + local elements = { + {unselectable = true, icon = "fas fa-smile", title = "Animations"} + } for i=1, #Config.Animations, 1 do - table.insert(elements, {label = Config.Animations[i].label, value = Config.Animations[i].name}) + elements[#elements+1] = { + icon = "fas fa-smile", + title = Config.Animations[i].label, + value = Config.Animations[i].name + } end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'animations', { - title = 'Animations', - align = 'top-left', - elements = elements - }, function(data, menu) - OpenAnimationsSubMenu(data.current.value) - end, function(data, menu) - menu.close() + ESX.OpenContext("right", elements, function(menu,element) + OpenAnimationsSubMenu(element.value) end) end @@ -40,30 +40,29 @@ function OpenAnimationsSubMenu(menu) local elements = {} for i=1, #Config.Animations, 1 do + elements = { + {unselectable = true, icon = "fas fa-smile", title = Config.Animations[i].label} + } + if Config.Animations[i].name == menu then title = Config.Animations[i].label for j=1, #Config.Animations[i].items, 1 do - table.insert(elements, { - label = Config.Animations[i].items[j].label, - type = Config.Animations[i].items[j].type, + elements[#elements+1] = { + icon = "fas fa-smile", + title = Config.Animations[i].items[j].label, + type = Config.Animations[i].items[j].type, value = Config.Animations[i].items[j].data - }) + } end - break - end end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'animations_sub', { - title = title, - align = 'top-left', - elements = elements - }, function(data, menu) - local type = data.current.type - local lib = data.current.value.lib - local anim = data.current.value.anim + ESX.OpenContext("right", elements, function(menu,element) + local type = element.type + local lib = element.value.lib + local anim = element.value.anim if type == 'scenario' then startScenario(anim) @@ -72,8 +71,6 @@ function OpenAnimationsSubMenu(menu) elseif type == 'anim' then startAnim(lib, anim) end - end, function(data, menu) - menu.close() end) end