-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(resource/interface): formatting and type definitions
- Loading branch information
Showing
8 changed files
with
414 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
---@param value string | ||
function lib.setClipboard(value) | ||
SendNUIMessage({ | ||
action = 'setClipboard', | ||
data = value | ||
}) | ||
end | ||
SendNUIMessage({ | ||
action = 'setClipboard', | ||
data = value | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,49 @@ | ||
local input | ||
|
||
function lib.inputDialog(heading, rows) | ||
if input then return end | ||
input = promise.new() | ||
---@class InputDialogRowProps | ||
---@field type 'input' | 'number' | 'checkbox' | 'select' | 'slider' | ||
---@field label string | ||
---@field options? { value: string, label: string, default?: string }[] | ||
---@field password? boolean | ||
---@field icon? string | ||
---@field iconColor? string | ||
---@field placeholder? string | ||
---@field default? string | number | ||
---@field checked? boolean | ||
---@field min? number | ||
---@field max? number | ||
---@field step? number | ||
|
||
-- Backwards compat with string tables | ||
for i = 1, #rows do | ||
if type(rows[i]) == 'string' then | ||
rows[i] = {type = 'input', label = rows[i]} | ||
end | ||
---@param heading string | ||
---@param rows string[] | InputDialogRowProps[] | ||
---@return string[] | number[] | boolean[] | nil | ||
function lib.inputDialog(heading, rows) | ||
if input then return end | ||
input = promise.new() | ||
|
||
end | ||
-- Backwards compat with string tables | ||
for i = 1, #rows do | ||
if type(rows[i]) == 'string' then | ||
rows[i] = { type = 'input', label = rows[i] --[[@as string]] } | ||
end | ||
end | ||
|
||
SetNuiFocus(true, true) | ||
SendNUIMessage({ | ||
action = 'openDialog', | ||
data = { | ||
heading = heading, | ||
rows = rows | ||
} | ||
}) | ||
SetNuiFocus(true, true) | ||
SendNUIMessage({ | ||
action = 'openDialog', | ||
data = { | ||
heading = heading, | ||
rows = rows | ||
} | ||
}) | ||
|
||
return Citizen.Await(input) | ||
return Citizen.Await(input) | ||
end | ||
|
||
RegisterNUICallback('inputData', function(data, cb) | ||
cb(1) | ||
SetNuiFocus(false, false) | ||
local promise = input | ||
input = nil | ||
promise:resolve(data) | ||
end) | ||
cb(1) | ||
SetNuiFocus(false, false) | ||
local promise = input | ||
input = nil | ||
promise:resolve(data) | ||
end) |
Oops, something went wrong.