|
| template<typename M = Manifest> |
| static std::enable_if_t< has_Font< M >::value, const sf::Font & > | get (typename M::Fonts font) |
| | Retrieve a cached sf::Font by manifest enum value.
|
| template<typename M = Manifest> |
| static std::enable_if_t< has_Image< M >::value, const sf::Texture & > | get (typename M::Images image) |
| | Retrieve a cached sf::Texture by manifest enum value.
|
| template<typename M = Manifest> |
| static std::enable_if_t< has_Sound< M >::value, const sf::SoundBuffer & > | get (typename M::Sounds sound) |
| | Retrieve a cached sf::SoundBuffer by manifest enum value.
|
| template<typename M = Manifest> |
| static std::enable_if_t< has_Font< M >::value, const sf::Font & > | getDefaultFont () |
| | Return the built-in Arial font.
|
template<typename
Manifest>
class ml::AssetsManager< Manifest >
Unified asset accessor for textures, fonts, and sound buffers.
AssetsManager<Manifest> combines TextureManager, FontManager, and SoundManager into a single class with overloaded get() methods. Each overload is enabled only when the manifest declares the corresponding enum (Images, Fonts, or Sounds), so attempting to retrieve an asset type the manifest does not declare is a compile error rather than a runtime failure.
When to use AssetsManager vs individual managers
Usage
public:
enum class Images { Background, Player };
enum class Fonts { Main };
enum class Sounds { Jump };
private:
inline static const auto _ = [](){
set(Images::Background,
"assets/bg.png");
set(Images::Player,
"assets/player.png");
set(Fonts::Main,
"assets/main.ttf");
set(Sounds::Jump,
"assets/jump.wav");
return 0;
}();
};
static std::enable_if_t< has_Image< M >::value, const sf::Texture & > get(typename M::Images image)
Retrieve a cached sf::Texture by manifest enum value.
static std::enable_if_t< has_Font< M >::value, const sf::Font & > getDefaultFont()
Return the built-in Arial font.
Base class for all Malena manifests.
static void set(EnumType key, const char *filepath)
Register an asset file path.
- Template Parameters
-
- See also
- TextureManager, FontManager, SoundManager, Context, Manifest
AssetsManager.
Definition at line 92 of file AssetsManager.h.