diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-17 15:40:19 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-17 15:40:19 -0500 |
commit | ad7c3e616fdc6f13812ec52675d226a19351494a (patch) | |
tree | 4cdd8b27c6df4e5f3475fe1b3f1815689b387fd7 /src/tracker_frame.cpp | |
parent | 5ea44a418ec5db446dd28daf5ed95f46fea504f8 (diff) | |
download | lingo-ap-tracker-ad7c3e616fdc6f13812ec52675d226a19351494a.tar.gz lingo-ap-tracker-ad7c3e616fdc6f13812ec52675d226a19351494a.tar.bz2 lingo-ap-tracker-ad7c3e616fdc6f13812ec52675d226a19351494a.zip |
Added getting player position from IPC
Diffstat (limited to 'src/tracker_frame.cpp')
-rw-r--r-- | src/tracker_frame.cpp | 49 |
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 | ||
24 | namespace { | ||
25 | |||
26 | std::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 | |||
23 | enum TrackerFrameIds { | 40 | enum 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 { | |||
32 | wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); | 49 | wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); |
33 | wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); | 50 | wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); |
34 | wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); | 51 | wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); |
52 | wxDEFINE_EVENT(REDRAW_POSITION, wxCommandEvent); | ||
35 | 53 | ||
36 | TrackerFrame::TrackerFrame() | 54 | TrackerFrame::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 | ||
120 | void 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 | |||
142 | void TrackerFrame::UpdateStatusMessage() { | ||
143 | QueueEvent(new wxCommandEvent(STATUS_CHANGED)); | ||
125 | } | 144 | } |
126 | 145 | ||
127 | void TrackerFrame::ResetIndicators() { | 146 | void 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 | ||
154 | void TrackerFrame::RedrawPosition() { | ||
155 | QueueEvent(new wxCommandEvent(REDRAW_POSITION)); | ||
156 | } | ||
157 | |||
135 | void TrackerFrame::OnAbout(wxCommandEvent &event) { | 158 | void 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 | ||
203 | void TrackerFrame::OnZoomOut(wxCommandEvent& event) { | 226 | void 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 | ||
214 | void TrackerFrame::OnOpenFile(wxCommandEvent& event) { | 237 | void 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 | ||
236 | void TrackerFrame::OnStateReset(wxCommandEvent& event) { | 259 | void 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 | ||
257 | void TrackerFrame::OnStatusChanged(wxCommandEvent &event) { | 280 | void TrackerFrame::OnStatusChanged(wxCommandEvent &event) { |
258 | SetStatusText(event.GetString()); | 281 | SetStatusText(GetStatusMessage()); |
282 | } | ||
283 | |||
284 | void TrackerFrame::OnRedrawPosition(wxCommandEvent &event) { | ||
285 | if (notebook_->GetSelection() == 0) { | ||
286 | tracker_panel_->Refresh(); | ||
287 | } | ||
259 | } | 288 | } |
260 | 289 | ||
261 | void TrackerFrame::CheckForUpdates(bool manual) { | 290 | void TrackerFrame::CheckForUpdates(bool manual) { |