about summary refs log tree commit diff stats
path: root/src/tracker_panel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tracker_panel.cpp')
-rw-r--r--src/tracker_panel.cpp91
1 files changed, 17 insertions, 74 deletions
diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 9adcb1f..ddb4df9 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp
@@ -9,7 +9,6 @@
9#include "area_popup.h" 9#include "area_popup.h"
10#include "game_data.h" 10#include "game_data.h"
11#include "global.h" 11#include "global.h"
12#include "godot_variant.h"
13#include "ipc_state.h" 12#include "ipc_state.h"
14#include "tracker_config.h" 13#include "tracker_config.h"
15#include "tracker_state.h" 14#include "tracker_state.h"
@@ -52,21 +51,17 @@ TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) {
52} 51}
53 52
54void TrackerPanel::UpdateIndicators(bool reset) { 53void TrackerPanel::UpdateIndicators(bool reset) {
55 if (panels_mode_ && !savedata_path_) {
56 solved_panels_ = IPC_GetSolvedPanels();
57 }
58
59 if (reset) { 54 if (reset) {
60 for (AreaIndicator &area : areas_) { 55 for (AreaIndicator &area : areas_) {
61 const MapArea &map_area = GD_GetMapArea(area.area_id); 56 const MapArea &map_area = GD_GetMapArea(area.area_id);
62 57
63 if (IsAreaPostgame(area.area_id)) { 58 if ((!AP_IsLocationVisible(map_area.classification) ||
64 area.active = false; 59 IsAreaPostgame(area.area_id)) &&
65 } else if (panels_mode_) { 60 !(map_area.hunt &&
66 area.active = map_area.has_single_panel; 61 GetTrackerConfig().visible_panels == TrackerConfig::kHUNT_PANELS) &&
67 } else if (!AP_IsLocationVisible(map_area.classification) && 62 !(map_area.has_single_panel &&
68 !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && 63 GetTrackerConfig().visible_panels == TrackerConfig::kALL_PANELS) &&
69 !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { 64 !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) {
70 area.active = false; 65 area.active = false;
71 } else { 66 } else {
72 area.active = true; 67 area.active = true;
@@ -85,47 +80,10 @@ void TrackerPanel::UpdateIndicators(bool reset) {
85 Redraw(); 80 Redraw();
86} 81}
87 82
88void TrackerPanel::SetPanelsMode() { panels_mode_ = true; }
89
90void TrackerPanel::SetSavedataPath(std::string savedata_path) {
91 if (!savedata_path_) {
92 refresh_button_ = new wxButton(this, wxID_ANY, "Refresh");
93 refresh_button_->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this);
94 SetUpRefreshButton();
95 }
96
97 savedata_path_ = savedata_path;
98 panels_mode_ = true;
99
100 UpdateIndicators(/*reset=*/true);
101 RefreshSavedata();
102}
103
104void TrackerPanel::RefreshSavedata() {
105 solved_panels_.clear();
106
107 GodotVariant godot_variant = ParseGodotFile(*savedata_path_);
108 for (const GodotVariant &panel_node : godot_variant.AsArray()) {
109 const std::vector<GodotVariant> &fields = panel_node.AsArray();
110 if (fields[1].AsBool()) {
111 const std::vector<std::string> &nodepath = fields[0].AsNodePath();
112 std::string key = fmt::format("{}/{}", nodepath[3], nodepath[4]);
113 solved_panels_.insert(key);
114 }
115 }
116
117 UpdateIndicators(/*reset=*/false);
118 Refresh();
119}
120
121void TrackerPanel::OnPaint(wxPaintEvent &event) { 83void TrackerPanel::OnPaint(wxPaintEvent &event) {
122 if (GetSize() != rendered_.GetSize()) { 84 if (GetSize() != rendered_.GetSize()) {
123 Resize(); 85 Resize();
124 Redraw(); 86 Redraw();
125
126 if (refresh_button_ != nullptr) {
127 SetUpRefreshButton();
128 }
129 } 87 }
130 88
131 wxBufferedPaintDC dc(this); 89 wxBufferedPaintDC dc(this);
@@ -174,10 +132,6 @@ void TrackerPanel::OnMouseMove(wxMouseEvent &event) {
174 event.Skip(); 132 event.Skip();
175} 133}
176 134
177void TrackerPanel::OnRefreshSavedata(wxCommandEvent &event) {
178 RefreshSavedata();
179}
180
181void TrackerPanel::Resize() { 135void TrackerPanel::Resize() {
182 wxSize panel_size = GetClientSize(); 136 wxSize panel_size = GetClientSize();
183 wxSize image_size = map_image_.GetSize(); 137 wxSize image_size = map_image_.GetSize();
@@ -277,23 +231,17 @@ void TrackerPanel::Redraw() {
277 bool has_unreachable_unchecked = false; 231 bool has_unreachable_unchecked = false;
278 for (const Location &section : map_area.locations) { 232 for (const Location &section : map_area.locations) {
279 bool has_unchecked = false; 233 bool has_unchecked = false;
280 if (IsLocationPostgame(section.ap_location_id)) { 234 if (IsLocationWinCondition(section)) {
281 // Nope.
282 } else if (IsLocationWinCondition(section)) {
283 has_unchecked = !AP_HasReachedGoal(); 235 has_unchecked = !AP_HasReachedGoal();
284 } else if (panels_mode_) { 236 } else if (AP_IsLocationVisible(section.classification) &&
285 if (section.single_panel) { 237 !IsLocationPostgame(section.ap_location_id)) {
286 const Panel &panel = GD_GetPanel(*section.single_panel);
287 if (panel.non_counting) {
288 has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id);
289 } else {
290 has_unchecked = !GetSolvedPanels().contains(panel.nodepath);
291 }
292 }
293 } else if (AP_IsLocationVisible(section.classification)) {
294 has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); 238 has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id);
295 } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { 239 } else if ((section.hunt && GetTrackerConfig().visible_panels ==
296 has_unchecked = !AP_HasCheckedHuntPanel(section.ap_location_id); 240 TrackerConfig::kHUNT_PANELS) ||
241 (section.single_panel && GetTrackerConfig().visible_panels ==
242 TrackerConfig::kALL_PANELS)) {
243 has_unchecked =
244 !AP_IsPanelSolved(GD_GetPanel(*section.single_panel).solve_index);
297 } 245 }
298 246
299 if (has_unchecked) { 247 if (has_unchecked) {
@@ -305,7 +253,7 @@ void TrackerPanel::Redraw() {
305 } 253 }
306 } 254 }
307 255
308 if (AP_IsPaintingShuffle() && !panels_mode_) { 256 if (AP_IsPaintingShuffle()) {
309 for (int painting_id : map_area.paintings) { 257 for (int painting_id : map_area.paintings) {
310 if (IsPaintingPostgame(painting_id)) { 258 if (IsPaintingPostgame(painting_id)) {
311 continue; 259 continue;
@@ -357,8 +305,3 @@ void TrackerPanel::Redraw() {
357 } 305 }
358 } 306 }
359} 307}
360
361void TrackerPanel::SetUpRefreshButton() {
362 refresh_button_->SetSize(FromDIP(15), FromDIP(15), wxDefaultCoord,
363 wxDefaultCoord, wxSIZE_AUTO);
364}