Fix spritesheet generator

This commit is contained in:
Charles Dang 2024-08-08 16:35:25 -04:00
parent c9ed3711b4
commit 367c6c8aa3

View File

@ -41,10 +41,10 @@ namespace
struct sheet_element struct sheet_element
{ {
explicit sheet_element(const std::filesystem::path& p) explicit sheet_element(const std::filesystem::path& p)
: surf{IMG_Load_RW(filesystem::make_read_RWops(p.string()).release(), true)} : surf(IMG_Load_RW(filesystem::make_read_RWops(p.string()).release(), true))
, filename{p.filename().string()} , filename(p.filename().string())
, src{get_non_transparent_portion(surf)} , src(get_non_transparent_portion(surf))
, dst{} , dst()
{ {
} }
@ -202,17 +202,21 @@ void handle_dir_contents(const std::filesystem::path& path)
} }
} // end anon namespace } // end anon namespace
#define DEBUG_SPRITESHEET_OUTPUT
void build_spritesheet_from(const std::string& entry_point) void build_spritesheet_from(const std::string& entry_point)
{ {
#ifdef DEBUG_SPRITESHEET_OUTPUT #ifdef DEBUG_SPRITESHEET_OUTPUT
const std::size_t start = SDL_GetTicks(); const std::size_t start = SDL_GetTicks();
#endif #endif
try { if(auto path = filesystem::get_binary_file_location("images", entry_point)) {
handle_dir_contents(filesystem::get_binary_file_location("images", entry_point)); try {
} catch(const std::filesystem::filesystem_error& e) { handle_dir_contents(*path);
PLAIN_LOG << "Error generating spritesheet: " << e.what(); } catch(const std::filesystem::filesystem_error& e) {
PLAIN_LOG << "Filesystem Error generating spritesheet: " << e.what();
}
} else {
PLAIN_LOG << "Cannot find entry point to build spritesheet: " << entry_point;
} }
#ifdef DEBUG_SPRITESHEET_OUTPUT #ifdef DEBUG_SPRITESHEET_OUTPUT