Skip to content

Commit

Permalink
Client: Add an error popup if assets folder does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
SirLynix committed Dec 20, 2023
1 parent 8a237f6 commit afb2644
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Game/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <Game/States/GameState.hpp>
#include <Game/States/MenuState.hpp>
#include <Game/States/StateData.hpp>
#include <fmt/color.h>
#include <fmt/format.h>
#include <fmt/ostream.h>

Expand All @@ -27,7 +28,22 @@ int GameMain(int argc, char* argv[])
Nz::Application<Nz::Graphics, Nz::JoltPhysics3D, Nz::Network, Nz::Widgets> app(argc, argv);

auto& filesystem = app.AddComponent<Nz::AppFilesystemComponent>();
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);
Expand Down

0 comments on commit afb2644

Please sign in to comment.