2023-12-05 17:58:45 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "MetasoundSettings.h"
2024-06-20 15:27:03 -04:00
2023-12-05 17:58:45 -05:00
# include "Algo/Count.h"
2024-07-18 13:40:05 -04:00
# include "HAL/IConsoleManager.h"
2024-06-20 15:27:03 -04:00
# include "MetasoundFrontendDocument.h"
2023-12-05 17:58:45 -05:00
2024-06-20 15:27:03 -04:00
# define LOCTEXT_NAMESPACE "MetaSound"
2024-06-20 13:33:47 -04:00
2024-06-20 15:27:03 -04:00
namespace Metasound : : SettingsPrivate
2024-06-20 14:26:46 -04:00
{
2024-06-20 15:27:03 -04:00
# if WITH_EDITOR
template < typename SettingsStructType >
TSet < FName > GetStructNames ( const TArray < SettingsStructType > & InSettings , int32 IgnoreIndex = INDEX_NONE )
2024-06-20 13:33:47 -04:00
{
2024-06-20 15:27:03 -04:00
TSet < FName > Names ;
for ( int32 Index = 0 ; Index < InSettings . Num ( ) ; + + Index )
2024-06-20 13:33:47 -04:00
{
2024-06-20 15:27:03 -04:00
if ( Index ! = IgnoreIndex )
{
Names . Add ( InSettings [ Index ] . Name ) ;
}
}
return Names ;
}
/** Generate new name for the item. **/
static FName GenerateUniqueName ( const TSet < FName > & Names , const TCHAR * InBaseName )
{
FString NewName = InBaseName ;
for ( int32 Postfix = 1 ; Names . Contains ( * NewName ) ; + + Postfix )
{
NewName = FString : : Format ( TEXT ( " {0}_{1} " ) , { InBaseName , Postfix } ) ;
2023-12-05 17:58:45 -05:00
}
return FName ( * NewName ) ;
}
2024-06-20 15:27:03 -04:00
template < typename SettingsStructType >
void OnCreateNewSettingsStruct ( const TArray < SettingsStructType > & InSettings , const FString & InBaseName , SettingsStructType & OutNewItem )
2023-12-05 17:58:45 -05:00
{
2024-06-20 15:27:03 -04:00
const TSet < FName > Names = GetStructNames ( InSettings ) ;
OutNewItem . Name = GenerateUniqueName ( Names , * InBaseName ) ;
OutNewItem . UniqueId = FGuid : : NewGuid ( ) ;
2023-12-05 17:58:45 -05:00
}
2024-06-20 15:27:03 -04:00
template < typename SettingsStructType >
void OnRenameSettingsStruct ( const TArray < SettingsStructType > & InSettings , int32 Index , const FString & InBaseName , SettingsStructType & OutRenamed )
2023-12-05 17:58:45 -05:00
{
2024-06-20 15:27:03 -04:00
if ( OutRenamed . Name . IsNone ( ) )
2023-12-13 19:54:40 -05:00
{
2024-06-20 15:27:03 -04:00
const TSet < FName > Names = GetStructNames ( InSettings ) ;
OutRenamed . Name = GenerateUniqueName ( Names , * InBaseName ) ;
2023-12-13 19:54:40 -05:00
}
2024-06-20 15:27:03 -04:00
else
2023-12-05 17:58:45 -05:00
{
2024-06-20 15:27:03 -04:00
const TSet < FName > Names = GetStructNames ( InSettings , Index ) ;
if ( Names . Contains ( OutRenamed . Name ) )
{
OutRenamed . Name = GenerateUniqueName ( Names , * OutRenamed . Name . ToString ( ) ) ;
}
}
2023-12-05 17:58:45 -05:00
}
2024-06-20 15:27:03 -04:00
# endif // WITH_EDITOR
2023-12-05 17:58:45 -05:00
2024-06-20 15:27:03 -04:00
template < typename SettingsStructType >
const SettingsStructType * FindSettingsStruct ( const TArray < SettingsStructType > & Settings , const FGuid & InUniqueID )
{
auto MatchesIDPredicate = [ & InUniqueID ] ( const SettingsStructType & Struct ) { return Struct . UniqueId = = InUniqueID ; } ;
return Settings . FindByPredicate ( MatchesIDPredicate ) ;
}
template < typename SettingsStructType >
const SettingsStructType * FindSettingsStruct ( const TArray < SettingsStructType > & Settings , FName Name )
{
auto MatchesNamePredicate = [ Name ] ( const SettingsStructType & Struct ) { return Struct . Name = = Name ; } ;
return Settings . FindByPredicate ( MatchesNamePredicate ) ;
}
# if WITH_EDITOR
template < typename SettingsStructType >
void PostEditChainChangedStructMember ( FPropertyChangedChainEvent & PostEditChangeChainProperty , TArray < SettingsStructType > & StructSettings , FName PropertyName , const FString & NewItemName )
{
const int32 ItemIndex = PostEditChangeChainProperty . GetArrayIndex ( PropertyName . ToString ( ) ) ;
if ( TDoubleLinkedList < FProperty * > : : TDoubleLinkedListNode * HeadNode = PostEditChangeChainProperty . PropertyChain . GetHead ( ) )
{
const FProperty * Prop = HeadNode - > GetValue ( ) ;
if ( Prop - > GetName ( ) ! = PropertyName )
{
return ;
}
}
// Item changed..
if ( ItemIndex ! = INDEX_NONE & & StructSettings . IsValidIndex ( ItemIndex ) )
{
SettingsStructType & Item = StructSettings [ ItemIndex ] ;
if ( PostEditChangeChainProperty . GetPropertyName ( ) = = " Name " )
{
OnRenameSettingsStruct < SettingsStructType > ( StructSettings , ItemIndex , NewItemName , Item ) ;
}
else if ( PostEditChangeChainProperty . GetPropertyName ( ) = = PropertyName )
{
// Array change add or duplicate
if ( PostEditChangeChainProperty . ChangeType = = EPropertyChangeType : : ArrayAdd
| | PostEditChangeChainProperty . ChangeType = = EPropertyChangeType : : Duplicate )
{
OnCreateNewSettingsStruct < SettingsStructType > ( StructSettings , NewItemName , Item ) ;
}
}
}
// Handle pasting separately as we might not have a valid index in the case of pasting when array is empty.
if ( PostEditChangeChainProperty . GetPropertyName ( ) = = PropertyName )
{
// Paste...
if ( PostEditChangeChainProperty . ChangeType = = EPropertyChangeType : : ValueSet )
{
const int32 IndexOfPastedItem = ItemIndex ! = INDEX_NONE ? ItemIndex : 0 ;
if ( StructSettings . IsValidIndex ( IndexOfPastedItem ) )
{
SettingsStructType & Item = StructSettings [ IndexOfPastedItem ] ;
OnCreateNewSettingsStruct < SettingsStructType > ( StructSettings , NewItemName , Item ) ;
}
}
}
}
# endif // WITH_EDITOR
} // namespace Metasound::SettingsPrivate
# if WITH_EDITOR
2024-08-23 23:03:23 -04:00
bool FMetaSoundPageSettings : : GetExcludeFromCook ( FName PlatformName ) const
2024-08-23 21:59:54 -04:00
{
if ( PlatformCanTargetPage ( PlatformName ) )
{
return false ;
}
2024-08-23 23:03:23 -04:00
return ExcludeFromCook . GetValueForPlatform ( PlatformName ) ;
2024-08-23 21:59:54 -04:00
}
2024-08-23 23:03:23 -04:00
TArray < FName > FMetaSoundPageSettings : : GetTargetPlatforms ( ) const
2024-08-23 21:59:54 -04:00
{
TArray < FName > PlatformNames ;
2024-08-28 10:50:41 -04:00
Algo : : TransformIf ( CanTarget . PerPlatform , PlatformNames ,
2024-08-23 23:03:23 -04:00
[ ] ( const TPair < FName , bool > & Pair ) { return Pair . Value ; } ,
[ ] ( const TPair < FName , bool > & Pair ) { return Pair . Key ; } ) ;
2024-08-23 21:59:54 -04:00
return PlatformNames ;
}
bool FMetaSoundPageSettings : : PlatformCanTargetPage ( FName PlatformName ) const
{
2024-08-28 10:50:41 -04:00
const bool bIsTargeted = CanTarget . GetValueForPlatform ( PlatformName ) ;
2024-08-23 21:59:54 -04:00
return bIsTargeted ;
}
void UMetaSoundSettings : : ConformPageSettings ( bool bNotifyDefaultRenamed )
2024-06-20 15:27:03 -04:00
{
using namespace Metasound ;
2024-08-30 12:53:13 -04:00
DefaultPageSettings . UniqueId = Metasound : : Frontend : : DefaultPageID ;
DefaultPageSettings . Name = Metasound : : Frontend : : DefaultPageName ;
DefaultPageSettings . bIsDefaultPage = true ;
DefaultPageSettings . ExcludeFromCook = false ;
bool bInvalidDefaultRenamed = false ;
TMap < FName , bool > PlatformHasTarget ;
auto GatherPlatformTargets = [ & PlatformHasTarget ] ( const FMetaSoundPageSettings & Page )
{
PlatformHasTarget . FindOrAdd ( { } ) | = Page . CanTarget . Default ;
for ( const TPair < FName , bool > & Pair : Page . CanTarget . PerPlatform )
{
PlatformHasTarget . FindOrAdd ( Pair . Key ) | = Pair . Value ;
}
} ;
GatherPlatformTargets ( DefaultPageSettings ) ;
for ( FMetaSoundPageSettings & Page : PageSettings )
2024-06-20 15:27:03 -04:00
{
2024-07-26 14:23:35 -04:00
const bool bIsDefaultName = Page . Name = = Frontend : : DefaultPageName ;
2024-06-20 15:27:03 -04:00
if ( bIsDefaultName )
{
2024-08-23 21:59:54 -04:00
const TSet < FName > PageNames ( GetPageNames ( ) ) ;
Page . Name = SettingsPrivate : : GenerateUniqueName ( PageNames , * Page . Name . ToString ( ) ) ;
2024-08-30 12:53:13 -04:00
bInvalidDefaultRenamed = true ;
2024-06-20 15:27:03 -04:00
}
2024-08-30 12:53:13 -04:00
GatherPlatformTargets ( Page ) ;
Page . bIsDefaultPage = false ;
2024-06-20 15:27:03 -04:00
}
2024-08-30 12:53:13 -04:00
// Forces each platform to target at least one page setting.
for ( const TPair < FName , bool > & Pair : PlatformHasTarget )
{
if ( ! Pair . Value )
{
if ( Pair . Key . IsNone ( ) )
{
DefaultPageSettings . CanTarget . Default = true ;
}
else
{
DefaultPageSettings . CanTarget . PerPlatform . FindOrAdd ( Pair . Key ) = true ;
}
}
}
2024-06-20 15:27:03 -04:00
2024-08-23 21:59:54 -04:00
# if WITH_EDITORONLY_DATA
2024-08-21 16:54:41 -04:00
{
2024-08-23 21:59:54 -04:00
FScopeLock Lock ( & CookPlatformTargetCritSec ) ;
CookPlatformTargetPageIDs . Reset ( ) ;
CookPlatformTargetPage = { } ;
2024-08-21 16:54:41 -04:00
}
2024-08-23 21:59:54 -04:00
# endif // WITH_EDITORONLY_DATA
2024-08-21 16:54:41 -04:00
2024-08-23 21:59:54 -04:00
TargetPageNameOverride . Reset ( ) ;
2024-09-16 16:06:49 -04:00
for ( int32 Index = PageSettings . Num ( ) - 1 ; Index > = 0 ; - - Index )
{
FMetaSoundPageSettings & PageSetting = PageSettings [ Index ] ;
if ( PageSetting . UniqueId = = Metasound : : Frontend : : DefaultPageID | | PageSetting . Name = = Metasound : : Frontend : : DefaultPageName )
{
PageSettings . RemoveAt ( Index ) ;
}
}
2024-08-30 12:53:13 -04:00
if ( bNotifyDefaultRenamed & & bInvalidDefaultRenamed )
2024-06-20 15:27:03 -04:00
{
2024-08-23 21:59:54 -04:00
OnDefaultRenamed . Broadcast ( ) ;
2024-06-20 15:27:03 -04:00
}
}
# endif // WITH_EDITOR
const FMetaSoundPageSettings * UMetaSoundSettings : : FindPageSettings ( FName Name ) const
{
2024-08-23 21:59:54 -04:00
if ( Name = = Metasound : : Frontend : : DefaultPageName )
{
return & GetDefaultPageSettings ( ) ;
}
2024-06-20 15:27:03 -04:00
return Metasound : : SettingsPrivate : : FindSettingsStruct ( PageSettings , Name ) ;
}
const FMetaSoundPageSettings * UMetaSoundSettings : : FindPageSettings ( const FGuid & InPageID ) const
{
2024-08-23 21:59:54 -04:00
if ( InPageID = = Metasound : : Frontend : : DefaultPageID )
{
return & GetDefaultPageSettings ( ) ;
}
2024-06-20 15:27:03 -04:00
return Metasound : : SettingsPrivate : : FindSettingsStruct ( PageSettings , InPageID ) ;
}
const FMetaSoundQualitySettings * UMetaSoundSettings : : FindQualitySettings ( FName Name ) const
{
return Metasound : : SettingsPrivate : : FindSettingsStruct ( QualitySettings , Name ) ;
}
const FMetaSoundQualitySettings * UMetaSoundSettings : : FindQualitySettings ( const FGuid & InQualityID ) const
{
return Metasound : : SettingsPrivate : : FindSettingsStruct ( QualitySettings , InQualityID ) ;
}
2024-08-23 21:59:54 -04:00
const FMetaSoundPageSettings & UMetaSoundSettings : : GetDefaultPageSettings ( ) const
2024-06-27 23:26:57 -04:00
{
2024-08-23 21:59:54 -04:00
return DefaultPageSettings ;
}
# if WITH_EDITOR
2024-08-23 23:03:23 -04:00
TArray < FName > UMetaSoundSettings : : GetAllPlatformNamesImplementingTargets ( ) const
2024-08-23 21:59:54 -04:00
{
2024-08-30 12:53:13 -04:00
TSet < FName > PlatformNames ;
2024-08-23 23:18:23 -04:00
IteratePageSettings ( [ & ] ( const FMetaSoundPageSettings & PageSetting )
2024-06-27 23:26:57 -04:00
{
2024-08-23 23:18:23 -04:00
TArray < FName > PagePlatforms = PageSetting . GetTargetPlatforms ( ) ;
2024-08-23 21:59:54 -04:00
PlatformNames . Append ( MoveTemp ( PagePlatforms ) ) ;
} ) ;
return PlatformNames . Array ( ) ;
}
# endif // WITH_EDITOR
# if WITH_EDITORONLY_DATA
2024-08-28 10:50:41 -04:00
TArray < FGuid > UMetaSoundSettings : : GetCookedTargetPageIDs ( FName PlatformName ) const
2024-08-23 21:59:54 -04:00
{
FScopeLock Lock ( & CookPlatformTargetCritSec ) ;
2024-08-28 10:50:41 -04:00
return GetCookedTargetPageIDsInternal ( PlatformName ) ;
}
const TArray < FGuid > & UMetaSoundSettings : : GetCookedTargetPageIDsInternal ( FName PlatformName ) const
{
2024-08-23 21:59:54 -04:00
if ( PlatformName ! = CookPlatformTargetPage )
{
CookPlatformTargetPage = PlatformName ;
CookPlatformTargetPageIDs . Reset ( ) ;
2024-08-28 10:50:41 -04:00
auto CanTargetPage = [ & PlatformName ] ( const FMetaSoundPageSettings & PageSetting )
2024-08-23 21:59:54 -04:00
{
# if WITH_EDITOR
return PageSetting . PlatformCanTargetPage ( PlatformName ) ;
# else // !WITH_EDITOR
return true ;
# endif // !WITH_EDITOR
2024-08-28 10:50:41 -04:00
} ;
auto GetID = [ ] ( const FMetaSoundPageSettings & PageSetting )
2024-08-23 21:59:54 -04:00
{
return PageSetting . UniqueId ;
2024-08-28 10:50:41 -04:00
} ;
if ( CanTargetPage ( DefaultPageSettings ) )
{
CookPlatformTargetPageIDs . Add ( DefaultPageSettings . UniqueId ) ;
}
Algo : : TransformIf ( PageSettings , CookPlatformTargetPageIDs , CanTargetPage , GetID ) ;
2024-08-23 21:59:54 -04:00
if ( CookPlatformTargetPageIDs . IsEmpty ( ) )
{
# if WITH_EDITOR
2024-08-28 10:50:41 -04:00
const bool bCanTargetDefault = DefaultPageSettings . CanTarget . GetValueForPlatform ( PlatformName ) ;
2024-08-23 22:12:23 -04:00
# else // !WITH_EDITOR
2024-08-28 10:50:41 -04:00
const bool bCanTargetDefault = DefaultPageSettings . CanTarget . GetValue ( ) ;
2024-08-23 21:59:54 -04:00
# endif // !WITH_EDITOR
if ( ! PageSettings . IsEmpty ( ) & & ! bCanTargetDefault )
{
UE_LOG ( LogMetaSound , Warning , TEXT ( " No pages set to be targeted for platform '%s', forcing 'Default' page as target " ) , * PlatformName . ToString ( ) ) ;
}
CookPlatformTargetPageIDs . Add ( Metasound : : Frontend : : DefaultPageID ) ;
}
2024-06-27 23:26:57 -04:00
}
2024-08-23 21:59:54 -04:00
return CookPlatformTargetPageIDs ;
}
2024-08-28 10:50:41 -04:00
void UMetaSoundSettings : : IterateCookedTargetPageIDs ( FName PlatformName , TFunctionRef < void ( const FGuid & ) > Iter ) const
{
FScopeLock Lock ( & CookPlatformTargetCritSec ) ;
const TArray < FGuid > & CookPlatforms = GetCookedTargetPageIDsInternal ( PlatformName ) ;
for ( const FGuid & CookPlatform : CookPlatforms )
{
Iter ( CookPlatform ) ;
}
}
2024-08-23 21:59:54 -04:00
# endif // WITH_EDITORONLY_DATA
const FMetaSoundPageSettings & UMetaSoundSettings : : GetTargetPageSettings ( ) const
{
const FName TargetPage = TargetPageNameOverride . IsSet ( ) ? * TargetPageNameOverride : TargetPageName ;
2024-10-01 17:46:57 -04:00
# if !NO_LOGGING
auto WarnIfUninitialized = [ this ] ( const FMetaSoundPageSettings & SettingsSet )
{
if ( bWarnAccessBeforeInit )
{
2024-10-01 19:07:55 -04:00
UE_LOG ( LogMetaSound , Display , TEXT ( " Target Page Settings accessed prior to 'PostInitProperties' being called. Uninitialized PageSettings '%s' being returned. " ) , * SettingsSet . Name . ToString ( ) ) ;
2024-10-01 17:46:57 -04:00
bWarnAccessBeforeInit = false ;
}
} ;
# endif // !NO_LOGGING
2024-08-23 21:59:54 -04:00
if ( const FMetaSoundPageSettings * TargetSettings = FindPageSettings ( TargetPage ) )
2024-06-27 23:26:57 -04:00
{
2024-10-01 17:46:57 -04:00
# if !NO_LOGGING
2024-10-01 19:22:54 -04:00
WarnIfUninitialized ( * TargetSettings ) ;
2024-10-01 17:46:57 -04:00
# endif // !NO_LOGGING
2024-10-01 19:22:54 -04:00
return * TargetSettings ;
2024-06-27 23:26:57 -04:00
}
2024-08-23 23:03:23 -04:00
// Shouldn't hit this, but if for some reason the target page is in a bad state,
// try and return any page setting set as a valid target.
2024-08-23 21:59:54 -04:00
for ( const FMetaSoundPageSettings & Setting : PageSettings )
{
2024-10-01 17:46:57 -04:00
# if !NO_LOGGING
2024-10-01 19:22:54 -04:00
WarnIfUninitialized ( Setting ) ;
2024-10-01 17:46:57 -04:00
# endif // !NO_LOGGING
2024-10-01 19:22:54 -04:00
return Setting ;
2024-08-23 21:59:54 -04:00
}
2024-10-01 17:46:57 -04:00
# if !NO_LOGGING
WarnIfUninitialized ( DefaultPageSettings ) ;
# endif // !NO_LOGGING
2024-08-23 21:59:54 -04:00
return DefaultPageSettings ;
2024-06-27 23:26:57 -04:00
}
2024-06-20 15:27:03 -04:00
# if WITH_EDITOR
2023-12-05 17:58:45 -05:00
void UMetaSoundSettings : : PostEditChangeChainProperty ( FPropertyChangedChainEvent & PostEditChangeChainProperty )
{
2024-06-20 15:27:03 -04:00
using namespace Metasound : : SettingsPrivate ;
2023-12-05 17:58:45 -05:00
2024-06-20 15:27:03 -04:00
PostEditChainChangedStructMember ( PostEditChangeChainProperty , PageSettings , GetPageSettingPropertyName ( ) , TEXT ( " New Page " ) ) ;
PostEditChainChangedStructMember ( PostEditChangeChainProperty , QualitySettings , GetQualitySettingPropertyName ( ) , TEXT ( " New Quality " ) ) ;
2023-12-05 17:58:45 -05:00
2024-08-23 21:59:54 -04:00
constexpr bool bNotifyDefaultRenamed = true ;
ConformPageSettings ( bNotifyDefaultRenamed ) ;
2023-12-05 17:58:45 -05:00
Super : : PostEditChangeChainProperty ( PostEditChangeChainProperty ) ;
}
void UMetaSoundSettings : : PostEditChangeProperty ( FPropertyChangedEvent & PropertyChangedEvent )
{
Super : : PostEditChangeProperty ( PropertyChangedEvent ) ;
2024-08-23 21:59:54 -04:00
constexpr bool bNotifyDefaultRenamed = true ;
ConformPageSettings ( bNotifyDefaultRenamed ) ;
2024-06-20 15:27:03 -04:00
if ( PropertyChangedEvent . MemberProperty - > GetName ( ) = = GetPageSettingPropertyName ( ) )
{
OnPageSettingsUpdated . Broadcast ( ) ;
}
2023-12-05 17:58:45 -05:00
DenyListCacheChangeID + + ;
}
2024-10-01 17:46:57 -04:00
# endif // WITH_EDITOR
2023-12-05 17:58:45 -05:00
2024-06-20 15:27:03 -04:00
void UMetaSoundSettings : : PostInitProperties ( )
{
Super : : PostInitProperties ( ) ;
2024-08-30 12:53:13 -04:00
2024-10-01 17:46:57 -04:00
# if WITH_EDITOR
2024-08-30 12:53:13 -04:00
constexpr bool bNotifyDefaultRenamed = false ;
ConformPageSettings ( bNotifyDefaultRenamed ) ;
2024-06-21 14:37:29 -04:00
# endif // WITH_EDITOR
2024-10-01 17:46:57 -04:00
# if !NO_LOGGING
bWarnAccessBeforeInit = false ;
# endif // !NO_LOGGING
if ( const FMetaSoundPageSettings * Page = FindPageSettings ( TargetPageName ) )
{
2024-10-01 19:22:54 -04:00
UE_LOG ( LogMetaSound , Display , TEXT ( " MetaSound Page Target Initialized to '%s' " ) , * GetTargetPageSettings ( ) . Name . ToString ( ) ) ;
2024-10-01 17:46:57 -04:00
}
else
{
2024-10-01 19:22:54 -04:00
UE_LOG ( LogMetaSound , Warning , TEXT ( " TargetPageName '%s' at time of 'UMetaSoundSettings::PostInitProperties' did not correspond to a valid page. " ) , * TargetPageName . ToString ( ) ) ;
if ( PageSettings . IsEmpty ( ) )
2024-10-01 17:46:57 -04:00
{
2024-10-01 19:22:54 -04:00
UE_LOG ( LogMetaSound , Warning , TEXT ( " Setting target to '%s' page settings. " ) , * DefaultPageSettings . Name . ToString ( ) ) ;
TargetPageName = DefaultPageSettings . Name ;
}
else
{
UE_LOG ( LogMetaSound , Warning , TEXT ( " Setting target to highest project page settings '%s'. " ) , * PageSettings . Last ( ) . Name . ToString ( ) ) ;
TargetPageName = PageSettings . Last ( ) . Name ;
2024-10-01 17:46:57 -04:00
}
}
}
2024-06-27 23:26:57 -04:00
bool UMetaSoundSettings : : SetTargetPage ( FName PageName )
{
if ( const FMetaSoundPageSettings * PageSetting = FindPageSettings ( PageName ) )
{
2024-10-01 19:22:54 -04:00
const FName TargetPage = TargetPageNameOverride . IsSet ( ) ? * TargetPageNameOverride : TargetPageName ;
if ( TargetPage ! = PageSetting - > Name )
2024-06-27 23:26:57 -04:00
{
2024-10-01 19:22:54 -04:00
UE_LOG ( LogMetaSound , Display , TEXT ( " Target page override set to '%s'. " ) , * TargetPage . ToString ( ) ) ;
TargetPageNameOverride = PageSetting - > Name ;
return true ;
2024-06-27 23:26:57 -04:00
}
}
return false ;
}
2024-06-21 14:37:29 -04:00
# if WITH_EDITORONLY_DATA
2024-08-23 21:59:54 -04:00
Metasound : : Engine : : FOnSettingsDefaultConformed & UMetaSoundSettings : : GetOnDefaultRenamedDelegate ( )
2024-06-21 14:37:29 -04:00
{
2024-08-23 21:59:54 -04:00
return OnDefaultRenamed ;
2024-06-21 14:37:29 -04:00
}
Metasound : : Engine : : FOnPageSettingsUpdated & UMetaSoundSettings : : GetOnPageSettingsUpdatedDelegate ( )
{
return OnPageSettingsUpdated ;
}
2024-06-20 15:27:03 -04:00
FName UMetaSoundSettings : : GetPageSettingPropertyName ( )
{
return GET_MEMBER_NAME_CHECKED ( UMetaSoundSettings , PageSettings ) ;
}
2024-03-20 12:42:32 -04:00
FName UMetaSoundSettings : : GetQualitySettingPropertyName ( )
{
return GET_MEMBER_NAME_CHECKED ( UMetaSoundSettings , QualitySettings ) ;
}
2024-06-21 14:37:29 -04:00
# endif // WITH_EDITORONLY_DATA
2023-12-05 17:58:45 -05:00
2024-07-17 16:31:15 -04:00
# if WITH_EDITOR
2024-08-13 15:48:07 -04:00
TArray < FName > UMetaSoundSettings : : GetPageNames ( )
2023-12-05 17:58:45 -05:00
{
if ( const UMetaSoundSettings * Settings = GetDefault < UMetaSoundSettings > ( ) )
{
2024-08-13 15:48:07 -04:00
TArray < FName > Names ;
2024-08-23 21:59:54 -04:00
Settings - > IteratePageSettings ( [ & Names ] ( const FMetaSoundPageSettings & PageSetting )
{
Names . Add ( PageSetting . Name ) ;
} ) ;
2024-08-13 15:48:07 -04:00
return Names ;
2023-12-05 17:58:45 -05:00
}
2024-08-13 15:48:07 -04:00
return { } ;
}
TArray < FName > UMetaSoundSettings : : GetQualityNames ( )
{
if ( const UMetaSoundSettings * Settings = GetDefault < UMetaSoundSettings > ( ) )
{
TArray < FName > Names ;
auto GetName = [ ] ( const FMetaSoundQualitySettings & Quality ) { return Quality . Name ; } ;
Algo : : Transform ( Settings - > GetQualitySettings ( ) , Names , GetName ) ;
return Names ;
}
return { } ;
2023-12-05 17:58:45 -05:00
}
2024-07-17 16:31:15 -04:00
# endif // WITH_EDITOR
2024-08-23 21:59:54 -04:00
void UMetaSoundSettings : : IteratePageSettings ( TFunctionRef < void ( const FMetaSoundPageSettings & ) > Iter , bool bReverse ) const
{
if ( bReverse )
{
for ( int32 Index = PageSettings . Num ( ) - 1 ; Index > = 0 ; - - Index )
{
Iter ( PageSettings [ Index ] ) ;
}
Iter ( GetDefaultPageSettings ( ) ) ;
}
else
{
Iter ( GetDefaultPageSettings ( ) ) ;
for ( const FMetaSoundPageSettings & Setting : PageSettings )
{
Iter ( Setting ) ;
}
}
}
2024-06-20 15:27:03 -04:00
# undef LOCTEXT_NAMESPACE // MetaSound