This commit is contained in:
2025-10-19 22:01:31 +02:00
parent 16306f2325
commit 2b4523d644
101 changed files with 2058 additions and 1564 deletions

View File

@@ -1,33 +1,31 @@
#pragma once
#include <filesystem>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include "resource_loader.hpp"
#include <cstdint> // Para uint8_t
#include <filesystem> // Para remove, path
#include <fstream> // Para basic_ofstream, basic_ios, basic_ostream::write, ios, ofstream
#include <string> // Para string, basic_string, hash, operator+, to_string, __str_hash_base
#include <vector> // Para vector
// Helper functions para integrar ResourceLoader con el sistema existente
namespace ResourceHelper {
// Inicializa ResourceLoader (llamar al inicio del programa)
bool initializeResourceSystem(const std::string& pack_file = "resources.pack");
auto initializeResourceSystem(const std::string& pack_file = "resources.pack") -> bool;
// Cierra ResourceLoader
void shutdownResourceSystem();
// Carga un archivo usando ResourceLoader o fallback a filesystem
std::vector<uint8_t> loadFile(const std::string& filepath);
auto loadFile(const std::string& filepath) -> std::vector<uint8_t>;
// Verifica si un archivo debería cargarse del pack vs filesystem
bool shouldUseResourcePack(const std::string& filepath);
auto shouldUseResourcePack(const std::string& filepath) -> bool;
// Convierte ruta Asset a ruta relativa para ResourceLoader
std::string getPackPath(const std::string& asset_path);
auto getPackPath(const std::string& asset_path) -> std::string;
// Wrappea la carga de archivos para mantener compatibilidad
template <typename T>
T* loadResourceFile(const std::string& asset_path, T* (*loader_func)(const char*)) {
auto loadResourceFile(const std::string& asset_path, T* (*loader_func)(const char*)) -> T* {
auto data = loadFile(asset_path);
if (data.empty()) {
return loader_func(asset_path.c_str());