diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-03 11:20:59 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-03 11:20:59 -0500 |
| commit | 6d6f5dbf8c8e39aa0cf641a932d4da12200160fe (patch) | |
| tree | 7ce1551c0c80d83af36b48ddf18274232514370f /src | |
| parent | 969919119acd83320c4deb621a60ce6f36ff9583 (diff) | |
| download | lingo-ap-tracker-6d6f5dbf8c8e39aa0cf641a932d4da12200160fe.tar.gz lingo-ap-tracker-6d6f5dbf8c8e39aa0cf641a932d4da12200160fe.tar.bz2 lingo-ap-tracker-6d6f5dbf8c8e39aa0cf641a932d4da12200160fe.zip | |
Handle unicode conversion between wx and rest of app
Diffstat (limited to 'src')
| -rw-r--r-- | src/connection_dialog.cpp | 39 | ||||
| -rw-r--r-- | src/connection_dialog.h | 6 | ||||
| -rw-r--r-- | src/ipc_dialog.cpp | 4 | ||||
| -rw-r--r-- | src/ipc_dialog.h | 2 | ||||
| -rw-r--r-- | src/tracker_frame.cpp | 2 |
5 files changed, 30 insertions, 23 deletions
| diff --git a/src/connection_dialog.cpp b/src/connection_dialog.cpp index 64fee98..45a5b53 100644 --- a/src/connection_dialog.cpp +++ b/src/connection_dialog.cpp | |||
| @@ -4,14 +4,17 @@ | |||
| 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, {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, {300, -1}); | ||
| 13 | password_box_ = new wxTextCtrl( | 15 | password_box_ = new wxTextCtrl( |
| 14 | this, -1, GetTrackerConfig().connection_details.ap_password, | 16 | this, -1, |
| 17 | wxString::FromUTF8(GetTrackerConfig().connection_details.ap_password), | ||
| 15 | wxDefaultPosition, {300, -1}); | 18 | wxDefaultPosition, {300, -1}); |
| 16 | 19 | ||
| 17 | wxFlexGridSizer* form_sizer = new wxFlexGridSizer(2, 10, 10); | 20 | wxFlexGridSizer* form_sizer = new wxFlexGridSizer(2, 10, 10); |
| @@ -30,17 +33,19 @@ ConnectionDialog::ConnectionDialog() | |||
| 30 | form_sizer->Add(password_box_, wxSizerFlags().Expand()); | 33 | form_sizer->Add(password_box_, wxSizerFlags().Expand()); |
| 31 | 34 | ||
| 32 | history_list_ = new wxListBox(this, -1); | 35 | history_list_ = new wxListBox(this, -1); |
| 33 | for (const ConnectionDetails& details : GetTrackerConfig().connection_history) { | 36 | for (const ConnectionDetails& details : |
| 37 | GetTrackerConfig().connection_history) { | ||
| 34 | wxString display_text; | 38 | wxString display_text; |
| 35 | display_text << details.ap_player; | 39 | display_text << wxString::FromUTF8(details.ap_player); |
| 36 | display_text << " ("; | 40 | display_text << " ("; |
| 37 | display_text << details.ap_server; | 41 | display_text << wxString::FromUTF8(details.ap_server); |
| 38 | display_text << ")"; | 42 | display_text << ")"; |
| 39 | 43 | ||
| 40 | history_list_->Append(display_text); | 44 | history_list_->Append(display_text); |
| 41 | } | 45 | } |
| 42 | 46 | ||
| 43 | history_list_->Bind(wxEVT_LISTBOX, &ConnectionDialog::OnOldConnectionChosen, this); | 47 | history_list_->Bind(wxEVT_LISTBOX, &ConnectionDialog::OnOldConnectionChosen, |
| 48 | this); | ||
| 44 | 49 | ||
| 45 | wxBoxSizer* mid_sizer = new wxBoxSizer(wxHORIZONTAL); | 50 | wxBoxSizer* mid_sizer = new wxBoxSizer(wxHORIZONTAL); |
| 46 | mid_sizer->Add(form_sizer, wxSizerFlags().Proportion(3).Expand()); | 51 | mid_sizer->Add(form_sizer, wxSizerFlags().Proportion(3).Expand()); |
| @@ -52,7 +57,8 @@ ConnectionDialog::ConnectionDialog() | |||
| 52 | this, -1, "Enter the details to connect to Archipelago."), | 57 | this, -1, "Enter the details to connect to Archipelago."), |
| 53 | wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder()); | 58 | wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder()); |
| 54 | top_sizer->Add(mid_sizer, wxSizerFlags().DoubleBorder().Expand()); | 59 | top_sizer->Add(mid_sizer, wxSizerFlags().DoubleBorder().Expand()); |
| 55 | top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Border().Center()); | 60 | top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), |
| 61 | wxSizerFlags().Border().Center()); | ||
| 56 | 62 | ||
| 57 | SetSizerAndFit(top_sizer); | 63 | SetSizerAndFit(top_sizer); |
| 58 | 64 | ||
| @@ -62,9 +68,10 @@ ConnectionDialog::ConnectionDialog() | |||
| 62 | 68 | ||
| 63 | void ConnectionDialog::OnOldConnectionChosen(wxCommandEvent& e) { | 69 | void ConnectionDialog::OnOldConnectionChosen(wxCommandEvent& e) { |
| 64 | if (e.IsSelection()) { | 70 | if (e.IsSelection()) { |
| 65 | const ConnectionDetails& details = GetTrackerConfig().connection_history.at(e.GetSelection()); | 71 | const ConnectionDetails& details = |
| 66 | server_box_->SetValue(details.ap_server); | 72 | GetTrackerConfig().connection_history.at(e.GetSelection()); |
| 67 | player_box_->SetValue(details.ap_player); | 73 | server_box_->SetValue(wxString::FromUTF8(details.ap_server)); |
| 68 | password_box_->SetValue(details.ap_password); | 74 | player_box_->SetValue(wxString::FromUTF8(details.ap_player)); |
| 75 | password_box_->SetValue(wxString::FromUTF8(details.ap_password)); | ||
| 69 | } | 76 | } |
| 70 | } | 77 | } |
| diff --git a/src/connection_dialog.h b/src/connection_dialog.h index 9fe62fd..ec2ee72 100644 --- a/src/connection_dialog.h +++ b/src/connection_dialog.h | |||
| @@ -14,12 +14,12 @@ class ConnectionDialog : public wxDialog { | |||
| 14 | public: | 14 | public: |
| 15 | ConnectionDialog(); | 15 | ConnectionDialog(); |
| 16 | 16 | ||
| 17 | std::string GetServerValue() { return server_box_->GetValue().ToStdString(); } | 17 | std::string GetServerValue() { return server_box_->GetValue().utf8_string(); } |
| 18 | 18 | ||
| 19 | std::string GetPlayerValue() { return player_box_->GetValue().ToStdString(); } | 19 | std::string GetPlayerValue() { return player_box_->GetValue().utf8_string(); } |
| 20 | 20 | ||
| 21 | std::string GetPasswordValue() { | 21 | std::string GetPasswordValue() { |
| 22 | return password_box_->GetValue().ToStdString(); | 22 | return password_box_->GetValue().utf8_string(); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | private: | 25 | private: |
| diff --git a/src/ipc_dialog.cpp b/src/ipc_dialog.cpp index f17c2d8..1e09a2f 100644 --- a/src/ipc_dialog.cpp +++ b/src/ipc_dialog.cpp | |||
| @@ -12,8 +12,8 @@ IpcDialog::IpcDialog() : wxDialog(nullptr, wxID_ANY, "Connect to game") { | |||
| 12 | address_value = GetTrackerConfig().ipc_address; | 12 | address_value = GetTrackerConfig().ipc_address; |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | address_box_ = | 15 | address_box_ = new wxTextCtrl(this, -1, wxString::FromUTF8(address_value), |
| 16 | new wxTextCtrl(this, -1, address_value, wxDefaultPosition, {300, -1}); | 16 | wxDefaultPosition, {300, -1}); |
| 17 | 17 | ||
| 18 | wxButton* reset_button = new wxButton(this, -1, "Use Default"); | 18 | wxButton* reset_button = new wxButton(this, -1, "Use Default"); |
| 19 | reset_button->Bind(wxEVT_BUTTON, &IpcDialog::OnResetClicked, this); | 19 | reset_button->Bind(wxEVT_BUTTON, &IpcDialog::OnResetClicked, this); |
| diff --git a/src/ipc_dialog.h b/src/ipc_dialog.h index 1caed01..a8c4512 100644 --- a/src/ipc_dialog.h +++ b/src/ipc_dialog.h | |||
| @@ -13,7 +13,7 @@ class IpcDialog : public wxDialog { | |||
| 13 | public: | 13 | public: |
| 14 | IpcDialog(); | 14 | IpcDialog(); |
| 15 | 15 | ||
| 16 | std::string GetIpcAddress() { return address_box_->GetValue().ToStdString(); } | 16 | std::string GetIpcAddress() { return address_box_->GetValue().utf8_string(); } |
| 17 | 17 | ||
| 18 | private: | 18 | private: |
| 19 | void OnResetClicked(wxCommandEvent& event); | 19 | void OnResetClicked(wxCommandEvent& event); |
| diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index 587d87b..bacef34 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp | |||
| @@ -317,7 +317,7 @@ void TrackerFrame::OnStateChanged(wxCommandEvent &event) { | |||
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | void TrackerFrame::OnStatusChanged(wxCommandEvent &event) { | 319 | void TrackerFrame::OnStatusChanged(wxCommandEvent &event) { |
| 320 | SetStatusText(GetStatusMessage()); | 320 | SetStatusText(wxString::FromUTF8(GetStatusMessage())); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | void TrackerFrame::OnRedrawPosition(wxCommandEvent &event) { | 323 | void TrackerFrame::OnRedrawPosition(wxCommandEvent &event) { |
