diff options
author | Aki <please@ignore.pl> | 2022-05-27 18:50:14 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-05-27 18:50:14 +0200 |
commit | dd1cd8c9647e5e16ae531c6da01ff9d261fdbe2a (patch) | |
tree | fd11a3a46580cb7f28459e88edb4df32c9a7ed68 | |
parent | 2cd33c5d81088a5235554330e8f0c7f7302fa740 (diff) | |
download | derelict-dd1cd8c9647e5e16ae531c6da01ff9d261fdbe2a.zip derelict-dd1cd8c9647e5e16ae531c6da01ff9d261fdbe2a.tar.gz derelict-dd1cd8c9647e5e16ae531c6da01ff9d261fdbe2a.tar.bz2 |
Icons are now resolved using groups
-rw-r--r-- | DumpSource.cpp | 8 | ||||
-rw-r--r-- | Icons.cpp | 66 | ||||
-rw-r--r-- | Icons.h | 2 | ||||
-rw-r--r-- | Killmail.h | 1 | ||||
-rw-r--r-- | View.cpp | 2 |
5 files changed, 33 insertions, 46 deletions
diff --git a/DumpSource.cpp b/DumpSource.cpp index cfcd9f0..57f81db 100644 --- a/DumpSource.cpp +++ b/DumpSource.cpp @@ -3,6 +3,7 @@ #include <ctime> #include <sstream> #include <string> +#include <unordered_map> #include <vector> #include <nlohmann/json.hpp> @@ -29,7 +30,14 @@ DumpSource::DumpSource(const char* filename) : throw "File does not exist"; char* text = LoadFileText(filename); auto dump = json::parse(text); + std::unordered_map<long int, long int> group_lookup; + for (const auto& item : dump["types"]) { + const auto type_id = item["type_id"].get<long int>(); + item["group_id"].get_to(group_lookup[type_id]); + } dump.at("killmails").get_to(m_killmails); + for (auto& km : m_killmails) + km.group = group_lookup[km.ship]; UnloadFileText(text); } @@ -7,48 +7,26 @@ 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"}, + {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"}, }; @@ -74,9 +52,9 @@ Icons::reset() Texture2D -Icons::find(const long int type) +Icons::find(const long int group) { - const auto search = FILENAMES.find(type); + const auto search = FILENAMES.find(group); std::string filename = "resources/wreck.png"; if (search != FILENAMES.end()) filename = search->second; @@ -12,7 +12,7 @@ public: Icons(); ~Icons(); void reset(); - Texture2D find(long int type); + Texture2D find(long int group); private: std::unordered_map<std::string, Texture2D> m_cache; }; @@ -10,6 +10,7 @@ struct Killmail { long int location; long int ship; + long int group; LongVector3 position; Owner owner; std::time_t time; @@ -66,7 +66,7 @@ View::update(const float dt) const auto length = dist(pos, base); const bool hover = 8.0f > dist(mouse, pos); m_labels.push_back( - Label{pos, base, depth, length, hover, std::ref(wreck), app.icons.find(wreck.killmail.ship)}); + Label{pos, base, depth, length, hover, std::ref(wreck), app.icons.find(wreck.killmail.group)}); } std::sort(m_labels.begin(), m_labels.end(), [](auto& a, auto& b){ return a.depth > b.depth; }); m_active = nullptr; |