Class for loading and storing resources (textures, fonts, sound buffers, images and music)
More...
#include <ResourceManager.h>
Class for loading and storing resources (textures, fonts, sound buffers, images and music)
Definition at line 60 of file ResourceManager.h.
◆ Callback
template<typename... Args>
◆ Ptr
◆ ResourceManager()
◆ ~ResourceManager()
ime::ResourceManager::~ResourceManager |
( |
| ) |
|
|
default |
◆ getFont()
const sf::Font& ime::ResourceManager::getFont |
( |
const std::string & |
fileName | ) |
|
Get a font.
- Parameters
-
fileName | Filename of the font |
- Exceptions
-
- Returns
- Requested font
◆ getImage()
const sf::Image& ime::ResourceManager::getImage |
( |
const std::string & |
fileName | ) |
|
Get an image.
- Parameters
-
fileName | File name of the image |
- Exceptions
-
- Returns
- The requested image
◆ getInstance()
Get class instance.
- Returns
- Shared pointer to class instance
◆ getMusic()
std::shared_ptr<sf::Music> ime::ResourceManager::getMusic |
( |
const std::string & |
fileName | ) |
|
Get music.
- Parameters
-
fileName | Filename of the music |
- Exceptions
-
- Returns
- Pointer to the requested music
◆ getPathFor()
std::string ime::ResourceManager::getPathFor |
( |
ResourceType |
type | ) |
const |
Get the path where resources are located on the disk.
- Parameters
-
type | Type of the resource to get path for |
- Returns
- The path where resources are located on the disk for the specified resource type
◆ getSoundBuffer()
const sf::SoundBuffer& ime::ResourceManager::getSoundBuffer |
( |
const std::string & |
fileName | ) |
|
Get a sound buffer.
- Parameters
-
fileName | File name of the sound buffer |
- Exceptions
-
- Returns
- The requested sound buffer
◆ getTexture()
const Texture& ime::ResourceManager::getTexture |
( |
const std::string & |
fileName | ) |
|
Get a texture.
- Parameters
-
fileName | Filename of the texture |
- Exceptions
-
- Returns
- The requested texture
◆ loadFromFile() [1/2]
void ime::ResourceManager::loadFromFile |
( |
ResourceType |
type, |
|
|
const std::initializer_list< std::string > & |
filenames, |
|
|
Callback< const std::string & > |
callback = nullptr |
|
) |
| |
load multiple resources of the same type from the disk
- Parameters
-
type | Type of the resources to be loaded |
filenames | Filenames of the resources to be loaded |
callback | Function to execute after successful load of each resource |
- Exceptions
-
The callback is passed the name of the resource that was loaded
◆ loadFromFile() [2/2]
bool ime::ResourceManager::loadFromFile |
( |
ResourceType |
type, |
|
|
const std::string & |
filename |
|
) |
| |
Load a resource from the disk.
- Parameters
-
type | Type of the resource to be loaded |
filename | Filename of the resource to be loaded |
- Exceptions
-
- Returns
- Returns true when the resource was loaded successfully
This function will cache any resource that is successfully loaded from the disk into the program such that is is not reloaded the next time it is required
◆ operator=()
◆ setPathFor()
void ime::ResourceManager::setPathFor |
( |
ResourceType |
type, |
|
|
const std::string & |
path |
|
) |
| |
Set the path where resources are located on the disk.
- Parameters
-
type | Type of the resource to set path for |
path | New path to resources on th disk |
The class will look for resources of the specified type in the new path when loading them
◆ unload()
bool ime::ResourceManager::unload |
( |
ResourceType |
type, |
|
|
const std::string & |
filename |
|
) |
| |
Unload a resource from the resource manager.
- Parameters
-
type | Type of the resource to unload |
filename | Filename of the resource to remove |
- Returns
- True if the resource was unloaded or false if the specified resource does not exist
The documentation for this class was generated from the following file: