Skip to content

How To Use

ach edited this page Mar 31, 2023 · 2 revisions

Contents

  1. GTA:O Menu
  2. 🚧 Work in progress

GTA:O Menu


🧬 Creation/Initializations of a menu:


Create Menu

GtaLib:createMenu(name, subtitle, banner)

Parameters Description
name Name write at the top in the banner. Left blank ("") if you don’t want text in the banner.
subtitle Subtitle write beyond the banner. Left blank (nil) if you don’t want subtitle rectangle.
banner Automaticly create material. Need to be in gta_lib/[material.png] folder.

Example:

local testMenu = GtaLib:createMenu("GTA Menu", "Test subtitle" --[[, "banner247" ]])

Create Submenu

GtaLib:createSubMenu(parent, name, subtitle, banner)

Parameters Description
parent Parent menu (can be a submenu). On goback is the menu displayed
name Name write at the top in the banner. Left blank ("") if you don’t want text in the banner.
subtitle Subtitle write beyond the banner. Left blank (nil) if you don’t want subtitle rectangle.
banner Automaticly create material. Need to be in gta_lib/[material.png] folder.

Example:

local testSubMenu = GtaLib:createSubMenu(testMenu, "GTA Submenu", "Test subtitle" --[[, "banner247" ]])
local testSubSubMenu = GtaLib:createSubMenu(testSubMenu , "GTA Subsubmenu", "Test subtitle" --[[, "banner247" ]])

👀 Display menu:


Draw Menu

GtaLib:drawMenu(menu, handler)

Parameters Description
menu Menu drawed
handler Function that contains buttons. Handler executed in display loop.

Example:

GtaLib:drawMenu(testMenu, function(menu)
    -- Handler
end)

🔧 Ajout de boutons:


Button

GtaLib:button(menu, name, description, action, style, submenu)

Parameters Description
menu Menu displayed
name Name drawed in button
description Description drawed below menu.
action Array contain mutiple possible action function.
style Array contain multiple style varibles.
submenu Submenu opened on button selected.

Example:

-- Var (put it outside )
local redColor = Color(255, 0, 0, 255)
local blueColor = Color(0, 0, 255, 255)

-- Button
GtaFW:button(menu, "Button", {
    onActive = function()
        print("onActive")
    end,
    onHovered = function()
        print("onHovered")
    end
}, { textColor = redColor, rightText = "Test Right", rightTextColor = blueColor } )

Checkbox

GtaLib:checkBox(menu, name, description, action, style, checked)

Parameters Description
menu Menu displayed
name Name drawed in button
description Description drawed below menu.
action Array contain mutiple possible action function.
style Array contain multiple style varibles.
checked Boolean for check/uncheck checkbox.

Example:

-- Var (put it outside )
local checkBox = false

-- CheckBox
GtaFW:checkBox(menu, "CheckBox", {
    onChecked = function()
        print("onChecked")
        checkBox = true
    end,
    onUnchecked = function()
        print("onUnchecked")
        checkBox = false
    end
}, {}, checkBox)

List

GtaLib:list(menu, name, action, style, list, index, submenu)

Parameters Description
menu Menu displayed
name Name drawed in button
action Array contain mutiple possible action function.
style Array contain multiple style varibles.
list Array contain string.
index Index in array list.
submenu Submenu opened on button selected.

Example:

-- Var (put it outside )
local listIndex = 1
local list = {
    "List Item #1",
    "List Item #2",
    "List Item #3",
    "List Item #4",
    "List Item #5"
}

-- List
GtaFW:list(menu, "List", {
    onListChange = function(index)
        print("onListChange")
        listIndex = index
    end
}, {}, list, listIndex, testSubmenu)

Separator

GtaLib:separator(menu, name, action, style, list, index, submenu)

Parameters Description
menu Menu displayed
name Name drawed in button
style Array contain mutiple possible style varibles.

Example:

-- Var (put it outside )
local blueColor = Color(0, 0, 255, 255)

-- List
GtaFW:separator(menu, "Separator", { textColor = blueColor })

Line Separator

GtaLib:lineSeparator(menu, style)

Parameters Description
menu Menu displayed
style Array contain mutiple possible style varibles.

Example:

-- Var (put it outside )
local blueColor = Color(0, 0, 255, 255)

-- List
GtaFW:lineSeparator(menu, { color = blueColor })

❕ Fonctions utiles:


menu:isClosable(active) Enable or disable menu can be closed

menu.onClose = function() print("onClose") end Execute function when menu closed

menu:setTitle(title) Set menu title

menu:setSubtitle(subtitle) Set menu subtitle

menu:close() Close menu

testSubmenu:goBack() Goback on menu parent

testMenu:setBackground(material) Set menu background