2022-09-18 09:06:32 +10:00
|
|
|
---@class TextUIOptions
|
2024-03-09 11:04:18 +01:00
|
|
|
---@field position? 'right-center' | 'left-center' | 'top-center' | 'bottom-center';
|
2023-03-10 19:38:34 +00:00
|
|
|
---@field icon? string | {[1]: IconProp, [2]: string};
|
2022-09-18 09:06:32 +10:00
|
|
|
---@field iconColor? string;
|
2023-04-17 06:50:12 +02:00
|
|
|
---@field style? string | table;
|
2023-11-15 14:30:33 +01:00
|
|
|
---@field alignIcon? 'top' | 'center';
|
2022-09-18 09:06:32 +10:00
|
|
|
|
2022-10-14 17:17:57 +02:00
|
|
|
local isOpen = false
|
2023-05-19 21:41:58 +10:00
|
|
|
local currentText
|
2022-10-14 17:17:57 +02:00
|
|
|
|
2022-09-18 09:06:32 +10:00
|
|
|
---@param text string
|
2022-10-14 17:08:20 -06:00
|
|
|
---@param options? TextUIOptions
|
2022-04-11 15:59:18 +02:00
|
|
|
function lib.showTextUI(text, options)
|
2023-05-19 21:41:58 +10:00
|
|
|
if currentText == text then return end
|
|
|
|
|
|
2022-04-11 15:59:18 +02:00
|
|
|
if not options then options = {} end
|
2023-05-19 21:41:58 +10:00
|
|
|
|
2022-04-11 15:59:18 +02:00
|
|
|
options.text = text
|
2023-05-19 21:41:58 +10:00
|
|
|
currentText = text
|
|
|
|
|
|
2022-04-11 15:59:18 +02:00
|
|
|
SendNUIMessage({
|
|
|
|
|
action = 'textUi',
|
|
|
|
|
data = options
|
|
|
|
|
})
|
2023-05-19 21:41:58 +10:00
|
|
|
|
2022-10-14 17:17:57 +02:00
|
|
|
isOpen = true
|
2022-04-11 15:59:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function lib.hideTextUI()
|
|
|
|
|
SendNUIMessage({
|
|
|
|
|
action = 'textUiHide'
|
|
|
|
|
})
|
2023-05-19 21:41:58 +10:00
|
|
|
|
2022-10-14 17:17:57 +02:00
|
|
|
isOpen = false
|
2023-05-19 21:41:58 +10:00
|
|
|
currentText = nil
|
2022-10-14 17:17:57 +02:00
|
|
|
end
|
|
|
|
|
|
2023-12-06 21:36:37 +01:00
|
|
|
---@return boolean, string | nil
|
2022-10-14 17:17:57 +02:00
|
|
|
function lib.isTextUIOpen()
|
2023-12-06 21:36:37 +01:00
|
|
|
return isOpen, currentText
|
|
|
|
|
end
|