From 8c5b719469bc61e33a451d9b3aeb66c7b0a6d68e Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 19 Jul 2024 03:51:23 -0400 Subject: Added savedata analyzer --- src/tracker_panel.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'src/tracker_panel.cpp') diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index d60c1b6..2e1497b 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp @@ -1,11 +1,15 @@ #include "tracker_panel.h" +#include #include +#include + #include "ap_state.h" #include "area_popup.h" #include "game_data.h" #include "global.h" +#include "godot_variant.h" #include "tracker_config.h" #include "tracker_state.h" @@ -53,6 +57,35 @@ void TrackerPanel::UpdateIndicators() { Redraw(); } +void TrackerPanel::SetSavedataPath(std::string savedata_path) { + if (!panels_mode_) { + wxButton *refresh_button = new wxButton(this, wxID_ANY, "Refresh", {15, 15}); + refresh_button->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this); + } + + savedata_path_ = savedata_path; + panels_mode_ = true; + + RefreshSavedata(); +} + +void TrackerPanel::RefreshSavedata() { + solved_panels_.clear(); + + GodotVariant godot_variant = ParseGodotFile(*savedata_path_); + for (const GodotVariant &panel_node : godot_variant.AsArray()) { + const std::vector &fields = panel_node.AsArray(); + if (fields[1].AsBool()) { + const std::vector &nodepath = fields[0].AsNodePath(); + std::string key = fmt::format("{}/{}", nodepath[3], nodepath[4]); + solved_panels_.insert(key); + } + } + + UpdateIndicators(); + Refresh(); +} + void TrackerPanel::OnPaint(wxPaintEvent &event) { if (GetSize() != rendered_.GetSize()) { Redraw(); @@ -92,6 +125,10 @@ void TrackerPanel::OnMouseMove(wxMouseEvent &event) { event.Skip(); } +void TrackerPanel::OnRefreshSavedata(wxCommandEvent &event) { + RefreshSavedata(); +} + void TrackerPanel::Redraw() { wxSize panel_size = GetSize(); wxSize image_size = map_image_.GetSize(); @@ -142,21 +179,32 @@ void TrackerPanel::Redraw() { for (AreaIndicator &area : areas_) { const MapArea &map_area = GD_GetMapArea(area.area_id); - if (!AP_IsLocationVisible(map_area.classification) && + if (panels_mode_) { + area.active = map_area.panel; + } else if (!AP_IsLocationVisible(map_area.classification) && !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { area.active = false; - continue; } else { area.active = true; } + if (!area.active) { + continue; + } + bool has_reachable_unchecked = false; bool has_unreachable_unchecked = false; for (const Location §ion : map_area.locations) { bool has_unchecked = false; if (IsLocationWinCondition(section)) { has_unchecked = !AP_HasReachedGoal(); + } else if (panels_mode_) { + has_unchecked = section.panel && std::any_of( + section.panels.begin(), section.panels.end(), [this](int panel_id) { + const Panel &panel = GD_GetPanel(panel_id); + return !solved_panels_.contains(panel.nodepath); + }); } else if (AP_IsLocationVisible(section.classification)) { has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { @@ -172,7 +220,7 @@ void TrackerPanel::Redraw() { } } - if (AP_IsPaintingShuffle()) { + if (AP_IsPaintingShuffle() && !panels_mode_) { for (int painting_id : map_area.paintings) { const PaintingExit &painting = GD_GetPaintingExit(painting_id); if (!AP_IsPaintingChecked(painting.internal_id)) { -- cgit 1.4.1