about summary refs log tree commit diff stats
path: root/src/tracker_panel.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-07-19 03:51:23 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-07-19 03:51:23 -0400
commit8c5b719469bc61e33a451d9b3aeb66c7b0a6d68e (patch)
tree1f452dc8a601630a1fd50f4ee3f8ea25aed7b315 /src/tracker_panel.cpp
parentb80e1b888a7203312119e5bfad9e26c2c17d9b9f (diff)
downloadlingo-ap-tracker-8c5b719469bc61e33a451d9b3aeb66c7b0a6d68e.tar.gz
lingo-ap-tracker-8c5b719469bc61e33a451d9b3aeb66c7b0a6d68e.tar.bz2
lingo-ap-tracker-8c5b719469bc61e33a451d9b3aeb66c7b0a6d68e.zip
Added savedata analyzer
Diffstat (limited to 'src/tracker_panel.cpp')
-rw-r--r--src/tracker_panel.cpp54
1 files changed, 51 insertions, 3 deletions
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 @@
1#include "tracker_panel.h" 1#include "tracker_panel.h"
2 2
3#include <fmt/core.h>
3#include <wx/dcbuffer.h> 4#include <wx/dcbuffer.h>
4 5
6#include <algorithm>
7
5#include "ap_state.h" 8#include "ap_state.h"
6#include "area_popup.h" 9#include "area_popup.h"
7#include "game_data.h" 10#include "game_data.h"
8#include "global.h" 11#include "global.h"
12#include "godot_variant.h"
9#include "tracker_config.h" 13#include "tracker_config.h"
10#include "tracker_state.h" 14#include "tracker_state.h"
11 15
@@ -53,6 +57,35 @@ void TrackerPanel::UpdateIndicators() {
53 Redraw(); 57 Redraw();
54} 58}
55 59
60void TrackerPanel::SetSavedataPath(std::string savedata_path) {
61 if (!panels_mode_) {
62 wxButton *refresh_button = new wxButton(this, wxID_ANY, "Refresh", {15, 15});
63 refresh_button->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this);
64 }
65
66 savedata_path_ = savedata_path;
67 panels_mode_ = true;
68
69 RefreshSavedata();
70}
71
72void TrackerPanel::RefreshSavedata() {
73 solved_panels_.clear();
74
75 GodotVariant godot_variant = ParseGodotFile(*savedata_path_);
76 for (const GodotVariant &panel_node : godot_variant.AsArray()) {
77 const std::vector<GodotVariant> &fields = panel_node.AsArray();
78 if (fields[1].AsBool()) {
79 const std::vector<std::string> &nodepath = fields[0].AsNodePath();
80 std::string key = fmt::format("{}/{}", nodepath[3], nodepath[4]);
81 solved_panels_.insert(key);
82 }
83 }
84
85 UpdateIndicators();
86 Refresh();
87}
88
56void TrackerPanel::OnPaint(wxPaintEvent &event) { 89void TrackerPanel::OnPaint(wxPaintEvent &event) {
57 if (GetSize() != rendered_.GetSize()) { 90 if (GetSize() != rendered_.GetSize()) {
58 Redraw(); 91 Redraw();
@@ -92,6 +125,10 @@ void TrackerPanel::OnMouseMove(wxMouseEvent &event) {
92 event.Skip(); 125 event.Skip();
93} 126}
94 127
128void TrackerPanel::OnRefreshSavedata(wxCommandEvent &event) {
129 RefreshSavedata();
130}
131
95void TrackerPanel::Redraw() { 132void TrackerPanel::Redraw() {
96 wxSize panel_size = GetSize(); 133 wxSize panel_size = GetSize();
97 wxSize image_size = map_image_.GetSize(); 134 wxSize image_size = map_image_.GetSize();
@@ -142,21 +179,32 @@ void TrackerPanel::Redraw() {
142 179
143 for (AreaIndicator &area : areas_) { 180 for (AreaIndicator &area : areas_) {
144 const MapArea &map_area = GD_GetMapArea(area.area_id); 181 const MapArea &map_area = GD_GetMapArea(area.area_id);
145 if (!AP_IsLocationVisible(map_area.classification) && 182 if (panels_mode_) {
183 area.active = map_area.panel;
184 } else if (!AP_IsLocationVisible(map_area.classification) &&
146 !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && 185 !(map_area.hunt && GetTrackerConfig().show_hunt_panels) &&
147 !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { 186 !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) {
148 area.active = false; 187 area.active = false;
149 continue;
150 } else { 188 } else {
151 area.active = true; 189 area.active = true;
152 } 190 }
153 191
192 if (!area.active) {
193 continue;
194 }
195
154 bool has_reachable_unchecked = false; 196 bool has_reachable_unchecked = false;
155 bool has_unreachable_unchecked = false; 197 bool has_unreachable_unchecked = false;
156 for (const Location &section : map_area.locations) { 198 for (const Location &section : map_area.locations) {
157 bool has_unchecked = false; 199 bool has_unchecked = false;
158 if (IsLocationWinCondition(section)) { 200 if (IsLocationWinCondition(section)) {
159 has_unchecked = !AP_HasReachedGoal(); 201 has_unchecked = !AP_HasReachedGoal();
202 } else if (panels_mode_) {
203 has_unchecked = section.panel && std::any_of(
204 section.panels.begin(), section.panels.end(), [this](int panel_id) {
205 const Panel &panel = GD_GetPanel(panel_id);
206 return !solved_panels_.contains(panel.nodepath);
207 });
160 } else if (AP_IsLocationVisible(section.classification)) { 208 } else if (AP_IsLocationVisible(section.classification)) {
161 has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id); 209 has_unchecked = !AP_HasCheckedGameLocation(section.ap_location_id);
162 } else if (section.hunt && GetTrackerConfig().show_hunt_panels) { 210 } else if (section.hunt && GetTrackerConfig().show_hunt_panels) {
@@ -172,7 +220,7 @@ void TrackerPanel::Redraw() {
172 } 220 }
173 } 221 }
174 222
175 if (AP_IsPaintingShuffle()) { 223 if (AP_IsPaintingShuffle() && !panels_mode_) {
176 for (int painting_id : map_area.paintings) { 224 for (int painting_id : map_area.paintings) {
177 const PaintingExit &painting = GD_GetPaintingExit(painting_id); 225 const PaintingExit &painting = GD_GetPaintingExit(painting_id);
178 if (!AP_IsPaintingChecked(painting.internal_id)) { 226 if (!AP_IsPaintingChecked(painting.internal_id)) {