-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POTENTIALLY BREAKING CHANGE: Added UAssetDefinition_FlowAsset impleme…
…nting a new way of defining editor-only asset properties like asset category. This is a direct replacement for FAssetTypeActions_FlowAsset. If you had any custom asset class extending `UFlowAsset`, you probably need to convert your custom FAssetTypeActions to UAssetDefinition. This is quite a straightforward process.
- Loading branch information
1 parent
ce85ed5
commit 5ef45f3
Showing
7 changed files
with
109 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
Source/FlowEditor/Private/Asset/AssetDefinition_FlowAsset.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright https://github.com/MothCocoon/FlowGraph/graphs/contributors | ||
|
||
#include "Asset/AssetDefinition_FlowAsset.h" | ||
#include "Asset/SFlowDiff.h" | ||
#include "FlowEditorModule.h" | ||
#include "Graph/FlowGraphSettings.h" | ||
|
||
#include "FlowAsset.h" | ||
|
||
#include UE_INLINE_GENERATED_CPP_BY_NAME(AssetDefinition_FlowAsset) | ||
|
||
#define LOCTEXT_NAMESPACE "AssetDefinition_FlowAsset" | ||
|
||
FText UAssetDefinition_FlowAsset::GetAssetDisplayName() const | ||
{ | ||
return LOCTEXT("AssetTypeActions_FlowAsset", "Flow Asset"); | ||
} | ||
|
||
FLinearColor UAssetDefinition_FlowAsset::GetAssetColor() const | ||
{ | ||
return FColor(255, 196, 128); | ||
} | ||
|
||
TSoftClassPtr<UObject> UAssetDefinition_FlowAsset::GetAssetClass() const | ||
{ | ||
return UFlowAsset::StaticClass(); | ||
} | ||
|
||
TConstArrayView<FAssetCategoryPath> UAssetDefinition_FlowAsset::GetAssetCategories() const | ||
{ | ||
if (UFlowGraphSettings::Get()->bExposeFlowAssetCreation) | ||
{ | ||
static const auto Categories = {FFLowAssetCategoryPaths::Flow}; | ||
return Categories; | ||
} | ||
|
||
return {}; | ||
} | ||
|
||
FAssetSupportResponse UAssetDefinition_FlowAsset::CanLocalize(const FAssetData& InAsset) const | ||
{ | ||
return FAssetSupportResponse::Supported(); | ||
} | ||
|
||
EAssetCommandResult UAssetDefinition_FlowAsset::OpenAssets(const FAssetOpenArgs& OpenArgs) const | ||
{ | ||
for (UFlowAsset* FlowAsset : OpenArgs.LoadObjects<UFlowAsset>()) | ||
{ | ||
const FFlowEditorModule* FlowModule = &FModuleManager::LoadModuleChecked<FFlowEditorModule>("FlowEditor"); | ||
FlowModule->CreateFlowAssetEditor(OpenArgs.GetToolkitMode(), OpenArgs.ToolkitHost, FlowAsset); | ||
} | ||
|
||
return EAssetCommandResult::Handled; | ||
} | ||
|
||
EAssetCommandResult UAssetDefinition_FlowAsset::PerformAssetDiff(const FAssetDiffArgs& DiffArgs) const | ||
{ | ||
if (DiffArgs.OldAsset == nullptr && DiffArgs.NewAsset == nullptr) | ||
{ | ||
return EAssetCommandResult::Unhandled; | ||
} | ||
|
||
const UFlowAsset* OldFlow = CastChecked<UFlowAsset>(DiffArgs.OldAsset); | ||
const UFlowAsset* NewFlow = CastChecked<UFlowAsset>(DiffArgs.NewAsset); | ||
|
||
// sometimes we're comparing different revisions of one single asset (other | ||
// times we're comparing two completely separate assets altogether) | ||
const bool bIsSingleAsset = (OldFlow->GetName() == NewFlow->GetName()); | ||
|
||
static const FText BasicWindowTitle = LOCTEXT("FlowAssetDiff", "FlowAsset Diff"); | ||
const FText WindowTitle = !bIsSingleAsset ? BasicWindowTitle : FText::Format(LOCTEXT("FlowAsset Diff", "{0} - FlowAsset Diff"), FText::FromString(NewFlow->GetName())); | ||
|
||
SFlowDiff::CreateDiffWindow(WindowTitle, OldFlow, NewFlow, DiffArgs.OldRevision, DiffArgs.NewRevision); | ||
return EAssetCommandResult::Handled; | ||
} | ||
|
||
#undef LOCTEXT_NAMESPACE |
58 changes: 0 additions & 58 deletions
58
Source/FlowEditor/Private/Asset/AssetTypeActions_FlowAsset.cpp
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Source/FlowEditor/Public/Asset/AssetDefinition_FlowAsset.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright https://github.com/MothCocoon/FlowGraph/graphs/contributors | ||
|
||
#pragma once | ||
|
||
#include "AssetDefinition.h" | ||
#include "AssetDefinition_FlowAsset.generated.h" | ||
|
||
/** | ||
* | ||
*/ | ||
UCLASS() | ||
class FLOWEDITOR_API UAssetDefinition_FlowAsset : public UAssetDefinition | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
virtual FText GetAssetDisplayName() const override; | ||
virtual FLinearColor GetAssetColor() const override; | ||
virtual TSoftClassPtr<UObject> GetAssetClass() const override; | ||
virtual TConstArrayView<FAssetCategoryPath> GetAssetCategories() const override; | ||
virtual FAssetSupportResponse CanLocalize(const FAssetData& InAsset) const override; | ||
|
||
virtual EAssetCommandResult OpenAssets(const FAssetOpenArgs& OpenArgs) const override; | ||
virtual EAssetCommandResult PerformAssetDiff(const FAssetDiffArgs& DiffArgs) const override; | ||
}; |
19 changes: 0 additions & 19 deletions
19
Source/FlowEditor/Public/Asset/AssetTypeActions_FlowAsset.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters