diff --git a/Content/Testing/BP_Test.uasset b/Content/Testing/BP_Test.uasset index 55a14655..59787bfc 100644 --- a/Content/Testing/BP_Test.uasset +++ b/Content/Testing/BP_Test.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a05f0d08018fb2e11072556cacabdf1dbf0c84f5ce668da3d9b4a325576ea63a -size 32465 +oid sha256:a64c677d48ce708657273004e2e6ed3a831bc6cc5d83e36be0bd001f8082fbae +size 49752 diff --git a/Plugins/UEWingman/Source/UEWingman/HalfBaked/BlueprintGraph_Delete.h b/Plugins/UEWingman/Source/UEWingman/HalfBaked/BlueprintGraph_Delete.h deleted file mode 100644 index 2ffef780..00000000 --- a/Plugins/UEWingman/Source/UEWingman/HalfBaked/BlueprintGraph_Delete.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "WingServer.h" -#include "WingHandler.h" -#include "WingFetcher.h" -#include "WingUtils.h" -#include "Engine/Blueprint.h" -#include "EdGraph/EdGraph.h" -#include "Kismet2/BlueprintEditorUtils.h" -#include "BlueprintGraph_Delete.generated.h" - - -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- - -UCLASS() -class UWing_BlueprintGraph_Delete : public UObject, public IWingHandler -{ - GENERATED_BODY() - -public: - UPROPERTY(meta=(Description="Path to a blueprint, e.g. /Game/Foo/Bar")) - FString Blueprint; - - UPROPERTY(meta=(Description="Name of the graph to delete")) - FString Graph; - - virtual FString GetDescription() const override - { - return TEXT("Delete a function or macro graph from a Blueprint. Cannot delete EventGraph pages."); - } - - virtual void Handle() override - { - WingFetcher F; - F.Walk(Blueprint); - if (!F.Ok()) return; - - UBlueprint* BP = F.Cast(); - if (!BP) return; - - // Search function graphs, then macro graphs - UEdGraph* TargetGraph = nullptr; - FString GraphType; - - for (UEdGraph* G : BP->FunctionGraphs) - { - if (G && WingUtils::Identifies(Graph, G)) - { - TargetGraph = G; - GraphType = TEXT("function"); - break; - } - } - if (!TargetGraph) - { - for (UEdGraph* G : BP->MacroGraphs) - { - if (G && WingUtils::Identifies(Graph, G)) - { - TargetGraph = G; - GraphType = TEXT("macro"); - break; - } - } - } - - // Check if it's an UbergraphPage (EventGraph) — disallow deletion - if (!TargetGraph) - { - for (UEdGraph* G : BP->UbergraphPages) - { - if (G && WingUtils::Identifies(Graph, G)) - { - UWingServer::Printf(TEXT("ERROR: Cannot delete UbergraphPage '%s'. EventGraph pages cannot be deleted.\n"), - *WingUtils::FormatName(G)); - return; - } - } - UWingServer::Printf(TEXT("ERROR: Graph '%s' not found in blueprint %s\n"), - *Graph, *WingUtils::FormatName(BP)); - return; - } - - // Remove the graph - FString GraphName = WingUtils::FormatName(TargetGraph); - FBlueprintEditorUtils::RemoveGraph(BP, TargetGraph, EGraphRemoveFlags::Default); - - UWingServer::Printf(TEXT("Deleted %s graph %s\n"), *GraphType, *GraphName); - } -}; diff --git a/Plugins/UEWingman/Source/UEWingman/HalfBaked/BlueprintGraph_Rename.h b/Plugins/UEWingman/Source/UEWingman/HalfBaked/BlueprintGraph_Rename.h deleted file mode 100644 index 447d5515..00000000 --- a/Plugins/UEWingman/Source/UEWingman/HalfBaked/BlueprintGraph_Rename.h +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "WingServer.h" -#include "WingHandler.h" -#include "WingFetcher.h" -#include "WingUtils.h" -#include "Engine/Blueprint.h" -#include "EdGraph/EdGraph.h" -#include "Kismet2/BlueprintEditorUtils.h" -#include "BlueprintGraph_Rename.generated.h" - - -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- - -UCLASS() -class UWing_BlueprintGraph_Rename : public UObject, public IWingHandler -{ - GENERATED_BODY() - -public: - UPROPERTY(meta=(Description="Path to the graph, e.g. /Game/Foo,graph:MyFunction")) - FString Graph; - - UPROPERTY(meta=(Description="New name for the graph")) - FString NewName; - - virtual FString GetDescription() const override - { - return TEXT("Rename a function or macro graph in a Blueprint. Cannot rename EventGraph pages."); - } - - virtual void Handle() override - { - WingFetcher F; - UEdGraph* TargetGraph = F.Walk(Graph).Cast(); - if (!TargetGraph) return; - - UBlueprint* BP = Cast(TargetGraph->GetOuter()); - if (!BP) - { - UWingServer::Printf(TEXT("Error: Graph '%s' is not owned by a Blueprint.\n"), *Graph); - return; - } - - // Check if it's an UbergraphPage -- disallow rename - if (BP->UbergraphPages.Contains(TargetGraph)) - { - UWingServer::Printf(TEXT("Error: Cannot rename UbergraphPage '%s'. EventGraph pages cannot be renamed.\n"), - *WingUtils::FormatName(TargetGraph)); - return; - } - - // Verify it's a function or macro graph - bool bIsFunction = BP->FunctionGraphs.Contains(TargetGraph); - bool bIsMacro = BP->MacroGraphs.Contains(TargetGraph); - if (!bIsFunction && !bIsMacro) - { - UWingServer::Printf(TEXT("Error: Graph '%s' is not a function or macro graph.\n"), - *WingUtils::FormatName(TargetGraph)); - return; - } - - // Check for name collision - for (UEdGraph* Existing : WingUtils::FindAllNamed(NewName, WingUtils::AllGraphs(BP))) - { - if (Existing != TargetGraph) - { - UWingServer::Printf(TEXT("Error: A graph named '%s' already exists in '%s'.\n"), - *NewName, *WingUtils::FormatName(BP)); - return; - } - } - - FBlueprintEditorUtils::RenameGraph(TargetGraph, NewName); - - UWingServer::Printf(TEXT("Renamed to %s %s\n"), - bIsFunction ? TEXT("function") : TEXT("macro"), - *WingUtils::FormatName(TargetGraph)); - } -}; diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/BlueprintGraph_Delete.h b/Plugins/UEWingman/Source/UEWingman/Handlers/BlueprintGraph_Delete.h new file mode 100644 index 00000000..27a271b8 --- /dev/null +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/BlueprintGraph_Delete.h @@ -0,0 +1,55 @@ +#pragma once + +#include "CoreMinimal.h" +#include "WingServer.h" +#include "WingHandler.h" +#include "WingFetcher.h" +#include "WingUtils.h" +#include "Engine/Blueprint.h" +#include "EdGraph/EdGraph.h" +#include "Kismet2/BlueprintEditorUtils.h" +#include "BlueprintGraph_Delete.generated.h" + + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- + +UCLASS() +class UWing_BlueprintGraph_Delete : public UObject, public IWingHandler +{ + GENERATED_BODY() + +public: + UPROPERTY(meta=(Description="Path to the graph, e.g. /Game/MyBP,graph:MyFunction")) + FString Graph; + + virtual FString GetDescription() const override + { + return TEXT("Delete a function or macro graph from a Blueprint."); + } + + virtual void Handle() override + { + WingFetcher F; + UEdGraph* FoundGraph = F.Walk(Graph).Cast(); + if (!FoundGraph) return; + + UBlueprint* BP = FBlueprintEditorUtils::FindBlueprintForGraph(FoundGraph); + if (!BP) + { + UWingServer::Print(TEXT("ERROR: Could not find owning blueprint for this graph.\n")); + return; + } + + if (!BP->FunctionGraphs.Contains(FoundGraph) && !BP->MacroGraphs.Contains(FoundGraph)) + { + UWingServer::Printf(TEXT("ERROR: %s is not a function or macro graph.\n"), *WingUtils::FormatName(FoundGraph)); + return; + } + + FBlueprintEditorUtils::RemoveGraph(BP, FoundGraph, EGraphRemoveFlags::Recompile); + + UWingServer::Printf(TEXT("Deleted graph from %s\n"), *WingUtils::FormatName(BP)); + } +};