feat(ContextMenu): add convenience methods to ContextMenuOpenedArgs

This commit is contained in:
goaaats 2022-01-29 15:45:36 +01:00
parent 6131c3efa1
commit d88e0bcf54
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
3 changed files with 34 additions and 16 deletions

View file

@ -19,9 +19,9 @@ namespace Dalamud.Game.Gui.ContextMenus
}
/// <summary>
/// Gets or sets the name of the item.
/// Gets the name of the item.
/// </summary>
public SeString Name { get; set; }
public SeString Name { get; internal set; }
/// <summary>
/// Gets or sets a value indicating whether or not the item is enabled. When enabled, an item is selectable.

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using Dalamud.Game.Text.SeStringHandling;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
@ -59,5 +60,22 @@ namespace Dalamud.Game.Gui.ContextMenus
/// Gets the item context associated with the context menu.
/// </summary>
public InventoryItemContext? InventoryItemContext { get; init; }
/// <summary>
/// Append a custom context menu item to this context menu.
/// </summary>
/// <param name="name">The name of the item.</param>
/// <param name="selected">The action to be executed once selected.</param>
public void AddCustomItem(SeString name, CustomContextMenuItemSelectedDelegate selected) =>
this.Items.Add(new CustomContextMenuItem(name, selected));
/// <summary>
/// Append a custom submenu to this context menu.
/// Note that these cannot be nested, and will be ignored if they are.
/// </summary>
/// <param name="name">The name of the submenu.</param>
/// <param name="opened">The action to be executed once opened.</param>
public void AddCustomSubMenu(SeString name, ContextMenuOpenedDelegate opened) =>
this.Items.Add(new OpenSubContextMenuItem(name, opened));
}
}