9f0dfc4e24
afegida gestió de ratolí
43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
// audio_cache.hpp - Caché simplificado de sonidos y música
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
#include "core/audio/jail_audio.hpp"
|
|
|
|
// Caché estático de sonidos y música
|
|
// Patrón inspirado en Graphics::ShapeLoader
|
|
class AudioCache {
|
|
public:
|
|
// No instanciable (todo estático)
|
|
AudioCache() = delete;
|
|
|
|
// Obtener sonido (carga bajo demanda)
|
|
// Retorna puntero (nullptr si error)
|
|
static JA_Sound_t* getSound(const std::string& name);
|
|
|
|
// Obtener música (carga bajo demanda)
|
|
// Retorna puntero (nullptr si error)
|
|
static JA_Music_t* getMusic(const std::string& name);
|
|
|
|
// Limpiar caché (útil para debug/recarga)
|
|
static void clear();
|
|
|
|
// Estadísticas (debug)
|
|
static size_t getSoundCacheSize();
|
|
static size_t getMusicCacheSize();
|
|
|
|
private:
|
|
static std::unordered_map<std::string, JA_Sound_t*> sounds_;
|
|
static std::unordered_map<std::string, JA_Music_t*> musics_;
|
|
static std::string sounds_base_path_; // "data/sounds/"
|
|
static std::string music_base_path_; // "data/music/"
|
|
|
|
// Helpers privados
|
|
static std::string resolveSoundPath(const std::string& name);
|
|
static std::string resolveMusicPath(const std::string& name);
|
|
};
|