Conversation
imports/scaleform/client.lua
Outdated
| end | ||
|
|
||
| self.handle = scaleform | ||
| self.draw = false |
There was a problem hiding this comment.
Please use more descriptive property names like isDrawing or such.
You could also use private properties or otherwise mark the property as private for LLS.
imports/scaleform/client.lua
Outdated
| ---@return nil | ||
| ---@description Create a new scaleform class | ||
| function lib.scaleform:constructor(details) | ||
| details = type(details) == "table" and details or { name = details } |
There was a problem hiding this comment.
You've mixed ' and " for strings in a number of places. We generally use '.
imports/scaleform/client.lua
Outdated
| if not self.handle then | ||
| return error('Scaleform handle is nil') | ||
| end | ||
|
|
||
| if type(args) ~= 'table' then | ||
| return error('Args must be a table') | ||
| end |
There was a problem hiding this comment.
These error messages (and elsewhere) could be formatted a little better. I've used a typeError function in some other parts of ox_lib.
| BeginScaleformMovieMethod(self.handle, name) | ||
|
|
||
| if args then | ||
| convertArgs(args) |
There was a problem hiding this comment.
args cannot be falsey, so this if statement is redundant.
There was a problem hiding this comment.
I corrected the code because args can be false. Here is a modified code from qbx_police where I tested the scaleform class.
local function setupIntructionalScaleform()
if not currentScaleform then
return
end
currentScaleform:callMethod('CLEAR_ALL')
currentScaleform:callMethod('SET_CLEAR_SPACE', { 200 })
currentScaleform:callMethod('SET_DATA_SLOT', { 1, GetControlInstructionalButton(1, 177, true), 'Fermer la caméra' })
currentScaleform:callMethod('DRAW_INSTRUCTIONAL_BUTTONS')
currentScaleform:callMethod('SET_BACKGROUND_COLOUR', { 0, 0, 0, 80 })
end
imports/scaleform/client.lua
Outdated
|
|
||
| ---@param expectedType 'boolean' | 'integer' | 'string' | ||
| ---@return boolean | integer | string | ||
| ---@description Awaits the return value, and converts it to a usable data type |
There was a problem hiding this comment.
No need for @description here and in other places.
imports/scaleform/client.lua
Outdated
| self.handle = scaleform | ||
| self.draw = false | ||
|
|
||
| self.fullScreen = details.fullScreen ~= nil and details.fullScreen or true |
imports/scaleform/client.lua
Outdated
| end | ||
|
|
||
| ---@param name string | ||
| ---@param args? table |
There was a problem hiding this comment.
Should not be marked as optional, as your type check ensures it is a table. You should also clarify that it's an array-like table and which types are valid - (number | string | boolean)[]
|
I did all the changes with this fix, check if this is what you wanted and let me know if there is something else. |
| local scaleform = lib.requestScaleformMovie(details.name) | ||
|
|
||
| self.sfHandle = scaleform | ||
| self.private.isDrawing = false |
There was a problem hiding this comment.
You've set isDrawing as private, but other references to the variable don't check the private table.
There was a problem hiding this comment.
Sorry I pushed without checking 😅
Signed-off-by: Linden <[email protected]>
This add a scaleform class for a better management and usage of scaleforms.
At first it was a PR from Mycroft-Studios intended for qbx_core, but after discussions with the team we felt that this code would fit better in ox_lib so chatty asked for someone to create a PR.