From afb264467c9ba43cd8adf0a7cd5bdec2753b911f Mon Sep 17 00:00:00 2001 From: SirLynix Date: Thu, 21 Dec 2023 00:20:23 +0100 Subject: [PATCH] Client: Add an error popup if assets folder does not exist --- src/Game/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Game/main.cpp b/src/Game/main.cpp index f6cd81ff..a4a18f3c 100644 --- a/src/Game/main.cpp +++ b/src/Game/main.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -27,7 +28,22 @@ int GameMain(int argc, char* argv[]) Nz::Application app(argc, argv); auto& filesystem = app.AddComponent(); - filesystem.Mount("assets", Nz::Utf8Path("assets")); + + std::filesystem::path assetPath = Nz::Utf8Path("assets"); + if (!std::filesystem::exists(assetPath)) + { + fmt::print(fg(fmt::color::red), "assets are missing!\n"); + + Nz::MessageBox errorBox(Nz::MessageBoxType::Error, "Missing assets folder", "The assets folder was not found, it should be located next to the executable."); + errorBox.AddButton(0, Nz::MessageBoxStandardButton::Close); + if (auto result = errorBox.Show(); !result) + fmt::print(fg(fmt::color::red), "failed to open the error message box: {0}!\n", result.GetError()); + + return EXIT_FAILURE; + } + + filesystem.Mount("assets", assetPath); + // Register a new SkyboxMaterial shader Nz::Graphics::Instance()->GetShaderModuleResolver()->RegisterModuleDirectory(Nz::Utf8Path("assets/shaders"), true);