Files
UnrealEngineUWP/Engine/Plugins/Runtime/StateTree/Source/StateTreeEditorModule/Public/StateTreeNodeClassCache.h
mikko mononen ef148ecd80 StateTree: StateTree UI spring clean.
- Added icons and icon colors for ST nodes
- Implemented icons for some common ST nodes
- Small update to ST logic icons
- Added icons to the task list in State treeview row, adjusted task list BG color to make icons visible
- Fixed ST editor tabs icons and names (e.g. there were two tabs that had the same label)
- Moved ST node picker to separate class
- Moved category array customization to common helper function
- Added node icons to the ST node picker
- Add node button is not node selector too (simila to Niagara)
- Consolidated the add button style across all lists
- Cleaned up the node customization
  - Moved type selector, debug, and property controls into one menu at right
  - The combined menu can be also summoned using right click
  - Renaming now has to be triggered via the menu
  - Replacing node happens via menu
  - Most of the row was left "clickable" to later use it for selection
  - Improved the visualization and controls for the expression indentation
- Cleaned up state customization
  - Moved parameters to own category (similar to the tree params)
  - Moved event to the enter conditions category
- Cleaned up transition customization
  - Improved the transition display
  - Consolidated add button styles

#jira UE-180608
#rb Juan.Portillo, Mieszko.Zielinski

[CL 33030431 by mikko mononen in ue5-main branch]
2024-04-17 03:01:36 -04:00

122 lines
3.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "StateTreeNodeClassCache.generated.h"
enum class EReloadCompleteReason;
struct FAssetData;
/**
* Describes a class or struct.
* If the class or struct is from a package that is not yet loaded, the data will update on GetStruct/Class/Scripstruct()
*/
USTRUCT()
struct STATETREEEDITORMODULE_API FStateTreeNodeClassData
{
GENERATED_BODY()
FStateTreeNodeClassData() {}
FStateTreeNodeClassData(UStruct* InStruct);
FStateTreeNodeClassData(const FString& InClassAssetName, const FString& InClassPackage, const FName InStructName, UStruct* InStruct);
FName GetStructName() const { return StructName; }
UStruct* GetStruct(bool bSilent = false);
UClass* GetClass(bool bSilent = false)
{
return Cast<UClass>(GetStruct(bSilent));
}
UScriptStruct* GetScriptStruct(bool bSilent = false)
{
return Cast<UScriptStruct>(GetStruct(bSilent));
}
private:
/** Pointer to described struct or class. */
TWeakObjectPtr<UStruct> Struct;
/** Resolved name of struct or class. */
FName StructName;
/** Path to class if it's not loaded yet. */
FString ClassAssetName;
/** Package of the asset if it's not loaded yet. */
FString ClassPackageName;
};
/**
* Caches specified classes or structs and reacts to engine events to keep the lists always up to date.
* All the derived classes or structs are kept in the cache.
*/
struct STATETREEEDITORMODULE_API FStateTreeNodeClassCache
{
FStateTreeNodeClassCache();
~FStateTreeNodeClassCache();
/** Adds a Struct to keep track of */
void AddRootStruct(UStruct* RootStruct);
/** Adds a Class to keep track of */
void AddRootClass(UClass* RootClass)
{
AddRootStruct(RootClass);
}
/** Adds a ScriptStruct to keep track of */
void AddRootScriptStruct(UScriptStruct* RootStruct)
{
AddRootStruct(RootStruct);
}
/** Returns know derived Structs based on provided base. If the base Struct is not added as root Struct, nothing is returned. */
void GetStructs(const UStruct* BaseStruct, TArray<TSharedPtr<FStateTreeNodeClassData>>& AvailableClasses);
/** Returns know derived Classes based on provided base. If the base Class is not added as root Class, nothing is returned. */
void GetClasses(const UStruct* BaseClass, TArray<TSharedPtr<FStateTreeNodeClassData>>& AvailableClasses)
{
GetStructs(BaseClass, AvailableClasses);
}
/** Returns know derived ScriptStructs based on provided base. If the base struct is not added as root ScriptStruct, nothing is returned. */
void GetScripStructs(const UScriptStruct* BaseStruct, TArray<TSharedPtr<FStateTreeNodeClassData>>& AvailableClasses)
{
GetStructs(BaseStruct, AvailableClasses);
}
/** Invalidates the cache, it will be rebuild on next access. */
void InvalidateCache();
protected:
void OnAssetAdded(const FAssetData& AssetData);
void OnAssetRemoved(const FAssetData& AssetData);
void OnReloadComplete(EReloadCompleteReason Reason);
private:
void UpdateBlueprintClass(const FAssetData& AssetData);
void CacheClasses();
struct FRootClassContainer
{
FRootClassContainer() = default;
FRootClassContainer(UStruct* InBaseStruct)
{
BaseStruct = InBaseStruct;
}
TWeakObjectPtr<UStruct> BaseStruct;
TArray<TSharedPtr<FStateTreeNodeClassData>> ClassData;
bool bUpdated = false;
};
TArray<FRootClassContainer> RootClasses;
TMap<FString, int32> ClassNameToRootIndex;
};
#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
#include "CoreMinimal.h"
#endif