about summary refs log tree commit diff stats
path: root/src/tracker_frame.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-07-24 09:40:22 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-07-24 09:40:22 -0400
commitc443acfd0b25b3e4f3446f795777b8dd18b00e2b (patch)
tree86340c00f1723310cbab02f0ebc496b25a780278 /src/tracker_frame.cpp
parent378766bcee3cad04256ada937f96b232aba85cf3 (diff)
parentab5206255603f6401d9c216ffce26607da16ad33 (diff)
downloadlingo-ap-tracker-c443acfd0b25b3e4f3446f795777b8dd18b00e2b.tar.gz
lingo-ap-tracker-c443acfd0b25b3e4f3446f795777b8dd18b00e2b.tar.bz2
lingo-ap-tracker-c443acfd0b25b3e4f3446f795777b8dd18b00e2b.zip
Merge branch 'main' into panels
Diffstat (limited to 'src/tracker_frame.cpp')
-rw-r--r--src/tracker_frame.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index 80fd137..3b6beda 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp
@@ -2,9 +2,12 @@
2 2
3#include <wx/aboutdlg.h> 3#include <wx/aboutdlg.h>
4#include <wx/choicebk.h> 4#include <wx/choicebk.h>
5#include <wx/filedlg.h>
5#include <wx/notebook.h> 6#include <wx/notebook.h>
7#include <wx/stdpaths.h>
6#include <wx/webrequest.h> 8#include <wx/webrequest.h>
7 9
10#include <fmt/core.h>
8#include <nlohmann/json.hpp> 11#include <nlohmann/json.hpp>
9#include <sstream> 12#include <sstream>
10 13
@@ -23,6 +26,7 @@ enum TrackerFrameIds {
23 ID_SETTINGS = 3, 26 ID_SETTINGS = 3,
24 ID_ZOOM_IN = 4, 27 ID_ZOOM_IN = 4,
25 ID_ZOOM_OUT = 5, 28 ID_ZOOM_OUT = 5,
29 ID_OPEN_SAVE_FILE = 6,
26}; 30};
27 31
28wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); 32wxDEFINE_EVENT(STATE_RESET, wxCommandEvent);
@@ -38,6 +42,7 @@ TrackerFrame::TrackerFrame()
38 42
39 wxMenu *menuFile = new wxMenu(); 43 wxMenu *menuFile = new wxMenu();
40 menuFile->Append(ID_CONNECT, "&Connect"); 44 menuFile->Append(ID_CONNECT, "&Connect");
45 menuFile->Append(ID_OPEN_SAVE_FILE, "&Open Save Data\tCtrl-O");
41 menuFile->Append(ID_SETTINGS, "&Settings"); 46 menuFile->Append(ID_SETTINGS, "&Settings");
42 menuFile->Append(wxID_EXIT); 47 menuFile->Append(wxID_EXIT);
43 48
@@ -71,6 +76,7 @@ TrackerFrame::TrackerFrame()
71 Bind(wxEVT_MENU, &TrackerFrame::OnZoomIn, this, ID_ZOOM_IN); 76 Bind(wxEVT_MENU, &TrackerFrame::OnZoomIn, this, ID_ZOOM_IN);
72 Bind(wxEVT_MENU, &TrackerFrame::OnZoomOut, this, ID_ZOOM_OUT); 77 Bind(wxEVT_MENU, &TrackerFrame::OnZoomOut, this, ID_ZOOM_OUT);
73 Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &TrackerFrame::OnChangePage, this); 78 Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &TrackerFrame::OnChangePage, this);
79 Bind(wxEVT_MENU, &TrackerFrame::OnOpenFile, this, ID_OPEN_SAVE_FILE);
74 Bind(STATE_RESET, &TrackerFrame::OnStateReset, this); 80 Bind(STATE_RESET, &TrackerFrame::OnStateReset, this);
75 Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); 81 Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this);
76 Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); 82 Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this);
@@ -204,10 +210,36 @@ void TrackerFrame::OnChangePage(wxBookCtrlEvent &event) {
204 zoom_out_menu_item_->Enable(event.GetSelection() == 1); 210 zoom_out_menu_item_->Enable(event.GetSelection() == 1);
205} 211}
206 212
213void TrackerFrame::OnOpenFile(wxCommandEvent& event) {
214 wxFileDialog open_file_dialog(
215 this, "Open Lingo Save File",
216 fmt::format("{}\\Godot\\app_userdata\\Lingo\\level1_stable",
217 wxStandardPaths::Get().GetUserConfigDir().ToStdString()),
218 AP_GetSaveName(), "Lingo save file (*.save)|*.save",
219 wxFD_OPEN | wxFD_FILE_MUST_EXIST);
220 if (open_file_dialog.ShowModal() == wxID_CANCEL) {
221 return;
222 }
223
224 std::string savedata_path = open_file_dialog.GetPath().ToStdString();
225
226 if (panels_panel_ == nullptr) {
227 panels_panel_ = new TrackerPanel(notebook_);
228 notebook_->AddPage(panels_panel_, "Panels");
229 }
230
231 notebook_->SetSelection(notebook_->FindPage(panels_panel_));
232 panels_panel_->SetSavedataPath(savedata_path);
233}
234
207void TrackerFrame::OnStateReset(wxCommandEvent& event) { 235void TrackerFrame::OnStateReset(wxCommandEvent& event) {
208 tracker_panel_->UpdateIndicators(); 236 tracker_panel_->UpdateIndicators();
209 achievements_pane_->UpdateIndicators(); 237 achievements_pane_->UpdateIndicators();
210 subway_map_->OnConnect(); 238 subway_map_->OnConnect();
239 if (panels_panel_ != nullptr) {
240 notebook_->DeletePage(notebook_->FindPage(panels_panel_));
241 panels_panel_ = nullptr;
242 }
211 Refresh(); 243 Refresh();
212} 244}
213 245
@@ -215,6 +247,9 @@ void TrackerFrame::OnStateChanged(wxCommandEvent &event) {
215 tracker_panel_->UpdateIndicators(); 247 tracker_panel_->UpdateIndicators();
216 achievements_pane_->UpdateIndicators(); 248 achievements_pane_->UpdateIndicators();
217 subway_map_->UpdateIndicators(); 249 subway_map_->UpdateIndicators();
250 if (panels_panel_ != nullptr) {
251 panels_panel_->UpdateIndicators();
252 }
218 Refresh(); 253 Refresh();
219} 254}
220 255