some other stuff
yum
This commit is contained in:
1 parent
c325f71453
commit
1ebcb8f492
7 files changed
+132
-104
No files matched your search
@@ -0,0 +1,55 @@
|
||||
if GetResourceState('ox_lib') ~= 'started' or (BridgeClientConfig.InputSystem ~= "ox" and BridgeClientConfig.InputSystem ~= "auto") then return end
|
||||
|
||||
|
||||
|
||||
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 OpenInput(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
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
if GetResourceState('qb-input') ~= 'started' or (BridgeClientConfig.InputSystem ~= "qb" and BridgeClientConfig.InputSystem ~= "auto") then return end
|
||||
|
||||
|
||||
-- ox to Qb
|
||||
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,
|
||||
placeholder = v.default,
|
||||
}
|
||||
if v.type == "select" then
|
||||
input.text = ""
|
||||
input.options = {
|
||||
{value = v.value, text = v.label}
|
||||
}
|
||||
elseif v.type == "checkbox" then
|
||||
input.text = ""
|
||||
input.options = {
|
||||
{value = v.value, text = v.label}
|
||||
}
|
||||
end
|
||||
table.insert(returnData, input)
|
||||
end
|
||||
return returnData
|
||||
end
|
||||
|
||||
function OpenInput(title, data, isQBFormat, submitText)
|
||||
print("Opening input", json.encode(data))
|
||||
local input = data.inputs
|
||||
if not isQBFormat then
|
||||
input = OxToQBInput(data)
|
||||
end
|
||||
return exports['qb-input']:ShowInput({
|
||||
header = title,
|
||||
submitText = submitText or "Submit",
|
||||
inputs = input
|
||||
})
|
||||
end
|
||||
@@ -79,104 +79,13 @@ if GetResourceState('ox_lib') ~= 'started' and GetResourceState('qb-menu') ~= 's
|
||||
Input = {}
|
||||
|
||||
|
||||
-- ox to Qb
|
||||
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,
|
||||
placeholder = v.default,
|
||||
}
|
||||
if v.type == "select" then
|
||||
input.text = ""
|
||||
input.options = {
|
||||
{value = v.value, text = v.label}
|
||||
}
|
||||
elseif v.type == "checkbox" then
|
||||
input.text = ""
|
||||
input.options = {
|
||||
{value = v.value, text = v.label}
|
||||
}
|
||||
end
|
||||
table.insert(returnData, input)
|
||||
end
|
||||
return returnData
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- qb to ox
|
||||
|
||||
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
|
||||
|
||||
--Open menu
|
||||
|
||||
function Input.Open(title, data, isQBFormat, submitText)
|
||||
@@ -202,7 +111,7 @@ function Input.Open(title, data, isQBFormat, submitText)
|
||||
})
|
||||
end
|
||||
end
|
||||
return id
|
||||
return OpenInput(title, data, isQBFormat, submitText)
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if GetResourceState('ox_lib') ~= 'started' and (BridgeClientConfig.MenuSystem ~= "ox" or BridgeClientConfig.MenuSystem ~= "auto") then return end
|
||||
if GetResourceState('ox_lib') ~= 'started' or (BridgeClientConfig.MenuSystem ~= "ox" and BridgeClientConfig.MenuSystem ~= "auto") then return end
|
||||
Menus = Menus or {}
|
||||
--- Converts a QB menu to an Ox menu.
|
||||
---@param id string The menu ID.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
if GetResourceState('qb-menu') ~= 'started' and (BridgeClientConfig.MenuSystem ~= "qb" or BridgeClientConfig.MenuSystem ~= "auto") then return end
|
||||
if GetResourceState('qb-menu') ~= 'started' or (BridgeClientConfig.MenuSystem ~= "qb" and BridgeClientConfig.MenuSystem ~= "auto") then return end
|
||||
print("Loading QB Menu")
|
||||
--- Converts an Ox menu to a QB menu.
|
||||
---@param id string The menu ID.
|
||||
---@param menu table The Ox menu data.
|
||||
@@ -16,7 +17,7 @@ function OxToQBMenu(id, menu)
|
||||
txt = v.description,
|
||||
icon = v.icon,
|
||||
}
|
||||
|
||||
|
||||
if v.onSelect then
|
||||
button.params = {
|
||||
event = "community_bridge:client:MenuCallback",
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
Menus = Menus or {}
|
||||
Menu = {}
|
||||
|
||||
if GetResourceState('ox_lib') ~= 'started' and GetResourceState('qb-menu') ~= 'started' then return end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--- Opens a menu based on the configuration.
|
||||
---@param data table The menu data.
|
||||
---@param useQb boolean Whether to use QB menu syntax.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
BridgeClientConfig = {}
|
||||
BridgeClientConfig.NotifySystem = "ox" -- Change this to your notification system (ox/qb/esx?)
|
||||
BridgeClientConfig.ZoneSystem = "ox" -- Change this to your dialog system (ox/poly)
|
||||
BridgeClientConfig.InputSystem = "ox" -- Change this to your Input system (ox/qb)
|
||||
BridgeClientConfig.InputSystem = "auto" -- Change this to your Input system (ox/qb)
|
||||
BridgeClientConfig.MenuSystem = "auto" -- Change this to your Menu system (ox/qb)
|
||||
BridgeClientConfig.ProgressBar = "ox" -- Change this to your preferred progress bar (ox/qb)
|
||||
BridgeClientConfig.DebugLevel = 3 -- Change this to your Debug level, 1 for none, 2 for some, 3 for all data
|
||||
|
||||
Reference in new issue
Block a user