diff --git a/README.md b/README.md index 9f6478a1..53522b3f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,38 @@ # esx_menu_dialog -Simple script used for inputs. \ No newline at end of file +Simple script used for inputs. + +## Download & Installation + +### Using [fvm](https://github.com/qlaffont/fvm-installer) +``` +fvm install --save --folder=esx esx-org/esx_menu_dialog +``` + +### Using Git +``` +cd resources +git clone https://github.com/ESX-Org/esx_menu_dialog [esx]/esx_menu_dialog +``` + +### Manually +- Download https://github.com/ESX-Org/esx_menu_dialog/archive/master.zip +- Put it in the `[esx]` directory + +## Installation +- Add this to your `server.cfg`: + +``` +start esx_menu_dialog +``` + +# Legal +### License +esx_menu_dialog - input dialog for ESX + +Copyright (C) 2015-2018 Jérémie N'gadi + +This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. + +This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details. + +You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/. \ No newline at end of file diff --git a/__resource.lua b/__resource.lua index 1a597038..081c5dfc 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,24 +2,20 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Menu Dialog' -version '1.0.0' +version '1.1.0' -client_scripts { - 'client/main.lua' -} +client_script 'client/main.lua' -ui_page { - 'html/ui.html' -} +ui_page 'html/ui.html' files { 'html/ui.html', + 'html/css/app.css', + 'html/js/mustache.min.js', 'html/js/app.js', + 'html/fonts/pdown.ttf', - 'html/fonts/bankgothic.ttf', - 'html/img/cursor.png', - 'html/img/keys/enter.png', - 'html/img/keys/return.png', + 'html/fonts/bankgothic.ttf' } \ No newline at end of file diff --git a/client/main.lua b/client/main.lua index bedc532e..b419cd73 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,32 +1,18 @@ -ESX = nil -local Timeouts = {} - Citizen.CreateThread(function() + -- internal variables + ESX = nil + local Timeouts = {} + local GUI = {} + GUI.Time = 0 + local MenuType = 'dialog' + local OpenedMenus = {} while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end - local Keys = { - ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, - ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, - ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, - ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, - ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, - ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, - ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, - ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, - ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 - } - - local GUI = {} - GUI.Time = 0 - local MenuType = 'dialog' - local OpenedMenus = {} - local openMenu = function(namespace, name, data) - for i=1, #Timeouts, 1 do ESX.ClearTimeout(Timeouts[i]) end @@ -45,11 +31,9 @@ Citizen.CreateThread(function() end) table.insert(Timeouts, timeoutId) - end local closeMenu = function(namespace, name) - OpenedMenus[namespace .. '_' .. name] = nil local OpenedMenuCount = 0 @@ -75,24 +59,23 @@ Citizen.CreateThread(function() ESX.UI.Menu.RegisterType(MenuType, openMenu, closeMenu) RegisterNUICallback('menu_submit', function(data, cb) - local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) local post = true - + if menu.submit ~= nil then - + -- Is the submitted data a number? if tonumber(data.value) ~= nil then - + -- Round float values data.value = round(tonumber(data.value)) - + -- Check for negative value if tonumber(data.value) <= 0 then post = false end end - + -- Don't post if the value is negative or if it's 0 if post then menu.submit(data, menu) @@ -100,14 +83,13 @@ Citizen.CreateThread(function() ESX.ShowNotification('That input is invalid!') end end - + cb('OK') end) RegisterNUICallback('menu_cancel', function(data, cb) - local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - + if menu.cancel ~= nil then menu.cancel(data, menu) end @@ -116,49 +98,41 @@ Citizen.CreateThread(function() end) RegisterNUICallback('menu_change', function(data, cb) - local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - + if menu.change ~= nil then menu.change(data, menu) end - + cb('OK') end) Citizen.CreateThread(function() while true do + Citizen.Wait(10) + local OpenedMenuCount = 0 - Wait(0) + for k,v in pairs(OpenedMenus) do + if v == true then + OpenedMenuCount = OpenedMenuCount + 1 + end + end - local OpenedMenuCount = 0 - - for k,v in pairs(OpenedMenus) do - if v == true then - OpenedMenuCount = OpenedMenuCount + 1 - end - end - - if OpenedMenuCount > 0 then - - DisableControlAction(0, 1, true) -- LookLeftRight - DisableControlAction(0, 2, true) -- LookUpDown - DisableControlAction(0, 142, true) -- MeleeAttackAlternate - DisableControlAction(0, 106, true) -- VehicleMouseControlOverride - - DisableControlAction(0, 12, true) -- WeaponWheelUpDown - DisableControlAction(0, 14, true) -- WeaponWheelNext - DisableControlAction(0, 15, true) -- WeaponWheelPrev - DisableControlAction(0, 16, true) -- SelectNextWeapon - DisableControlAction(0, 17, true) -- SelectPrevWeapon - - end - - end + if OpenedMenuCount > 0 then + DisableControlAction(0, 1, true) -- LookLeftRight + DisableControlAction(0, 2, true) -- LookUpDown + DisableControlAction(0, 142, true) -- MeleeAttackAlternate + DisableControlAction(0, 106, true) -- VehicleMouseControlOverride + DisableControlAction(0, 12, true) -- WeaponWheelUpDown + DisableControlAction(0, 14, true) -- WeaponWheelNext + DisableControlAction(0, 15, true) -- WeaponWheelPrev + DisableControlAction(0, 16, true) -- SelectNextWeapon + DisableControlAction(0, 17, true) -- SelectPrevWeapon + end + end end) -end) - -function round(x) - return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5) -end \ No newline at end of file + function round(x) + return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5) + end +end) \ No newline at end of file diff --git a/html/css/app.css b/html/css/app.css index 55577105..e50e4d31 100644 --- a/html/css/app.css +++ b/html/css/app.css @@ -8,12 +8,6 @@ src: url('../fonts/pdown.ttf'); } -#cursor { - position: absolute; - z-index: 999999999; - display: none; -} - #controls { font-family : pcdown; font-size : 3em; diff --git a/html/img/accounts/bank.png b/html/img/accounts/bank.png deleted file mode 100644 index eb36dc8e..00000000 Binary files a/html/img/accounts/bank.png and /dev/null differ diff --git a/html/img/accounts/black_money.png b/html/img/accounts/black_money.png deleted file mode 100644 index a42f6aa5..00000000 Binary files a/html/img/accounts/black_money.png and /dev/null differ diff --git a/html/img/cursor.png b/html/img/cursor.png deleted file mode 100644 index 6ada58a4..00000000 Binary files a/html/img/cursor.png and /dev/null differ diff --git a/html/img/keys/enter.png b/html/img/keys/enter.png deleted file mode 100644 index 3eb9a1f6..00000000 Binary files a/html/img/keys/enter.png and /dev/null differ diff --git a/html/img/keys/return.png b/html/img/keys/return.png deleted file mode 100644 index a3ca125a..00000000 Binary files a/html/img/keys/return.png and /dev/null differ diff --git a/html/js/app.js b/html/js/app.js index b2d97d85..8d136b59 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -3,7 +3,7 @@ let MenuTpl = '