|
| template<typename E, typename V, typename... Args> |
| static void | set (E key, V &&value, Args &&... args) |
| | Register multiple key-value pairs in one call.
|
| template<typename EnumType> |
| static void | set (EnumType key, const char *filepath) |
| | Register an asset file path.
|
| template<typename EnumType> |
| static void | set (EnumType key, std::string value) |
| | Register a string configuration value.
|
| template<typename EnumType, typename ValueType> |
| static std::enable_if_t< !std::is_same_v< std::decay_t< ValueType >, const char * > &&!std::is_same_v< std::decay_t< ValueType >, std::string > > | set (EnumType key, ValueType &&value) |
| | Register a typed configuration value (int, float, bool, etc.).
|
Base class for all Malena manifests.
A manifest is a static registry that maps enum keys to file paths or configuration values. Subclasses declare inner enum types (Images, Fonts, Sounds, Text, Ints, etc.) and populate them using the protected set() methods, typically in an inline static initializer.
The manifest is the contract between a class and its resources. By declaring what a class needs in its manifest, the framework's template machinery (AssetsManager, ConfigManager, ResourceManager) can load and cache those resources automatically without any manual loading code in the class body.
Manifest structure
{
public:
static constexpr const char* name = "My Plugin";
static constexpr const char* version = "1.0.0";
enum class Images { Background,
Button };
enum class Fonts { Main };
enum class Sounds { Click };
enum class Text { WelcomeMessage };
enum class Ints { MaxPlayers };
enum class Flag { Selected };
enum class State { Idle, Active };
private:
inline static const auto _ = [](){
set(Images::Background,
"assets/bg.png");
set(Images::Button,
"assets/btn.png");
set(Fonts::Main,
"assets/main.ttf");
set(Sounds::Click,
"assets/click.wav");
set(Text::WelcomeMessage, std::string(
"Hello!"));
set(Ints::MaxPlayers, 4);
return 0;
}();
};
Base class for all Malena manifests.
static void set(EnumType key, const char *filepath)
Register an asset file path.
Flag
System-level boolean flags available on every ml::Core object.
Accessing registered values
static const ValueType & getConfig(ConfigType config)
Retrieve a typed configuration value by enum key.
static const sf::Texture & get(const Asset &asset)
Or more conveniently through AssetsManager or Context:
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.
- See also
- AssetsManager, Context, Resources, ResourceManager, ConfigManager
Definition at line 80 of file Manifest.h.
template<typename EnumType, typename ValueType>
| std::enable_if_t< !std::is_same_v< std::decay_t< ValueType >, const char * > &&!std::is_same_v< std::decay_t< ValueType >, std::string > > ml::Manifest::set |
( |
EnumType | key, |
|
|
ValueType && | value ) |
|
staticprotected |
Register a typed configuration value (int, float, bool, etc.).
Enabled for any ValueType that is not const char* or std::string, routing numeric and boolean config values into their own type-indexed storage.
- Template Parameters
-
| EnumType | Enum type of the key (inferred). |
| ValueType | Type of the configuration value (inferred). |
- Parameters
-
| key | The enum value to register. |
| value | The configuration value. |