#include "Icons.h" #include #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 {}, m_teams {} { } Icons::~Icons() { reset(); } void Icons::reset() { for (const auto& [_, texture] : m_cache) UnloadTexture(texture); m_cache.clear(); for (const auto& texture : m_teams) UnloadRenderTexture(texture); m_teams.clear(); } void Icons::draw_team_icons() { if (!m_teams.empty()) return; m_teams.reserve(2); for (const auto color : {Color{204, 8, 153, 255}, Color{20, 234, 106, 255}}) { auto texture = LoadRenderTexture(6, 6); BeginTextureMode(texture); DrawRectangle(0, 0, 6, 6, color); EndTextureMode(); m_teams.push_back(std::move(texture)); } } 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; } } Texture2D Icons::team_icon(const int team) { auto& render = m_teams.at(team); return render.texture; }