about summary refs log tree commit diff stats
path: root/src/tracker_frame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tracker_frame.cpp')
-rw-r--r--src/tracker_frame.cpp66
1 files changed, 16 insertions, 50 deletions
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index fa68582..e8d7ef6 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp
@@ -9,6 +9,7 @@
9#include <wx/stdpaths.h> 9#include <wx/stdpaths.h>
10#include <wx/webrequest.h> 10#include <wx/webrequest.h>
11 11
12#include <algorithm>
12#include <nlohmann/json.hpp> 13#include <nlohmann/json.hpp>
13#include <sstream> 14#include <sstream>
14 15
@@ -50,7 +51,6 @@ enum TrackerFrameIds {
50 ID_SETTINGS = 3, 51 ID_SETTINGS = 3,
51 ID_ZOOM_IN = 4, 52 ID_ZOOM_IN = 4,
52 ID_ZOOM_OUT = 5, 53 ID_ZOOM_OUT = 5,
53 ID_OPEN_SAVE_FILE = 6,
54 ID_IPC_CONNECT = 7, 54 ID_IPC_CONNECT = 7,
55 ID_LOG_DIALOG = 8, 55 ID_LOG_DIALOG = 8,
56}; 56};
@@ -76,7 +76,6 @@ TrackerFrame::TrackerFrame()
76 wxMenu *menuFile = new wxMenu(); 76 wxMenu *menuFile = new wxMenu();
77 menuFile->Append(ID_AP_CONNECT, "&Connect to Archipelago"); 77 menuFile->Append(ID_AP_CONNECT, "&Connect to Archipelago");
78 menuFile->Append(ID_IPC_CONNECT, "&Connect to Lingo"); 78 menuFile->Append(ID_IPC_CONNECT, "&Connect to Lingo");
79 menuFile->Append(ID_OPEN_SAVE_FILE, "&Open Save Data\tCtrl-O");
80 menuFile->Append(ID_SETTINGS, "&Settings"); 79 menuFile->Append(ID_SETTINGS, "&Settings");
81 menuFile->Append(wxID_EXIT); 80 menuFile->Append(wxID_EXIT);
82 81
@@ -113,7 +112,6 @@ TrackerFrame::TrackerFrame()
113 Bind(wxEVT_MENU, &TrackerFrame::OnZoomOut, this, ID_ZOOM_OUT); 112 Bind(wxEVT_MENU, &TrackerFrame::OnZoomOut, this, ID_ZOOM_OUT);
114 Bind(wxEVT_MENU, &TrackerFrame::OnOpenLogWindow, this, ID_LOG_DIALOG); 113 Bind(wxEVT_MENU, &TrackerFrame::OnOpenLogWindow, this, ID_LOG_DIALOG);
115 Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &TrackerFrame::OnChangePage, this); 114 Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &TrackerFrame::OnChangePage, this);
116 Bind(wxEVT_MENU, &TrackerFrame::OnOpenFile, this, ID_OPEN_SAVE_FILE);
117 Bind(wxEVT_SPLITTER_SASH_POS_CHANGED, &TrackerFrame::OnSashPositionChanged, 115 Bind(wxEVT_SPLITTER_SASH_POS_CHANGED, &TrackerFrame::OnSashPositionChanged,
118 this); 116 this);
119 Bind(STATE_RESET, &TrackerFrame::OnStateReset, this); 117 Bind(STATE_RESET, &TrackerFrame::OnStateReset, this);
@@ -251,7 +249,7 @@ void TrackerFrame::OnSettings(wxCommandEvent &event) {
251 GetTrackerConfig().should_check_for_updates = 249 GetTrackerConfig().should_check_for_updates =
252 dlg.GetShouldCheckForUpdates(); 250 dlg.GetShouldCheckForUpdates();
253 GetTrackerConfig().hybrid_areas = dlg.GetHybridAreas(); 251 GetTrackerConfig().hybrid_areas = dlg.GetHybridAreas();
254 GetTrackerConfig().show_hunt_panels = dlg.GetShowHuntPanels(); 252 GetTrackerConfig().visible_panels = dlg.GetVisiblePanels();
255 GetTrackerConfig().track_position = dlg.GetTrackPosition(); 253 GetTrackerConfig().track_position = dlg.GetTrackPosition();
256 GetTrackerConfig().Save(); 254 GetTrackerConfig().Save();
257 255
@@ -302,28 +300,6 @@ void TrackerFrame::OnChangePage(wxBookCtrlEvent &event) {
302 zoom_out_menu_item_->Enable(event.GetSelection() == 1); 300 zoom_out_menu_item_->Enable(event.GetSelection() == 1);
303} 301}
304 302
305void TrackerFrame::OnOpenFile(wxCommandEvent &event) {
306 wxFileDialog open_file_dialog(
307 this, "Open Lingo Save File",
308 fmt::format("{}\\Godot\\app_userdata\\Lingo\\level1_stable",
309 wxStandardPaths::Get().GetUserConfigDir().ToStdString()),
310 AP_GetSaveName(), "Lingo save file (*.save)|*.save",
311 wxFD_OPEN | wxFD_FILE_MUST_EXIST);
312 if (open_file_dialog.ShowModal() == wxID_CANCEL) {
313 return;
314 }
315
316 std::string savedata_path = open_file_dialog.GetPath().ToStdString();
317
318 if (panels_panel_ == nullptr) {
319 panels_panel_ = new TrackerPanel(notebook_);
320 notebook_->AddPage(panels_panel_, "Panels");
321 }
322
323 notebook_->SetSelection(notebook_->FindPage(panels_panel_));
324 panels_panel_->SetSavedataPath(savedata_path);
325}
326
327void TrackerFrame::OnSashPositionChanged(wxSplitterEvent& event) { 303void TrackerFrame::OnSashPositionChanged(wxSplitterEvent& event) {
328 notebook_->Refresh(); 304 notebook_->Refresh();
329} 305}
@@ -335,51 +311,41 @@ void TrackerFrame::OnStateReset(wxCommandEvent &event) {
335 options_pane_->OnConnect(); 311 options_pane_->OnConnect();
336 paintings_pane_->ResetIndicators(); 312 paintings_pane_->ResetIndicators();
337 subway_map_->OnConnect(); 313 subway_map_->OnConnect();
338 if (panels_panel_ != nullptr) {
339 notebook_->DeletePage(notebook_->FindPage(panels_panel_));
340 panels_panel_ = nullptr;
341 }
342 Refresh(); 314 Refresh();
343} 315}
344 316
345void TrackerFrame::OnStateChanged(StateChangedEvent &event) { 317void TrackerFrame::OnStateChanged(StateChangedEvent &event) {
346 const StateUpdate &state = event.GetState(); 318 const StateUpdate &state = event.GetState();
347 319
348 if (state.open_panels_tab) { 320 bool hunt_panels = false;
349 if (panels_panel_ == nullptr) { 321 if (GetTrackerConfig().visible_panels == TrackerConfig::kHUNT_PANELS) {
350 panels_panel_ = new TrackerPanel(notebook_); 322 hunt_panels = std::any_of(
351 panels_panel_->SetPanelsMode(); 323 state.panels.begin(), state.panels.end(), [](int solve_index) {
352 notebook_->AddPage(panels_panel_, "Panels"); 324 return GD_GetPanel(GD_GetPanelBySolveIndex(solve_index)).hunt;
353 } 325 });
354 panels_panel_->UpdateIndicators(/*reset=*/false); 326 } else if (GetTrackerConfig().visible_panels == TrackerConfig::kALL_PANELS) {
355 if (notebook_->GetSelection() == 2) { 327 hunt_panels = true;
356 Refresh();
357 }
358
359 return;
360 } 328 }
361 329
362 if (!state.items.empty() || !state.paintings.empty() || 330 if (!state.items.empty() || !state.paintings.empty() ||
363 state.cleared_locations || 331 state.cleared_locations || hunt_panels) {
364 (state.hunt_panels && GetTrackerConfig().show_hunt_panels)) {
365 // TODO: The only real reason to reset tracker_panel during an active 332 // TODO: The only real reason to reset tracker_panel during an active
366 // connection is if the hunt panels setting changes. If we remove hunt 333 // connection is if the hunt panels setting changes. If we remove hunt
367 // panels later, we can get rid of this. 334 // panels later, we can get rid of this.
368 tracker_panel_->UpdateIndicators(/*reset=*/state.changed_settings); 335 tracker_panel_->UpdateIndicators(/*reset=*/state.changed_settings);
369 subway_map_->UpdateIndicators(); 336 subway_map_->UpdateIndicators();
370 if (panels_panel_ != nullptr) {
371 panels_panel_->UpdateIndicators(/*reset=*/false);
372 }
373 Refresh(); 337 Refresh();
374 } else if (state.player_position && GetTrackerConfig().track_position) { 338 } else if (state.player_position && GetTrackerConfig().track_position) {
375 if (notebook_->GetSelection() == 0) { 339 if (notebook_->GetSelection() == 0) {
376 tracker_panel_->Refresh(); 340 tracker_panel_->Refresh();
377 } else if (notebook_->GetSelection() == 2) {
378 panels_panel_->Refresh();
379 } 341 }
380 } 342 }
381 343
382 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 })) {
383 achievements_pane_->UpdateIndicators(); 349 achievements_pane_->UpdateIndicators();
384 } 350 }
385 351