From ad7c3e616fdc6f13812ec52675d226a19351494a Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 17 Dec 2024 15:40:19 -0500 Subject: Added getting player position from IPC --- src/tracker_frame.cpp | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'src/tracker_frame.cpp') 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 @@ #include "achievements_pane.h" #include "ap_state.h" #include "connection_dialog.h" +#include "ipc_state.h" #include "settings_dialog.h" #include "subway_map.h" #include "tracker_config.h" #include "tracker_panel.h" #include "version.h" +namespace { + +std::string GetStatusMessage() { + std::string msg = AP_GetStatusMessage(); + + std::optional ipc_msg = IPC_GetStatusMessage(); + if (ipc_msg) { + msg += " "; + msg += *ipc_msg; + } + + return msg; +} + +} // namespace + enum TrackerFrameIds { ID_CONNECT = 1, ID_CHECK_FOR_UPDATES = 2, @@ -32,6 +49,7 @@ enum TrackerFrameIds { wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); +wxDEFINE_EVENT(REDRAW_POSITION, wxCommandEvent); TrackerFrame::TrackerFrame() : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker", wxDefaultPosition, @@ -65,7 +83,6 @@ TrackerFrame::TrackerFrame() SetMenuBar(menuBar); CreateStatusBar(); - SetStatusText("Not connected to Archipelago."); Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT); Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT); @@ -80,6 +97,7 @@ TrackerFrame::TrackerFrame() Bind(STATE_RESET, &TrackerFrame::OnStateReset, this); Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); + Bind(REDRAW_POSITION, &TrackerFrame::OnRedrawPosition, this); wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); achievements_pane_ = new AchievementsPane(choicebook); @@ -115,13 +133,14 @@ TrackerFrame::TrackerFrame() if (GetTrackerConfig().should_check_for_updates) { CheckForUpdates(/*manual=*/false); } -} -void TrackerFrame::SetStatusMessage(std::string message) { - wxCommandEvent *event = new wxCommandEvent(STATUS_CHANGED); - event->SetString(message.c_str()); + IPC_Start(this); - QueueEvent(event); + SetStatusText(GetStatusMessage()); +} + +void TrackerFrame::UpdateStatusMessage() { + QueueEvent(new wxCommandEvent(STATUS_CHANGED)); } void TrackerFrame::ResetIndicators() { @@ -132,6 +151,10 @@ void TrackerFrame::UpdateIndicators() { QueueEvent(new wxCommandEvent(STATE_CHANGED)); } +void TrackerFrame::RedrawPosition() { + QueueEvent(new wxCommandEvent(REDRAW_POSITION)); +} + void TrackerFrame::OnAbout(wxCommandEvent &event) { wxAboutDialogInfo about_info; about_info.SetName("Lingo Archipelago Tracker"); @@ -200,7 +223,7 @@ void TrackerFrame::OnZoomIn(wxCommandEvent &event) { } } -void TrackerFrame::OnZoomOut(wxCommandEvent& event) { +void TrackerFrame::OnZoomOut(wxCommandEvent &event) { if (notebook_->GetSelection() == 1) { subway_map_->Zoom(false); } @@ -211,7 +234,7 @@ void TrackerFrame::OnChangePage(wxBookCtrlEvent &event) { zoom_out_menu_item_->Enable(event.GetSelection() == 1); } -void TrackerFrame::OnOpenFile(wxCommandEvent& event) { +void TrackerFrame::OnOpenFile(wxCommandEvent &event) { wxFileDialog open_file_dialog( this, "Open Lingo Save File", fmt::format("{}\\Godot\\app_userdata\\Lingo\\level1_stable", @@ -233,7 +256,7 @@ void TrackerFrame::OnOpenFile(wxCommandEvent& event) { panels_panel_->SetSavedataPath(savedata_path); } -void TrackerFrame::OnStateReset(wxCommandEvent& event) { +void TrackerFrame::OnStateReset(wxCommandEvent &event) { tracker_panel_->UpdateIndicators(); achievements_pane_->UpdateIndicators(); subway_map_->OnConnect(); @@ -255,7 +278,13 @@ void TrackerFrame::OnStateChanged(wxCommandEvent &event) { } void TrackerFrame::OnStatusChanged(wxCommandEvent &event) { - SetStatusText(event.GetString()); + SetStatusText(GetStatusMessage()); +} + +void TrackerFrame::OnRedrawPosition(wxCommandEvent &event) { + if (notebook_->GetSelection() == 0) { + tracker_panel_->Refresh(); + } } void TrackerFrame::CheckForUpdates(bool manual) { -- cgit 1.4.1