From d0029a806b8b6d244a6a3ec5b243303a8203cdd5 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 7 Mar 2024 10:31:22 -0500 Subject: Added connection history --- src/tracker_frame.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/tracker_frame.cpp') diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index a8c1063..d64e0d3 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp @@ -115,9 +115,24 @@ void TrackerFrame::OnConnect(wxCommandEvent &event) { ConnectionDialog dlg; if (dlg.ShowModal() == wxID_OK) { - GetTrackerConfig().ap_server = dlg.GetServerValue(); - GetTrackerConfig().ap_player = dlg.GetPlayerValue(); - GetTrackerConfig().ap_password = dlg.GetPasswordValue(); + GetTrackerConfig().connection_details.ap_server = dlg.GetServerValue(); + GetTrackerConfig().connection_details.ap_player = dlg.GetPlayerValue(); + GetTrackerConfig().connection_details.ap_password = dlg.GetPasswordValue(); + + std::deque new_history; + new_history.push_back(GetTrackerConfig().connection_details); + + for (const ConnectionDetails& details : GetTrackerConfig().connection_history) { + if (details != GetTrackerConfig().connection_details) { + new_history.push_back(details); + } + } + + while (new_history.size() > 5) { + new_history.pop_back(); + } + + GetTrackerConfig().connection_history = std::move(new_history); GetTrackerConfig().Save(); AP_Connect(dlg.GetServerValue(), dlg.GetPlayerValue(), -- cgit 1.4.1