-
Notifications
You must be signed in to change notification settings - Fork 1
Menus
Mike edited this page Jan 1, 2022
·
2 revisions
IPT.Common contains UXMenu and UXMenuItem which extend RAGENativeUI menus.
Very simply adjusts the UIMenu width based on the items added when their text length exceeds 30 characters.
Uses an underlying Setting
object to generate a UIMenuItem which can interact with the user configuration.
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();
}
}