actualitzada la carpeta release a SDL3
migrat a resources.pack
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
// resource_loader.hpp
|
||||
// Singleton resource loader for managing pack and filesystem access
|
||||
|
||||
#ifndef RESOURCE_LOADER_HPP
|
||||
#define RESOURCE_LOADER_HPP
|
||||
|
||||
#include "resource_pack.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace jdd {
|
||||
|
||||
// Singleton class for loading resources from pack or filesystem
|
||||
class ResourceLoader {
|
||||
public:
|
||||
// Get singleton instance
|
||||
static auto get() -> ResourceLoader&;
|
||||
|
||||
// Initialize with a pack file (optional)
|
||||
auto initialize(const std::string& pack_file, bool enable_fallback = true) -> bool;
|
||||
|
||||
// Load a resource (tries pack first, then filesystem if fallback enabled)
|
||||
auto loadResource(const std::string& filename) -> std::vector<uint8_t>;
|
||||
|
||||
// Check if a resource exists
|
||||
auto resourceExists(const std::string& filename) -> bool;
|
||||
|
||||
// Check if pack is loaded
|
||||
auto isPackLoaded() const -> bool;
|
||||
|
||||
// Get pack statistics
|
||||
auto getPackResourceCount() const -> size_t;
|
||||
|
||||
// Validate pack integrity (checksum)
|
||||
auto validatePack() const -> bool;
|
||||
|
||||
// Load assets.txt from pack (for release builds)
|
||||
auto loadAssetsConfig() const -> std::string;
|
||||
|
||||
// Cleanup
|
||||
void shutdown();
|
||||
|
||||
private:
|
||||
ResourceLoader() = default;
|
||||
~ResourceLoader() = default;
|
||||
|
||||
// Disable copy/move
|
||||
ResourceLoader(const ResourceLoader&) = delete;
|
||||
ResourceLoader& operator=(const ResourceLoader&) = delete;
|
||||
ResourceLoader(ResourceLoader&&) = delete;
|
||||
ResourceLoader& operator=(ResourceLoader&&) = delete;
|
||||
|
||||
// Load from filesystem
|
||||
static auto loadFromFilesystem(const std::string& filepath) -> std::vector<uint8_t>;
|
||||
|
||||
// Check if file exists on filesystem
|
||||
static auto fileExistsOnFilesystem(const std::string& filepath) -> bool;
|
||||
|
||||
// Member data
|
||||
std::unique_ptr<ResourcePack> resource_pack_;
|
||||
bool fallback_to_files_{true};
|
||||
bool initialized_{false};
|
||||
};
|
||||
|
||||
} // namespace jdd
|
||||
|
||||
#endif // RESOURCE_LOADER_HPP
|
||||
Reference in New Issue
Block a user