-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResourceManager.cpp
112 lines (99 loc) · 2.54 KB
/
ResourceManager.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* Definition of ResourceManager as declared in ResourceManager.h
*
* Author: Skylar Payne
* Date: 7/30/2013
* File: ResourceManager.cpp
**/
#include "ResourceManager.h"
FontCache ResourceAccessor::_FontCache;
SoundCache ResourceAccessor::_SoundCache;
TextureCache ResourceAccessor::_TextureCache;
/**
* @brief ResourceManager::~ResourceManager RAII
*/
ResourceManager::~ResourceManager()
{
Unload();
}
/**
* @brief ResourceManager::AddFont adds a font into the FontCache
* @param file the font to add
* @return true if successful, false otherwise
*/
bool ResourceManager::AddFont(const char *file)
{
return ResourceAccessor::_FontCache.Add(file);
}
/**
* @brief ResourceManager::RemoveFont removes a font from the FontCache
* @param file the font to remove
*/
void ResourceManager::RemoveFont(const char *file)
{
ResourceAccessor::_FontCache.Remove(file);
}
/**
* @brief ResourceManager::UnloadFonts unloads all fonts from the FontCache
*/
void ResourceManager::UnloadFonts()
{
ResourceAccessor::_FontCache.Unload();
}
/**
* @brief ResourceManager::AddSound adds a sound into the SoundCache
* @param file the sound to add
* @return true if successful, false otherwise
*/
bool ResourceManager::AddSound(const char *file)
{
return ResourceAccessor::_SoundCache.Add(file);
}
/**
* @brief ResourceManager::RemoveSound removes a sound from the SoundCache
* @param file the sound to remove
*/
void ResourceManager::RemoveSound(const char *file)
{
ResourceAccessor::_SoundCache.Remove(file);
}
/**
* @brief ResourceManager::UnloadSounds unloads all sounds from the SoundCache
*/
void ResourceManager::UnloadSounds()
{
ResourceAccessor::_SoundCache.Unload();
}
/**
* @brief ResourceManager::AddTexture adds a texture into the TextureCache
* @param file the texture to add
* @return true if successful, false otherwise
*/
bool ResourceManager::AddTexture(const char *file)
{
return ResourceAccessor::_TextureCache.Add(file);
}
/**
* @brief ResourceManager::RemoveTexture removes a texture from the TextureCache
* @param file the texture to remove
*/
void ResourceManager::RemoveTexture(const char *file)
{
ResourceAccessor::_TextureCache.Remove(file);
}
/**
* @brief ResourceManager::UnloadTextures unloads all textures from the TextureCache
*/
void ResourceManager::UnloadTextures()
{
ResourceAccessor::_TextureCache.Unload();
}
/**
* @brief ResourceManager::Unload unloads all resources
*/
void ResourceManager::Unload()
{
this->UnloadFonts();
this->UnloadSounds();
this->UnloadTextures();
}