Skip to content
cyudevPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

CyuUI Menu Creation Guide (FR/EN)

Francais

Objectif

Ce README explique comment creer un menu CyuUI en Lua (FiveM), avec tous les styles de boutons/items disponibles dans ce module.

Types d'items disponibles

  • AddButton
  • AddLinkButton
  • AddCheckbox
  • AddList
  • AddColorList
  • AddSlider
  • AddSeparator
  • AddLine

Creation d'un menu

local MainMenu = CyuUI.CreateMenu(
    "Mon Menu",                -- title
    "INTERACTIONS",            -- subTitle
    "Selectionnez une action", -- description
    "",                        -- banner (url ou vide)
    "F6",                      -- key (optionnel)
    "Ouvrir le menu",          -- mappingDescription (optionnel)
    "#E53935"                  -- bannerColor (optionnel)
)

local SubMenu = CyuUI.CreateSubMenu(
    MainMenu,
    "Sous Menu",
    "DETAILS",
    "Options secondaires",
    "",
    "#1E88E5"
)

Affichage / callbacks

MainMenu:OnOpen(function()
    print("Menu ouvert")
end)

MainMenu:OnClose(function()
    print("Menu ferme")
end)

MainMenu:SetClosable(true) -- false pour bloquer la fermeture via retour

Structure recommandee: SetItems

Le menu reconstruit ses items en temps reel. Utilisez SetItems pour declarer le contenu:

local checkboxState = false
local listIndex = 0
local colorIndex = 0
local sliderValue = 50

MainMenu:SetItems(function(Items)
    Items:AddButton("Bouton simple", "Action classique", {
        IsDisabled = false,
        RightLabel = "~g~OK",
        LeftBadge = "TICK_ICON",
        RightBadge = "NEW_STAR",
        Color = "#FFFFFF" -- actuellement non applique dans l'UI
    }, function(onSelected, onHovered)
        if onSelected then
            print("Bouton selectionne")
        end
    end)

    Items:AddButton("Aller au sous-menu", "Navigation", {
        IsDisabled = false
    }, function(onSelected)
        if onSelected then
            print("Ouverture sous-menu")
        end
    end, SubMenu)

    Items:AddLinkButton("Documentation", "Ouvre un lien externe", {
        IsDisabled = false,
        LeftBadge = "HOST_CROWN",
        Color = "#FFFFFF" -- actuellement non applique dans l'UI
    }, "https://github.com/")

    Items:AddCheckbox("Mode actif", "Etat On/Off", checkboxState, {
        IsDisabled = false,
        LeftBadge = "TICK_ICON",
        Color = "#FFFFFF" -- actuellement non applique dans l'UI
    }, function(onSelected)
        if onSelected then
            checkboxState = not checkboxState
        end
    end)

    Items:AddList("Difficulte", "Choix de niveau", listIndex, {
        "Facile", "Normal", "Difficile"
    }, {
        IsDisabled = false,
        LeftBadge = "ARROWS_UPDOWN",
        Color = "#FFFFFF" -- actuellement non applique dans l'UI
    }, function(onSelected, onHovered, onListChange, index)
        if onListChange then
            listIndex = index
        end
        if onSelected then
            print("Difficulte:", index)
        end
    end)

    Items:AddColorList("Couleur UI", "Choix de couleur", colorIndex, {
        "#E53935", "#FB8C00", "#FDD835", "#43A047", "#1E88E5"
    }, {
        IsDisabled = false,
        LeftBadge = "ART_ICON_A",
        Color = "#FFFFFF" -- actuellement non applique dans l'UI
    }, function(onSelected, onHovered, onListChange, index)
        if onListChange then
            colorIndex = index
        end
        if onSelected then
            print("Couleur index:", index)
        end
    end)

    Items:AddSlider("Volume", "Reglage du son", sliderValue, 10, {
        IsDisabled = false,
        ShowPercentage = true,
        Color = "#FFFFFF" -- actuellement non applique dans l'UI
    }, function(onSelected, onHovered, onChange, percentage)
        if onChange then
            sliderValue = percentage
        end
    end)

    Items:AddSeparator("SEPARATEUR", "center") -- left | center | right
    Items:AddLine({ "#E53935", "#1E88E5", "#43A047" })
end)

Ouvrir / fermer le menu

MainMenu:SetVisible(true)   -- ouvrir
MainMenu:SetVisible(false)  -- fermer

Navigation entre menus

MainMenu:Goto(SubMenu) -- aller vers cible
SubMenu:Goback()       -- retour parent

Details des styles par type

AddButton

  • IsDisabled: boolean
  • RightLabel: string|number
  • LeftBadge: BadgeName
  • RightBadge: BadgeName
  • Color: string (champ present mais non applique visuellement dans la version actuelle)

AddLinkButton

  • IsDisabled: boolean
  • LeftBadge: BadgeName
  • Color: string (non applique visuellement actuellement)

AddCheckbox

  • IsDisabled: boolean
  • LeftBadge: BadgeName
  • Color: string (non applique visuellement actuellement)

AddList / AddColorList

  • IsDisabled: boolean
  • LeftBadge: BadgeName
  • Color: string (non applique visuellement actuellement)
  • Index attendu en base 0

AddSlider

  • IsDisabled: boolean
  • ShowPercentage: boolean
  • Color: string (non applique visuellement actuellement)
  • Percentage: 0 a 100
  • Step: increment/decrement du slider

AddSeparator

  • Position: "left" | "center" | "right"

AddLine

  • Colors: string[] (hex/rgb/rgba)

Badges supportes (exemples)

ARROW_LEFT, ARROW_RIGHT, HOST_CROWN, NEW_STAR, TICK_ICON, LOCK_ICON, ART_ICON_A, BARBER_ICON_A, GUNCLUB_ICON_A, etc.

La liste complete est definie dans items/_loadItems.lua (---@alias BadgeName).

Notes importantes

  • AddList, AddColorList et AddSlider sont valides uniquement sur un menu (pas sur contextMenu).
  • Le systeme met a jour les items en boucle (UpdateItems), donc vos etats (checkboxState, listIndex, etc.) doivent etre stockes dans des variables persistantes.
  • Les champs styles.Color existent cote Lua/props mais ne sont pas rendus dans les composants React actuels.

English

Goal

This README explains how to build a CyuUI menu in Lua (FiveM), including every button/item style currently available in this module.

Available item types

  • AddButton
  • AddLinkButton
  • AddCheckbox
  • AddList
  • AddColorList
  • AddSlider
  • AddSeparator
  • AddLine

Create a menu

local MainMenu = CyuUI.CreateMenu(
    "My Menu",                -- title
    "INTERACTIONS",           -- subTitle
    "Select an action",       -- description
    "",                       -- banner (url or empty)
    "F6",                     -- key (optional)
    "Open menu",              -- mappingDescription (optional)
    "#E53935"                 -- bannerColor (optional)
)

local SubMenu = CyuUI.CreateSubMenu(
    MainMenu,
    "Sub Menu",
    "DETAILS",
    "Secondary options",
    "",
    "#1E88E5"
)

Visibility / callbacks

MainMenu:OnOpen(function()
    print("Menu opened")
end)

MainMenu:OnClose(function()
    print("Menu closed")
end)

MainMenu:SetClosable(true) -- false to prevent close on back

Recommended structure: SetItems

The menu rebuilds items in real time. Use SetItems to declare content:

local checkboxState = false
local listIndex = 0
local colorIndex = 0
local sliderValue = 50

MainMenu:SetItems(function(Items)
    Items:AddButton("Simple button", "Classic action", {
        IsDisabled = false,
        RightLabel = "~g~OK",
        LeftBadge = "TICK_ICON",
        RightBadge = "NEW_STAR",
        Color = "#FFFFFF" -- currently not rendered in UI
    }, function(onSelected, onHovered)
        if onSelected then
            print("Button selected")
        end
    end)

    Items:AddButton("Go to submenu", "Navigation", {
        IsDisabled = false
    }, function(onSelected)
        if onSelected then
            print("Opening submenu")
        end
    end, SubMenu)

    Items:AddLinkButton("Documentation", "Open external link", {
        IsDisabled = false,
        LeftBadge = "HOST_CROWN",
        Color = "#FFFFFF" -- currently not rendered in UI
    }, "https://github.com/")

    Items:AddCheckbox("Active mode", "On/Off state", checkboxState, {
        IsDisabled = false,
        LeftBadge = "TICK_ICON",
        Color = "#FFFFFF" -- currently not rendered in UI
    }, function(onSelected)
        if onSelected then
            checkboxState = not checkboxState
        end
    end)

    Items:AddList("Difficulty", "Select level", listIndex, {
        "Easy", "Normal", "Hard"
    }, {
        IsDisabled = false,
        LeftBadge = "ARROWS_UPDOWN",
        Color = "#FFFFFF" -- currently not rendered in UI
    }, function(onSelected, onHovered, onListChange, index)
        if onListChange then
            listIndex = index
        end
        if onSelected then
            print("Difficulty:", index)
        end
    end)

    Items:AddColorList("UI Color", "Pick a color", colorIndex, {
        "#E53935", "#FB8C00", "#FDD835", "#43A047", "#1E88E5"
    }, {
        IsDisabled = false,
        LeftBadge = "ART_ICON_A",
        Color = "#FFFFFF" -- currently not rendered in UI
    }, function(onSelected, onHovered, onListChange, index)
        if onListChange then
            colorIndex = index
        end
        if onSelected then
            print("Color index:", index)
        end
    end)

    Items:AddSlider("Volume", "Audio setting", sliderValue, 10, {
        IsDisabled = false,
        ShowPercentage = true,
        Color = "#FFFFFF" -- currently not rendered in UI
    }, function(onSelected, onHovered, onChange, percentage)
        if onChange then
            sliderValue = percentage
        end
    end)

    Items:AddSeparator("SEPARATOR", "center") -- left | center | right
    Items:AddLine({ "#E53935", "#1E88E5", "#43A047" })
end)

Open / close

MainMenu:SetVisible(true)   -- open
MainMenu:SetVisible(false)  -- close

Navigation

MainMenu:Goto(SubMenu) -- go to target
SubMenu:Goback()       -- return to parent

Style fields per item type

AddButton

  • IsDisabled: boolean
  • RightLabel: string|number
  • LeftBadge: BadgeName
  • RightBadge: BadgeName
  • Color: string (field exists but is not visually rendered in current UI)

AddLinkButton

  • IsDisabled: boolean
  • LeftBadge: BadgeName
  • Color: string (currently not visually rendered)

AddCheckbox

  • IsDisabled: boolean
  • LeftBadge: BadgeName
  • Color: string (currently not visually rendered)

AddList / AddColorList

  • IsDisabled: boolean
  • LeftBadge: BadgeName
  • Color: string (currently not visually rendered)
  • Index is expected to be 0-based

AddSlider

  • IsDisabled: boolean
  • ShowPercentage: boolean
  • Color: string (currently not visually rendered)
  • Percentage: 0 to 100
  • Step: slider increment/decrement

AddSeparator

  • Position: "left" | "center" | "right"

AddLine

  • Colors: string[] (hex/rgb/rgba)

Supported badges (examples)

ARROW_LEFT, ARROW_RIGHT, HOST_CROWN, NEW_STAR, TICK_ICON, LOCK_ICON, ART_ICON_A, BARBER_ICON_A, GUNCLUB_ICON_A, etc.

Full list is defined in items/_loadItems.lua (---@alias BadgeName).

Important notes

  • AddList, AddColorList, and AddSlider only work on menu (not contextMenu).
  • Items are refreshed continuously (UpdateItems), so your state (checkboxState, listIndex, etc.) must live in persistent variables.
  • styles.Color is exposed in Lua/props but is not rendered by the current React item components.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors