Made the codgen run on async

This commit is contained in:
Edward R. Gonzalez 2024-10-21 22:58:24 -04:00
parent a1a5f2f309
commit d4bf7cfaec
6 changed files with 114 additions and 94 deletions

Binary file not shown.

View File

@ -16,6 +16,9 @@ public:
// NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp // NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp
// They are used by GasaGen for the GasaDevOptionsCache // They are used by GasaGen for the GasaDevOptionsCache
UPROPERTY(Config)
TSoftObjectPtr<UDataTable> RandomBullshit;
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="GAS") UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="GAS")
TArray< TSoftObjectPtr<UDataTable>> AttributeSets; TArray< TSoftObjectPtr<UDataTable>> AttributeSets;

View File

@ -11,6 +11,9 @@ void FGasaDevOptionsCache::CachedDevOptions()
{ {
UGasaDevOptions* DevOpts = GetMutDevOptions(); UGasaDevOptions* DevOpts = GetMutDevOptions();
RandomBullshit = DevOpts->RandomBullshit.LoadSynchronous();
ensureMsgf( RandomBullshit != nullptr, TEXT( "RandomBullshit is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" ) );
for ( auto& entry : DevOpts->AttributeSets ) for ( auto& entry : DevOpts->AttributeSets )
{ {
AttributeSets.Push( entry.LoadSynchronous() ); AttributeSets.Push( entry.LoadSynchronous() );

View File

@ -8,6 +8,8 @@ struct GASA_API FGasaDevOptionsCache
{ {
GENERATED_BODY() GENERATED_BODY()
UPROPERTY()
UObject* RandomBullshit;
UPROPERTY() UPROPERTY()
TArray<UObject*> AttributeSets; TArray<UObject*> AttributeSets;
UPROPERTY() UPROPERTY()

View File

@ -5,6 +5,8 @@
// Editor Module // Editor Module
#include "GasaEditorCommon.h" #include "GasaEditorCommon.h"
#define LOCTEXT_NAMESPACE "GasaEditor"
global String Project_Path; global String Project_Path;
global String Root_Path; global String Root_Path;
@ -15,6 +17,11 @@ global Code UHT_USTRUCT;
global Code UModule_GASA_API; global Code UModule_GASA_API;
void Execute_GasaModule_Codegen() void Execute_GasaModule_Codegen()
{
FScopedSlowTask SlowTask(100.0f, LOCTEXT("RunningGasaGen", "Running GasaGen..."));
SlowTask.MakeDialog(); // Shows a progress dialog
AsyncTask(ENamedThreads::AnyBackgroundThreadNormalTask, [&SlowTask]()
{ {
Gasa::LogEditor("Executing: Gasa Module code generation."); Gasa::LogEditor("Executing: Gasa Module code generation.");
@ -110,5 +117,13 @@ void Execute_GasaModule_Codegen()
//generate_HostWidgetController(); //generate_HostWidgetController();
gen::deinit(); gen::deinit();
AsyncTask(ENamedThreads::GameThread, []()
{
// UI updates if needed
});
});
} }
#undef LOCTEXT_NAMESPACE

View File

@ -6,8 +6,6 @@
#undef GASA_API #undef GASA_API
#undef ensureMsgf #undef ensureMsgf
PRAGMA_DISABLE_OPTIMIZATION
void generate_DevOptionsCache() void generate_DevOptionsCache()
{ {
Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator); Array<CodeVar> GasaDevOptions_UPROPERTIES = Array<CodeVar>::init(GlobalAllocator);
@ -162,7 +160,6 @@ void generate_DevOptionsCache()
format_file( path_module_gasa "GasaDevOptionsCache.cpp" ); format_file( path_module_gasa "GasaDevOptionsCache.cpp" );
} }
} }
PRAGMA_ENABLE_OPTIMIZATION
#pragma pop_macro("ensureMsgf") #pragma pop_macro("ensureMsgf")
#pragma pop_macro("GASA_API") #pragma pop_macro("GASA_API")