diff options
Diffstat (limited to 'src/connection_dialog.cpp')
| -rw-r--r-- | src/connection_dialog.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
| diff --git a/src/connection_dialog.cpp b/src/connection_dialog.cpp index 64fee98..b55a138 100644 --- a/src/connection_dialog.cpp +++ b/src/connection_dialog.cpp | |||
| @@ -4,17 +4,21 @@ | |||
| 4 | 4 | ||
| 5 | ConnectionDialog::ConnectionDialog() | 5 | ConnectionDialog::ConnectionDialog() |
| 6 | : wxDialog(nullptr, wxID_ANY, "Connect to Archipelago") { | 6 | : wxDialog(nullptr, wxID_ANY, "Connect to Archipelago") { |
| 7 | server_box_ = | 7 | server_box_ = new wxTextCtrl( |
| 8 | new wxTextCtrl(this, -1, GetTrackerConfig().connection_details.ap_server, | 8 | this, -1, |
| 9 | wxDefaultPosition, {300, -1}); | 9 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_server), |
| 10 | player_box_ = | 10 | wxDefaultPosition, FromDIP(wxSize{300, -1})); |
| 11 | new wxTextCtrl(this, -1, GetTrackerConfig().connection_details.ap_player, | 11 | player_box_ = new wxTextCtrl( |
| 12 | wxDefaultPosition, {300, -1}); | 12 | this, -1, |
| 13 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_player), | ||
| 14 | wxDefaultPosition, FromDIP(wxSize{300, -1})); | ||
| 13 | password_box_ = new wxTextCtrl( | 15 | password_box_ = new wxTextCtrl( |
| 14 | this, -1, GetTrackerConfig().connection_details.ap_password, | 16 | this, -1, |
| 15 | wxDefaultPosition, {300, -1}); | 17 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_password), |
| 18 | wxDefaultPosition, FromDIP(wxSize{300, -1})); | ||
| 16 | 19 | ||
| 17 | wxFlexGridSizer* form_sizer = new wxFlexGridSizer(2, 10, 10); | 20 | wxFlexGridSizer* form_sizer = |
| 21 | new wxFlexGridSizer(2, FromDIP(10), FromDIP(10)); | ||
| 18 | 22 | ||
| 19 | form_sizer->Add( | 23 | form_sizer->Add( |
| 20 | new wxStaticText(this, -1, "Server:"), | 24 | new wxStaticText(this, -1, "Server:"), |
| @@ -30,17 +34,19 @@ ConnectionDialog::ConnectionDialog() | |||
| 30 | form_sizer->Add(password_box_, wxSizerFlags().Expand()); | 34 | form_sizer->Add(password_box_, wxSizerFlags().Expand()); |
| 31 | 35 | ||
| 32 | history_list_ = new wxListBox(this, -1); | 36 | history_list_ = new wxListBox(this, -1); |
| 33 | for (const ConnectionDetails& details : GetTrackerConfig().connection_history) { | 37 | for (const ConnectionDetails& details : |
| 38 | GetTrackerConfig().connection_history) { | ||
| 34 | wxString display_text; | 39 | wxString display_text; |
| 35 | display_text << details.ap_player; | 40 | display_text << wxString::FromUTF8(details.ap_player); |
| 36 | display_text << " ("; | 41 | display_text << " ("; |
| 37 | display_text << details.ap_server; | 42 | display_text << wxString::FromUTF8(details.ap_server); |
| 38 | display_text << ")"; | 43 | display_text << ")"; |
| 39 | 44 | ||
| 40 | history_list_->Append(display_text); | 45 | history_list_->Append(display_text); |
| 41 | } | 46 | } |
| 42 | 47 | ||
| 43 | history_list_->Bind(wxEVT_LISTBOX, &ConnectionDialog::OnOldConnectionChosen, this); | 48 | history_list_->Bind(wxEVT_LISTBOX, &ConnectionDialog::OnOldConnectionChosen, |
| 49 | this); | ||
| 44 | 50 | ||
| 45 | wxBoxSizer* mid_sizer = new wxBoxSizer(wxHORIZONTAL); | 51 | wxBoxSizer* mid_sizer = new wxBoxSizer(wxHORIZONTAL); |
| 46 | mid_sizer->Add(form_sizer, wxSizerFlags().Proportion(3).Expand()); | 52 | mid_sizer->Add(form_sizer, wxSizerFlags().Proportion(3).Expand()); |
| @@ -52,7 +58,8 @@ ConnectionDialog::ConnectionDialog() | |||
| 52 | this, -1, "Enter the details to connect to Archipelago."), | 58 | this, -1, "Enter the details to connect to Archipelago."), |
| 53 | wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder()); | 59 | wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder()); |
| 54 | top_sizer->Add(mid_sizer, wxSizerFlags().DoubleBorder().Expand()); | 60 | top_sizer->Add(mid_sizer, wxSizerFlags().DoubleBorder().Expand()); |
| 55 | top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Border().Center()); | 61 | top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), |
| 62 | wxSizerFlags().Border().Center()); | ||
| 56 | 63 | ||
| 57 | SetSizerAndFit(top_sizer); | 64 | SetSizerAndFit(top_sizer); |
| 58 | 65 | ||
| @@ -62,9 +69,10 @@ ConnectionDialog::ConnectionDialog() | |||
| 62 | 69 | ||
| 63 | void ConnectionDialog::OnOldConnectionChosen(wxCommandEvent& e) { | 70 | void ConnectionDialog::OnOldConnectionChosen(wxCommandEvent& e) { |
| 64 | if (e.IsSelection()) { | 71 | if (e.IsSelection()) { |
| 65 | const ConnectionDetails& details = GetTrackerConfig().connection_history.at(e.GetSelection()); | 72 | const ConnectionDetails& details = |
| 66 | server_box_->SetValue(details.ap_server); | 73 | GetTrackerConfig().connection_history.at(e.GetSelection()); |
| 67 | player_box_->SetValue(details.ap_player); | 74 | server_box_->SetValue(wxString::FromUTF8(details.ap_server)); |
| 68 | password_box_->SetValue(details.ap_password); | 75 | player_box_->SetValue(wxString::FromUTF8(details.ap_player)); |
| 76 | password_box_->SetValue(wxString::FromUTF8(details.ap_password)); | ||
| 69 | } | 77 | } |
| 70 | } | 78 | } |
