diff options
Diffstat (limited to 'src/ipc_dialog.cpp')
| -rw-r--r-- | src/ipc_dialog.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
| diff --git a/src/ipc_dialog.cpp b/src/ipc_dialog.cpp new file mode 100644 index 0000000..6763b7f --- /dev/null +++ b/src/ipc_dialog.cpp | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | #include "ipc_dialog.h" | ||
| 2 | |||
| 3 | #include "tracker_config.h" | ||
| 4 | |||
| 5 | constexpr const char* kDefaultIpcAddress = "ws://127.0.0.1:41253"; | ||
| 6 | |||
| 7 | IpcDialog::IpcDialog() : wxDialog(nullptr, wxID_ANY, "Connect to game") { | ||
| 8 | std::string address_value; | ||
| 9 | if (GetTrackerConfig().ipc_address.empty()) { | ||
| 10 | address_value = kDefaultIpcAddress; | ||
| 11 | } else { | ||
| 12 | address_value = GetTrackerConfig().ipc_address; | ||
| 13 | } | ||
| 14 | |||
| 15 | address_box_ = new wxTextCtrl(this, -1, wxString::FromUTF8(address_value), | ||
| 16 | wxDefaultPosition, FromDIP(wxSize{300, -1})); | ||
| 17 | |||
| 18 | wxButton* reset_button = new wxButton(this, -1, "Use Default"); | ||
| 19 | reset_button->Bind(wxEVT_BUTTON, &IpcDialog::OnResetClicked, this); | ||
| 20 | |||
| 21 | wxFlexGridSizer* form_sizer = | ||
| 22 | new wxFlexGridSizer(3, FromDIP(10), FromDIP(10)); | ||
| 23 | form_sizer->Add( | ||
| 24 | new wxStaticText(this, -1, "Address:"), | ||
| 25 | wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | ||
| 26 | form_sizer->Add(address_box_, wxSizerFlags().Expand()); | ||
| 27 | form_sizer->Add(reset_button); | ||
| 28 | |||
| 29 | wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); | ||
| 30 | wxStaticText* top_text = new wxStaticText(this, -1, ""); | ||
| 31 | top_sizer->Add(top_text, wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder().Expand()); | ||
| 32 | top_sizer->Add(form_sizer, wxSizerFlags().DoubleBorder().Expand()); | ||
| 33 | top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), | ||
| 34 | wxSizerFlags().Border().Center()); | ||
| 35 | |||
| 36 | SetSizer(top_sizer); | ||
| 37 | Layout(); | ||
| 38 | Fit(); | ||
| 39 | |||
| 40 | int width = top_text->GetClientSize().GetWidth(); | ||
| 41 | top_text->SetLabel( | ||
| 42 | "This allows you to connect to a running Lingo game and track non-multiworld " | ||
| 43 | "state, such as the player's position and what panels are solved. Unless " | ||
| 44 | "you are doing something weird, the default value for the address is " | ||
| 45 | "probably correct."); | ||
| 46 | top_text->Wrap(width); | ||
| 47 | |||
| 48 | Fit(); | ||
| 49 | Center(); | ||
| 50 | } | ||
| 51 | |||
| 52 | void IpcDialog::OnResetClicked(wxCommandEvent& event) { | ||
| 53 | address_box_->SetValue(kDefaultIpcAddress); | ||
| 54 | } | ||
