about summary refs log tree commit diff stats
path: root/src/connection_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/connection_dialog.cpp')
-rw-r--r--src/connection_dialog.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/connection_dialog.cpp b/src/connection_dialog.cpp index 9dd9984..64fee98 100644 --- a/src/connection_dialog.cpp +++ b/src/connection_dialog.cpp
@@ -4,12 +4,15 @@
4 4
5ConnectionDialog::ConnectionDialog() 5ConnectionDialog::ConnectionDialog()
6 : wxDialog(nullptr, wxID_ANY, "Connect to Archipelago") { 6 : wxDialog(nullptr, wxID_ANY, "Connect to Archipelago") {
7 server_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_server, wxDefaultPosition, 7 server_box_ =
8 {300, -1}); 8 new wxTextCtrl(this, -1, GetTrackerConfig().connection_details.ap_server,
9 player_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_player, wxDefaultPosition, 9 wxDefaultPosition, {300, -1});
10 {300, -1}); 10 player_box_ =
11 password_box_ = new wxTextCtrl(this, -1, GetTrackerConfig().ap_password, 11 new wxTextCtrl(this, -1, GetTrackerConfig().connection_details.ap_player,
12 wxDefaultPosition, {300, -1}); 12 wxDefaultPosition, {300, -1});
13 password_box_ = new wxTextCtrl(
14 this, -1, GetTrackerConfig().connection_details.ap_password,
15 wxDefaultPosition, {300, -1});
13 16
14 wxFlexGridSizer* form_sizer = new wxFlexGridSizer(2, 10, 10); 17 wxFlexGridSizer* form_sizer = new wxFlexGridSizer(2, 10, 10);
15 18
@@ -26,15 +29,42 @@ ConnectionDialog::ConnectionDialog()
26 wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 29 wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
27 form_sizer->Add(password_box_, wxSizerFlags().Expand()); 30 form_sizer->Add(password_box_, wxSizerFlags().Expand());
28 31
32 history_list_ = new wxListBox(this, -1);
33 for (const ConnectionDetails& details : GetTrackerConfig().connection_history) {
34 wxString display_text;
35 display_text << details.ap_player;
36 display_text << " (";
37 display_text << details.ap_server;
38 display_text << ")";
39
40 history_list_->Append(display_text);
41 }
42
43 history_list_->Bind(wxEVT_LISTBOX, &ConnectionDialog::OnOldConnectionChosen, this);
44
45 wxBoxSizer* mid_sizer = new wxBoxSizer(wxHORIZONTAL);
46 mid_sizer->Add(form_sizer, wxSizerFlags().Proportion(3).Expand());
47 mid_sizer->AddSpacer(10);
48 mid_sizer->Add(history_list_, wxSizerFlags().Proportion(2).Expand());
49
29 wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); 50 wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
30 top_sizer->Add(new wxStaticText( 51 top_sizer->Add(new wxStaticText(
31 this, -1, "Enter the details to connect to Archipelago."), 52 this, -1, "Enter the details to connect to Archipelago."),
32 wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder()); 53 wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder());
33 top_sizer->Add(form_sizer, wxSizerFlags().DoubleBorder().Expand()); 54 top_sizer->Add(mid_sizer, wxSizerFlags().DoubleBorder().Expand());
34 top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Center()); 55 top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Border().Center());
35 56
36 SetSizerAndFit(top_sizer); 57 SetSizerAndFit(top_sizer);
37 58
38 Center(); 59 Center();
39 server_box_->SetFocus(); 60 server_box_->SetFocus();
40} 61}
62
63void ConnectionDialog::OnOldConnectionChosen(wxCommandEvent& e) {
64 if (e.IsSelection()) {
65 const ConnectionDetails& details = GetTrackerConfig().connection_history.at(e.GetSelection());
66 server_box_->SetValue(details.ap_server);
67 player_box_->SetValue(details.ap_player);
68 password_box_->SetValue(details.ap_password);
69 }
70}