-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #649 from bitpredator/dev
chore+fix: 🎨 Run formatter - unexpected token ?
- Loading branch information
Showing
31 changed files
with
1,403 additions
and
1,248 deletions.
There are no files selected for viewing
200 changes: 100 additions & 100 deletions
200
server-data/resources/[esx]/esx_menu_default/client/main.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
server-data/resources/[esx]/esx_menu_default/fxmanifest.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }) |
Oops, something went wrong.