Skip to content

Commit

Permalink
feat: recipes are now configurable (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Aug 7, 2024
1 parent b4b954a commit 3e5e2f6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
2 changes: 1 addition & 1 deletion Ecsact.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"LoadingPhase": "Default"
}
]
}
}
39 changes: 37 additions & 2 deletions Source/EcsactEditor/Private/EcsactEditor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "EcsactEditor.h"
#include "Async/Async.h"
#include "Async/TaskGraphInterfaces.h"
#include "Editor.h"
#include "ISettingsModule.h"
Expand Down Expand Up @@ -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<FString>{
"build",
"--format=json",
"--recipe=rt_entt",
"-o",
ecsact_runtime_path,
"--temp=" + temp_dir,
Expand All @@ -240,6 +261,10 @@ auto FEcsactEditorModule::RunBuild() -> void {
break;
}

for(const auto& recipe : recipes) {
args.Push("--recipe=" + recipe);
}

args.Append(ecsact_files);

SpawnEcsactCli(
Expand Down Expand Up @@ -378,6 +403,16 @@ auto FEcsactEditorModule::OnReceiveEcsactCliJsonMessage(FString Json) -> void {
}

auto FEcsactEditorModule::OnEcsactSettingsModified() -> bool {
const auto* settings = GetDefault<UEcsactSettings>();
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;
}

Expand Down
6 changes: 6 additions & 0 deletions Source/EcsactEditor/Private/EcsactSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

UEcsactSettings::UEcsactSettings() {
}

auto UEcsactSettings::GetValidRecipes() const -> TArray<FString> {
return Recipes.FilterByPredicate([](const FString& recipe) -> bool {
return !recipe.TrimStartAndEnd().IsEmpty();
});
}
2 changes: 2 additions & 0 deletions Source/EcsactEditor/Private/EcsactSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class UEcsactSettings : public UObject {

UPROPERTY(EditAnywhere, Config, Category = Ecsact)
TArray<FString> Recipes;

auto GetValidRecipes() const -> TArray<FString>;
};

0 comments on commit 3e5e2f6

Please sign in to comment.