Moved spritesheet texture handling to anm2 instead of resources; added undoing for spritesheet texture changes; refactoring

This commit is contained in:
2025-08-27 00:28:41 -04:00
parent c9056ce707
commit 3546f27655
22 changed files with 376 additions and 391 deletions

View File

@@ -1,17 +1,5 @@
#include "resources.h"
void resources_texture_init(Resources* self, const std::string& path, s32 id)
{
Texture texture;
if (map_find(self->textures, id))
texture_free(&self->textures[id]);
texture_from_path_init(&texture, path);
self->textures[id] = texture;
}
void resources_init(Resources* self)
{
texture_from_encoded_data_init(&self->atlas, TEXTURE_ATLAS_SIZE, TEXTURE_CHANNELS, (u8*)TEXTURE_ATLAS, TEXTURE_ATLAS_LENGTH);
@@ -22,18 +10,8 @@ void resources_init(Resources* self)
void resources_free(Resources* self)
{
resources_textures_free(self);
for (auto& shader : self->shaders)
shader_free(&shader);
texture_free(&self->atlas);
}
void resources_textures_free(Resources* self)
{
for (auto& [id, texture] : self->textures)
texture_free(&self->textures[id]);
log_info(RESOURCES_TEXTURES_FREE_INFO);
}