35 [[nodiscard]] std::optional<std::reference_wrapper<
36 const std::vector<std::reference_wrapper<Texture>>>>
50 std::reference_wrapper<const std::vector<std::reference_wrapper<Texture>>>
52 size_t from,
size_t to);
61 const std::string& sprite)
const;
73 const std::string& resource_name,
const std::string& texture_name,
87 const std::string& file,
const std::string& name,
int rows,
int cols);
101 [[nodiscard]] std::optional<std::reference_wrapper<Font>>
try_get_font(
102 const std::string& font_name,
int font_size)
const;
112 const std::string& font_name,
const std::string& font_path,
116 static constexpr const char*
const resource_path =
"resources/sprites/";
118 std::vector<std::unique_ptr<Texture>> textures_;
119 std::map<std::string, std::vector<std::reference_wrapper<Texture>>>
121 std::map<std::string, std::unique_ptr<Font>> font_cache_;
Service responsible for managing game assets such as textures and spritesheets.
Definition assetService.h:20
AssetService & operator=(AssetService &&)=default
AssetService(const AssetService &)=delete
std::reference_wrapper< Texture > get_default_texture()
Retrieves the default white texture.
std::reference_wrapper< Font > register_font(const std::string &font_name, const std::string &font_path, int font_size)
Registers a font with the given name and size.
std::vector< std::reference_wrapper< Texture > > load_from_resource(const std::string &file, const std::string &name, int rows, int cols)
Loads textures from a resource file and splits them into a grid of sprites.
AssetService(AssetService &&)=default
std::optional< std::reference_wrapper< Texture > > try_get_texture(const std::string &sprite) const
Attempts to retrieve a texture by its sprite name.
std::reference_wrapper< Texture > register_texture(const std::string &resource_name, const std::string &texture_name, size_t index)
Registers a texture with a given resource name and texture name.
AssetService & operator=(const AssetService &)=delete
std::optional< std::reference_wrapper< const std::vector< std::reference_wrapper< Texture > > > > try_get_spritesheet(const std::string &key) const
Attempts to retrieve a spritesheet by its key.
std::optional< std::reference_wrapper< Font > > try_get_font(const std::string &font_name, int font_size) const
Attempts to retrieve a font by its name and size.
std::reference_wrapper< const std::vector< std::reference_wrapper< Texture > > > create_spritesheet_for(const std::string &source, const std::string &name, size_t from, size_t to)
Creates and registers a spritesheet from a stored resource.
Definition iEngineService.h:4