123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- #pragma once
- #include "AkAudioType.h"
- #include "AssetRegistry/AssetData.h"
- #include "Engine/GameEngine.h"
- #include "Widgets/Views/STableRow.h"
- #include "WwiseItemType.h"
- #if WITH_EDITORONLY_DATA
- #include "Wwise/Metadata/WwiseMetadataBasicReference.h"
- #endif
- struct AKAUDIO_API FWwiseTreeItem : public TSharedFromThis<FWwiseTreeItem>
- {
- private:
- TArray< TSharedPtr<FWwiseTreeItem> > m_Children;
- public:
-
- FString DisplayName;
-
- FString FolderPath;
-
- EWwiseItemType::Type ItemType = EWwiseItemType::None;
-
- FGuid ItemId;
-
- uint32 ShortId = 0;
-
- const TArray< TSharedPtr<FWwiseTreeItem> > GetChildren() { return m_Children; }
- TArray< TSharedPtr<FWwiseTreeItem> >* GetChildrenMutable() { return &m_Children; }
-
-
- uint32_t ChildCountInWwise = 0;
-
- TWeakPtr<FWwiseTreeItem> Parent;
-
- TWeakPtr<ITableRow> TreeRow;
-
- bool IsVisible = true;
-
- TArray<FAssetData> Assets;
-
- FName UAssetName;
-
- FString WaapiName;
- #if WITH_EDITORONLY_DATA
-
- TSharedPtr<FWwiseMetadataBasicReference> WwiseItemRef;
- #endif
-
- bool bWaapiRefExists = false;
-
- bool bSameLocation = true;
- bool IsExpanded = false;
- bool UEAssetExists() const;
- bool WwiseBankRefExists() const;
- bool WaapiRefExists() const;
- bool IsRenamedInWwise() const;
- bool IsDeletedInWwise() const;
- bool IsNotInWwiseOrSoundBank() const;
- bool IsNewInWwise() const;
- bool IsMovedInWwise() const;
- bool IsSoundBankUpToDate() const;
- bool IsRenamedInSoundBank() const;
- bool IsUAssetMissing() const;
- bool IsUAssetOrphaned() const;
- bool IsNotInSoundBankOrUnreal() const;
- bool IsUAssetUpToDate() const;
- bool HasUniqueUAsset() const;
- bool HasMultipleUAssets() const;
- bool IsUAssetOutOfDate() const;
-
- bool IsItemUpToDate() const;
- bool IsFolder() const;
- bool IsAuxBus() const;
- bool ShouldDisplayInfo() const;
- bool IsRootItem() const;
- TSharedPtr<FWwiseTreeItem> GetRoot();
- void SetWaapiRef(bool bExistsInWaapi);
- FString GetSwitchAssetName() const;
- const FString GetDefaultAssetName() const;
-
- FWwiseTreeItem(FString InDisplayName, FString InFolderPath, TSharedPtr<FWwiseTreeItem> InParent, EWwiseItemType::Type InItemType, const FGuid& InItemId)
- : DisplayName(MoveTemp(InDisplayName))
- , FolderPath(MoveTemp(InFolderPath))
- , ItemType(MoveTemp(InItemType))
- , ItemId(InItemId)
- , ChildCountInWwise(m_Children.Num())
- , Parent(MoveTemp(InParent))
- {
- }
- #if WITH_EDITORONLY_DATA
- FWwiseTreeItem(const FWwiseMetadataBasicReference& ItemRef, TSharedPtr<FWwiseTreeItem> InParent, EWwiseItemType::Type InItemType)
- : ItemType(InItemType)
- , ChildCountInWwise(m_Children.Num())
- , Parent(MoveTemp(InParent))
- {
- WwiseItemRef = MakeShared<FWwiseMetadataBasicReference>(ItemRef.Id, ItemRef.Name, ItemRef.ObjectPath, ItemRef.GUID);
- ItemId = WwiseItemRef->GUID;
- DisplayName = WwiseItemRef->Name.ToString();
- FolderPath = WwiseItemRef->ObjectPath.ToString();
- }
- #endif
- void AddChild(TSharedPtr<FWwiseTreeItem> Child);
- void AddChildren(TArray<TSharedPtr<FWwiseTreeItem>> Children);
- void EmptyChildren();
- void RemoveChild(const FGuid& childGuid);
- void RemoveChild(const TSharedPtr< FWwiseTreeItem> child);
- void RemoveChildren(const TArray<TSharedPtr<FWwiseTreeItem>> Children);
-
-
- bool IsChildOf(const FWwiseTreeItem& InParent);
- bool IsBrowserType() const;
- bool IsOfType(const TArray<EWwiseItemType::Type>& Types) const;
- bool IsNotOfType(const TArray<EWwiseItemType::Type>& Types) const;
-
- TSharedPtr<FWwiseTreeItem> GetChild(const FString& InChildName);
-
- TSharedPtr<FWwiseTreeItem> GetChild(const FGuid& InGuid, const AkUInt32 InShortId, const FString& InChildName);
-
- TSharedPtr<FWwiseTreeItem> FindItemRecursive(const FString& InFullPath);
-
- TSharedPtr<FWwiseTreeItem> FindItemRecursive(const TSharedPtr<FWwiseTreeItem>& InItem);
- struct FCompareWwiseTreeItem
- {
- template<typename CT>
- inline int StringCompareLogical(const CT* pA1, const CT* pA2) const
- {
- if (pA1 && pA2)
- {
- while (*pA1)
- {
- if (!*pA2)
- {
-
-
- return 1;
- }
- else if (TChar<CT>::IsDigit(*pA1))
- {
-
- if (!TChar<CT>::IsDigit(*pA2))
- return -1;
-
- CT* pEnd1 = nullptr;
- CT* pEnd2 = nullptr;
- const auto i1 = TCString<CT>::Strtoi(pA1, &pEnd1, 10);
- const auto i2 = TCString<CT>::Strtoi(pA2, &pEnd2, 10);
- if (i1 < i2)
- return -1;
- else if (i1 > i2)
- return 1;
- pA1 = pEnd1;
- pA2 = pEnd2;
- }
- else if (TChar<CT>::IsDigit(*pA2))
- {
-
- return 1;
- }
- else
- {
-
- int diff = TChar<CT>::ToLower(*pA1) - TChar<CT>::ToLower(*pA2);
- if (diff > 0)
- return 1;
- else if (diff < 0)
- return -1;
- ++pA1;
- ++pA2;
- }
- }
- if (*pA2)
- {
-
-
- return -1;
- }
- }
- return 0;
- }
- FORCEINLINE bool operator()( TSharedPtr<FWwiseTreeItem> A, TSharedPtr<FWwiseTreeItem> B ) const
- {
-
-
-
-
-
- if( A->ItemType == B->ItemType)
- {
- return StringCompareLogical(*A->DisplayName, *B->DisplayName) < 0;
- }
- else if( A->ItemType == EWwiseItemType::PhysicalFolder )
- {
- return true;
- }
- else if( B->ItemType == EWwiseItemType::PhysicalFolder )
- {
- return false;
- }
- else if( A->ItemType == EWwiseItemType::StandaloneWorkUnit || A->ItemType == EWwiseItemType::NestedWorkUnit )
- {
- return true;
- }
- else if( B->ItemType == EWwiseItemType::StandaloneWorkUnit || B->ItemType == EWwiseItemType::NestedWorkUnit )
- {
- return false;
- }
- else if( A->ItemType == EWwiseItemType::Folder )
- {
- return true;
- }
- else if( B->ItemType == EWwiseItemType::Folder )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- };
-
- void SortChildren();
- };
|