#include "ipc_dialog.h" #include "tracker_config.h" constexpr const char* kDefaultIpcAddress = "ws://127.0.0.1:41253"; IpcDialog::IpcDialog() : wxDialog(nullptr, wxID_ANY, "Connect to game") { std::string address_value; if (GetTrackerConfig().ipc_address.empty()) { address_value = kDefaultIpcAddress; } else { address_value = GetTrackerConfig().ipc_address; } address_box_ = new wxTextCtrl(this, -1, address_value, wxDefaultPosition, {300, -1}); wxButton* reset_button = new wxButton(this, -1, "Use Default"); reset_button->Bind(wxEVT_BUTTON, &IpcDialog::OnResetClicked, this); wxFlexGridSizer* form_sizer = new wxFlexGridSizer(3, 10, 10); form_sizer->Add( new wxStaticText(this, -1, "Address:"), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); form_sizer->Add(address_box_, wxSizerFlags().Expand()); form_sizer->Add(reset_button); wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); wxStaticText* top_text = new wxStaticText(this, -1, ""); top_sizer->Add(top_text, wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder().Expand()); top_sizer->Add(form_sizer, wxSizerFlags().DoubleBorder().Expand()); top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Border().Center()); SetSizer(top_sizer); Layout(); Fit(); int width = top_text->GetClientSize().GetWidth(); top_text->SetLabel( "This allows you to connect to a running Lingo game and track non-multiworld " "state, such as the player's position and what panels are solved. Unless " "you are doing something weird, the default value for the address is " "probably correct."); top_text->Wrap(width); Fit(); Center(); } void IpcDialog::OnResetClicked(wxCommandEvent& event) { address_box_->SetValue(kDefaultIpcAddress); }