Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: recipes are now configurable #6

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
};