unificats els resources en un namespace

This commit is contained in:
2025-11-11 10:04:57 +01:00
parent 1821b84e73
commit 54fc6d2902
35 changed files with 356 additions and 341 deletions
+9 -9
View File
@@ -10,7 +10,7 @@
#include "resource_loader.hpp"
namespace Jdd::ResourceHelper {
namespace Resource::Helper {
static bool resource_system_initialized = false;
@@ -26,7 +26,7 @@ auto initializeResourceSystem(const std::string& pack_file, bool enable_fallback
std::cout << "ResourceHelper: Fallback enabled: " << (enable_fallback ? "Yes" : "No")
<< '\n';
bool success = ResourceLoader::get().initialize(pack_file, enable_fallback);
bool success = Loader::get().initialize(pack_file, enable_fallback);
if (success) {
resource_system_initialized = true;
std::cout << "ResourceHelper: Initialization successful\n";
@@ -40,7 +40,7 @@ auto initializeResourceSystem(const std::string& pack_file, bool enable_fallback
// Shutdown the resource system
void shutdownResourceSystem() {
if (resource_system_initialized) {
ResourceLoader::get().shutdown();
Loader::get().shutdown();
resource_system_initialized = false;
std::cout << "ResourceHelper: Shutdown complete\n";
}
@@ -68,7 +68,7 @@ auto loadFile(const std::string& filepath) -> std::vector<uint8_t> {
std::string pack_path = getPackPath(filepath);
// Try to load from pack
auto data = ResourceLoader::get().loadResource(pack_path);
auto data = Loader::get().loadResource(pack_path);
if (!data.empty()) {
return data;
}
@@ -79,7 +79,7 @@ auto loadFile(const std::string& filepath) -> std::vector<uint8_t> {
}
// Load from filesystem
return ResourceLoader::get().loadResource(filepath);
return Loader::get().loadResource(filepath);
}
// Check if a file exists
@@ -91,7 +91,7 @@ auto fileExists(const std::string& filepath) -> bool {
// Check pack if appropriate
if (shouldUseResourcePack(filepath)) {
std::string pack_path = getPackPath(filepath);
if (ResourceLoader::get().resourceExists(pack_path)) {
if (Loader::get().resourceExists(pack_path)) {
return true;
}
}
@@ -150,7 +150,7 @@ auto shouldUseResourcePack(const std::string& filepath) -> bool {
std::ranges::replace(path, '\\', '/');
// Don't use pack for most config files (except config/assets.txt which is loaded
// directly via ResourceLoader::loadAssetsConfig() in release builds)
// directly via Loader::loadAssetsConfig() in release builds)
if (path.find("config/") != std::string::npos) {
return false;
}
@@ -177,7 +177,7 @@ auto isPackLoaded() -> bool {
if (!resource_system_initialized) {
return false;
}
return ResourceLoader::get().isPackLoaded();
return Loader::get().isPackLoaded();
}
} // namespace Jdd::ResourceHelper
} // namespace Resource::Helper