#include "Icons.h" #include #include #include static const std::unordered_map 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 search = FILENAMES.find(type); std::string filename = "resources/wreck.png"; if (search != FILENAMES.end()) filename = search->second; const auto existing = m_cache.find(filename); if (existing != m_cache.end()) { return existing->second; } else { auto texture = LoadTexture(filename.data()); m_cache[filename] = texture; return texture; } }