Menus Items - alexguirre/RAGENativeUI GitHub Wiki

Table of Contents

  1. UIMenuItem
  2. UIMenuCheckboxItem
  3. UIMenuScrollerItem
  4. UIMenuListScrollerItem<T>
  5. UIMenuNumericScrollerItem<T>
  6. UIMenuListItem
  7. UIMenuSwitchMenusItem

UIMenuItem

The most basic item and base class for all menu items.

UIMenuItem.Activated occurs when the user activates the item, for example, when clicking on it with the mouse or by pressing Enter when it is selected. The event handler has the following signature:

public delegate void ItemActivatedEvent(UIMenu sender, UIMenuItem selectedItem);

UIMenuCheckboxItem

Item that the user can toggle, representing a true or false value.

UIMenuCheckboxItem.Checked gets or sets the current state of the checkbox.

UIMenuCheckboxItem.CheckboxEvent occurs when the user toggles the checkbox. The event handler has the following signature:

public delegate void ItemCheckboxEvent(UIMenuCheckboxItem sender, bool Checked);

UIMenuScrollerItem.Style gets or sets whether to display a tick (default) or a cross when Checked is true.

UIMenuScrollerItem

Base class for items that consist of a list of values that the user can scroll through.

When selected, two arrows appear indicating that the user can scroll through the values.

UIMenuScrollerItem.Index gets or sets the index of the value currently selected.

UIMenuScrollerItem.IndexChanged event occurs when the Index property changes, for example, when the user scrolls through the values. The event handler has the following signature:

public delegate void ItemScrollerEvent(UIMenuScrollerItem sender, int oldIndex, int newIndex);

Slider Bars

Setting the UIMenuScrollerItem.SliderBar property to a UIMenuScrollerSliderBar instance allows to display a scroller item as a slider bar, which is empty when the first value is selected (Index == 0) and full when the last one is selected (Index == OptionCount - 1).

scroller.SliderBar = new UIMenuScrollerSliderBar();

The properties in UIMenuScrollerSliderBar allow to change the bar color and size and add markers.

sliderBar.ForegroundColor = HudColor.Green.GetColor();
sliderBar.BackgroundColor = Color.FromArgb(120, sliderBar.ForegroundColor);
sliderBar.Width = 0.5f;
sliderBar.Height = 0.4f;
sliderBar.Markers.Add(new UIMenuScrollerSliderBarMarker(0.25f));
sliderBar.Markers.Add(new UIMenuScrollerSliderBarMarker(0.5f, Color.Red));

UIMenuListScrollerItem<T>

Implementation of UIMenuScrollerItem for a list of values of type T.

UIMenuListScrollerItem<T>.SelectedItem gets or sets the value currently selected.

UIMenuListScrollerItem<T>.Items gets or sets the list of values.

UIMenuListScrollerItem<T>.Formatter specifies how the value is converted to a string. By default, T.ToString() is used.

var scroller = new UIMenuListScrollerItem<bool>("Scroller", "", new[] { true, false })
{
    Formatter = v => v ? "On" : "Off"
};

UIMenuNumericScrollerItem<T>

Implementation of UIMenuScrollerItem for numeric values of type T. Supports any built-in numeric type: sbyte, byte, short, ushort, int, uint, long, ulong, float, double and decimal.

UIMenuNumericScrollerItem<T>.Value gets or sets the value currently selected.

UIMenuNumericScrollerItem<T>.Minimum/Maximum/Step determine the range of values that can be selected.

UIMenuNumericScrollerItem<T>.Formatter specifies how the value is converted to a string. By default, T.ToString() is used.

scroller.Formatter = v => v.ToString("$0");

UIMenuListItem

Item with a list that can be scrolled through. Since 1.7, UIMenuListScrollerItem<T> is the recommended item for this purpose.

UIMenuSwitchMenusItem

TBD

⚠️ **GitHub.com Fallback** ⚠️