R-Type
GameEngine
include
AssetManager.hpp
Go to the documentation of this file.
1
/*
2
** EPITECH PROJECT, 2023
3
** R-type
4
** File description:
5
** AssetManager
6
*/
7
8
#ifndef AssetManager_HPP_
9
#define AssetManager_HPP_
10
#include <unordered_map>
11
#include <iostream>
12
#include "
utils/SfmlTypes.hpp
"
13
14
namespace
GameEngine
15
{
17
class
AssetManager
18
{
19
public
:
21
AssetManager
() =
default
;
23
~AssetManager
() =
default
;
27
void
loadTexture
(
const
std::string &filename,
Recti
area)
28
{
29
if
(_texture.find(filename) == _texture.end()) {
30
_texture[filename] =
Texture
();
31
_texture[filename].load(filename, area);
32
}
33
}
34
35
void
loadFont
(
const
std::string &filename)
36
{
37
if
(_font.find(filename) == _font.end()) {
38
_font[filename] =
Font
();
39
_font[filename].load(filename);
40
}
41
}
42
46
const
Texture
&
getTexture
(
const
std::string &textureName)
const
{
return
_texture.at(textureName); }
47
48
const
Font
&
getFont
(
const
std::string &fontName)
const
{
return
_font.at(fontName); }
49
50
protected
:
51
private
:
52
std::unordered_map<std::string, Texture> _texture;
53
std::unordered_map<std::string, Font> _font;
54
};
55
}
// namespace GameEngine
56
57
#endif
/* !AssetManager_HPP_ */
SfmlTypes.hpp
GameEngine::AssetManager
Class to manage assets.
Definition:
AssetManager.hpp:18
GameEngine::AssetManager::loadFont
void loadFont(const std::string &filename)
Definition:
AssetManager.hpp:35
GameEngine::AssetManager::~AssetManager
~AssetManager()=default
Default destructor.
GameEngine::AssetManager::getTexture
const Texture & getTexture(const std::string &textureName) const
Get a texture previously loaded.
Definition:
AssetManager.hpp:46
GameEngine::AssetManager::getFont
const Font & getFont(const std::string &fontName) const
Definition:
AssetManager.hpp:48
GameEngine::AssetManager::AssetManager
AssetManager()=default
Default constructor.
GameEngine::AssetManager::loadTexture
void loadTexture(const std::string &filename, Recti area)
Load a texture from a file.
Definition:
AssetManager.hpp:27
GameEngine::Font
Class representing a font wrapper for sf::Font.
Definition:
SfmlTypes.hpp:293
GameEngine::Rect< int >
GameEngine::Texture
Class representing a texture wrapper for sf::Texture with an associated area.
Definition:
SfmlTypes.hpp:58
GameEngine
Definition:
AssetManager.hpp:15
Generated by
1.9.1