mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
Some people accidentally, mistakenly, and without any malicious intent forget to attribute code from this resource to its source. This change will hopefully assist people, so that they do not make that mistake again.
50 lines
1.1 KiB
Lua
50 lines
1.1 KiB
Lua
--[[
|
|
https://github.com/overextended/ox_lib
|
|
|
|
This file is licensed under LGPL-3.0 or higher <https://www.gnu.org/licenses/lgpl-3.0.en.html>
|
|
|
|
Copyright (c) 2025 Linden <https://github.com/thelindat/fivem>
|
|
]]
|
|
|
|
---@class TextUIOptions
|
|
---@field position? 'right-center' | 'left-center' | 'top-center' | 'bottom-center';
|
|
---@field icon? string | {[1]: IconProp, [2]: string};
|
|
---@field iconColor? string;
|
|
---@field style? string | table;
|
|
---@field alignIcon? 'top' | 'center';
|
|
|
|
local isOpen = false
|
|
local currentText
|
|
|
|
---@param text string
|
|
---@param options? TextUIOptions
|
|
function lib.showTextUI(text, options)
|
|
if currentText == text then return end
|
|
|
|
if not options then options = {} end
|
|
|
|
options.text = text
|
|
currentText = text
|
|
|
|
SendNUIMessage({
|
|
action = 'textUi',
|
|
data = options
|
|
})
|
|
|
|
isOpen = true
|
|
end
|
|
|
|
function lib.hideTextUI()
|
|
SendNUIMessage({
|
|
action = 'textUiHide'
|
|
})
|
|
|
|
isOpen = false
|
|
currentText = nil
|
|
end
|
|
|
|
---@return boolean, string | nil
|
|
function lib.isTextUIOpen()
|
|
return isOpen, currentText
|
|
end
|