Skip to content
Mike edited this page Jan 1, 2022 · 2 revisions

IPT.Common contains UXMenu and UXMenuItem which extend RAGENativeUI menus.

UXMenu

Very simply adjusts the UIMenu width based on the items added when their text length exceeds 30 characters.

UXMenuItem

Uses an underlying Setting object to generate a UIMenuItem which can interact with the user configuration.

Example

private UXMenu BuildSettingsMenu()
{
    var menu = new UXMenu("Plugin Name", "Configuration");
    foreach (var entry in Config.Instance.AllSettings.Where(
        x => !x.Section.Equals("Advanced") && UXMenuItem.IsSupportedType(x.GetType())))
    {
        var item = new UXMenuItem(entry);
        item.OnListChanged -= this.Settings_OnListChanged;  // to prevent multiple subscriptions
        item.OnListChanged += this.Settings_OnListChanged;
        menu.AddItem(item);
    }

    return menu;
}
private void Settings_OnListChanged(UIMenuItem sender, int newIndex)
{
    if (sender is UXMenuItem item)
    {
        item.Update();
    }
}
Clone this wiki locally