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,106 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "lation_ui"
local configValue = BridgeClientConfig.ProgressBarSystem
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
ProgressBar = ProgressBar or {}
---This function converts a QB progress bar options table to an lation progress bar options table.
---@param options table
---@return table
local function convertFromQB(options)
if not options then return options end
local prop1 = options.prop or {}
local prop2 = options.propTwo or {}
local props = {
{
model = prop1?.model,
bone = prop1?.bone,
pos = prop1?.coords,
rot = prop1?.rotation,
},
{
model = prop2?.model,
bone = prop2?.bone,
pos = prop2?.coords,
rot = prop2?.rotation,
}
}
return {
duration = options.duration,
label = options.label,
description = options?.description,
icon = options?.icon,
iconColor = options?.iconColor,
iconAnimation = options?.iconAnimation,
useWhileDead = options.useWhileDead,
canCancel = options.canCancel,
disable = {
move = options.controlDisables?.disableMovement,
car = options.controlDisables?.disableCarMovement,
combat = options.controlDisables?.disableCombat,
mouse = options.controlDisables?.disableMouse
},
anim = {
dict = options.animation?.animDict,
clip = options.animation?.anim,
flag = options.animation?.flags or 49,
},
prop = props,
}
end
---This function converts a ox progress bar options table to an lation progress bar options table.
---@param options table
---@return table
local function convertFromOx(options)
if not options then return options end
local prop1 = options.prop or {}
local prop2 = options.propTwo or {}
return {
duration = options.duration,
label = options.label,
description = options?.description,
icon = options?.icon,
iconColor = options?.iconColor,
iconAnimation = options?.iconAnimation,
useWhileDead = options.useWhileDead,
canCancel = options.canCancel,
disable = options.disable,
anim = options.anim,
prop = {
{
model = prop1?.model,
bone = prop1?.bone,
pos = prop1?.coords,
rot = prop1?.rotation,
},
{
model = prop2?.model,
bone = prop2?.bone,
pos = prop2?.coords,
rot = prop2?.rotation,
}
},
}
end
---This function opens a progress bar.
---@param options table
---@param cb any
---@param isQBInput boolean||optional
---@return boolean
function ProgressBar.Open(options, cb, isQBInput)
if isQBInput then
options = convertFromQB(options)
else
options = convertFromOx(options)
end
local success = exports.lation_ui:progressBar(options)
if cb then cb(not success) end
return success
end
return ProgressBar

View file

@ -0,0 +1,67 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "ox_lib"
local configValue = BridgeClientConfig.ProgressBarSystem
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
ProgressBar = ProgressBar or {}
---This function converts a QB progress bar options table to an Ox progress bar options table.
---@param options table
---@return table
local function convertFromQB(options)
if not options then return options end
local prop1 = options.prop or {}
local prop2 = options.propTwo or {}
local props = {
{
model = prop1.model,
bone = prop1.bone,
pos = prop1.coords,
rot = prop1.rotation,
},
{
model = prop2.model,
bone = prop2.bone,
pos = prop2.coords,
rot = prop2.rotation,
}
}
return {
duration = options.duration,
label = options.label,
position = 'bottom',
useWhileDead = options.useWhileDead,
canCancel = options.canCancel,
disable = {
move = options.controlDisables?.disableMovement,
car = options.controlDisables?.disableCarMovement,
combat = options.controlDisables?.disableCombat,
mouse = options.controlDisables?.disableMouse
},
anim = {
dict = options.animation?.animDict,
clip = options.animation?.anim,
flag = options.animation?.flags or 49,
},
prop = props,
}
end
---This function opens a progress bar.
---@param options table
---@param cb any
---@param isQBInput boolean||optional
---@return boolean
function ProgressBar.Open(options, cb, isQBInput)
if isQBInput then
options = convertFromQB(options)
end
local style = options.style or 'bar'
local success = style == 'circle' and exports.ox_lib:progressCircle(options) or exports.ox_lib:progressBar(options)
if cb then cb(not success) end
return success
end
return ProgressBar

View file

@ -0,0 +1,66 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "progressbar"
local configValue = BridgeClientConfig.ProgressBarSystem
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
ProgressBar = ProgressBar or {}
---This function converts an Ox progress bar options table to a QB progress bar options table.
---@param options table
---@return table
local function convertFromOx(options)
if not options then return options end
local prop1 = options.prop?[1] or options.prop or {}
local prop2 = options.prop?[2] or {}
return {
name = options.label,
duration = options.duration,
label = options.label,
useWhileDead = options.useWhileDead,
canCancel = options.canCancel,
controlDisables = {
disableMovement = options.disable?.move,
disableCarMovement = options.disable?.car,
disableMouse = options.disable?.mouse,
disableCombat = options.disable?.combat
},
animation = {
animDict = options.anim?.dict,
anim = options.anim?.clip,
flags = options.anim?.flag or 49
},
prop = {
model = prop1.model,
bone = prop1.bone,
coords = prop1.pos,
rotation = prop1.rot
},
propTwo = {
model = prop2.model,
bone = prop2.bone,
coords = prop2.pos,
rotation = prop2.rot
}
}
end
---This function opens a progress bar.
---@param options table
---@param cb any
---@param qbFormat boolean
---@return boolean boolean
function ProgressBar.Open(options, cb, qbFormat)
if not exports['progressbar'] then return false end
if not qbFormat then
options = convertFromOx(options)
end
local prom = promise.new()
exports['progressbar']:Progress(options, function(cancelled)
if cb then cb(not cancelled) end
prom:resolve(not cancelled)
end)
return Citizen.Await(prom)
end
return ProgressBar