[Release] Scaleform

lua
scaleform
gui

#1

Scaleform

Simple and easy-to-use module for Scaleform GUI.
You can use it as a separate resource or just add the file to your client_scripts.

Usage Example
local buttons = {
    { input = ~INPUT_CELLPHONE_LEFT~,  text = "Previous Player" },
    { input = ~INPUT_CELLPHONE_RIGHT~, text = "Next Player" },
}

local scaleform = Scaleform:Request('INSTRUCTIONAL_BUTTONS')
for i = 1, #buttons do
	scaleform:Call('SET_DATA_SLOT', i - 1, buttons[i].input, buttons[i].text)
end
scaleform:Call('DRAW_INSTRUCTIONAL_BUTTONS')

while true do
    Citizen.Wait(0)
    scaleform:RenderFullscreen()
end
API
Scaleform:Request(id)
Scaleform:Delete()
Scaleform:Call(func, ...) -- use string, number or boolean parameters
Scaleform:Render(x, y, w, h, r, g, b, a)
Scaleform:RenderFullscreen(r, g, b, a)
Scaleform:RenderTimed(ms, x, y, w, h, r, g, b, a)
Scaleform:RenderFullscreenTimed(ms, r, g, b, a)

Helpful Resources

Scaleform Wiki
Scaleforms + Functions List

Links

Read and Comment
Download


#2

Updated

  • Used simple Lua class implementation for more friendly API
  • Added timeout parameter to Scaleform:Request() to prevent infinite while-true loop

#3

There no need for a timeout parameter, check the handle instead…

function LoadScaleForm(scaleform)
	local scaleform = RequestScaleformMovie(scaleform)
	if scaleform ~= 0 then
		while not HasScaleformMovieLoaded(scaleform) do
			Citizen.Wait(0)
		end
	end
	return scaleform
end

#4

Updated

  • Added Scaleform:RenderTimed and Scaleform:RenderFullscreenTimed API
  • Improved log format and code style