diff options
author | Aki <please@ignore.pl> | 2022-06-09 20:08:22 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-06-09 20:08:22 +0200 |
commit | e0de78eecfbc8898b028f191326e87f647d6aa5b (patch) | |
tree | 1041ba51f7a5638d5bc84bcdf5c48cd8f59443d1 /Icons.cpp | |
parent | b08f360cf92e76fabf5b762bf79032f60f751e30 (diff) | |
download | derelict-e0de78eecfbc8898b028f191326e87f647d6aa5b.zip derelict-e0de78eecfbc8898b028f191326e87f647d6aa5b.tar.gz derelict-e0de78eecfbc8898b028f191326e87f647d6aa5b.tar.bz2 |
Added group icons to wreck labels
Diffstat (limited to 'Icons.cpp')
-rw-r--r-- | Icons.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -2,6 +2,7 @@ #include <string> #include <unordered_map> +#include <utility> #include <raylib.h> @@ -31,7 +32,8 @@ static const std::unordered_map<long int, std::string> FILENAMES { Icons::Icons() : - m_cache {} + m_cache {}, + m_teams {} { } @@ -48,6 +50,25 @@ 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)); + } } @@ -68,3 +89,11 @@ Icons::find(const long int group) return texture; } } + + +Texture2D +Icons::team_icon(const int team) +{ + auto& render = m_teams.at(team); + return render.texture; +} |