|
wPlot2D version: 0.1.1
A lightweight C++ library for clear and customizable 2D scientific plots.
|
Manages graphical assets such as fonts for reuse across the application. More...
#include <wAssetManager.hpp>
Public Member Functions | |
| AssetManager ()=default | |
| AssetManager (const AssetManager &)=delete | |
| AssetManager & | operator= (const AssetManager &)=delete |
| ~AssetManager ()=default | |
| void | LoadFont (const std::string &name, const std::string &fileName) |
| Loads a font from file and stores it under a given name. | |
| void | LoadFont (const std::string &name, const std::vector< std::string > &possiblePaths) |
| Loads a font by trying multiple possible file paths until success. | |
| sf::Font & | getFont (const std::string &name) |
| Retrieves a reference to a previously loaded font. | |
| void | RemoveFont (const std::string &name) |
| Removes a previously loaded font from memory. | |
| void | debugPrintFonts () const |
| Prints the list of loaded fonts to standard output. | |
Manages graphical assets such as fonts for reuse across the application.
This class provides a centralized way to load, access, and manage graphical assets, currently supporting fonts via SFML. Assets are identified by string keys and stored internally to avoid reloading them multiple times.
This manager is non-copyable to ensure centralized ownership and avoid accidental duplication of resources.
|
default |
|
delete |
|
default |
|
delete |
| void wEngine::AssetManager::LoadFont | ( | const std::string & | name, |
| const std::string & | fileName ) |
Loads a font from file and stores it under a given name.
If successful, the font is stored under the given name and can later be retrieved with getFont( name ). If loading fails, an exception is thrown.
| name | The unique name used to identify the font. |
| fileName | The path to the font file on disk. |
| std::runtime_error | if the font cannot be loaded from file. |
| void wEngine::AssetManager::LoadFont | ( | const std::string & | name, |
| const std::vector< std::string > & | possiblePaths ) |
Loads a font by trying multiple possible file paths until success.
This function attempts to load the specified font (name) by iterating through several possible paths provided in possiblePaths.
It silences SFML's internal error messages during the process to avoid clutter.
| name | Logical name of the font (used as key in the font map). |
| possiblePaths | List of file paths to try (in order of priority). |
| std::runtime_error | if all paths fail to load the font. |
| sf::Font & wEngine::AssetManager::getFont | ( | const std::string & | name | ) |
Retrieves a reference to a previously loaded font.
| name | The name of the font previously loaded. |
| std::runtime_error | if the font does not exist. |
| void wEngine::AssetManager::RemoveFont | ( | const std::string & | name | ) |
Removes a previously loaded font from memory.
| name | The name of the font to remove. |
| std::runtime_error | if the font does not exist. |
| void wEngine::AssetManager::debugPrintFonts | ( | ) | const |
Prints the list of loaded fonts to standard output.