-
Notifications
You must be signed in to change notification settings - Fork 1
/
AssetManager.cpp
67 lines (54 loc) · 1.33 KB
/
AssetManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "AssetManager.h"
AssetManager::AssetManager()
{
}
AssetManager::~AssetManager()
{
m_sounds.clear();
}
void AssetManager::LoadTexture(std::string p_textureName, std::string p_fileName)
{
sf::Texture texture;
if (texture.loadFromFile(p_fileName))
{
this->m_textures[p_textureName] = texture;
}
}
sf::Texture& AssetManager::GetTexture(std::string name)
{
return this->m_textures.at(name);
}
void AssetManager::SetRect(std::string p_rectName, int p_left, int p_top, int p_width, int p_height)
{
sf::IntRect rect;
rect.left = p_left;
rect.top = p_top;
rect.width = p_width;
rect.height = p_height;
this->m_rects[p_rectName] = rect;
}
sf::IntRect AssetManager::GetRect(std::string p_rectName)
{
return this->m_rects.at(p_rectName);
}
void AssetManager::LoadSound(std::string p_soundName, std::string p_fileName)
{
auto& buff = m_sounds[p_soundName];
buff.loadFromFile(p_fileName);
}
const sf::SoundBuffer& AssetManager::GetSound(std::string p_soundName)
{
return this->m_sounds.at(p_soundName);
}
void AssetManager::LoadFont(std::string p_fontName, std::string p_fileName)
{
sf::Font font;
if (font.loadFromFile(p_fileName))
{
this->m_fonts[p_fontName] = font;
}
}
sf::Font& AssetManager::GetFont(std::string name)
{
return this->m_fonts.at(name);
}