// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Input/Reply.h" #include "Widgets/SWidget.h" #include "Widgets/SCompoundWidget.h" #include "AssetRegistry/AssetData.h" #include "Widgets/Views/STableViewBase.h" #include "Widgets/Views/STableRow.h" #include "Widgets/Views/SListView.h" #define LOCTEXT_NAMESPACE "SlotRefWindow" class SWindow; class UAnimBlueprint; class UAnimGraphNode_Base; class UAnimGraphNode_Slot; class UEdGraph; // This type can't exist in a SLATE_ARGUMENT macro so typedef away the template typedef TMultiMap* NodeMapPtr; // List display helper for montage references class FDisplayedMontageReferenceInfo { public: FAssetData AssetData; static TSharedRef Make(const FAssetData& AssetData); protected: /** Hidden constructor, always use Make above */ FDisplayedMontageReferenceInfo(const FAssetData& InData) : AssetData(InData) {} /** Hidden constructor, always use Make above */ FDisplayedMontageReferenceInfo() {} }; // List display helper for blueprint references class FDisplayedBlueprintReferenceInfo { public: FString BlueprintName; FString GraphName; FString NodeName; UAnimBlueprint* AnimBlueprint; UEdGraph* NodeGraph; UAnimGraphNode_Base* Node; static TSharedRef Make(UAnimBlueprint* Blueprint, UAnimGraphNode_Slot* SlotNode); protected: /** Hidden constructor, always use Make above */ FDisplayedBlueprintReferenceInfo(UAnimBlueprint* Blueprint, UAnimGraphNode_Slot* SlotNode); /** Hidden constructor, always use Make above */ FDisplayedBlueprintReferenceInfo() {} }; typedef SListView> SMontageReferenceList; typedef SListView> SBlueprintReferenceList; class SMontageReferenceListRow : public SMultiColumnTableRow < TSharedPtr > { public: SLATE_BEGIN_ARGS(SMontageReferenceListRow) {} SLATE_ARGUMENT(TSharedPtr, ReferenceInfo) SLATE_END_ARGS() public: void Construct(const FArguments& InArgs, const TSharedRef& InOwnerTableView); virtual TSharedRef GenerateWidgetForColumn(const FName& ColumnName) override; protected: // Handlers for asset interaction buttons FReply OnViewInContentBrowserClicked(); FReply OnOpenAssetClicked(); TSharedPtr ReferenceInfo; }; class SBlueprintReferenceListRow : public SMultiColumnTableRow> { public: SLATE_BEGIN_ARGS(SBlueprintReferenceListRow) {} SLATE_ARGUMENT(TSharedPtr, ReferenceInfo) SLATE_END_ARGS() public: void Construct(const FArguments& InArgs, const TSharedRef& InOwnerTableView); virtual TSharedRef GenerateWidgetForColumn(const FName& ColumnName) override; protected: // Handlers for asset interaction buttons FReply OnViewInContentBrowserClicked(); FReply OnOpenAssetClicked(); TSharedPtr ReferenceInfo; }; // Required information to update a reference window widget, used in conjunction with SSlotNameReferenceWindow::UpdateInfo // any fields that do not get set by the caller will not be updated and will keep its previous value struct FReferenceWindowInfo { FReferenceWindowInfo() : ReferencingMontages(nullptr) , ReferencingNodes(nullptr) , bRefresh(true) { } TArray* ReferencingMontages; NodeMapPtr ReferencingNodes; FText OperationText; FText ItemText; FSimpleDelegate RetryDelegate; bool bRefresh; }; // Widget used to slot name references that are blocking an edit operation class SSlotNameReferenceWindow : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SSlotNameReferenceWindow) {} SLATE_ARGUMENT(TArray*, ReferencingMontages) SLATE_ARGUMENT(NodeMapPtr, ReferencingNodes) SLATE_ARGUMENT(FString, SlotName) SLATE_ARGUMENT(TSharedPtr, WidgetWindow) SLATE_ARGUMENT(FText, OperationText) SLATE_EVENT(FSimpleDelegate, OnRetry) SLATE_END_ARGS() public: void Construct(const FArguments& InArgs); // Refresh the child content of this widget void RefreshContent(); // Update the reference arrays and optionally rebuild the widget void UpdateInfo(FReferenceWindowInfo& UpdatedInfo); // The name of the slot we're referencing FString SlotName; protected: // Rebuild the internal content of the widget TSharedRef GetContent(); // Row generators for montage and blueprint/node data views TSharedRef HandleGenerateMontageReferenceRow( TSharedPtr Item, const TSharedRef& OwnerTable ); TSharedRef HandleGenerateBlueprintReferenceRow( TSharedPtr Item, const TSharedRef& OwnerTable ); // Button handlers FReply OnRetryClicked(); FReply OnCloseClicked(); // Operation type to display FText OperationText; // Objects referencing the given slot name TArray> ReferencingMontages; TArray> ReferencingNodes; // Ptr to the window this widget resides in TSharedPtr ContainingWindow; // Called when the retry button is clicked. User code determines retry behaviour FSimpleDelegate OnRetry; }; #undef LOCTEXT_NAMESPACE