Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

kalilistic/Dalamud.ContextMenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THIS IS DEPRECATED AND WILL NOT BE UPDATED FOR 7.0.

Dalamud.ContextMenu

Nuget

This is a library to add context menus to dalamud plugins.

Features

  • Add context menu items to game objects (e.g. players).
  • Add context menu items to inventory items.
  • Add an dalamud indicator icon so players know a plugin is adding the menu item (optional).

Limitations

  • No sub menus.
  • No random inserts - all custom items are added to the end of the menu.

Credits

  • The logic is all copied from a deprecated version of annaclemens' XIVCommon library.

How to Use

  • Import from nuget.
  • Add <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> in your csproj file.

Example

// create instance
DalamudContextMenu contextMenu = new DalamudContextMenu(PluginInterface);

// create context menu item
GameObjectContextMenuItem contextMenuItem = new GameObjectContextMenuItem(
    new SeString(new TextPayload("My Menu Item"), // text
    MyMenuItemAction, // action to invoke
    true); // use dalamud indicator

// add event handler
contextMenu.OnOpenGameObjectContextMenu += OpenGameObjectContextMenu;

// add custom item on game object menu open
private void OpenGameObjectContextMenu(GameObjectContextMenuOpenArgs args)
{
    args.AddCustomItem(contextMenuItem);
}

// add action method when custom item is clicked
private void MyMenuItemAction(GameObjectContextMenuItemSelectedArgs args)
{
    // do something
}

// dispose
contextMenu.OnOpenGameObjectContextMenu -= OpenGameObjectContextMenu;
contextMenu.Dispose();