From dd1cd8c9647e5e16ae531c6da01ff9d261fdbe2a Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 27 May 2022 18:50:14 +0200 Subject: Icons are now resolved using groups --- DumpSource.cpp | 8 +++++++ Icons.cpp | 66 ++++++++++++++++++++-------------------------------------- Icons.h | 2 +- Killmail.h | 1 + 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 #include #include +#include #include #include @@ -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 group_lookup; + for (const auto& item : dump["types"]) { + const auto type_id = item["type_id"].get(); + 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); } diff --git a/Icons.cpp b/Icons.cpp index cb50740..a903e19 100644 --- a/Icons.cpp +++ b/Icons.cpp @@ -7,48 +7,26 @@ 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"}, + {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; diff --git a/Icons.h b/Icons.h index 3acc8cf..a6d4b89 100644 --- a/Icons.h +++ b/Icons.h @@ -12,7 +12,7 @@ public: Icons(); ~Icons(); void reset(); - Texture2D find(long int type); + Texture2D find(long int group); private: std::unordered_map m_cache; }; diff --git a/Killmail.h b/Killmail.h index 59e2c54..5dcdd02 100644 --- a/Killmail.h +++ b/Killmail.h @@ -10,6 +10,7 @@ struct Killmail { long int location; long int ship; + long int group; LongVector3 position; Owner owner; std::time_t time; diff --git a/View.cpp b/View.cpp index 3360808..dc36cce 100644 --- a/View.cpp +++ b/View.cpp @@ -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; -- cgit v1.1