Context Menu - Item Side
Each UCrimsonInventoryItemInstance is automatically a context-action provider. Designers declare actions per item or per item-type tag; the function library merges both sources and the item instance implements ICrimsonContextActionProvider so client and server agree.
Two action sources, merged at runtime
| Source | Where it lives | Use case |
|---|---|---|
UCrimsonInventoryItemFragment_ContextActions | Attached to the item definition's Fragments array. Instanced TArray<UCrimsonContextAction*> authored inline. | Per-item overrides: 'this health potion can also be Combined'. |
UCrimsonInventoryItemTypeActionSet | UPrimaryDataAsset referenced by UCrimsonInventorySettings::DefaultContextActionTypeSet. | Per-type defaults: 'all weapons have Drop/Inspect', 'all consumables have Use/Drop'. |
UCrimsonInventoryFunctionLibrary::GetContextActionsForItem(Item) merges both sources, dedupes by ActionTag (fragment wins), and sorts by SortPriority. The registry is always the project default - there is deliberately no per-call override, so the server's execution-time re-gather always matches the client's view. Deterministic for the same Item on client and server.
Authoring per-item actions
| Step | Action |
|---|---|
| 1 | Open the UCrimsonInventoryItemDefinition asset |
| 2 | Add UCrimsonInventoryItemFragment_ContextActions to its Fragments array |
| 3 | Populate the fragment's Actions array - pick UCrimsonContextAction_GrantAbility for ability-triggered actions, or your own BP/C++ subclass |
| 4 | On each action, fill ActionTag, DisplayName, Tooltip, Icon, SortPriority, and optionally SectionTag, bIsDefault, bIsDestructive, ConfirmationMode, CloseBehavior |
Authoring per-type defaults
| Step | Action |
|---|---|
| 1 | Content Browser -> Miscellaneous -> Data Asset -> CrimsonInventoryItemTypeActionSet |
| 2 | Add rows mapping Item.Type.* tags to instanced action arrays |
| 3 | Project Settings -> Crimson -> Crimson Inventory -> Default Context Action Type Set -> soft ref to the asset |
ICrimsonContextActionProvider on UCrimsonInventoryItemInstance
The instance class already implements the interface and delegates straight to the function library, so server-side gather always matches the client's view:
void UCrimsonInventoryItemInstance::GatherContextActions_Implementation(const FCrimsonContextActionContext& Context,TArray<UCrimsonContextAction*>& OutActions){OutActions = UCrimsonInventoryFunctionLibrary::GetContextActionsForItem(this);}
ValidateContextActionRequest (server-side): the item must live in an inventory component owned by the requesting player (directly, or via Pawn/PlayerState owner chains). Requests for another player's items are rejected before any action runs.UCrimsonCoreContextMenuSubsystem::ShowContextMenuForItem(ItemInstance, Request) from your inventory slot widget (e.g. on OnContextMenuRequested). CrimsonInventory itself stays UI-free - all presentation routing lives in CrimsonCore.