Merge branch 'main' of https://github.com/SinapsDev/community_bridge
This commit is contained in:
commit
56043f06ed
19 files changed
+465
-959
No files matched your search
@@ -0,0 +1,27 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
HelpText = HelpText or {}
|
||||
local resourceName = "ZSX_UIV2"
|
||||
local configValue = BridgeSharedConfig.HelpText
|
||||
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
|
||||
|
||||
---This will get the name of the in use resource.
|
||||
---@return string
|
||||
HelpText.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
---This will show a help text message at the screen position passed
|
||||
---@param message string
|
||||
---@param position string
|
||||
---@return nil
|
||||
HelpText.ShowHelpText = function(message, position)
|
||||
return exports['ZSX_UIV2']:TextUI_Persistent(nil, message, nil, nil, nil)
|
||||
end
|
||||
|
||||
---This will hide the help text message on the screen
|
||||
---@return nil
|
||||
HelpText.HideHelpText = function()
|
||||
return exports['ZSX_UIV2']:TextUI_RemovePersistent(false)
|
||||
end
|
||||
|
||||
return HelpText
|
||||
@@ -0,0 +1,48 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
Notify = Notify or {}
|
||||
local resourceName = "ZSX_UIV2"
|
||||
local configValue = BridgeSharedConfig.Notify
|
||||
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
|
||||
|
||||
Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
local function getIconByType(_type)
|
||||
local icon = "info"
|
||||
if _type == "success" then
|
||||
icon = "check-circle"
|
||||
elseif _type == "error" then
|
||||
icon = "times-circle"
|
||||
elseif _type == "warning" then
|
||||
icon = "exclamation-triangle"
|
||||
end
|
||||
return icon
|
||||
end
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
local icon = getIconByType(_type)
|
||||
local serial = exports['ZSX_UIV2']:Notification(placeHolderText, message, icon, time)
|
||||
return serial
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
---@param _type string
|
||||
---@param time number
|
||||
---@props table optional
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = placeHolderText end
|
||||
local icon = getIconByType(_type)
|
||||
exports['ZSX_UIV2']:Notification(title, message, icon, time)
|
||||
end
|
||||
|
||||
return Notify
|
||||
@@ -0,0 +1,121 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
local resourceName = "ZSX_UIV2"
|
||||
local configValue = BridgeClientConfig.ProgressBarSystem
|
||||
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
|
||||
|
||||
ProgressBar = ProgressBar or {}
|
||||
|
||||
ProgressBar.GetResourceName = function()
|
||||
return "ZSX_UIV2"
|
||||
end
|
||||
|
||||
---This function converts an Ox progress bar options table to ZSX_UIV2 format.
|
||||
---@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 {
|
||||
label = options.label,
|
||||
duration = options.duration,
|
||||
canCancel = options.canCancel,
|
||||
disableControls = {
|
||||
disable_mouse = options.disable?.mouse,
|
||||
disable_walk = options.disable?.move,
|
||||
disable_driving = options.disable?.car,
|
||||
disable_combat = options.disable?.combat
|
||||
},
|
||||
anim = options.anim and {
|
||||
dict = options.anim.dict,
|
||||
clip = options.anim.clip,
|
||||
flag = options.anim.flag or 49
|
||||
} or nil,
|
||||
prop1 = prop1.model and {
|
||||
model = prop1.model,
|
||||
bone = prop1.bone,
|
||||
pos = prop1.pos,
|
||||
rot = prop1.rot
|
||||
} or nil,
|
||||
prop2 = prop2.model and {
|
||||
model = prop2.model,
|
||||
bone = prop2.bone,
|
||||
pos = prop2.pos,
|
||||
rot = prop2.rot
|
||||
} or nil
|
||||
}
|
||||
end
|
||||
|
||||
---This function converts a QB progress bar options table to ZSX_UIV2 format.
|
||||
---@param options table
|
||||
---@return table
|
||||
local function convertFromQB(options)
|
||||
if not options then return options end
|
||||
|
||||
return {
|
||||
label = options.label,
|
||||
duration = options.duration,
|
||||
canCancel = options.canCancel,
|
||||
disableControls = {
|
||||
disable_mouse = options.controlDisables?.disableMouse,
|
||||
disable_walk = options.controlDisables?.disableMovement,
|
||||
disable_driving = options.controlDisables?.disableCarMovement,
|
||||
disable_combat = options.controlDisables?.disableCombat
|
||||
},
|
||||
anim = options.animation and {
|
||||
dict = options.animation.animDict,
|
||||
clip = options.animation.anim,
|
||||
flag = options.animation.flags or 49
|
||||
} or nil,
|
||||
prop1 = options.prop and options.prop.model and {
|
||||
model = options.prop.model,
|
||||
bone = options.prop.bone,
|
||||
pos = options.prop.coords,
|
||||
rot = options.prop.rotation
|
||||
} or nil,
|
||||
prop2 = options.propTwo and options.propTwo.model and {
|
||||
model = options.propTwo.model,
|
||||
bone = options.propTwo.bone,
|
||||
pos = options.propTwo.coords,
|
||||
rot = options.propTwo.rotation
|
||||
} or nil
|
||||
}
|
||||
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['ZSX_UIV2'] then return false end
|
||||
|
||||
if qbFormat then
|
||||
options = convertFromQB(options)
|
||||
else
|
||||
options = convertFromOx(options)
|
||||
end
|
||||
local prom = promise.new()
|
||||
exports['ZSX_UIV2']:ProgressBar(
|
||||
'fas fa-circle-notch',
|
||||
options.label,
|
||||
options.duration or 5000,
|
||||
function()
|
||||
if cb then cb(true) end
|
||||
prom:resolve(true)
|
||||
end,
|
||||
function()
|
||||
if cb then cb(false) end
|
||||
prom:resolve(false)
|
||||
end,
|
||||
options.canCancel,
|
||||
options.disableControls,
|
||||
options.anim,
|
||||
options.prop1,
|
||||
options.prop2
|
||||
)
|
||||
return Citizen.Await(prom)
|
||||
end
|
||||
|
||||
return ProgressBar
|
||||
Reference in new issue
Block a user