Skip to content

Commit

Permalink
Merge pull request #467 from crazytuzi/develop
Browse files Browse the repository at this point in the history
Compatible with 5.5
  • Loading branch information
crazytuzi authored Nov 27, 2024
2 parents 6da5a82 + a434c54 commit 3ac627c
Show file tree
Hide file tree
Showing 37 changed files with 622 additions and 2,153 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "Source/ThirdParty/Mono"]
path = Source/ThirdParty/Mono
url = https://github.com/crazytuzi/Mono
[submodule "Source/SourceCodeGenerator"]
path = Source/SourceCodeGenerator
url = https://github.com/crazytuzi/SourceCodeGenerator
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# 平台支持

- 运行平台:Windows / macOS / Linux / Android / IOS
- 引擎版本:Unreal Engine 5.0 - Unreal Engine 5.4
- 引擎版本:Unreal Engine 5.0 - Unreal Engine 5.5

# 文档

Expand Down
6 changes: 6 additions & 0 deletions Script/UE/Reflection/Property/FMapProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Script.Reflection.Property
{
public class FMapProperty : FProperty
{
}
}
47 changes: 41 additions & 6 deletions Source/Compiler/Private/FCSharpCompilerRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,31 @@ void FCSharpCompilerRunnable::Compile(const TFunction<void()>& InFunction)

void FCSharpCompilerRunnable::Compile()
{
AsyncTask(ENamedThreads::GameThread, [this]()
{
static const FName CompileStatusBackground("Blueprint.CompileStatus.Background");

FNotificationInfo NotificationInfo(FText::FromString(TEXT("Compilation background")));

NotificationInfo.bUseSuccessFailIcons = true;

#if UE_APP_STYLE_GET_BRUSH
NotificationInfo.Image = FAppStyle::GetBrush(CompileStatusBackground);
#else
NotificationInfo.Image = FEditorStyle::GetBrush(CompileStatusBackground);
#endif

NotificationInfo.bFireAndForget = true;

NotificationInfo.ExpireDuration = 60.f;

NotificationInfo.FadeOutDuration = 0.5f;

NotificationInfo.FadeInDuration = 0.5f;

NotificationItem = FSlateNotificationManager::Get().AddNotification(NotificationInfo);
});

static auto CompileTool = FUnrealCSharpFunctionLibrary::GetDotNet();

const auto CompileParam = FString::Printf(TEXT(
Expand Down Expand Up @@ -276,16 +301,26 @@ void FCSharpCompilerRunnable::Compile()

FPlatformProcess::CloseProc(ProcessHandle);

if (NotificationInfo != nullptr)
AsyncTask(ENamedThreads::GameThread, [this, NotificationInfo]()
{
NotificationInfo->bFireAndForget = true;
if (NotificationItem.IsValid())
{
NotificationItem->Fadeout();

NotificationInfo->FadeOutDuration = 2.0f;
NotificationItem.Reset();
}

NotificationInfo->FadeInDuration = 0.5f;
if (NotificationInfo != nullptr)
{
NotificationInfo->bFireAndForget = true;

FSlateNotificationManager::Get().QueueNotification(NotificationInfo);
}
NotificationInfo->FadeOutDuration = 2.0f;

NotificationInfo->FadeInDuration = 0.5f;

FSlateNotificationManager::Get().QueueNotification(NotificationInfo);
}
});
}

void FCSharpCompilerRunnable::OnBeginGenerator()
Expand Down
4 changes: 3 additions & 1 deletion Source/Compiler/Public/FCSharpCompilerRunnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FCSharpCompilerRunnable final : public FRunnable
void Compile(const TFunction<void()>& InFunction);

private:
static void Compile();
void Compile();

private:
void OnBeginGenerator();
Expand All @@ -57,4 +57,6 @@ class FCSharpCompilerRunnable final : public FRunnable
bool bIsGenerating;

bool bIsStopped;

TSharedPtr<SNotificationItem> NotificationItem;
};
22 changes: 22 additions & 0 deletions Source/CrossVersion/Public/UEVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,32 @@

#define UE_F_OPTIONAL_PROPERTY UE_VERSION_START(5, 3, 0)

#define UE_F_DELEGATE_PROPERTY_SIGNATURE_FUNCTION_T_OBJECT_PTR UE_VERSION_START(5, 3, 0)

#define UE_T_BASE_STRUCTURE_F_STRATA_MATERIAL_INPUT !UE_VERSION_START(5, 4, 0)

#define UE_SOFT_OBJECT_PATH_GET_CURRENT_TAG !UE_VERSION_START(5, 4, 0)

#define UE_SOFT_OBJECT_PATH_INVALIDATE_TAG !UE_VERSION_START(5, 4, 0)

#define UE_E_CONTENT_BROWSER_ITEM_FLAGS_CATEGORY_PLUGIN UE_VERSION_START(5, 4, 0)

#define UE_T_BASE_STRUCTURE_F_FRAME_RATE !UE_VERSION_START(5, 5, 0)

#define UE_U_CONTENT_BROWSER_DATA_SOURCE_NOTIFY_ITEM_DATA_REFRESHED !UE_VERSION_START(5, 5, 0)

#define UE_STRUCT_UTILS_U_USER_DEFINED_STRUCT UE_VERSION_START(5, 5, 0)

#define UE_F_CONTENT_BROWSER_ITEM_DATA_F_NAME UE_VERSION_START(5, 5, 0)

#define UE_F_PROPERTY_GET_ELEMENT_SIZE UE_VERSION_START(5, 5, 0)

#define UE_F_PROPERTY_SET_ELEMENT_SIZE UE_VERSION_START(5, 5, 0)

#define UE_F_STRING_REMOVE_AT_E_ALLOW_SHRINKING UE_VERSION_START(5, 5, 0)

#define UE_E_INTERNAL_OBJECT_FLAGS_ASYNC_LOADING UE_VERSION_START(5, 5, 0)

#define UE_F_STRING_LEFT_CHOP_IN_LINE_E_ALLOW_SHRINKING UE_VERSION_START(5, 5, 0)

#define UE_DO_NATIVE_IMPL_OPTIMIZATION UE_VERSION_START(5, 5, 0)
6 changes: 5 additions & 1 deletion Source/ScriptCodeGenerator/Private/FAssetGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
#include "FStructGenerator.h"
#include "AssetRegistry/AssetRegistryModule.h"
#include "Engine/UserDefinedEnum.h"
#include "Engine/UserDefinedStruct.h"
#include "WidgetBlueprint.h"
#include "FGeneratorCore.h"
#include "Common/FUnrealCSharpFunctionLibrary.h"
#include "CoreMacro/NamespaceMacro.h"
#include "UEVersion.h"
#include "Setting/UnrealCSharpEditorSetting.h"
#if UE_STRUCT_UTILS_U_USER_DEFINED_STRUCT
#include "StructUtils/UserDefinedStruct.h"
#else
#include "Engine/UserDefinedStruct.h"
#endif

TArray<UUserDefinedEnum*> FAssetGenerator::UserDefinedEnums;

Expand Down
2 changes: 1 addition & 1 deletion Source/ScriptCodeGenerator/Private/FClassGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void FClassGenerator::Generator(const UClass* InClass)
if (FunctionParams[Index]->HasAnyPropertyFlags(CPF_OutParm) && !FunctionParams[Index]->HasAnyPropertyFlags(
CPF_ConstParm))
{
if (Function->GetOwnerClass()->IsNative() ||
if (FUnrealCSharpFunctionLibrary::IsNativeFunction(InClass, Function->GetFName()) ||
FunctionParams[Index]->HasAnyPropertyFlags(CPF_ReferenceParm))
{
FunctionOutParamIndexMapping[FunctionParams.Num() - 1 - FunctionRefParamIndex.Num()] =
Expand Down
43 changes: 7 additions & 36 deletions Source/ScriptCodeGenerator/Private/FGeneratorCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,13 @@ FString FGeneratorCore::GetBufferCast(FProperty* Property)

int32 FGeneratorCore::GetBufferSize(FProperty* Property)
{
return IsPrimitiveProperty(Property) ? Property->ElementSize : sizeof(void*);
return IsPrimitiveProperty(Property)
#if UE_F_PROPERTY_GET_ELEMENT_SIZE
? Property->GetElementSize()
#else
? Property->ElementSize
#endif
: sizeof(void*);
}

FString FGeneratorCore::GetTypeImplementation(FProperty* Property)
Expand Down Expand Up @@ -615,41 +621,6 @@ int32 FGeneratorCore::GetFunctionIndex(const bool bHasReturn, const bool bHasInp
static_cast<int32>(bIsNet) << 4;
}

FString FGeneratorCore::GetModuleRelativePath(const UField* InField)
{
return InField != nullptr
? GetModuleRelativePath(InField->GetMetaData(TEXT("ModuleRelativePath")))
: FString();
}

FString FGeneratorCore::GetModuleRelativePath(const UEnum* InEnum)
{
return InEnum != nullptr
? GetModuleRelativePath(InEnum->GetMetaData(TEXT("ModuleRelativePath")))
: FString();
}

FString FGeneratorCore::GetModuleRelativePath(const FDelegateProperty* InDelegateProperty)
{
return InDelegateProperty != nullptr
? GetModuleRelativePath(
InDelegateProperty->SignatureFunction->GetMetaData(TEXT("ModuleRelativePath")))
: FString();
}

FString FGeneratorCore::GetModuleRelativePath(const FMulticastDelegateProperty* InMulticastDelegateProperty)
{
return InMulticastDelegateProperty != nullptr
? GetModuleRelativePath(
InMulticastDelegateProperty->SignatureFunction->GetMetaData(TEXT("ModuleRelativePath")))
: FString();
}

FString FGeneratorCore::GetModuleRelativePath(const FString& InModuleRelativePath)
{
return InModuleRelativePath.Replace(TEXT("Public/"), TEXT("")).Replace(TEXT("Private/"), TEXT(""));
}

TArray<FString> FGeneratorCore::GetOverrideFunctions(const FString& InNameSpace, const FString& InClass)
{
const auto FoundFunctions = OverrideFunctionsMap.Find(FString::Printf(TEXT(
Expand Down
10 changes: 0 additions & 10 deletions Source/ScriptCodeGenerator/Public/FGeneratorCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ class FGeneratorCore

static int32 GetFunctionIndex(bool bHasReturn, bool bHasInput, bool bHasOutput, bool bIsNative, bool bIsNet);

static FString GetModuleRelativePath(const UField* InField);

static FString GetModuleRelativePath(const UEnum* InEnum);

static FString GetModuleRelativePath(const FDelegateProperty* InDelegateProperty);

static FString GetModuleRelativePath(const FMulticastDelegateProperty* InMulticastDelegateProperty);

static FString GetModuleRelativePath(const FString& InModuleRelativePath);

template <typename T>
static auto GetFileName(const T* InField);

Expand Down
51 changes: 13 additions & 38 deletions Source/ScriptCodeGenerator/Public/FGeneratorCore.inl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "UEVersion.h"
#include "Common/FUnrealCSharpFunctionLibrary.h"
#include "CoreMacro/Macro.h"

Expand All @@ -8,49 +9,23 @@ auto FGeneratorCore::GetFileName(const T* InField)
{
if constexpr (std::is_same_v<T, FDelegateProperty> || std::is_same_v<T, FMulticastDelegateProperty>)
{
FString RelativeModuleName;

const auto SignatureFunction = InField->SignatureFunction;

if (const auto Class = Cast<UClass>(SignatureFunction->GetOuter()))
if (SignatureFunction == nullptr)
{
if (InField->IsNative())
{
RelativeModuleName = FString::Printf(TEXT(
"%s/%s"
),
*(Class->GetOuter() ? Class->GetOuter()->GetName() : TEXT("")),
*Class->GetName());
}
else
{
RelativeModuleName = *(Class->GetOuter() ? Class->GetOuter()->GetName() : TEXT(""));
}
return FString();
}

if (const auto Package = Cast<UPackage>(SignatureFunction->GetOuter()))
{
RelativeModuleName = Package->GetName().Replace(TEXT("/Script/"), TEXT("/"));
}

if (!InField->IsNative())
{
if (auto Index = 0; RelativeModuleName.FindLastChar(TEXT('/'), Index))
{
RelativeModuleName.LeftInline(Index);
}
}

auto ModuleName = FUnrealCSharpFunctionLibrary::GetModuleName(RelativeModuleName);
auto ModuleName = FUnrealCSharpFunctionLibrary::GetModuleName(SignatureFunction);

auto DirectoryName = FPaths::Combine(
FUnrealCSharpFunctionLibrary::GetGenerationPath(InField->SignatureFunction), ModuleName);
FUnrealCSharpFunctionLibrary::GetGenerationPath(SignatureFunction), ModuleName);

auto ModuleRelativeFile = FPaths::Combine(
FPaths::GetPath(FGeneratorCore::GetModuleRelativePath(InField)),
FUnrealCSharpFunctionLibrary::GetFullClass(InField));
auto ModuleRelativePath = FUnrealCSharpFunctionLibrary::GetModuleRelativePath(InField);

return FPaths::Combine(DirectoryName, ModuleRelativeFile) + CSHARP_SUFFIX;
auto FileName = FUnrealCSharpFunctionLibrary::GetFullClass(InField) + CSHARP_SUFFIX;

return FPaths::Combine(DirectoryName, ModuleRelativePath, FileName);
}
else
{
Expand All @@ -59,10 +34,10 @@ auto FGeneratorCore::GetFileName(const T* InField)
auto DirectoryName = FPaths::Combine(
FUnrealCSharpFunctionLibrary::GetGenerationPath(InField), ModuleName);

auto ModuleRelativeFile = FPaths::Combine(
FPaths::GetPath(FGeneratorCore::GetModuleRelativePath(InField)),
InField->GetName());
auto ModuleRelativePath = FUnrealCSharpFunctionLibrary::GetModuleRelativePath(InField);

auto FileName = InField->GetName() + CSHARP_SUFFIX;

return FPaths::Combine(DirectoryName, ModuleRelativeFile) + CSHARP_SUFFIX;
return FPaths::Combine(DirectoryName, ModuleRelativePath, FileName);
}
}
1 change: 1 addition & 0 deletions Source/SourceCodeGenerator
Submodule SourceCodeGenerator added at 4aac4c
Loading

0 comments on commit 3ac627c

Please sign in to comment.