#include "Icons.h" #include #include #include static const std::unordered_map FILENAMES { {834, "resources/frigate_16.png"}, {324, "resources/frigate_16.png"}, {830, "resources/frigate_16.png"}, {25, "resources/frigate_16.png"}, {27, "resources/battleship_16.png"}, {540, "resources/battleCruiser_16.png"}, {1305, "resources/destroyer_16.png"}, {420, "resources/destroyer_16.png"}, {1534, "resources/destroyer_16.png"}, {541, "resources/destroyer_16.png"}, {29, "resources/capsule_16.png"}, {361, "resources/mobileWarpDisruptor.png"}, {963, "resources/cruiser_16.png"}, {894, "resources/cruiser_16.png"}, {26, "resources/cruiser_16.png"}, {832, "resources/cruiser_16.png"}, {906, "resources/cruiser_16.png"}, {358, "resources/cruiser_16.png"}, {237, "resources/rookie_16.png"}, {1404, "resources/engineeringComplexLarge.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 group) { const auto search = FILENAMES.find(group); 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; } }