46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "core/resources/resource_types.hpp"
|
|
|
|
namespace Resource {
|
|
|
|
// Cache mínim per a la fase 2: només surfaces i animacions, càrrega
|
|
// explícita per nom + path. Per ara la cerca és lineal sobre vector.
|
|
// Meyers singleton: la destrucció estàtica només toca smart pointers, no
|
|
// depén d'SDL ni de Screen, així que és segura sense ordenació explícita.
|
|
class Cache {
|
|
public:
|
|
static auto get() -> Cache&;
|
|
|
|
Cache(const Cache&) = delete;
|
|
Cache(Cache&&) = delete;
|
|
auto operator=(const Cache&) -> Cache& = delete;
|
|
auto operator=(Cache&&) -> Cache& = delete;
|
|
|
|
// Carrega una surface des de fitxer i la registra amb el nom donat.
|
|
void loadSurface(const std::string& name, const std::string& file_path);
|
|
// Llig el YAML d'animació en cru i el registra amb el nom donat.
|
|
void loadAnimation(const std::string& name, const std::string& file_path);
|
|
// Carrega una paleta (.pal JASC o .gif) i la registra amb el nom donat.
|
|
// Pensat per a paletes compartides (UI, fonts, tilesets reciclats).
|
|
void loadPalette(const std::string& name, const std::string& file_path);
|
|
|
|
auto getSurface(const std::string& name) -> std::shared_ptr<Surface>;
|
|
auto getAnimationData(const std::string& name) -> const AnimationResource&;
|
|
auto getPalette(const std::string& name) -> const Palette&;
|
|
|
|
private:
|
|
Cache() = default;
|
|
~Cache() = default;
|
|
|
|
std::vector<SurfaceResource> surfaces_;
|
|
std::vector<AnimationResource> animations_;
|
|
std::vector<PaletteResource> palettes_;
|
|
};
|
|
|
|
} // namespace Resource
|