diff --git a/CHANGELOG.md b/CHANGELOG.md index c30902a..66b67c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,4 +11,4 @@ All notable changes to this project will be documented in this file. See [conven - - - -Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto). \ No newline at end of file +Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto). diff --git a/Ecsact.uplugin b/Ecsact.uplugin index b359d78..e60c1d3 100644 --- a/Ecsact.uplugin +++ b/Ecsact.uplugin @@ -27,4 +27,4 @@ "LoadingPhase": "Default" } ] -} \ No newline at end of file +} diff --git a/Source/EcsactEditor/Private/EcsactEditor.cpp b/Source/EcsactEditor/Private/EcsactEditor.cpp index 027b110..6c7e0f1 100644 --- a/Source/EcsactEditor/Private/EcsactEditor.cpp +++ b/Source/EcsactEditor/Private/EcsactEditor.cpp @@ -1,4 +1,5 @@ #include "EcsactEditor.h" +#include "Async/Async.h" #include "Async/TaskGraphInterfaces.h" #include "Editor.h" #include "ISettingsModule.h" @@ -218,12 +219,32 @@ auto FEcsactEditorModule::RunBuild() -> void { TEXT("Binaries/Win64/EcsactRuntime.dll") ); auto temp_dir = FPaths::CreateTempFilename(TEXT("EcsactBuild")); - + auto recipes = settings->GetValidRecipes(); auto ecsact_files = GetAllEcsactFiles(); + + if(ecsact_files.IsEmpty()) { + UE_LOG( + EcsactEditor, + Warning, + TEXT("There are no .ecsact files found in your Source directory") + ); + return; + } + + if(recipes.IsEmpty()) { + FMessageDialog::Open( + EAppMsgType::Ok, + LOCTEXT( + "NoRecipesErrorMessage", + "There are no recipes configured in your Ecsact plugin settings." + ) + ); + return; + } + auto args = TArray{ "build", "--format=json", - "--recipe=rt_entt", "-o", ecsact_runtime_path, "--temp=" + temp_dir, @@ -240,6 +261,10 @@ auto FEcsactEditorModule::RunBuild() -> void { break; } + for(const auto& recipe : recipes) { + args.Push("--recipe=" + recipe); + } + args.Append(ecsact_files); SpawnEcsactCli( @@ -378,6 +403,16 @@ auto FEcsactEditorModule::OnReceiveEcsactCliJsonMessage(FString Json) -> void { } auto FEcsactEditorModule::OnEcsactSettingsModified() -> bool { + const auto* settings = GetDefault(); + static auto prev_valid_recipes = settings->GetValidRecipes(); + + auto valid_recipes = settings->GetValidRecipes(); + + if(prev_valid_recipes != valid_recipes) { + prev_valid_recipes = valid_recipes; + RunBuild(); + } + return true; } diff --git a/Source/EcsactEditor/Private/EcsactSettings.cpp b/Source/EcsactEditor/Private/EcsactSettings.cpp index a6006dd..be6e0c7 100644 --- a/Source/EcsactEditor/Private/EcsactSettings.cpp +++ b/Source/EcsactEditor/Private/EcsactSettings.cpp @@ -2,3 +2,9 @@ UEcsactSettings::UEcsactSettings() { } + +auto UEcsactSettings::GetValidRecipes() const -> TArray { + return Recipes.FilterByPredicate([](const FString& recipe) -> bool { + return !recipe.TrimStartAndEnd().IsEmpty(); + }); +} diff --git a/Source/EcsactEditor/Private/EcsactSettings.h b/Source/EcsactEditor/Private/EcsactSettings.h index f2ff232..ae1268f 100644 --- a/Source/EcsactEditor/Private/EcsactSettings.h +++ b/Source/EcsactEditor/Private/EcsactSettings.h @@ -24,4 +24,6 @@ class UEcsactSettings : public UObject { UPROPERTY(EditAnywhere, Config, Category = Ecsact) TArray Recipes; + + auto GetValidRecipes() const -> TArray; };