arreglos d'estil en source/core/resources

This commit is contained in:
2025-11-18 12:41:30 +01:00
parent 4477cc4bbc
commit b7db34cdf7
9 changed files with 135 additions and 295 deletions
+12 -33
View File
@@ -1,8 +1,7 @@
// resource_loader.hpp
// Singleton resource loader for managing pack and filesystem access
#ifndef RESOURCE_LOADER_HPP
#define RESOURCE_LOADER_HPP
#pragma once
#include <memory>
#include <string>
@@ -15,35 +14,21 @@ namespace Resource {
// Singleton class for loading resources from pack or filesystem
class Loader {
public:
// Get singleton instance
static auto get() -> Loader&;
static auto get() -> Loader&; // Singleton instance access
// Initialize with a pack file (optional)
auto initialize(const std::string& pack_file, bool enable_fallback = true) -> bool;
auto initialize(const std::string& pack_file, bool enable_fallback = true) -> bool; // Initialize loader with pack file
// Load a resource (tries pack first, then filesystem if fallback enabled)
auto loadResource(const std::string& filename) -> std::vector<uint8_t>;
auto loadResource(const std::string& filename) -> std::vector<uint8_t>; // Load resource data
auto resourceExists(const std::string& filename) -> bool; // Check resource availability
// Check if a resource exists
auto resourceExists(const std::string& filename) -> bool;
// Check if pack is loaded
[[nodiscard]] auto isPackLoaded() const -> bool;
// Get pack statistics
[[nodiscard]] auto isPackLoaded() const -> bool; // Pack status queries
[[nodiscard]] auto getPackResourceCount() const -> size_t;
[[nodiscard]] auto validatePack() const -> bool; // Validate pack integrity
[[nodiscard]] auto loadAssetsConfig() const -> std::string; // Load assets.yaml from pack
// Validate pack integrity (checksum)
[[nodiscard]] auto validatePack() const -> bool;
void shutdown(); // Cleanup
// Load assets.yaml from pack (for release builds)
[[nodiscard]] auto loadAssetsConfig() const -> std::string;
// Cleanup
void shutdown();
// Disable copy/move
Loader(const Loader&) = delete;
Loader(const Loader&) = delete; // Deleted copy/move constructors
auto operator=(const Loader&) -> Loader& = delete;
Loader(Loader&&) = delete;
auto operator=(Loader&&) -> Loader& = delete;
@@ -52,18 +37,12 @@ class Loader {
Loader() = default;
~Loader() = default;
// Load from filesystem
static auto loadFromFilesystem(const std::string& filepath) -> std::vector<uint8_t>;
// Check if file exists on filesystem
static auto loadFromFilesystem(const std::string& filepath) -> std::vector<uint8_t>; // Filesystem helpers
static auto fileExistsOnFilesystem(const std::string& filepath) -> bool;
// Member data
std::unique_ptr<Pack> resource_pack_;
std::unique_ptr<Pack> resource_pack_; // Member variables
bool fallback_to_files_{true};
bool initialized_{false};
};
} // namespace Resource
#endif // RESOURCE_LOADER_HPP