From 3151ac6274e796f54f2d9269186f1fd2e69f90c3 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 15 May 2024 12:11:00 -0400 Subject: Get checked paintings from server --- src/ap_state.cpp | 24 +++++++++++++++++++++++- src/ap_state.h | 5 ++++- src/subway_map.cpp | 24 ++++++++++++++---------- src/subway_map.h | 2 -- 4 files changed, 41 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ap_state.cpp b/src/ap_state.cpp index e5ff74d..68a6902 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp @@ -103,6 +103,7 @@ struct APState { } tracked_data_storage_keys.push_back("PlayerPos"); + tracked_data_storage_keys.push_back("Paintings"); initialized = true; } @@ -384,6 +385,14 @@ struct APState { } wxLogMessage("Data storage %s retrieved as null", key); + } else if (value.is_array()) { + if (key.ends_with("Paintings")) { + data_storage[key] = value.get>(); + } else { + data_storage[key] = value.get>(); + } + + wxLogMessage("Data storage %s retrieved as list", key); } } @@ -406,6 +415,15 @@ struct APState { return data_storage.count(key) && std::any_cast(data_storage.at(key)); } + const std::set& GetCheckedPaintings() { + std::string key = data_storage_prefix + "Paintings"; + if (!data_storage.count(key)) { + data_storage[key] = std::set(); + } + + return std::any_cast&>(data_storage.at(key)); + } + void RefreshTracker(bool reset) { wxLogMessage("Refreshing display..."); @@ -471,10 +489,14 @@ bool AP_IsColorShuffle() { return GetState().color_shuffle; } bool AP_IsPaintingShuffle() { return GetState().painting_shuffle; } -const std::map AP_GetPaintingMapping() { +const std::map& AP_GetPaintingMapping() { return GetState().painting_mapping; } +const std::set& AP_GetCheckedPaintings() { + return GetState().GetCheckedPaintings(); +} + int AP_GetMasteryRequirement() { return GetState().mastery_requirement; } int AP_GetLevel2Requirement() { return GetState().level_2_requirement; } diff --git a/src/ap_state.h b/src/ap_state.h index 6667e0d..5fbb720 100644 --- a/src/ap_state.h +++ b/src/ap_state.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -54,7 +55,9 @@ bool AP_IsColorShuffle(); bool AP_IsPaintingShuffle(); -const std::map AP_GetPaintingMapping(); +const std::map& AP_GetPaintingMapping(); + +const std::set& AP_GetCheckedPaintings(); int AP_GetMasteryRequirement(); diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 99638aa..460532c 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -82,17 +82,21 @@ void SubwayMap::OnConnect() { } void SubwayMap::UpdateIndicators() { - Redraw(); -} - -void SubwayMap::UpdatePainting(std::string from_painting_id, - std::optional to_painting_id) { - checked_paintings_.insert(from_painting_id); - - if (to_painting_id) { - networks_.AddLink(GD_GetSubwayItemForPainting(from_painting_id), - GD_GetSubwayItemForPainting(*to_painting_id)); + if (AP_IsPaintingShuffle()) { + for (const std::string &painting_id : AP_GetCheckedPaintings()) { + if (!checked_paintings_.count(painting_id)) { + checked_paintings_.insert(painting_id); + + if (AP_GetPaintingMapping().count(painting_id)) { + networks_.AddLink(GD_GetSubwayItemForPainting(painting_id), + GD_GetSubwayItemForPainting( + AP_GetPaintingMapping().at(painting_id))); + } + } + } } + + Redraw(); } void SubwayMap::UpdateSunwarp(SubwaySunwarp from_sunwarp, diff --git a/src/subway_map.h b/src/subway_map.h index 1637125..e5f0bf6 100644 --- a/src/subway_map.h +++ b/src/subway_map.h @@ -24,8 +24,6 @@ class SubwayMap : public wxPanel { void OnConnect(); void UpdateIndicators(); - void UpdatePainting(std::string from_painting_id, - std::optional to_painting_id); void UpdateSunwarp(SubwaySunwarp from_sunwarp, SubwaySunwarp to_sunwarp); private: -- cgit 1.4.1