about summary refs log tree commit diff stats
path: root/src/tracker_frame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tracker_frame.cpp')
-rw-r--r--src/tracker_frame.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index d0fd5a6..587d87b 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp
@@ -14,6 +14,7 @@
14#include "achievements_pane.h" 14#include "achievements_pane.h"
15#include "ap_state.h" 15#include "ap_state.h"
16#include "connection_dialog.h" 16#include "connection_dialog.h"
17#include "ipc_dialog.h"
17#include "ipc_state.h" 18#include "ipc_state.h"
18#include "settings_dialog.h" 19#include "settings_dialog.h"
19#include "subway_map.h" 20#include "subway_map.h"
@@ -38,18 +39,20 @@ std::string GetStatusMessage() {
38} // namespace 39} // namespace
39 40
40enum TrackerFrameIds { 41enum TrackerFrameIds {
41 ID_CONNECT = 1, 42 ID_AP_CONNECT = 1,
42 ID_CHECK_FOR_UPDATES = 2, 43 ID_CHECK_FOR_UPDATES = 2,
43 ID_SETTINGS = 3, 44 ID_SETTINGS = 3,
44 ID_ZOOM_IN = 4, 45 ID_ZOOM_IN = 4,
45 ID_ZOOM_OUT = 5, 46 ID_ZOOM_OUT = 5,
46 ID_OPEN_SAVE_FILE = 6, 47 ID_OPEN_SAVE_FILE = 6,
48 ID_IPC_CONNECT = 7,
47}; 49};
48 50
49wxDEFINE_EVENT(STATE_RESET, wxCommandEvent); 51wxDEFINE_EVENT(STATE_RESET, wxCommandEvent);
50wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); 52wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent);
51wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); 53wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent);
52wxDEFINE_EVENT(REDRAW_POSITION, wxCommandEvent); 54wxDEFINE_EVENT(REDRAW_POSITION, wxCommandEvent);
55wxDEFINE_EVENT(CONNECT_TO_AP, ApConnectEvent);
53 56
54TrackerFrame::TrackerFrame() 57TrackerFrame::TrackerFrame()
55 : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker", wxDefaultPosition, 58 : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker", wxDefaultPosition,
@@ -57,9 +60,11 @@ TrackerFrame::TrackerFrame()
57 ::wxInitAllImageHandlers(); 60 ::wxInitAllImageHandlers();
58 61
59 AP_SetTrackerFrame(this); 62 AP_SetTrackerFrame(this);
63 IPC_SetTrackerFrame(this);
60 64
61 wxMenu *menuFile = new wxMenu(); 65 wxMenu *menuFile = new wxMenu();
62 menuFile->Append(ID_CONNECT, "&Connect"); 66 menuFile->Append(ID_AP_CONNECT, "&Connect to Archipelago");
67 menuFile->Append(ID_IPC_CONNECT, "&Connect to Lingo");
63 menuFile->Append(ID_OPEN_SAVE_FILE, "&Open Save Data\tCtrl-O"); 68 menuFile->Append(ID_OPEN_SAVE_FILE, "&Open Save Data\tCtrl-O");
64 menuFile->Append(ID_SETTINGS, "&Settings"); 69 menuFile->Append(ID_SETTINGS, "&Settings");
65 menuFile->Append(wxID_EXIT); 70 menuFile->Append(wxID_EXIT);
@@ -86,7 +91,8 @@ TrackerFrame::TrackerFrame()
86 91
87 Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT); 92 Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT);
88 Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT); 93 Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT);
89 Bind(wxEVT_MENU, &TrackerFrame::OnConnect, this, ID_CONNECT); 94 Bind(wxEVT_MENU, &TrackerFrame::OnApConnect, this, ID_AP_CONNECT);
95 Bind(wxEVT_MENU, &TrackerFrame::OnIpcConnect, this, ID_IPC_CONNECT);
90 Bind(wxEVT_MENU, &TrackerFrame::OnSettings, this, ID_SETTINGS); 96 Bind(wxEVT_MENU, &TrackerFrame::OnSettings, this, ID_SETTINGS);
91 Bind(wxEVT_MENU, &TrackerFrame::OnCheckForUpdates, this, 97 Bind(wxEVT_MENU, &TrackerFrame::OnCheckForUpdates, this,
92 ID_CHECK_FOR_UPDATES); 98 ID_CHECK_FOR_UPDATES);
@@ -98,6 +104,7 @@ TrackerFrame::TrackerFrame()
98 Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); 104 Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this);
99 Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this); 105 Bind(STATUS_CHANGED, &TrackerFrame::OnStatusChanged, this);
100 Bind(REDRAW_POSITION, &TrackerFrame::OnRedrawPosition, this); 106 Bind(REDRAW_POSITION, &TrackerFrame::OnRedrawPosition, this);
107 Bind(CONNECT_TO_AP, &TrackerFrame::OnConnectToAp, this);
101 108
102 wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY); 109 wxChoicebook *choicebook = new wxChoicebook(this, wxID_ANY);
103 achievements_pane_ = new AchievementsPane(choicebook); 110 achievements_pane_ = new AchievementsPane(choicebook);
@@ -134,11 +141,15 @@ TrackerFrame::TrackerFrame()
134 CheckForUpdates(/*manual=*/false); 141 CheckForUpdates(/*manual=*/false);
135 } 142 }
136 143
137 IPC_Start(this);
138
139 SetStatusText(GetStatusMessage()); 144 SetStatusText(GetStatusMessage());
140} 145}
141 146
147void TrackerFrame::ConnectToAp(std::string server, std::string user,
148 std::string pass) {
149 QueueEvent(new ApConnectEvent(CONNECT_TO_AP, GetId(), std::move(server),
150 std::move(user), std::move(pass)));
151}
152
142void TrackerFrame::UpdateStatusMessage() { 153void TrackerFrame::UpdateStatusMessage() {
143 QueueEvent(new wxCommandEvent(STATUS_CHANGED)); 154 QueueEvent(new wxCommandEvent(STATUS_CHANGED));
144} 155}
@@ -172,7 +183,7 @@ void TrackerFrame::OnAbout(wxCommandEvent &event) {
172 183
173void TrackerFrame::OnExit(wxCommandEvent &event) { Close(true); } 184void TrackerFrame::OnExit(wxCommandEvent &event) { Close(true); }
174 185
175void TrackerFrame::OnConnect(wxCommandEvent &event) { 186void TrackerFrame::OnApConnect(wxCommandEvent &event) {
176 ConnectionDialog dlg; 187 ConnectionDialog dlg;
177 188
178 if (dlg.ShowModal() == wxID_OK) { 189 if (dlg.ShowModal() == wxID_OK) {
@@ -202,6 +213,17 @@ void TrackerFrame::OnConnect(wxCommandEvent &event) {
202 } 213 }
203} 214}
204 215
216void TrackerFrame::OnIpcConnect(wxCommandEvent &event) {
217 IpcDialog dlg;
218
219 if (dlg.ShowModal() == wxID_OK) {
220 GetTrackerConfig().ipc_address = dlg.GetIpcAddress();
221 GetTrackerConfig().Save();
222
223 IPC_Connect(dlg.GetIpcAddress());
224 }
225}
226
205void TrackerFrame::OnSettings(wxCommandEvent &event) { 227void TrackerFrame::OnSettings(wxCommandEvent &event) {
206 SettingsDialog dlg; 228 SettingsDialog dlg;
207 229
@@ -306,6 +328,10 @@ void TrackerFrame::OnRedrawPosition(wxCommandEvent &event) {
306 } 328 }
307} 329}
308 330
331void TrackerFrame::OnConnectToAp(ApConnectEvent &event) {
332 AP_Connect(event.GetServer(), event.GetUser(), event.GetPass());
333}
334
309void TrackerFrame::CheckForUpdates(bool manual) { 335void TrackerFrame::CheckForUpdates(bool manual) {
310 wxWebRequest request = wxWebSession::GetDefault().CreateRequest( 336 wxWebRequest request = wxWebSession::GetDefault().CreateRequest(
311 this, "https://code.fourisland.com/lingo-ap-tracker/plain/VERSION"); 337 this, "https://code.fourisland.com/lingo-ap-tracker/plain/VERSION");