-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaleform class #698
base: master
Are you sure you want to change the base?
Scaleform class #698
Conversation
imports/scaleform/client.lua
Outdated
end | ||
|
||
self.handle = scaleform | ||
self.draw = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args
cannot be falsey, so this if statement is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always be true
.
imports/scaleform/client.lua
Outdated
end | ||
|
||
---@param name string | ||
---@param args? table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I pushed without checking 😅
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.