From 2d46087ade9369c46df1d80b706dc13e6e4ac673 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Tue, 14 Apr 2020 16:37:55 +0200 Subject: [PATCH] Added back removed NUI chunking code --- client/main.lua | 74 +++++++++------------------------ html/css/app.css | 2 +- html/js/app.js | 106 ++++++++++++++++++++--------------------------- html/ui.html | 11 ++--- 4 files changed, 71 insertions(+), 122 deletions(-) diff --git a/client/main.lua b/client/main.lua index f5cb316e..e6f799c9 100644 --- a/client/main.lua +++ b/client/main.lua @@ -11,45 +11,41 @@ Citizen.CreateThread(function() local openMenu = function(namespace, name, data) SendNUIMessage({ - action = 'openMenu', + action = 'openMenu', namespace = namespace, - name = name, - data = data + name = name, + data = data }) end local closeMenu = function(namespace, name) SendNUIMessage({ - action = 'closeMenu', + action = 'closeMenu', namespace = namespace, - name = name, - data = data + name = name, + data = data }) end ESX.UI.Menu.RegisterType(MenuType, openMenu, closeMenu) - RegisterNUICallback('menu_submit', function(data, cb) + AddEventHandler('esx_menu_default:message:menu_submit', function(data) local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - - if menu.submit then + + if menu.submit ~= nil then menu.submit(data, menu) end - - cb('OK') end) - RegisterNUICallback('menu_cancel', function(data, cb) + AddEventHandler('esx_menu_default:message:menu_cancel', function(data) local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - - if menu.cancel then + + if menu.cancel ~= nil then menu.cancel(data, menu) end - - cb('OK') end) - RegisterNUICallback('menu_change', function(data, cb) + AddEventHandler('esx_menu_default:message:menu_change', function(data) local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) for i=1, #data.elements, 1 do @@ -60,76 +56,46 @@ Citizen.CreateThread(function() else menu.setElement(i, 'selected', false) end - end - if menu.change then + if menu.change ~= nil then menu.change(data, menu) end - - cb('OK') end) Citizen.CreateThread(function() while true do - Citizen.Wait(10) if IsControlPressed(0, 18) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then - SendNUIMessage({ - action = 'controlPressed', - control = 'ENTER' - }) - + SendNUIMessage({action = 'controlPressed', control = 'ENTER'}) GUI.Time = GetGameTimer() end if IsControlPressed(0, 177) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then - SendNUIMessage({ - action = 'controlPressed', - control = 'BACKSPACE' - }) - + SendNUIMessage({action = 'controlPressed', control = 'BACKSPACE'}) GUI.Time = GetGameTimer() end if IsControlPressed(0, 27) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 200 then - SendNUIMessage({ - action = 'controlPressed', - control = 'TOP' - }) - + SendNUIMessage({action = 'controlPressed', control = 'TOP'}) GUI.Time = GetGameTimer() end if IsControlPressed(0, 173) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 200 then - SendNUIMessage({ - action = 'controlPressed', - control = 'DOWN' - }) - + SendNUIMessage({action = 'controlPressed', control = 'DOWN'}) GUI.Time = GetGameTimer() end if IsControlPressed(0, 174) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then - SendNUIMessage({ - action = 'controlPressed', - control = 'LEFT' - }) - + SendNUIMessage({action = 'controlPressed', control = 'LEFT'}) GUI.Time = GetGameTimer() end if IsControlPressed(0, 175) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then - SendNUIMessage({ - action = 'controlPressed', - control = 'RIGHT' - }) - + SendNUIMessage({action = 'controlPressed', control = 'RIGHT'}) GUI.Time = GetGameTimer() end - end end) - end) diff --git a/html/css/app.css b/html/css/app.css index 84c72576..4ad1a0fb 100644 --- a/html/css/app.css +++ b/html/css/app.css @@ -91,4 +91,4 @@ .menu .menu-items .menu-item.selected { background-color: #d0d0d0; -} \ No newline at end of file +} diff --git a/html/js/app.js b/html/js/app.js index c3c5f52d..320fc386 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -1,9 +1,8 @@ (function(){ - let MenuTpl = '