about summary refs log tree commit diff stats
path: root/src/ipc_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipc_dialog.cpp')
-rw-r--r--src/ipc_dialog.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/ipc_dialog.cpp b/src/ipc_dialog.cpp new file mode 100644 index 0000000..f17c2d8 --- /dev/null +++ b/src/ipc_dialog.cpp
@@ -0,0 +1,53 @@
1#include "ipc_dialog.h"
2
3#include "tracker_config.h"
4
5constexpr const char* kDefaultIpcAddress = "ws://127.0.0.1:41253";
6
7IpcDialog::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_ =
16 new wxTextCtrl(this, -1, address_value, wxDefaultPosition, {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 = new wxFlexGridSizer(3, 10, 10);
22 form_sizer->Add(
23 new wxStaticText(this, -1, "Address:"),
24 wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
25 form_sizer->Add(address_box_, wxSizerFlags().Expand());
26 form_sizer->Add(reset_button);
27
28 wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
29 wxStaticText* top_text = new wxStaticText(this, -1, "");
30 top_sizer->Add(top_text, wxSizerFlags().Align(wxALIGN_LEFT).DoubleBorder().Expand());
31 top_sizer->Add(form_sizer, wxSizerFlags().DoubleBorder().Expand());
32 top_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL),
33 wxSizerFlags().Border().Center());
34
35 SetSizer(top_sizer);
36 Layout();
37 Fit();
38
39 int width = top_text->GetClientSize().GetWidth();
40 top_text->SetLabel(
41 "This allows you to connect to a running Lingo game and track non-multiworld "
42 "state, such as the player's position and what panels are solved. Unless "
43 "you are doing something weird, the default value for the address is "
44 "probably correct.");
45 top_text->Wrap(width);
46
47 Fit();
48 Center();
49}
50
51void IpcDialog::OnResetClicked(wxCommandEvent& event) {
52 address_box_->SetValue(kDefaultIpcAddress);
53}