/
ofxAssets.cpp
72 lines (61 loc) · 1.46 KB
/
ofxAssets.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
//
// ofxAssets.cpp
//
#include "ofxAssets.h"
namespace ofxAssets {
//----------
Register & AssetRegister() {
return Register::X();
}
//----------
ofTrueTypeFont & font(const string & name, int size) {
return Register::X().getFont(name, size);
}
//----------
ofImage & image(const string & name) {
return Register::X().getImage(name);
}
//----------
ofShader & shader(const string & name) {
return Register::X().getShader(name);
}
#ifndef TARGET_NO_SOUND
//----------
ofSoundPlayer & sound(const string & name) {
return Register::X().getSound(name);
}
#endif
//----------
bool hasFont(const string & name) {
return Register::X().getFonts().has(name);
}
//----------
bool hasFont(const string & name, int size) {
const auto & fonts = Register::X().getFonts();
auto findFont = fonts.find(name);
if (findFont == fonts.end()) {
return false;
} else {
const auto & sizes = findFont->second->getSizes();
if(find(sizes.begin(), sizes.end(), size) != sizes.end()) {
return true;
} else {
return false;
}
}
}
//----------
bool hasImage(const string & name) {
return Register::X().getImages().has(name);
}
//----------
bool hasShader(const string & name) {
return Register::X().getShaders().has(name);
}
#ifndef TARGET_NO_SOUND
//----------
bool hasSound(const string & name) {
return Register::X().getSounds().has(name);
}
#endif
}