This commit is contained in:
Nordi98 2025-08-06 16:37:06 +02:00
parent 510e3ffcf2
commit f43cf424cf
305 changed files with 34683 additions and 0 deletions

View file

@ -0,0 +1,99 @@
function QBTypeToOxType(_type)
if _type == "text" then
return "input"
elseif _type == "password" then
return "input"
elseif _type == "number" then
return "number"
elseif _type == "radio" then
return "checkbox"
elseif _type == "checkbox" then
return "checkbox"
elseif _type == "select" then
return "select"
end
end
function QBToOxInput(data)
local returnData = {}
for i, v in pairs(data) do
local input = {
label = v.text,
name = i,
type = QBTypeToOxType(v.type),
required = v.isRequired,
default = v.placeholder,
}
if v.type == "select" then
input.options = {}
for i, v in pairs(v.options) do
table.insert(input.options, {value = v.value, label = v.text})
end
elseif v.type == "checkbox" then
for i, v in pairs(v.options) do
table.insert(returnData, {value = v.value, label = v.text})
end
end
table.insert(returnData, input)
end
return returnData
end
function OxTypeToQBType(_type)
if _type == "input" then
return "text"
elseif _type == "number" then
return "number"
elseif _type == "checkbox" then
return "checkbox"
elseif _type == "select" then
return "select"
elseif _type == "multi-select" then
return "select"
elseif _type == "slider" then
return "number"
elseif _type == "color" then
return "text"
elseif _type == "date" then
return "date"
elseif _type == "date-range" then
return "date"
elseif _type == "time" then
return "time"
elseif _type == "textarea" then
return "text"
end
end
function OxToQBInput(data)
local returnData = {}
for i, v in pairs(data) do
local input = {
text = v.label,
name = i,
type = OxTypeToQBType(v.type),
isRequired = v.required,
default = v.default or "",
}
if v.type == "select" then
input.text = ""
input.options = {}
for k, j in pairs(v.options) do
table.insert(input.options, {value = j.value, text = j.label})
end
elseif v.type == "checkbox" then
input.text = ""
input.options = {}
if v.options then -- Checks if options varible is valid so checkboxes are bundled together (not used by ox for each checkpoint)
for k, j in pairs(v.options) do
table.insert(input.options, {value = j.value, text = j.label, checked = j.checked}) -- added checked option (used to show box as ticked or not)
end
else -- If options is not valid or people pass a single checkbox then it will be a single checkbox per entry
table.insert(input.options, {value = v.value, text = v.label, checked = v.checked}) -- Kept value just incase it's used for other stuffs
end
end
table.insert(returnData, input)
end
return returnData
end

View file

@ -0,0 +1,21 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "lation_ui"
local configValue = BridgeClientConfig.InputSystem
if (configValue == "auto" and GetResourceState(resourceName) == "missing") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Input = {}
function Input.Open(title, data, isQBFormat, submitText)
local inputs = data.inputs
if isQBFormat then
return exports.lation_ui:input({title = title, inputs = QBToOxInput(inputs)})
else
return exports.lation_ui:input({title = title, options = data})
end
end
function Input.GetResourceName()
return resourceName
end
return Input

View file

@ -0,0 +1,21 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "ox_lib"
local configValue = BridgeClientConfig.InputSystem
if (configValue == "auto" and GetResourceState(resourceName) == "missing") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Input = {}
function Input.Open(title, data, isQBFormat, submitText)
local inputs = data.inputs
if isQBFormat then
return lib.inputDialog(title, QBToOxInput(inputs))
else
return lib.inputDialog(title, data)
end
end
function Input.GetResourceName()
return resourceName
end
return Input

View file

@ -0,0 +1,49 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "qb-input"
local configValue = BridgeClientConfig.InputSystem
if (configValue == "auto" and GetResourceState(resourceName) == "missing") or (configValue ~= "auto" and configValue ~= resourceName) then return end
Input = {}
-- this probably needs improvement
function Input.Open(title, data, isQBFormat, submitText)
local input = data.inputs
if not isQBFormat then
input = OxToQBInput(data)
end
local returnData = exports['qb-input']:ShowInput({
header = title,
submitText = submitText or "Submit",
inputs = input
})
if not returnData then return end
if returnData[1] then return returnData end
--converting to standard format (ox)
local convertedData = {}
if isQBFormat then
for i, v in pairs(input) do
for k, j in pairs(returnData) do
if k == v.name then
convertedData[tonumber(i)] = j
end
end
end
return convertedData
end
for i, v in pairs(returnData) do
local index = i and tonumber(i)
if not index then
table.insert(convertedData, v)
else
convertedData[index] = v
end
end
return convertedData
end
function Input.GetResourceName()
return resourceName
end
return Input