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.cpp49
1 files changed, 39 insertions, 10 deletions
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index b9282f5..a06e46b 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp
@@ -14,12 +14,29 @@
14#include "achievements_pane.h" 14#include "achievements_pane.h"
15#include "ap_state.h" 15#include "ap_state.h"
16#include "connection_dialog.h" 16#include "connection_dialog.h"
17#include "ipc_state.h"
17#include "settings_dialog.h" 18#include "settings_dialog.h"
18#include "subway_map.h" 19#include "subway_map.h"
19#include "tracker_config.h" 20#include "tracker_config.h"
20#include "tracker_panel.h" 21#include "tracker_panel.h"
21#include "version.h" 22#include "version.h"
22 23
24namespace {
25
26std::string GetStatusMessage() {
27 std::string msg = AP_GetStatusMessage();
28
29 std::optional<std::string> ipc_msg = IPC_GetStatusMessage();
30 if (ipc_msg) {
31 msg += " ";
32 msg += *ipc_msg;
33 }
34
35 return msg;
36}
37
38} // namespace
39
23enum TrackerFrameIds { 40enum TrackerFrameIds {
24 ID_CONNECT = 1, 41 ID_CONNECT = 1,
25 ID_CHECK_FOR_UPDATES = 2, 42 ID_CHECK_FOR_UPDATES = 2,
@@ -32,6 +49,7 @@ enum TrackerFrameIds {
32wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); 49wxDEFINE_EVENT(STATE_RESET, wxCommandEvent);
33wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); 50wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent);
34wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); 51wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent);
52wxDEFINE_EVENT(REDRAW_POSITION, wxCommandEvent);
35 53
36TrackerFrame::TrackerFrame() 54TrackerFrame::TrackerFrame()
37 : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker", wxDefaultPosition, 55 : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker", wxDefaultPosition,
@@ -65,7 +83,6 @@ TrackerFrame::TrackerFrame()
65 SetMenuBar(menuBar); 83 SetMenuBar(menuBar);
66 84
67 CreateStatusBar(); 85 CreateStatusBar();
68 SetStatusText("Not connected to Archipelago.");
69 86
70 Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT); 87 Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT);
71 Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT); 88 Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT);
@@ -80,6 +97,7 @@ TrackerFrame::TrackerFrame()
80 Bind(STATE_RESET, &TrackerFrame::OnStateReset, this); 97 Bind(STATE_RESET, &TrackerFrame::OnStateReset, this);
81 Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); 98 Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this);
82 Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); 99 Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this);
100 Bind(REDRAW_POSITION, &TrackerFrame::OnRedrawPosition, this);
83 101
84 wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); 102 wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY);
85 achievements_pane_ = new AchievementsPane(choicebook); 103 achievements_pane_ = new AchievementsPane(choicebook);
@@ -115,13 +133,14 @@ TrackerFrame::TrackerFrame()
115 if (GetTrackerConfig().should_check_for_updates) { 133 if (GetTrackerConfig().should_check_for_updates) {
116 CheckForUpdates(/*manual=*/false); 134 CheckForUpdates(/*manual=*/false);
117 } 135 }
118}
119 136
120void TrackerFrame::SetStatusMessage(std::string message) { 137 IPC_Start(this);
121 wxCommandEvent *event = new wxCommandEvent(STATUS_CHANGED);
122 event->SetString(message.c_str());
123 138
124 QueueEvent(event); 139 SetStatusText(GetStatusMessage());
140}
141
142void TrackerFrame::UpdateStatusMessage() {
143 QueueEvent(new wxCommandEvent(STATUS_CHANGED));
125} 144}
126 145
127void TrackerFrame::ResetIndicators() { 146void TrackerFrame::ResetIndicators() {
@@ -132,6 +151,10 @@ void TrackerFrame::UpdateIndicators() {
132 QueueEvent(new wxCommandEvent(STATE_CHANGED)); 151 QueueEvent(new wxCommandEvent(STATE_CHANGED));
133} 152}
134 153
154void TrackerFrame::RedrawPosition() {
155 QueueEvent(new wxCommandEvent(REDRAW_POSITION));
156}
157
135void TrackerFrame::OnAbout(wxCommandEvent &event) { 158void TrackerFrame::OnAbout(wxCommandEvent &event) {
136 wxAboutDialogInfo about_info; 159 wxAboutDialogInfo about_info;
137 about_info.SetName("Lingo Archipelago Tracker"); 160 about_info.SetName("Lingo Archipelago Tracker");
@@ -200,7 +223,7 @@ void TrackerFrame::OnZoomIn(wxCommandEvent &event) {
200 } 223 }
201} 224}
202 225
203void TrackerFrame::OnZoomOut(wxCommandEvent& event) { 226void TrackerFrame::OnZoomOut(wxCommandEvent &event) {
204 if (notebook_->GetSelection() == 1) { 227 if (notebook_->GetSelection() == 1) {
205 subway_map_->Zoom(false); 228 subway_map_->Zoom(false);
206 } 229 }
@@ -211,7 +234,7 @@ void TrackerFrame::OnChangePage(wxBookCtrlEvent &event) {
211 zoom_out_menu_item_->Enable(event.GetSelection() == 1); 234 zoom_out_menu_item_->Enable(event.GetSelection() == 1);
212} 235}
213 236
214void TrackerFrame::OnOpenFile(wxCommandEvent& event) { 237void TrackerFrame::OnOpenFile(wxCommandEvent &event) {
215 wxFileDialog open_file_dialog( 238 wxFileDialog open_file_dialog(
216 this, "Open Lingo Save File", 239 this, "Open Lingo Save File",
217 fmt::format("{}\\Godot\\app_userdata\\Lingo\\level1_stable", 240 fmt::format("{}\\Godot\\app_userdata\\Lingo\\level1_stable",
@@ -233,7 +256,7 @@ void TrackerFrame::OnOpenFile(wxCommandEvent& event) {
233 panels_panel_->SetSavedataPath(savedata_path); 256 panels_panel_->SetSavedataPath(savedata_path);
234} 257}
235 258
236void TrackerFrame::OnStateReset(wxCommandEvent& event) { 259void TrackerFrame::OnStateReset(wxCommandEvent &event) {
237 tracker_panel_->UpdateIndicators(); 260 tracker_panel_->UpdateIndicators();
238 achievements_pane_->UpdateIndicators(); 261 achievements_pane_->UpdateIndicators();
239 subway_map_->OnConnect(); 262 subway_map_->OnConnect();
@@ -255,7 +278,13 @@ void TrackerFrame::OnStateChanged(wxCommandEvent &event) {
255} 278}
256 279
257void TrackerFrame::OnStatusChanged(wxCommandEvent &event) { 280void TrackerFrame::OnStatusChanged(wxCommandEvent &event) {
258 SetStatusText(event.GetString()); 281 SetStatusText(GetStatusMessage());
282}
283
284void TrackerFrame::OnRedrawPosition(wxCommandEvent &event) {
285 if (notebook_->GetSelection() == 0) {
286 tracker_panel_->Refresh();
287 }
259} 288}
260 289
261void TrackerFrame::CheckForUpdates(bool manual) { 290void TrackerFrame::CheckForUpdates(bool manual) {