diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-21 13:00:13 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-21 13:00:13 -0400 |
commit | 829bffa5912f1b6da4ebba580450cfba6d320295 (patch) | |
tree | d94d09b219661913198eca72510a31f07eb09c13 /src | |
parent | 900355a291cd2c2452e909407a57d3e81d7ad85e (diff) | |
download | lingo-ap-tracker-829bffa5912f1b6da4ebba580450cfba6d320295.tar.gz lingo-ap-tracker-829bffa5912f1b6da4ebba580450cfba6d320295.tar.bz2 lingo-ap-tracker-829bffa5912f1b6da4ebba580450cfba6d320295.zip |
Use sync panels for achievement state
Diffstat (limited to 'src')
-rw-r--r-- | src/achievements_pane.cpp | 13 | ||||
-rw-r--r-- | src/achievements_pane.h | 6 | ||||
-rw-r--r-- | src/ap_state.cpp | 20 | ||||
-rw-r--r-- | src/ap_state.h | 2 | ||||
-rw-r--r-- | src/tracker_frame.cpp | 6 | ||||
-rw-r--r-- | src/tracker_frame.h | 1 |
6 files changed, 17 insertions, 31 deletions
diff --git a/src/achievements_pane.cpp b/src/achievements_pane.cpp index b255f3b..d23c434 100644 --- a/src/achievements_pane.cpp +++ b/src/achievements_pane.cpp | |||
@@ -8,13 +8,14 @@ AchievementsPane::AchievementsPane(wxWindow* parent) | |||
8 | AppendColumn("Achievement"); | 8 | AppendColumn("Achievement"); |
9 | 9 | ||
10 | for (int panel_id : GD_GetAchievementPanels()) { | 10 | for (int panel_id : GD_GetAchievementPanels()) { |
11 | achievement_names_.push_back(GD_GetPanel(panel_id).achievement_name); | 11 | const Panel& panel = GD_GetPanel(panel_id); |
12 | achievements_.emplace_back(panel.achievement_name, panel.solve_index); | ||
12 | } | 13 | } |
13 | 14 | ||
14 | std::sort(std::begin(achievement_names_), std::end(achievement_names_)); | 15 | std::sort(std::begin(achievements_), std::end(achievements_)); |
15 | 16 | ||
16 | for (int i = 0; i < achievement_names_.size(); i++) { | 17 | for (int i = 0; i < achievements_.size(); i++) { |
17 | InsertItem(i, achievement_names_.at(i)); | 18 | InsertItem(i, std::get<0>(achievements_.at(i))); |
18 | } | 19 | } |
19 | 20 | ||
20 | SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); | 21 | SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); |
@@ -23,8 +24,8 @@ AchievementsPane::AchievementsPane(wxWindow* parent) | |||
23 | } | 24 | } |
24 | 25 | ||
25 | void AchievementsPane::UpdateIndicators() { | 26 | void AchievementsPane::UpdateIndicators() { |
26 | for (int i = 0; i < achievement_names_.size(); i++) { | 27 | for (int i = 0; i < achievements_.size(); i++) { |
27 | if (AP_HasAchievement(achievement_names_.at(i))) { | 28 | if (AP_IsPanelSolved(std::get<1>(achievements_.at(i)))) { |
28 | SetItemTextColour(i, *wxBLACK); | 29 | SetItemTextColour(i, *wxBLACK); |
29 | } else { | 30 | } else { |
30 | SetItemTextColour(i, *wxRED); | 31 | SetItemTextColour(i, *wxRED); |
diff --git a/src/achievements_pane.h b/src/achievements_pane.h index ac88cac..941b5e3 100644 --- a/src/achievements_pane.h +++ b/src/achievements_pane.h | |||
@@ -9,6 +9,10 @@ | |||
9 | 9 | ||
10 | #include <wx/listctrl.h> | 10 | #include <wx/listctrl.h> |
11 | 11 | ||
12 | #include <string> | ||
13 | #include <tuple> | ||
14 | #include <vector> | ||
15 | |||
12 | class AchievementsPane : public wxListView { | 16 | class AchievementsPane : public wxListView { |
13 | public: | 17 | public: |
14 | explicit AchievementsPane(wxWindow* parent); | 18 | explicit AchievementsPane(wxWindow* parent); |
@@ -16,7 +20,7 @@ class AchievementsPane : public wxListView { | |||
16 | void UpdateIndicators(); | 20 | void UpdateIndicators(); |
17 | 21 | ||
18 | private: | 22 | private: |
19 | std::vector<std::string> achievement_names_; | 23 | std::vector<std::tuple<std::string, int>> achievements_; // name, solve index |
20 | }; | 24 | }; |
21 | 25 | ||
22 | #endif /* end of include guard: ACHIEVEMENTS_PANE_H_C320D0B8 */ \ No newline at end of file | 26 | #endif /* end of include guard: ACHIEVEMENTS_PANE_H_C320D0B8 */ \ No newline at end of file |
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index c1147f6..a969892 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
@@ -232,14 +232,6 @@ struct APState { | |||
232 | return HasItem(item_id, quantity); | 232 | return HasItem(item_id, quantity); |
233 | } | 233 | } |
234 | 234 | ||
235 | bool HasAchievement(const std::string& name) { | ||
236 | std::lock_guard state_guard(state_mutex); | ||
237 | |||
238 | std::string key = | ||
239 | fmt::format("{}Achievement|{}", data_storage_prefix, name); | ||
240 | return data_storage.count(key) && std::any_cast<bool>(data_storage.at(key)); | ||
241 | } | ||
242 | |||
243 | const std::set<std::string>& GetCheckedPaintings() { | 235 | const std::set<std::string>& GetCheckedPaintings() { |
244 | std::lock_guard state_guard(state_mutex); | 236 | std::lock_guard state_guard(state_mutex); |
245 | 237 | ||
@@ -298,11 +290,6 @@ struct APState { | |||
298 | 290 | ||
299 | std::thread([this]() { Thread(); }).detach(); | 291 | std::thread([this]() { Thread(); }).detach(); |
300 | 292 | ||
301 | for (int panel_id : GD_GetAchievementPanels()) { | ||
302 | tracked_data_storage_keys.push_back(fmt::format( | ||
303 | "Achievement|{}", GD_GetPanel(panel_id).achievement_name)); | ||
304 | } | ||
305 | |||
306 | for (int i = 0; i < PANEL_BITFIELDS; i++) { | 293 | for (int i = 0; i < PANEL_BITFIELDS; i++) { |
307 | tracked_data_storage_keys.push_back(fmt::format("Panels_{}", i)); | 294 | tracked_data_storage_keys.push_back(fmt::format("Panels_{}", i)); |
308 | } | 295 | } |
@@ -608,9 +595,6 @@ struct APState { | |||
608 | TrackerLog(fmt::format("Data storage {} retrieved as {}", key, | 595 | TrackerLog(fmt::format("Data storage {} retrieved as {}", key, |
609 | (value.get<bool>() ? "true" : "false"))); | 596 | (value.get<bool>() ? "true" : "false"))); |
610 | 597 | ||
611 | if (key.find("Achievement|") != std::string::npos) { | ||
612 | state_update.achievements = true; | ||
613 | } | ||
614 | } else if (value.is_number()) { | 598 | } else if (value.is_number()) { |
615 | data_storage[key] = value.get<int>(); | 599 | data_storage[key] = value.get<int>(); |
616 | TrackerLog(fmt::format("Data storage {} retrieved as {}", key, | 600 | TrackerLog(fmt::format("Data storage {} retrieved as {}", key, |
@@ -844,10 +828,6 @@ VictoryCondition AP_GetVictoryCondition() { | |||
844 | return GetState().victory_condition; | 828 | return GetState().victory_condition; |
845 | } | 829 | } |
846 | 830 | ||
847 | bool AP_HasAchievement(const std::string& achievement_name) { | ||
848 | return GetState().HasAchievement(achievement_name); | ||
849 | } | ||
850 | |||
851 | bool AP_HasEarlyColorHallways() { | 831 | bool AP_HasEarlyColorHallways() { |
852 | std::lock_guard state_guard(GetState().state_mutex); | 832 | std::lock_guard state_guard(GetState().state_mutex); |
853 | 833 | ||
diff --git a/src/ap_state.h b/src/ap_state.h index 54e1187..a757d89 100644 --- a/src/ap_state.h +++ b/src/ap_state.h | |||
@@ -93,8 +93,6 @@ PanelShuffleMode AP_GetPanelShuffleMode(); | |||
93 | 93 | ||
94 | VictoryCondition AP_GetVictoryCondition(); | 94 | VictoryCondition AP_GetVictoryCondition(); |
95 | 95 | ||
96 | bool AP_HasAchievement(const std::string& achievement_name); | ||
97 | |||
98 | bool AP_HasEarlyColorHallways(); | 96 | bool AP_HasEarlyColorHallways(); |
99 | 97 | ||
100 | bool AP_IsPilgrimageEnabled(); | 98 | bool AP_IsPilgrimageEnabled(); |
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index c0b070b..e8d7ef6 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp | |||
@@ -341,7 +341,11 @@ void TrackerFrame::OnStateChanged(StateChangedEvent &event) { | |||
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | if (state.achievements) { | 344 | if (std::any_of(state.panels.begin(), state.panels.end(), |
345 | [](int solve_index) { | ||
346 | return GD_GetPanel(GD_GetPanelBySolveIndex(solve_index)) | ||
347 | .achievement; | ||
348 | })) { | ||
345 | achievements_pane_->UpdateIndicators(); | 349 | achievements_pane_->UpdateIndicators(); |
346 | } | 350 | } |
347 | 351 | ||
diff --git a/src/tracker_frame.h b/src/tracker_frame.h index 2167852..00bbe70 100644 --- a/src/tracker_frame.h +++ b/src/tracker_frame.h | |||
@@ -53,7 +53,6 @@ struct StateUpdate { | |||
53 | std::vector<ItemState> items; | 53 | std::vector<ItemState> items; |
54 | bool progression_items = false; | 54 | bool progression_items = false; |
55 | std::vector<std::string> paintings; | 55 | std::vector<std::string> paintings; |
56 | bool achievements = false; | ||
57 | bool cleared_locations = false; | 56 | bool cleared_locations = false; |
58 | std::set<int> panels; | 57 | std::set<int> panels; |
59 | bool player_position = false; | 58 | bool player_position = false; |