build: new repos

This commit is contained in:
Benzo
2023-01-18 15:06:15 +01:00
parent 4267f1d915
commit cfb8e742e4
973 changed files with 1226 additions and 81196 deletions

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 1015 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 662 B

After

Width:  |  Height:  |  Size: 662 B

@@ -1,24 +1,24 @@
fx_version 'bodacious'
game 'gta5'
author 'ESX-Framework & Brayden'
description 'Offical ESX Legacy Context Menu'
lua54 'yes'
version '1.9.0'
ui_page 'index.html'
shared_script '@es_extended/imports.lua'
client_scripts {
'config.lua',
'main.lua',
}
files {
'index.html'
}
dependencies {
'es_extended'
fx_version 'bodacious'
game 'gta5'
author 'ESX-Framework & Brayden'
description 'Offical ESX Legacy Context Menu'
lua54 'yes'
version '1.9.0'
ui_page 'index.html'
shared_script '@es_extended/imports.lua'
client_scripts {
'config.lua',
'main.lua',
}
files {
'index.html'
}
dependencies {
'es_extended'
}
@@ -1,443 +1,443 @@
<!DOCTYPE html>
<html>
<head>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESX Context HUD</title>
<style type="text/css">
:root {
--item-main: #242424;
--item-unselectable: #161616;
--item-hover: #404040;
--item-disabled: #393939;
}
html,
body {
margin: 0;
padding: 0;
outline: none;
border: none;
}
body {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
display: none;
}
#container {
position: absolute;
width: 280px;
max-height: 50%;
height: auto;
display: flex;
flex-direction: column;
gap: 10px;
overflow-y: auto;
padding-right: 5px;
}
.center {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.left {
top: 50%;
left: 25%;
transform: translate(-50%, -50%);
}
.right {
top: 50%;
left: 75%;
transform: translate(-50%, -50%);
}
.item {
display: grid;
grid-template-columns: 30px calc(100% - 30px);
padding: 15px 10px;
border-radius: 5px;
background: var(--item-main);
}
.item:hover {
background: var(--item-hover);
}
.item>i {
text-align: center;
}
.item>div {
display: flex;
flex-direction: column;
gap: 5px;
}
.item>div>i {
opacity: 0.5;
}
.input {
display: flex;
flex-direction: column;
gap: 5px;
padding: 15px 10px;
border-radius: 5px;
background: var(--item-main);
}
.input:hover {
background: var(--item-hover);
}
input {
position: relative;
width: auto;
padding: 5px;
margin: 0;
border: none;
border: none;
background: transparent;
}
.unselectable {
background: var(--item-unselectable);
pointer-events: none;
}
.disabled {
pointer-events: none;
background: var(--item-disabled);
}
* {
color: white;
font-family: Arial;
user-select: none;
font-size: 14px;
}
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-thumb {
background: rgb(20, 20, 20);
border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
background: rgb(30, 30, 30);
}
.container {
display: flex;
position: relative;
cursor: pointer;
font-size: 14px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
flex-direction: row-reverse;
align-items: center;
justify-content: flex-end;
gap: 5px;
}
/* Hide the browser's default checkbox */
.container input {
position: relative;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
/* Create a custom checkbox */
.checkmark {
position: relative;
height: 10px;
width: 10px;
border-radius: 8px;
background-color: #eee;
}
/* On mouse-over, add a grey background color */
.container:hover input~.checkmark {
background-color: #ccc;
}
/* When the checkbox is checked, add a blue background */
.container input:checked~.checkmark {
background-color: #2196F3;
}
/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
content: "";
position: relative;
display: none;
}
/* Show the checkmark when checked */
.container input:checked~.checkmark:after {
display: block;
}
</style>
</head>
<body>
<div id="container" class="right">
<div class="item unselectable">
<i class="fas fa-info-circle"></i>
<div>
<b>Unselectable Item</b>
<i>Testing, testing a description here.</i>
</div>
</div>
<div class="item disabled">
<i class="fas fa-times"></i>
<div>
<b>Disabled Item</b>
<i>Testing, testing a description here.</i>
</div>
</div>
<div class="item">
<i class="fas fa-check"></i>
<div>
<b>Item</b>
<i>Testing, testing a description here. Generic words to force overflow.</i>
</div>
</div>
</div>
<script type="text/javascript">
const container = document.getElementById("container")
const CreateElement = (tag = "div", className = "", parent) => {
const e = document.createElement(tag)
e.className = className
if (parent) {
parent.append(e)
}
return e
}
function Open(eles, position = "right") {
container.innerHTML = ""
container.className = position
for (let i = 0; i < eles.length; i++) {
let ele = eles[i]
let item = CreateElement("div", "item", container)
let icon = CreateElement("i", ele.icon, item)
let div = CreateElement("div", "", item)
let title = CreateElement("b", "", div)
title.innerHTML = ele.title
if (ele.description) {
let desc = CreateElement("i", "", div)
desc.innerHTML = ele.description || ""
}
if (ele.input) {
if (ele.inputType == "radio") {
for (let j = 0; j < ele.inputValues.length; j++) {
let v = ele.inputValues[j]
let container = CreateElement("label", "container", div)
container.innerHTML = v.text
let input = CreateElement("INPUT", "", container)
input.type = "radio"
input.name = i + 1
input.checked = (ele.inputValue || ele.inputPlaceholder || -1) == v.value
let span = CreateElement("SPAN", "checkmark", container)
input.onchange = function () {
$.post(`https://${GetParentResourceName()}/changed`, JSON.stringify({
index: i + 1,
value: v.value
}))
}
}
} else {
let input = CreateElement("input", "", div)
input.type = ele.inputType
if (ele.inputValue) {
input.value = ele.inputValue
}
if (ele.inputPlaceholder) {
input.placeholder = ele.inputPlaceholder
}
switch (ele.inputType) {
case "number":
if (ele.inputMin) input.min = ele.inputMin;
if (ele.inputMax) input.max = ele.inputMax;
input.onchange = function () {
let v = Number(input.value)
if (ele.inputMin) {
v = Math.max(ele.inputMin, v)
}
if (ele.inputMax) {
v = Math.min(ele.inputMax, v)
}
input.value = v
$.post(`https://${GetParentResourceName()}/changed`, JSON.stringify({
index: i + 1,
value: v
}))
}
break
case "text":
input.onchange = function () {
$.post(`https://${GetParentResourceName()}/changed`, JSON.stringify({
index: i + 1,
value: input.value
}))
}
break
}
}
} else {
if (ele.disabled) {
item.className += " disabled"
} else if (ele.unselectable) {
item.className += " unselectable"
} else if (!ele.input) {
item.onclick = function () {
$.post(`https://${GetParentResourceName()}/selected`, JSON.stringify({
index: i + 1
}))
}
}
}
}
document.body.style.display = "block"
}
function Closed() {
document.body.style.display = "none"
}
function Close() {
$.post(`https://${GetParentResourceName()}/closed`,(retVal)=>{
if(retVal){
Closed()
}
})
}
window.addEventListener("message", (e) => {
let data = e.data
if (!data.func || !window[data.func]) {
return
}
window[data.func](...data.args)
})
window.addEventListener("keydown", (e) => {
if (e.key == "Escape" || e.key == "Backspace") {
if (e.target.tagName.toLowerCase() == "input") {
return
}
Close()
}
})
// Open([
// {
// unselectable:true,
// icon:"fas fa-info-circle",
// title:"Unselectable Item (Header/Label?)",
// },
// {
// icon:"fas fa-check",
// title:"Item A",
// description:"Some description here. Add some words to make the text overflow."
// },
// {
// disabled:true,
// icon:"fas fa-times",
// title:"Disabled Item",
// description:"Some description here. Add some words to make the text overflow."
// },
// {
// icon:"fas fa-check",
// title:"Item B",
// description:"Some description here. Add some words to make the text overflow."
// },
// {
// input:true,
// icon:"fas fa-times",
// title:"Input Text",
// inputType:"text",
// inputPlaceholder:"Placeholder..."
// },
// {
// input:true,
// icon:"",
// title:"Input Number",
// inputType:"number",
// inputPlaceholder:"Placeholder...",
// inputValue:0,
// inputMin:0,
// inputMax:50
// },
// {
// input:true,
// icon:"",
// title:"Input Radio",
// inputType:"radio",
// inputPlaceholder:"turbocharger",
// inputValue:"supercharger",
// inputValues:[
// {
// value:"turbocharger",
// title:"Turbocharger"
// },
// {
// value:"supercharger",
// title:"Supercharger"
// },
// ]
// }
// ])
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESX Context HUD</title>
<style type="text/css">
:root {
--item-main: #242424;
--item-unselectable: #161616;
--item-hover: #404040;
--item-disabled: #393939;
}
html,
body {
margin: 0;
padding: 0;
outline: none;
border: none;
}
body {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
display: none;
}
#container {
position: absolute;
width: 280px;
max-height: 50%;
height: auto;
display: flex;
flex-direction: column;
gap: 10px;
overflow-y: auto;
padding-right: 5px;
}
.center {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.left {
top: 50%;
left: 25%;
transform: translate(-50%, -50%);
}
.right {
top: 50%;
left: 75%;
transform: translate(-50%, -50%);
}
.item {
display: grid;
grid-template-columns: 30px calc(100% - 30px);
padding: 15px 10px;
border-radius: 5px;
background: var(--item-main);
}
.item:hover {
background: var(--item-hover);
}
.item>i {
text-align: center;
}
.item>div {
display: flex;
flex-direction: column;
gap: 5px;
}
.item>div>i {
opacity: 0.5;
}
.input {
display: flex;
flex-direction: column;
gap: 5px;
padding: 15px 10px;
border-radius: 5px;
background: var(--item-main);
}
.input:hover {
background: var(--item-hover);
}
input {
position: relative;
width: auto;
padding: 5px;
margin: 0;
border: none;
border: none;
background: transparent;
}
.unselectable {
background: var(--item-unselectable);
pointer-events: none;
}
.disabled {
pointer-events: none;
background: var(--item-disabled);
}
* {
color: white;
font-family: Arial;
user-select: none;
font-size: 14px;
}
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-thumb {
background: rgb(20, 20, 20);
border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
background: rgb(30, 30, 30);
}
.container {
display: flex;
position: relative;
cursor: pointer;
font-size: 14px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
flex-direction: row-reverse;
align-items: center;
justify-content: flex-end;
gap: 5px;
}
/* Hide the browser's default checkbox */
.container input {
position: relative;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
/* Create a custom checkbox */
.checkmark {
position: relative;
height: 10px;
width: 10px;
border-radius: 8px;
background-color: #eee;
}
/* On mouse-over, add a grey background color */
.container:hover input~.checkmark {
background-color: #ccc;
}
/* When the checkbox is checked, add a blue background */
.container input:checked~.checkmark {
background-color: #2196F3;
}
/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
content: "";
position: relative;
display: none;
}
/* Show the checkmark when checked */
.container input:checked~.checkmark:after {
display: block;
}
</style>
</head>
<body>
<div id="container" class="right">
<div class="item unselectable">
<i class="fas fa-info-circle"></i>
<div>
<b>Unselectable Item</b>
<i>Testing, testing a description here.</i>
</div>
</div>
<div class="item disabled">
<i class="fas fa-times"></i>
<div>
<b>Disabled Item</b>
<i>Testing, testing a description here.</i>
</div>
</div>
<div class="item">
<i class="fas fa-check"></i>
<div>
<b>Item</b>
<i>Testing, testing a description here. Generic words to force overflow.</i>
</div>
</div>
</div>
<script type="text/javascript">
const container = document.getElementById("container")
const CreateElement = (tag = "div", className = "", parent) => {
const e = document.createElement(tag)
e.className = className
if (parent) {
parent.append(e)
}
return e
}
function Open(eles, position = "right") {
container.innerHTML = ""
container.className = position
for (let i = 0; i < eles.length; i++) {
let ele = eles[i]
let item = CreateElement("div", "item", container)
let icon = CreateElement("i", ele.icon, item)
let div = CreateElement("div", "", item)
let title = CreateElement("b", "", div)
title.innerHTML = ele.title
if (ele.description) {
let desc = CreateElement("i", "", div)
desc.innerHTML = ele.description || ""
}
if (ele.input) {
if (ele.inputType == "radio") {
for (let j = 0; j < ele.inputValues.length; j++) {
let v = ele.inputValues[j]
let container = CreateElement("label", "container", div)
container.innerHTML = v.text
let input = CreateElement("INPUT", "", container)
input.type = "radio"
input.name = i + 1
input.checked = (ele.inputValue || ele.inputPlaceholder || -1) == v.value
let span = CreateElement("SPAN", "checkmark", container)
input.onchange = function () {
$.post(`https://${GetParentResourceName()}/changed`, JSON.stringify({
index: i + 1,
value: v.value
}))
}
}
} else {
let input = CreateElement("input", "", div)
input.type = ele.inputType
if (ele.inputValue) {
input.value = ele.inputValue
}
if (ele.inputPlaceholder) {
input.placeholder = ele.inputPlaceholder
}
switch (ele.inputType) {
case "number":
if (ele.inputMin) input.min = ele.inputMin;
if (ele.inputMax) input.max = ele.inputMax;
input.onchange = function () {
let v = Number(input.value)
if (ele.inputMin) {
v = Math.max(ele.inputMin, v)
}
if (ele.inputMax) {
v = Math.min(ele.inputMax, v)
}
input.value = v
$.post(`https://${GetParentResourceName()}/changed`, JSON.stringify({
index: i + 1,
value: v
}))
}
break
case "text":
input.onchange = function () {
$.post(`https://${GetParentResourceName()}/changed`, JSON.stringify({
index: i + 1,
value: input.value
}))
}
break
}
}
} else {
if (ele.disabled) {
item.className += " disabled"
} else if (ele.unselectable) {
item.className += " unselectable"
} else if (!ele.input) {
item.onclick = function () {
$.post(`https://${GetParentResourceName()}/selected`, JSON.stringify({
index: i + 1
}))
}
}
}
}
document.body.style.display = "block"
}
function Closed() {
document.body.style.display = "none"
}
function Close() {
$.post(`https://${GetParentResourceName()}/closed`,(retVal)=>{
if(retVal){
Closed()
}
})
}
window.addEventListener("message", (e) => {
let data = e.data
if (!data.func || !window[data.func]) {
return
}
window[data.func](...data.args)
})
window.addEventListener("keydown", (e) => {
if (e.key == "Escape" || e.key == "Backspace") {
if (e.target.tagName.toLowerCase() == "input") {
return
}
Close()
}
})
// Open([
// {
// unselectable:true,
// icon:"fas fa-info-circle",
// title:"Unselectable Item (Header/Label?)",
// },
// {
// icon:"fas fa-check",
// title:"Item A",
// description:"Some description here. Add some words to make the text overflow."
// },
// {
// disabled:true,
// icon:"fas fa-times",
// title:"Disabled Item",
// description:"Some description here. Add some words to make the text overflow."
// },
// {
// icon:"fas fa-check",
// title:"Item B",
// description:"Some description here. Add some words to make the text overflow."
// },
// {
// input:true,
// icon:"fas fa-times",
// title:"Input Text",
// inputType:"text",
// inputPlaceholder:"Placeholder..."
// },
// {
// input:true,
// icon:"",
// title:"Input Number",
// inputType:"number",
// inputPlaceholder:"Placeholder...",
// inputValue:0,
// inputMin:0,
// inputMax:50
// },
// {
// input:true,
// icon:"",
// title:"Input Radio",
// inputType:"radio",
// inputPlaceholder:"turbocharger",
// inputValue:"supercharger",
// inputValues:[
// {
// value:"turbocharger",
// title:"Turbocharger"
// },
// {
// value:"supercharger",
// title:"Supercharger"
// },
// ]
// }
// ])
</script>
</body>
</html>
@@ -1,271 +1,271 @@
local defaultPosition = "right" -- [ left | center | right ]
local activeMenu
local Debug = ESX.GetConfig().EnableDebug
-- Global functions
-- [ Post | Open | Closed ]
function Post(fn,...)
SendNUIMessage({
func = fn,
args = {...}
})
end
function Open(position,eles,onSelect,onClose,canClose)
local canClose = canClose == nil and true or canClose
activeMenu = {
position = position,
eles = eles,
canClose = canClose,
onSelect = onSelect,
onClose = onClose
}
LocalPlayer.state:set("context:active",true)
Post("Open",eles,position)
end
function Closed()
SetNuiFocus(false,false)
local menu = activeMenu
local cb = menu.onClose
activeMenu = nil
LocalPlayer.state:set("context:active",false)
if cb then
cb(menu)
end
end
-- Exports
-- [ Preview | Open | Close ]
exports("Preview",Open)
exports("Open",function(...)
Open(...)
SetNuiFocus(true,true)
end)
exports("Close",function()
if not activeMenu then
return
end
Post("Closed")
Closed()
end)
exports("Refresh",function(eles,position)
if not activeMenu then
return
end
activeMenu.eles = eles or activeMenu.eles
activeMenu.position = position or activeMenu.position
Post("Open",activeMenu.eles,activeMenu.position)
end)
-- NUI Callbacks
-- [ closed | selected | changed ]
RegisterNUICallback("closed",function(data,cb)
if not activeMenu or (activeMenu and not activeMenu.canClose) then
return cb(false)
end
cb(true)
Closed()
end)
RegisterNUICallback("selected",function(data)
if not activeMenu
or not activeMenu.onSelect
or not data.index
then
return
end
local index = tonumber(data.index)
local ele = activeMenu.eles[index]
if not ele
or ele.input
then
return
end
activeMenu:onSelect(ele)
end)
RegisterNUICallback("changed",function(data)
if not activeMenu
or not data.index
or not data.value
then
return
end
local index = tonumber(data.index)
local ele = activeMenu.eles[index]
if not ele
or not ele.input
then
return
end
if ele.inputType == "number" then
ele.inputValue = tonumber(data.value)
if ele.inputMin then
ele.inputValue = math.max(ele.inputMin,ele.inputValue)
end
if ele.inputMax then
ele.inputValue = math.min(ele.inputMax,ele.inputValue)
end
elseif ele.inputType == "text" then
ele.inputValue = data.value
elseif ele.inputType == "radio" then
ele.inputValue = data.value
end
end)
-- Keybind
local function focusPreview()
if not activeMenu
or not activeMenu.onSelect
then
return
end
SetNuiFocus(true,true)
end
if PREVIEW_KEYBIND then
RegisterCommand("previewContext",focusPreview)
RegisterKeyMapping("previewContext","Preview Active Context","keyboard",PREVIEW_KEYBIND)
end
exports("focusPreview",focusPreview)
-- Debug/Test
-- Commands:
-- [ ctx:preview | ctx:open | ctx:close | ctx:form ]
if Debug then
local position = "right"
local eles = {
{
unselectable=true,
icon="fas fa-info-circle",
title="Unselectable Item (Header/Label?)",
},
{
icon="fas fa-check",
title="Item A",
description="Some description here. Add some words to make the text overflow."
},
{
disabled=true,
icon="fas fa-times",
title="Disabled Item",
description="Some description here. Add some words to make the text overflow."
},
{
icon="fas fa-check",
title="Item B",
description="Some description here. Add some words to make the text overflow."
},
}
local function onSelect(menu,ele)
print("Ele selected",ele.title)
if ele.name == "close" then
exports["esx_context"]:Close()
end
if ele.name ~= "submit" then
return
end
for _,ele in ipairs(menu.eles) do
if ele.input then
print(ele.name,ele.inputType,ele.inputValue)
end
end
exports["esx_context"]:Close()
end
local function onClose(menu)
print("Menu closed.")
end
RegisterCommand("ctx:preview",function()
exports["esx_context"]:Preview(position,eles)
end)
RegisterCommand("ctx:open",function()
exports["esx_context"]:Open(position,eles,onSelect,onClose)
end)
RegisterCommand("ctx:close",function()
exports["esx_context"]:Close()
end)
RegisterCommand("ctx:form",function()
local eles = {
{
unselectable=true,
icon="fas fa-info-circle",
title="Unselectable Item (Header/Label?)",
},
{
icon="",
title="Input Text",
input=true,
inputType="text",
inputPlaceholder="Placeholder...",
name="firstname",
},
{
icon="",
title="Input Text",
input=true,
inputType="text",
inputPlaceholder="Placeholder...",
name="lastname",
},
{
icon="",
title="Input Number",
input=true,
inputType="number",
inputPlaceholder="Placeholder...",
inputValue=0,
inputMin=0,
inputMax=50,
name="age",
},
{
icon = "fas fa-check",
title = "Submit",
name = "submit"
}
}
exports["esx_context"]:Open(position,eles,onSelect,onClose)
end)
end
local defaultPosition = "right" -- [ left | center | right ]
local activeMenu
local Debug = ESX.GetConfig().EnableDebug
-- Global functions
-- [ Post | Open | Closed ]
function Post(fn,...)
SendNUIMessage({
func = fn,
args = {...}
})
end
function Open(position,eles,onSelect,onClose,canClose)
local canClose = canClose == nil and true or canClose
activeMenu = {
position = position,
eles = eles,
canClose = canClose,
onSelect = onSelect,
onClose = onClose
}
LocalPlayer.state:set("context:active",true)
Post("Open",eles,position)
end
function Closed()
SetNuiFocus(false,false)
local menu = activeMenu
local cb = menu.onClose
activeMenu = nil
LocalPlayer.state:set("context:active",false)
if cb then
cb(menu)
end
end
-- Exports
-- [ Preview | Open | Close ]
exports("Preview",Open)
exports("Open",function(...)
Open(...)
SetNuiFocus(true,true)
end)
exports("Close",function()
if not activeMenu then
return
end
Post("Closed")
Closed()
end)
exports("Refresh",function(eles,position)
if not activeMenu then
return
end
activeMenu.eles = eles or activeMenu.eles
activeMenu.position = position or activeMenu.position
Post("Open",activeMenu.eles,activeMenu.position)
end)
-- NUI Callbacks
-- [ closed | selected | changed ]
RegisterNUICallback("closed",function(data,cb)
if not activeMenu or (activeMenu and not activeMenu.canClose) then
return cb(false)
end
cb(true)
Closed()
end)
RegisterNUICallback("selected",function(data)
if not activeMenu
or not activeMenu.onSelect
or not data.index
then
return
end
local index = tonumber(data.index)
local ele = activeMenu.eles[index]
if not ele
or ele.input
then
return
end
activeMenu:onSelect(ele)
end)
RegisterNUICallback("changed",function(data)
if not activeMenu
or not data.index
or not data.value
then
return
end
local index = tonumber(data.index)
local ele = activeMenu.eles[index]
if not ele
or not ele.input
then
return
end
if ele.inputType == "number" then
ele.inputValue = tonumber(data.value)
if ele.inputMin then
ele.inputValue = math.max(ele.inputMin,ele.inputValue)
end
if ele.inputMax then
ele.inputValue = math.min(ele.inputMax,ele.inputValue)
end
elseif ele.inputType == "text" then
ele.inputValue = data.value
elseif ele.inputType == "radio" then
ele.inputValue = data.value
end
end)
-- Keybind
local function focusPreview()
if not activeMenu
or not activeMenu.onSelect
then
return
end
SetNuiFocus(true,true)
end
if PREVIEW_KEYBIND then
RegisterCommand("previewContext",focusPreview)
RegisterKeyMapping("previewContext","Preview Active Context","keyboard",PREVIEW_KEYBIND)
end
exports("focusPreview",focusPreview)
-- Debug/Test
-- Commands:
-- [ ctx:preview | ctx:open | ctx:close | ctx:form ]
if Debug then
local position = "right"
local eles = {
{
unselectable=true,
icon="fas fa-info-circle",
title="Unselectable Item (Header/Label?)",
},
{
icon="fas fa-check",
title="Item A",
description="Some description here. Add some words to make the text overflow."
},
{
disabled=true,
icon="fas fa-times",
title="Disabled Item",
description="Some description here. Add some words to make the text overflow."
},
{
icon="fas fa-check",
title="Item B",
description="Some description here. Add some words to make the text overflow."
},
}
local function onSelect(menu,ele)
print("Ele selected",ele.title)
if ele.name == "close" then
exports["esx_context"]:Close()
end
if ele.name ~= "submit" then
return
end
for _,ele in ipairs(menu.eles) do
if ele.input then
print(ele.name,ele.inputType,ele.inputValue)
end
end
exports["esx_context"]:Close()
end
local function onClose(menu)
print("Menu closed.")
end
RegisterCommand("ctx:preview",function()
exports["esx_context"]:Preview(position,eles)
end)
RegisterCommand("ctx:open",function()
exports["esx_context"]:Open(position,eles,onSelect,onClose)
end)
RegisterCommand("ctx:close",function()
exports["esx_context"]:Close()
end)
RegisterCommand("ctx:form",function()
local eles = {
{
unselectable=true,
icon="fas fa-info-circle",
title="Unselectable Item (Header/Label?)",
},
{
icon="",
title="Input Text",
input=true,
inputType="text",
inputPlaceholder="Placeholder...",
name="firstname",
},
{
icon="",
title="Input Text",
input=true,
inputType="text",
inputPlaceholder="Placeholder...",
name="lastname",
},
{
icon="",
title="Input Number",
input=true,
inputType="number",
inputPlaceholder="Placeholder...",
inputValue=0,
inputMin=0,
inputMax=50,
name="age",
},
{
icon = "fas fa-check",
title = "Submit",
name = "submit"
}
}
exports["esx_context"]:Open(position,eles,onSelect,onClose)
end)
end

Before

Width:  |  Height:  |  Size: 943 KiB

After

Width:  |  Height:  |  Size: 943 KiB

Some files were not shown because too many files have changed in this diff Show More