2022-09-23 20:46:19 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "MVVMDeveloperProjectSettings.h"
|
2023-02-08 12:16:32 -05:00
|
|
|
#include "Engine/Blueprint.h"
|
2022-09-23 20:46:19 -04:00
|
|
|
|
2023-02-13 08:39:55 -05:00
|
|
|
#include "BlueprintEditorSettings.h"
|
2023-02-14 12:07:02 -05:00
|
|
|
#include "MVVMBlueprintViewModelContext.h"
|
2023-02-27 16:27:44 -05:00
|
|
|
#include "PropertyPermissionList.h"
|
2023-02-14 12:07:02 -05:00
|
|
|
#include "Types/MVVMExecutionMode.h"
|
2023-02-13 08:39:55 -05:00
|
|
|
|
2022-09-23 20:46:19 -04:00
|
|
|
#define LOCTEXT_NAMESPACE "MVVMDeveloperProjectSettings"
|
|
|
|
|
|
2023-01-31 10:21:03 -05:00
|
|
|
UMVVMDeveloperProjectSettings::UMVVMDeveloperProjectSettings()
|
|
|
|
|
{
|
|
|
|
|
AllowedExecutionMode.Add(EMVVMExecutionMode::Immediate);
|
|
|
|
|
AllowedExecutionMode.Add(EMVVMExecutionMode::Delayed);
|
|
|
|
|
AllowedExecutionMode.Add(EMVVMExecutionMode::Tick);
|
2023-05-26 11:58:47 -04:00
|
|
|
AllowedExecutionMode.Add(EMVVMExecutionMode::DelayedWhenSharedElseImmediate);
|
2023-02-09 16:22:43 -05:00
|
|
|
|
|
|
|
|
AllowedContextCreationType.Add(EMVVMBlueprintViewModelContextCreationType::Manual);
|
|
|
|
|
AllowedContextCreationType.Add(EMVVMBlueprintViewModelContextCreationType::CreateInstance);
|
|
|
|
|
AllowedContextCreationType.Add(EMVVMBlueprintViewModelContextCreationType::GlobalViewModelCollection);
|
|
|
|
|
AllowedContextCreationType.Add(EMVVMBlueprintViewModelContextCreationType::PropertyPath);
|
|
|
|
|
AllowedContextCreationType.Add(EMVVMBlueprintViewModelContextCreationType::PropertyPath);
|
|
|
|
|
AllowedContextCreationType.Add(EMVVMBlueprintViewModelContextCreationType::Resolver);
|
2023-01-31 10:21:03 -05:00
|
|
|
}
|
|
|
|
|
|
2022-09-23 20:46:19 -04:00
|
|
|
FName UMVVMDeveloperProjectSettings::GetCategoryName() const
|
|
|
|
|
{
|
|
|
|
|
return TEXT("Plugins");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FText UMVVMDeveloperProjectSettings::GetSectionText() const
|
|
|
|
|
{
|
|
|
|
|
return LOCTEXT("MVVMProjectSettings", "Model View Viewmodel");
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 08:20:42 -05:00
|
|
|
bool UMVVMDeveloperProjectSettings::IsPropertyAllowed(const FProperty* Property) const
|
2022-09-23 20:46:19 -04:00
|
|
|
{
|
|
|
|
|
check(Property);
|
2023-02-13 08:39:55 -05:00
|
|
|
if (!FPropertyEditorPermissionList::Get().DoesPropertyPassFilter(Property->GetOwnerStruct(), Property->GetFName()))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-14 12:07:02 -05:00
|
|
|
TStringBuilder<512> StringBuilder;
|
2022-09-23 20:46:19 -04:00
|
|
|
Property->GetOwnerClass()->GetPathName(nullptr, StringBuilder);
|
|
|
|
|
FSoftClassPath StructPath;
|
|
|
|
|
StructPath.SetPath(StringBuilder);
|
|
|
|
|
if (const FMVVMDeveloperProjectWidgetSettings* Settings = FieldSelectorPermissions.Find(StructPath))
|
|
|
|
|
{
|
|
|
|
|
return !Settings->DisallowedFieldNames.Find(Property->GetFName());
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 08:20:42 -05:00
|
|
|
bool UMVVMDeveloperProjectSettings::IsFunctionAllowed(const UFunction* Function) const
|
2022-09-23 20:46:19 -04:00
|
|
|
{
|
|
|
|
|
check(Function);
|
2023-02-14 12:07:02 -05:00
|
|
|
|
|
|
|
|
TStringBuilder<512> StringBuilder;
|
2023-02-17 15:28:46 -05:00
|
|
|
const FPathPermissionList& FunctionPermissions = GetMutableDefault<UBlueprintEditorSettings>()->GetFunctionPermissions();
|
|
|
|
|
if (FunctionPermissions.HasFiltering())
|
2023-02-13 08:39:55 -05:00
|
|
|
{
|
2023-02-17 15:28:46 -05:00
|
|
|
Function->GetPathName(nullptr, StringBuilder);
|
|
|
|
|
if (!FunctionPermissions.PassesFilter(StringBuilder.ToView()))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-02-13 08:39:55 -05:00
|
|
|
}
|
|
|
|
|
|
2023-02-14 12:07:02 -05:00
|
|
|
StringBuilder.Reset();
|
2022-09-23 20:46:19 -04:00
|
|
|
Function->GetOwnerClass()->GetPathName(nullptr, StringBuilder);
|
|
|
|
|
FSoftClassPath StructPath;
|
|
|
|
|
StructPath.SetPath(StringBuilder);
|
|
|
|
|
if (const FMVVMDeveloperProjectWidgetSettings* Settings = FieldSelectorPermissions.Find(StructPath))
|
|
|
|
|
{
|
|
|
|
|
return !Settings->DisallowedFieldNames.Find(Function->GetFName());
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-14 12:07:02 -05:00
|
|
|
bool UMVVMDeveloperProjectSettings::IsConversionFunctionAllowed(const UFunction* Function) const
|
|
|
|
|
{
|
2023-02-17 15:28:46 -05:00
|
|
|
static FName NAME_ComplexConversionFunction = TEXT("MVVMComplexConversionFunction");
|
|
|
|
|
if (Function->HasMetaData(NAME_ComplexConversionFunction))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConversionFunctionFilter == EMVVMDeveloperConversionFunctionFilterType::BlueprintActionRegistry)
|
2023-02-14 12:07:02 -05:00
|
|
|
{
|
|
|
|
|
return IsFunctionAllowed(Function);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-02-17 15:28:46 -05:00
|
|
|
check(ConversionFunctionFilter == EMVVMDeveloperConversionFunctionFilterType::AllowedList);
|
|
|
|
|
|
|
|
|
|
if (Function->HasAllFunctionFlags(FUNC_Static))
|
2023-02-14 12:07:02 -05:00
|
|
|
{
|
2023-02-17 15:28:46 -05:00
|
|
|
TStringBuilder<512> FunctionClassPath;
|
|
|
|
|
Function->GetOwnerClass()->GetPathName(nullptr, FunctionClassPath);
|
|
|
|
|
TStringBuilder<512> AllowedClassPath;
|
|
|
|
|
for (const FSoftClassPath& SoftClass : AllowedClassForConversionFunctions)
|
2023-02-14 12:07:02 -05:00
|
|
|
{
|
2023-02-17 15:28:46 -05:00
|
|
|
SoftClass.ToString(AllowedClassPath);
|
|
|
|
|
if (AllowedClassPath.ToView() == FunctionClassPath.ToView())
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
AllowedClassPath.Reset();
|
2023-02-14 12:07:02 -05:00
|
|
|
}
|
2023-02-17 15:28:46 -05:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// The function is on self and may have been filtered.
|
|
|
|
|
return IsFunctionAllowed(Function);
|
2023-02-14 12:07:02 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-08 12:16:32 -05:00
|
|
|
TArray<const UClass*> UMVVMDeveloperProjectSettings::GetAllowedConversionFunctionClasses() const
|
|
|
|
|
{
|
|
|
|
|
TArray<const UClass*> Result;
|
|
|
|
|
for (const FSoftClassPath& SoftClass : AllowedClassForConversionFunctions)
|
|
|
|
|
{
|
|
|
|
|
if (UClass* Class = SoftClass.ResolveClass())
|
|
|
|
|
{
|
|
|
|
|
Result.Add(Class);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 20:46:19 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|