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
|
#include "Icons.h"
#include <string>
#include <unordered_map>
#include <raylib.h>
static const std::unordered_map<long int, std::string> FILENAMES {
{11176, "resources/frigate_16.png"},
{11198, "resources/frigate_16.png"},
{11202, "resources/frigate_16.png"},
{11393, "resources/frigate_16.png"},
{11400, "resources/frigate_16.png"},
{11963, "resources/cruiser_16.png"},
{11965, "resources/cruiser_16.png"},
{11969, "resources/cruiser_16.png"},
{11971, "resources/cruiser_16.png"},
{11987, "resources/cruiser_16.png"},
{11989, "resources/cruiser_16.png"},
{11993, "resources/cruiser_16.png"},
{12017, "resources/cruiser_16.png"},
{12034, "resources/frigate_16.png"},
{17920, "resources/battleship_16.png"},
{19720, "resources/dreadnought_16.png"},
{19722, "resources/dreadnought_16.png"},
{2161, "resources/frigate_16.png"},
{22442, "resources/battleCruiser_16.png"},
{22456, "resources/destroyer_16.png"},
{22460, "resources/destroyer_16.png"},
{22464, "resources/destroyer_16.png"},
{32876, "resources/destroyer_16.png"},
{33468, "resources/frigate_16.png"},
{33474, "resources/mobileStorage.png"},
{33476, "resources/mobileCynosuralInhibitor.png"},
{34828, "resources/destroyer_16.png"},
{35683, "resources/destroyer_16.png"},
{37480, "resources/destroyer_16.png"},
{37482, "resources/destroyer_16.png"},
{37604, "resources/forceAuxiliary_16.png"},
{3766, "resources/frigate_16.png"},
{45534, "resources/cruiser_16.png"},
{583, "resources/frigate_16.png"},
{585, "resources/frigate_16.png"},
{606, "resources/rookie_16.png"},
{634, "resources/cruiser_16.png"},
{640, "resources/battleship_16.png"},
{644, "resources/battleship_16.png"},
{651, "resources/industrial_16.png"},
{670, "resources/frozenCorpse.png"},
{672, "resources/shuttle_16.png"},
};
Icons::Icons() :
m_cache {}
{
}
Icons::~Icons()
{
reset();
}
void
Icons::reset()
{
for (const auto& [_, texture] : m_cache)
UnloadTexture(texture);
m_cache.clear();
}
Texture2D
Icons::find(const long int type)
{
const auto existing = m_cache.find(type);
if (existing != m_cache.end()) {
return existing->second;
}
else {
Texture2D texture;
const auto filename = FILENAMES.find(type);
if (filename != FILENAMES.end())
texture = LoadTexture(filename->second.data());
else
texture = LoadTexture("resources/wreck.png");
m_cache[type] = texture;
return texture;
}
}
|