41 lines
844 B
Lua
41 lines
844 B
Lua
|
---@class TextUIOptions
|
||
|
---@field position? 'right-center' | 'left-center' | 'top-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
|