More work on MCP
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include "Engine/SimpleConstructionScript.h"
|
||||
#include "Engine/SCS_Node.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Materials/Material.h"
|
||||
#include "MaterialGraph/MaterialGraph.h"
|
||||
#include "Engine/LevelScriptBlueprint.h"
|
||||
|
||||
MCPFetcher& MCPFetcher::SetError(const FString& Msg)
|
||||
@@ -55,7 +57,8 @@ MCPFetcher& MCPFetcher::Walk(const FString& Path)
|
||||
for (int32 i = Start; i < Segments.Num(); i++)
|
||||
{
|
||||
FString Key, Value;
|
||||
Segments[i].Split(TEXT(":"), &Key, &Value);
|
||||
if (!Segments[i].Split(TEXT(":"), &Key, &Value))
|
||||
Key = Segments[i];
|
||||
|
||||
if (StrEq(Key, TEXT("graph"))) Graph(Value);
|
||||
else if (StrEq(Key, TEXT("node"))) Node(Value);
|
||||
@@ -80,15 +83,31 @@ void MCPFetcher::LoadUAsset(const FString& PackagePath)
|
||||
SetObj(LoadObject<UObject>(nullptr, *PackagePath));
|
||||
if (!Obj)
|
||||
SetError(FString::Printf(TEXT("Could not load asset '%s'"), *PackagePath));
|
||||
|
||||
// If this is a material open in the editor, use the editor's transient copy.
|
||||
if (UMaterial* Mat = ::Cast<UMaterial>(Obj))
|
||||
SetObj(MCPUtils::ReplaceMaterialWithTransientCopy(Mat));
|
||||
}
|
||||
|
||||
MCPFetcher& MCPFetcher::Graph(const FString& Value)
|
||||
{
|
||||
if (bError) return *this;
|
||||
|
||||
// Material with blank graph name → navigate to the material graph.
|
||||
if (UMaterial* Mat = ::Cast<UMaterial>(Obj))
|
||||
{
|
||||
if (!Value.IsEmpty())
|
||||
return SetError(FString::Printf(TEXT("Materials do not have named graphs (got '%s')"), *Value));
|
||||
MCPUtils::EnsureMaterialGraph(Mat);
|
||||
if (!Mat->MaterialGraph)
|
||||
return SetError(FString::Printf(TEXT("Material '%s' has no material graph"), *Mat->GetName()));
|
||||
SetObj(Mat->MaterialGraph);
|
||||
return *this;
|
||||
}
|
||||
|
||||
UBlueprint* BP = ::Cast<UBlueprint>(Obj);
|
||||
if (!BP)
|
||||
return TypeMismatch(TEXT("graph"), TEXT("Blueprint"));
|
||||
return TypeMismatch(TEXT("graph"), TEXT("Blueprint or Material"));
|
||||
|
||||
TArray<UEdGraph*> Matches = MCPUtils::AllGraphsNamed(BP, Value);
|
||||
if (Matches.Num() == 0)
|
||||
|
||||
Reference in New Issue
Block a user