Skip to content

Commit

Permalink
Merge pull request #649 from bitpredator/dev
Browse files Browse the repository at this point in the history
chore+fix: 🎨 Run formatter -  unexpected token ?
  • Loading branch information
bitpredator authored Feb 23, 2024
2 parents e885a12 + a9995e8 commit fe85ea0
Show file tree
Hide file tree
Showing 31 changed files with 1,403 additions and 1,248 deletions.
200 changes: 100 additions & 100 deletions server-data/resources/[esx]/esx_menu_default/client/main.lua
Original file line number Diff line number Diff line change
@@ -1,132 +1,132 @@
local GUI, MenuType, OpenedMenus, CurrentNameSpace = {}, 'default', 0, nil
local GUI, MenuType, OpenedMenus, CurrentNameSpace = {}, "default", 0, nil
GUI.Time = 0

local function openMenu(namespace, name, data)
CurrentNameSpace = namespace
OpenedMenus = OpenedMenus + 1
SendNUIMessage({
action = 'openMenu',
namespace = namespace,
name = name,
data = data
})
CurrentNameSpace = namespace
OpenedMenus = OpenedMenus + 1
SendNUIMessage({
action = "openMenu",
namespace = namespace,
name = name,
data = data,
})
end

local function closeMenu(namespace, name)
CurrentNameSpace = namespace
OpenedMenus = OpenedMenus - 1
if OpenedMenus < 0 then
OpenedMenus = 0
end
SendNUIMessage({
action = 'closeMenu',
namespace = namespace,
name = name
})
CurrentNameSpace = namespace
OpenedMenus = OpenedMenus - 1
if OpenedMenus < 0 then
OpenedMenus = 0
end
SendNUIMessage({
action = "closeMenu",
namespace = namespace,
name = name,
})
end

AddEventHandler('onResourceStop', function(resource)
if GetCurrentResourceName() == resource and OpenedMenus > 0 then
ESX.UI.Menu.CloseAll()
elseif CurrentNameSpace ~= nil and CurrentNameSpace == resource and OpenedMenus > 0 then
ESX.UI.Menu.CloseAll()
end
AddEventHandler("onResourceStop", function(resource)
if GetCurrentResourceName() == resource and OpenedMenus > 0 then
ESX.UI.Menu.CloseAll()
elseif CurrentNameSpace ~= nil and CurrentNameSpace == resource and OpenedMenus > 0 then
ESX.UI.Menu.CloseAll()
end
end)

ESX.UI.Menu.RegisterType(MenuType, openMenu, closeMenu)

RegisterNUICallback('menu_submit', function(data, cb)
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
if menu.submit ~= nil then
menu.submit(data, menu)
end
cb('OK')
RegisterNUICallback("menu_submit", function(data, cb)
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
if menu.submit ~= nil then
menu.submit(data, menu)
end
cb("OK")
end)

RegisterNUICallback('menu_cancel', function(data, cb)
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
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
cb('OK')
if menu.cancel ~= nil then
menu.cancel(data, menu)
end
cb("OK")
end)

RegisterNUICallback('menu_change', function(data, cb)
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)
RegisterNUICallback("menu_change", function(data, cb)
local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name)

for i = 1, #data.elements, 1 do
menu.setElement(i, 'value', data.elements[i].value)
for i = 1, #data.elements, 1 do
menu.setElement(i, "value", data.elements[i].value)

if data.elements[i].selected then
menu.setElement(i, 'selected', true)
else
menu.setElement(i, 'selected', false)
end
end
if data.elements[i].selected then
menu.setElement(i, "selected", true)
else
menu.setElement(i, "selected", false)
end
end

if menu.change ~= nil then
menu.change(data, menu)
end
cb('OK')
if menu.change ~= nil then
menu.change(data, menu)
end
cb("OK")
end)

ESX.RegisterInput('menu_default_enter', 'Submit menu item', 'keyboard', 'RETURN', function()
if OpenedMenus > 0 and (GetGameTimer() - GUI.Time) > 200 then
SendNUIMessage({
action = 'controlPressed',
control = 'ENTER'
})
GUI.Time = GetGameTimer()
end
ESX.RegisterInput("menu_default_enter", "Submit menu item", "keyboard", "RETURN", function()
if OpenedMenus > 0 and (GetGameTimer() - GUI.Time) > 200 then
SendNUIMessage({
action = "controlPressed",
control = "ENTER",
})
GUI.Time = GetGameTimer()
end
end)

ESX.RegisterInput('menu_default_backspace', 'Close menu', 'keyboard', 'BACK', function()
if OpenedMenus > 0 then
SendNUIMessage({
action = 'controlPressed',
control = 'BACKSPACE'
})
GUI.Time = GetGameTimer()
end
ESX.RegisterInput("menu_default_backspace", "Close menu", "keyboard", "BACK", function()
if OpenedMenus > 0 then
SendNUIMessage({
action = "controlPressed",
control = "BACKSPACE",
})
GUI.Time = GetGameTimer()
end
end)

ESX.RegisterInput('menu_default_top', 'Change menu focus to top item', 'keyboard', 'UP', function()
if OpenedMenus > 0 then
SendNUIMessage({
action = 'controlPressed',
control = 'TOP'
})
GUI.Time = GetGameTimer()
end
ESX.RegisterInput("menu_default_top", "Change menu focus to top item", "keyboard", "UP", function()
if OpenedMenus > 0 then
SendNUIMessage({
action = "controlPressed",
control = "TOP",
})
GUI.Time = GetGameTimer()
end
end)

ESX.RegisterInput('menu_default_down', 'Change menu focus to down item', 'keyboard', 'DOWN', function()
if OpenedMenus > 0 then
SendNUIMessage({
action = 'controlPressed',
control = 'DOWN'
})
GUI.Time = GetGameTimer()
end
ESX.RegisterInput("menu_default_down", "Change menu focus to down item", "keyboard", "DOWN", function()
if OpenedMenus > 0 then
SendNUIMessage({
action = "controlPressed",
control = "DOWN",
})
GUI.Time = GetGameTimer()
end
end)

ESX.RegisterInput('menu_default_left', 'Change menu slider to left', 'keyboard', 'LEFT', function()
if OpenedMenus > 0 then
SendNUIMessage({
action = 'controlPressed',
control = 'LEFT'
})
GUI.Time = GetGameTimer()
end
ESX.RegisterInput("menu_default_left", "Change menu slider to left", "keyboard", "LEFT", function()
if OpenedMenus > 0 then
SendNUIMessage({
action = "controlPressed",
control = "LEFT",
})
GUI.Time = GetGameTimer()
end
end)

ESX.RegisterInput('menu_default_right', 'Change menu slider to right', 'keyboard', 'RIGHT', function()
if OpenedMenus > 0 then
SendNUIMessage({
action = 'controlPressed',
control = 'RIGHT'
})
GUI.Time = GetGameTimer()
end
end)
ESX.RegisterInput("menu_default_right", "Change menu slider to right", "keyboard", "RIGHT", function()
if OpenedMenus > 0 then
SendNUIMessage({
action = "controlPressed",
control = "RIGHT",
})
GUI.Time = GetGameTimer()
end
end)
18 changes: 9 additions & 9 deletions server-data/resources/[esx]/esx_menu_default/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
fx_version 'adamant'
fx_version("adamant")

game 'gta5'
game("gta5")

description 'Menu Default'
lua54 'yes'
version '1.0.0'
description("Menu Default")
lua54("yes")
version("1.0.0")

client_scripts {'@es_extended/imports.lua', 'client/main.lua'}
client_scripts({ "@es_extended/imports.lua", "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'}
files({ "html/ui.html", "html/css/app.css", "html/js/mustache.min.js", "html/js/app.js" })

dependencies {'es_extended'}
dependencies({ "es_extended" })
Loading

0 comments on commit fe85ea0

Please sign in to comment.