53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "WingBasics.h"
|
|
#include "WingFetcher.h"
|
|
#include "WingToolMenu.h"
|
|
#include "WingServer.h"
|
|
#include "ToolMenus.h"
|
|
#include "MaterialGraph/MaterialGraphNode.h"
|
|
#include "GraphNode_ShowMenu.generated.h"
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
|
UCLASS()
|
|
class UWing_GraphNode_ShowMenu : public UWingHandler
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UPROPERTY(EditAnywhere, meta=(Description="Target node"))
|
|
FString Node;
|
|
|
|
virtual void Register() override
|
|
{
|
|
UWingServer::AddHandler(this,
|
|
TEXT("Show context menu actions available for a node and its pins."));
|
|
}
|
|
private:
|
|
virtual void Handle() override
|
|
{
|
|
WingFetcher F(WingOut::Stdout);
|
|
UEdGraphNode* NodeObj = F.Walk(Node).Cast<UEdGraphNode>();
|
|
if (!NodeObj) return;
|
|
|
|
if (Cast<UMaterialGraphNode>(NodeObj))
|
|
{
|
|
WingOut::Stdout.Printf(TEXT("Material graph nodes do not have usable context menus."));
|
|
return;
|
|
}
|
|
FToolMenuContext Context;
|
|
TArray<FToolMenuEntry> Entries = WingToolMenu::GetMenuItems(NodeObj, Context);
|
|
for (FToolMenuEntry &Entry : Entries)
|
|
{
|
|
FString LabelText = Entry.Label.Get().ToString();
|
|
WingOut::Stdout.Printf(TEXT("%s\n"), *LabelText);
|
|
}
|
|
if (Entries.IsEmpty()) WingOut::Stdout.Printf(TEXT("No selectable menu entries right now.\n"));
|
|
}
|
|
};
|