-
Notifications
You must be signed in to change notification settings - Fork 2
/
resources.cpp
67 lines (59 loc) · 1.9 KB
/
resources.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
// Handles embedded data.
#include "resources.hpp"
#include "util.hpp"
#define INCBIN_PREFIX _
#include "incbin.h"
#include <filesystem>
#include <string_view>
extern "C" {
INCBIN(Toon01, "toons/toon01.bmp");
INCBIN(Toon02, "toons/toon02.bmp");
INCBIN(Toon03, "toons/toon03.bmp");
INCBIN(Toon04, "toons/toon04.bmp");
INCBIN(Toon05, "toons/toon05.bmp");
INCBIN(Toon06, "toons/toon06.bmp");
INCBIN(Toon07, "toons/toon07.bmp");
INCBIN(Toon08, "toons/toon08.bmp");
INCBIN(Toon09, "toons/toon09.bmp");
INCBIN(Toon10, "toons/toon10.bmp");
INCBIN(StatusIcon, "icons/statusicon.png");
}
namespace Resource {
namespace fs = std::filesystem;
const unsigned char *View::data() const {
return first;
}
std::size_t View::length() const {
return second;
}
View getToonData(std::string_view path) {
const std::string basename = fs::path(String::tou8(path)).filename().string();
if (basename == "toon01.bmp") {
return {_Toon01Data, _Toon01Size};
} else if (basename == "toon02.bmp") {
return {_Toon02Data, _Toon02Size};
} else if (basename == "toon03.bmp") {
return {_Toon03Data, _Toon03Size};
} else if (basename == "toon04.bmp") {
return {_Toon04Data, _Toon04Size};
} else if (basename == "toon05.bmp") {
return {_Toon05Data, _Toon05Size};
} else if (basename == "toon06.bmp") {
return {_Toon06Data, _Toon06Size};
} else if (basename == "toon07.bmp") {
return {_Toon07Data, _Toon07Size};
} else if (basename == "toon08.bmp") {
return {_Toon08Data, _Toon08Size};
} else if (basename == "toon09.bmp") {
return {_Toon09Data, _Toon09Size};
} else if (basename == "toon10.bmp") {
return {_Toon10Data, _Toon10Size};
} else {
Err::Log("Internal error: Unknown toon image:", path);
return {nullptr, 0};
}
}
View getStatusIconData() {
return {_StatusIconData, _StatusIconSize};
}
} // namespace Resource