diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-13 12:47:54 -0400 | 
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-13 12:47:54 -0400 | 
| commit | dfddd07b8b5cbff7c09103a694aed40bda254a2d (patch) | |
| tree | 220364fa26eff54d9a3fd49f1b52a8afce2bf907 /src/tracker_panel.cpp | |
| parent | dacbe8e3fbda85f7c2e7e7b660795f2a080a9d25 (diff) | |
| download | lingo-ap-tracker-dfddd07b8b5cbff7c09103a694aed40bda254a2d.tar.gz lingo-ap-tracker-dfddd07b8b5cbff7c09103a694aed40bda254a2d.tar.bz2 lingo-ap-tracker-dfddd07b8b5cbff7c09103a694aed40bda254a2d.zip | |
Obsolete savefile reader + IPC solves
Now, panel solve state is all read from the sync fields in datastorage. The "show hunt panels" field in settings is now a radio box, and you can choose to show all panels.
Diffstat (limited to 'src/tracker_panel.cpp')
| -rw-r--r-- | src/tracker_panel.cpp | 75 | 
1 files changed, 10 insertions, 65 deletions
| diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index d8ba054..0a756e6 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,20 +51,18 @@ TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | |||
| 52 | } | 51 | } | 
| 53 | 52 | ||
| 54 | void TrackerPanel::UpdateIndicators(bool reset) { | 53 | void 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 (IsAreaPostgame(area.area_id)) { | 
| 64 | area.active = false; | 59 | area.active = false; | 
| 65 | } else if (panels_mode_) { | ||
| 66 | area.active = map_area.has_single_panel; | ||
| 67 | } else if (!AP_IsLocationVisible(map_area.classification) && | 60 | } else if (!AP_IsLocationVisible(map_area.classification) && | 
| 68 | !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && | 61 | !(map_area.hunt && GetTrackerConfig().visible_panels == | 
| 62 | TrackerConfig::kHUNT_PANELS) && | ||
| 63 | !(map_area.has_single_panel && | ||
| 64 | GetTrackerConfig().visible_panels == | ||
| 65 | TrackerConfig::kALL_PANELS) && | ||
| 69 | !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { | 66 | !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { | 
| 70 | area.active = false; | 67 | area.active = false; | 
| 71 | } else { | 68 | } else { | 
| @@ -85,47 +82,10 @@ void TrackerPanel::UpdateIndicators(bool reset) { | |||
| 85 | Redraw(); | 82 | Redraw(); | 
| 86 | } | 83 | } | 
| 87 | 84 | ||
| 88 | void TrackerPanel::SetPanelsMode() { panels_mode_ = true; } | ||
| 89 | |||
| 90 | void 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 | |||
| 104 | void 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 | |||
| 121 | void TrackerPanel::OnPaint(wxPaintEvent &event) { | 85 | void TrackerPanel::OnPaint(wxPaintEvent &event) { | 
| 122 | if (GetSize() != rendered_.GetSize()) { | 86 | if (GetSize() != rendered_.GetSize()) { | 
| 123 | Resize(); | 87 | Resize(); | 
| 124 | Redraw(); | 88 | Redraw(); | 
| 125 | |||
| 126 | if (refresh_button_ != nullptr) { | ||
| 127 | SetUpRefreshButton(); | ||
| 128 | } | ||
| 129 | } | 89 | } | 
| 130 | 90 | ||
| 131 | wxBufferedPaintDC dc(this); | 91 | wxBufferedPaintDC dc(this); | 
| @@ -174,10 +134,6 @@ void TrackerPanel::OnMouseMove(wxMouseEvent &event) { | |||
| 174 | event.Skip(); | 134 | event.Skip(); | 
| 175 | } | 135 | } | 
| 176 | 136 | ||
| 177 | void TrackerPanel::OnRefreshSavedata(wxCommandEvent &event) { | ||
| 178 | RefreshSavedata(); | ||
| 179 | } | ||
| 180 | |||
| 181 | void TrackerPanel::Resize() { | 137 | void TrackerPanel::Resize() { | 
| 182 | wxSize panel_size = GetClientSize(); | 138 | wxSize panel_size = GetClientSize(); | 
| 183 | wxSize image_size = map_image_.GetSize(); | 139 | wxSize image_size = map_image_.GetSize(); | 
| @@ -281,18 +237,12 @@ void TrackerPanel::Redraw() { | |||
| 281 | // Nope. | 237 | // Nope. | 
| 282 | } else if (IsLocationWinCondition(section)) { | 238 | } else if (IsLocationWinCondition(section)) { | 
| 283 | has_unchecked = !AP_HasReachedGoal(); | 239 | has_unchecked = !AP_HasReachedGoal(); | 
| 284 | } else if (panels_mode_) { | ||
| 285 | if (section.single_panel) { | ||
| 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)) { | 240 | } else if (AP_IsLocationVisible(section.classification)) { | 
| 294 | has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); | 241 | has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); | 
| 295 | } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { | 242 | } else if ((section.hunt && GetTrackerConfig().visible_panels == | 
| 243 | TrackerConfig::kHUNT_PANELS) || | ||
| 244 | (section.single_panel && GetTrackerConfig().visible_panels == | ||
| 245 | TrackerConfig::kALL_PANELS)) { | ||
| 296 | has_unchecked = | 246 | has_unchecked = | 
| 297 | !AP_IsPanelSolved(GD_GetPanel(*section.single_panel).solve_index); | 247 | !AP_IsPanelSolved(GD_GetPanel(*section.single_panel).solve_index); | 
| 298 | } | 248 | } | 
| @@ -306,7 +256,7 @@ void TrackerPanel::Redraw() { | |||
| 306 | } | 256 | } | 
| 307 | } | 257 | } | 
| 308 | 258 | ||
| 309 | if (AP_IsPaintingShuffle() && !panels_mode_) { | 259 | if (AP_IsPaintingShuffle()) { | 
| 310 | for (int painting_id : map_area.paintings) { | 260 | for (int painting_id : map_area.paintings) { | 
| 311 | if (IsPaintingPostgame(painting_id)) { | 261 | if (IsPaintingPostgame(painting_id)) { | 
| 312 | continue; | 262 | continue; | 
| @@ -358,8 +308,3 @@ void TrackerPanel::Redraw() { | |||
| 358 | } | 308 | } | 
| 359 | } | 309 | } | 
| 360 | } | 310 | } | 
| 361 | |||
| 362 | void TrackerPanel::SetUpRefreshButton() { | ||
| 363 | refresh_button_->SetSize(FromDIP(15), FromDIP(15), wxDefaultCoord, | ||
| 364 | wxDefaultCoord, wxSIZE_AUTO); | ||
| 365 | } | ||
