Skip to content
Leonardo Emanuele edited this page Aug 5, 2023 · 9 revisions

UIMenu is the NativeUI main class, it creates the base menu for you to add items to.

C#

UIMenu mainMenu = new UIMenu("Banner Title", "SUBTITLE", new PointF(0, 0));
MenuPool.Add(mainMenu); // (deprecated after The Gary release v4)

Lua:

local mainMenu = UIMenu.New("Banner Title", "SUBTITLE", 0, 0)
MenuPool:Add(mainMenu) -- (deprecated after The Gary release v4)

UIMenu

image
The base of each menu.
UIMenu contains the banner, title, subtitle, descriptions, a list of items and windows, the events when anything happens is handled by the menu itself.
It controls everything.. 👀
How do we create a UIMenu?
It is created like this:
C#:

public UIMenu(string title, string subtitle, bool glare = false, bool alternativeTitle = false, float fadingTime = 0.1f)
public UIMenu(string title, string subtitle, PointF offset, bool glare = false, bool alternativeTitle = false, float fadingTime = 0.1f)
public UIMenu(string title, string subtitle, PointF offset, KeyValuePair<string, string> customBanner, bool glare = false, bool alternativeTitle = false, float fadingTime = 0.1f)
public UIMenu(string title, string subtitle, PointF offset, string spriteLibrary, string spriteName, bool glare = false, bool alternativeTitle = false, float fadingTime = 0.1f)

Lua:

UIMenu.New(Title, Subtitle, X, Y, glare, txtDictionary, txtName, alternativeTitle, fadingTime)

What can i do with it?
These are some of the main things you can do with it:
C#:

bool MouseControlsEnabled // true to use mouse 
bool EnableAnimation // enable / disable the scrolling animation (deprecated)
MenuAnimationType AnimationType // what scrolling animation you want it to do? 
bool MouseWheelControlEnabled // true to enable the mouse wheel to scroll the menu
int MaxItemsOnScreen // the number of item to see on the screen before the scrolling kicks in.
ItemFont DescriptionFont // the font that will be used to draw the description text (default ScaleformFonts.CHALET_LONDON_NINETEENSIXTY)
ScrollingType ScrollingType // how the menu will be scrolled (CLASSIC, PAGINATED, ENDLESS)
AddItem(UIMenuItem item) // adds an item to the menu
RemoveItemAt(int index) // removes an item by its index
RemoveItem(UIMenuItem item) // removes an item
AddWindow(UIMenuWindow window) // Adds a windows to the menu
RemoveWindowAt(int index) // removes the window at index
GoUp() // makes the menu go up by 1 item
GoDown() // makes the menu go down by 1 item
GoLeft() // if the item supports it, it makes the item index go left once
GoRight() // if the item supports it, it makes the item index go right once
Select(bool playSound) // the same as pressing return on your keyboard
GoBack() // the same as pressing backspace on your keyboard
bool Visible // this activate the menu and makes it visible on screen, it can return if the menu is visible or not
int CurrentSelection // sets or returns the current selection in menu
bool IsUsingController // returns true if you're using the controller
IndexChangedEvent OnIndexChange(UIMenu sender, int newIndex) // this is called everytime you go up or down in the menu
ItemSelectEvent OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index) // called when a UIMenuItem is selected
CheckboxChangeEvent OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool Checked) // called when a UIMenuCheckBoxItem is changed true or false
ListChangedEvent OnListChange(UIMenu sender, UIMenuListItem listItem, int newIndex)  // called when a UIMenuListItem is changed left or right
ListSelectedEvent OnListSelect(UIMenu sender, UIMenuListItem listItem, int newIndex) // called when a UIMenuListItem is selected
SliderChangedEvent OnSliderChange(UIMenu sender, UIMenuSliderItem listItem, int newIndex) // called when a UIMenuSliderItem is changed left or right
OnProgressChanged OnProgressChange(UIMenu menu, UIMenuProgressItem item, int newIndex) // called when a UIMenuProgressItem is changed left or right
OnProgressSelected OnProgressSelect(UIMenu menu, UIMenuProgressItem item, int newIndex) // called when a UIMenuProgressItem is selected
StatItemProgressChange OnStatsItemChanged(UIMenu menu, UIMenuStatsItem item, int value) // called when a UIMenuStatsItem is changed left or right
ColorPanelChangedEvent OnColorPanelChange(UIMenuItem menu, UIMenuColorPanel panel, int index) // called when a UIMenuColorPanel is interacted with
PercentagePanelChangedEvent OnPercentagePanelChange(UIMenuItem menu, UIMenuPercentagePanel panel, float value) // called when a UIMenuPercentagePanel is interacted with
GridPanelChangedEvent OnGridPanelChange(UIMenuItem menu, UIMenuGridPanel panel, PointF value) // called when a UIMenuGridPanel is interacted with
MenuStateChangeEvent OnMenuStateChanged(UIMenu oldMenu, UIMenu newMenu, MenuState state) // called when a the menu is opened, closed, changed to a submenu, or gone back to a parent menu

Lua:

:MaxItemsOnScreen(max) -- the number of item to see on the screen before the scrolling kicks in.
:AnimationEnabled(enable) -- enable / disable the scrolling animation
:AnimationType(animType) -- what scrolling animation you want it to do?
:DescriptionFont(font) -- the font that will be used to draw the description text (default ScaleformFonts.CHALET_LONDON_NINETEENSIXTY)
:ScrollingType(type) -- how the menu will be scrolled (CLASSIC, PAGINATED, ENDLESS)
:CurrentSelection(value) -- sets or returns the current selection in menu
:AddWindow(Window) -- Adds a windows to the menu
:RemoveWindowAt(Index) -- removes the window at index
:AddItem(Item) -- adds an item to the menu
:RemoveItemAt(Index) -- removes an item by its index
:RemoveItem(item) -- removes an item
:Visible(bool) -- this activate the menu and makes it visible on screen, it can return if the menu is visible or not
:GoUp() -- makes the menu go up by 1 item
:GoDown() -- makes the menu go down by 1 item
:GoLeft() -- if the item supports it, it makes the item index go left once
:GoRight() -- if the item supports it, it makes the item index go right once
:SelectItem(play) -- the same as pressing return on your keyboard
:GoBack() -- the same as pressing backspace on your keyboard
:AddInstructionButton(button) -- adds an instructional button to the current menu
:RemoveInstructionButton(button) -- removes an instructional button to the current menu
OnIndexChange = function(menu, newindex) -- this is called everytime you go up or down in the menu
OnListChange = function(menu, list, newindex) -- called when a UIMenuListItem is changed left or right
OnSliderChange = function(menu, slider, newindex) -- called when a UIMenuSliderItem is changed left or right
OnProgressChange = function(menu, progress, newindex) -- called when a UIMenuProgressItem is changed left or right
OnCheckboxChange = function(menu, item, checked) -- called when a UIMenuCheckBoxItem is changed true or false
OnListSelect = function(menu, list, index) -- called when a UIMenuListItem is selected
OnSliderSelect = function(menu, slider, index) -- called when a UIMenuSliderItem is selected
OnProgressSelect = function(menu, progress, index) -- called when a UIMenuProgressItem is selected
OnItemSelect = function(menu, item, index) -- called when a UIMenuItem is selected
OnMenuChanged = function(oldmenu, newmenu, change) -- called when a the menu is opened, closed, changed to a submenu, or gone back to a parent menu
OnColorPanelChanged = function(oldmenu, newmenu, change) -- called when a UIMenuColorPanel is interacted with
OnPercentagePanelChanged = function(oldmenu, newmenu, change) -- called when a UIMenuPercentagePanel is interacted with
OnGridPanelChanged = function(oldmenu, newmenu, change) -- called when a UIMenuGridPanel is interacted with

Note that this are some of the UIMenu function working atm and they can be changed / added / removed in any moment due to development needs!

Description

image
The menu will show a description for each item that has one, the description is bounded to the selected item and will change when you select a different item.
It supports emojis, blips, and input icons.


Panels and Side Panels

Panels in ScaleformUI are available in 2 different types, classic panels, and side panels.
Each panel is bound to an item, this means that if a panel is added to an item, it will be visible only if that item is selected.
All panels are directly accessible only by the mouse cursor, but can be interacted with the controller or code via their methods / values.

Panels

UIMenuColorPanel

image
The first of the panels we are gonna see now is the Color panel.
It comes in 3 different color templates:

  • Makeup colors (64 colors for make up palette)
  • Hair colors (64 colors for hair palette)
  • Custom colors (customizable number of colors decided by the developer) It's called via: C#:
UIMenuColorPanel(string title, ColorPanelType ColorType, int startIndex = 0) // for the predefined palettes
UIMenuColorPanel(string title, List<HudColor> colors, int startIndex = 0) // for the customizable colors

Lua:

UIMenuColorPanel.New(title, colorType, startIndex, colors) // colors is nil if using predefined palettes or a table of colors

Currently ScaleformUI supports only HUD colors, this means you can only set a custom palette by using a List in C# or a table of strings in Lua ad example: {"HUD_COLOUR_GREEN", "HUD_COLOUR_RED", "HUD_COLOUR_FREEMODE", "HUD_COLOUR_PURPLE", "HUD_COLOUR_TREVOR"}
The color panel has only a couple more of features: C#:

int CurrentSelection{ get; set; }
ColorPanelChangedEvent OnColorPanelChange(UIMenuItem parentItem, UIMenuColorPanel panel, int newValue)

Lua:

:CurrentSelection(new_value)
OnColorPanelChanged = function(item, panel, newindex)

UIMenuPercentagePanel

image This panel is simply a progressive panel.
Called via: C#:

UIMenuPercentagePanel(string title, string MinText = "0%", string MaxText = "100%", float initialValue = 0)

Lua:

UIMenuPercentagePanel.New(title, minText, maxText, initialValue)

Its functions are: C#:

float Percentage { get; set; }
PercentagePanelChangedEvent OnPercentagePanelChange(UIMenuItem item, UIMenuPercentagePanel panel, float value)

Lua:

:Percentage(value)
OnPercentagePanelChange = function(item, panel, value)

UIMenuGridPanel

image

  • This scaleform comes 2 variants: full / horizontal.
  • It's value is a Vector2 in Lua and a PointF in C#, both X and Y go from 0 to 1 this means that a value of 0.5 is the center of the grid.

Called via:
C#:

UIMenuGridPanel(string TopText, string LeftText, string RightText, string BottomText, PointF circlePosition) // full grid
UIMenuGridPanel(string LeftText, string RightText, PointF circlePosition) // half grid

Lua:

UIMenuGridPanel.New(topText, leftText, rightText, bottomText, circlePosition, gridType) -- set gridType to 0 for the full grid or 1 for the horizontal grid

Its functions are:
C#:

PointF CirclePosition { get; set; }
GridPanelChangedEvent OnGridPanelChange(UIMenuItem item, UIMenuGridPanel panel, PointF newPosition)

Lua:

:CirclePosition(position)
OnGridPanelChanged = function(item, panel, newPosition) 

UIMenuStatisticsPanel

image
This panel is not interactable by user input, it will only show given infos.
Called via: C#:

UIMenuStatisticsPanel()

Lua:

UIMenuStatisticsPanel.New(items)

The panel is essentially a list of statistics, you can add them via: C#:

panel.AddStatistics(string Name, float val)

Lua:

:AddStatistic(name, value)

The available functions for this panel are:
C#:

AddStatistics(string Name, float val)
float GetPercentage(int ItemId)
SetPercentage(int ItemId, float number)

Lua:

:AddStatistic(name, value)
:GetPercentage(id) -- returns a statistic value
:UpdateStatistic(id, value) -- updates an existing statistic value


Side Panels

Currently only 2 side panels are available.

UIVehicleColourPickerPanel

image
Since the classic color panel is not enough to show all the vehicle colors available, i decided to make a new side panel only for them.

you call it via:
C#

public UIVehicleColourPickerPanel(PanelSide side, string title)
public UIVehicleColourPickerPanel(PanelSide side, string title, HudColor BgColor)

Lua

UIVehicleColorPickerPanel.New(side, title, color)

Its functions are:
C#

string Title { get; set; }
VehicleColorPickerSelectEvent OnVehicleColorPickerSelect(UIMenuItem item, UIVehicleColourPickerPanel panel, int colorIndex)

Lua

:UpdatePanelTitle(title)
PickerSelect = function(item, panel, colorIndex)

UIMissionDetailsPanel

image
Initialized via:

public UIMissionDetailsPanel(PanelSide side, string title, bool inside, string txd = "", string txn = "")
public UIMissionDetailsPanel(PanelSide side, string title, HudColor color, string txd = "", string txn = "")

Lua:

UIMissionDetailsPanel.New(side, title, color, inside, txd, txn)

This panel is a bit more complex as it needs 1 more item to work, for each item in the side panel we must initialize a new UIMenuFreemodeDetailsItem:
C#:

UIFreemodeDetailsItem(string textLeft, string textRight, bool separator)
UIFreemodeDetailsItem(string textLeft, string textRight, BadgeIcon icon, HudColor iconColor = HudColor.HUD_COLOUR_FREEMODE, bool tick = false)

Lua:

UIMenuFreemodeDetailsItem.New(textLeft, textRight, seperator, icon, iconColor, tick) -- if icon and iconColor are specified, then separator will be ignored, also icon is a Badge.. the same used for normal UIMenuItems

The panel's functions are:
C#:

string Title { get; set; }
UpdatePanelPicture(string txd, string txn)
AddItem(UIFreemodeDetailsItem item)
RemoveItem(int idx)

Lua:

:UpdatePanelTitle(title)
:UpdatePanelPicture(txd, txn)
:AddItem(newitem)
:RemoveItemAt(index)

H2

H3

Clone this wiki locally