]> icculus.org git repositories - taylor/freespace2.git/blob - include/stand_gui.h
clean up Windows #include's and use winsock2
[taylor/freespace2.git] / include / stand_gui.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9
10 #ifndef STAND_GUI_H
11 #define STAND_GUI_H
12
13 // must come first to prevent wxWidgets from including winsock.h on Windows
14 #include <libwebsockets.h>
15
16 #include "wx/wxprec.h"
17
18 #ifndef WX_PRECOMP
19         #include "wx/wx.h"
20 #endif
21
22 #include "wx/notebook.h"
23 #include "wx/treectrl.h"
24 #include "wx/evtloop.h"
25
26 #include <list>
27 #include <vector>
28
29
30 class Standalone;
31
32 class StandaloneTimer : public wxTimer
33 {
34         private:
35                 Standalone *m_stand;
36
37         public:
38                 StandaloneTimer(Standalone *stand);
39
40                 ~StandaloneTimer();
41
42                 void Notify();
43 };
44
45 class StandPopup : public wxFrame
46 {
47         private:
48
49         protected:
50                 wxStaticText* m_Label1;
51                 wxStaticText* m_Label2;
52
53         public:
54                 StandPopup( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Popup"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxFRAME_FLOAT_ON_PARENT|wxFRAME_TOOL_WINDOW );
55
56                 ~StandPopup();
57
58                 void SetLabel1(const char *val)
59                 {
60                         m_Label1->SetLabel(val);
61                 }
62
63                 void SetLabel2(const char *val)
64                 {
65                         m_Label2->SetLabel(val);
66                 }
67 };
68
69 class Standalone : public wxDialog
70 {
71         private:
72                 void createTab_Server(wxNotebook *parent);
73                 void createTab_Multi(wxNotebook *parent);
74                 void createTab_Player(wxNotebook *parent);
75                 void createTab_GodStuff(wxNotebook *parent);
76                 void createTab_Debug(wxNotebook *parent);
77
78                 long fspid;
79                 int fsport;
80                 struct lws_context *stand_context;
81                 struct lws *wsi_standalone;
82                 struct lws_client_connect_info ccinfo;
83                 StandaloneTimer *m_timer;
84                 int m_rate_limit;
85                 std::list<std::string> send_buf;
86
87                 wxDECLARE_EVENT_TABLE();
88
89         protected:
90                 enum
91                 {
92                         ID_B_KICK = 1000,
93                         ID_B_MREFRESH,
94                         ID_B_RESET_ALL,
95                         ID_FPS_SLIDER,
96                         ID_B_SHUTDOWN,
97                         ID_T_SERVER_NAME,
98                         ID_T_HOST_PASS,
99                         ID_T_MSG,
100                         ID_C_P_PLAYERS
101                 };
102
103                 StandPopup *m_popup;
104
105                 wxTextCtrl* m_S_ServerName;
106                 wxTextCtrl* m_S_HostPass;
107                 wxStaticText* m_S_NumConn;
108                 wxTextCtrl* m_S_Connections;
109                 wxButton* m_S_btnKick;
110                 wxButton* m_S_btnMRefresh;
111                 wxButton* m_S_btnResetAll;
112
113                 wxSlider* m_M_sliderFPS;
114                 wxStaticText* m_M_FPS;
115                 wxStaticText* m_M_FPSRel;
116                 wxStaticText* m_M_MissionName;
117                 wxStaticText* m_M_MissionTime;
118                 wxStaticText* m_M_ngMaxPlayers;
119                 wxStaticText* m_M_ngMaxObservers;
120                 wxStaticText* m_M_ngSecurity;
121                 wxStaticText* m_M_ngRespawns;
122                 wxTreeCtrl* m_M_Goals;
123                 wxTreeItemId m_M_GoalItems[3];
124
125                 wxChoice* m_P_Players;
126                 wxStaticText* m_P_ShipType;
127                 wxStaticText* m_P_AvgPing;
128                 wxStaticText* m_P_atsPriShots;
129                 wxStaticText* m_P_atsPriHits;
130                 wxStaticText* m_P_atsPriBHHits;
131                 wxStaticText* m_P_atsPriHitPer;
132                 wxStaticText* m_P_atsPriBHHitPer;
133                 wxStaticText* m_P_atsSecShots;
134                 wxStaticText* m_P_atsSecHits;
135                 wxStaticText* m_P_atsSecBHHits;
136                 wxStaticText* m_P_atsSecHitPer;
137                 wxStaticText* m_P_atsSecBHHitPer;
138                 wxStaticText* m_P_atsAssists;
139                 wxStaticText* m_P_msPriShots;
140                 wxStaticText* m_P_msPriHits;
141                 wxStaticText* m_P_msPriBHHits;
142                 wxStaticText* m_P_msPriHitPer;
143                 wxStaticText* m_P_msPriBHHitPer;
144                 wxStaticText* m_P_msSecShots;
145                 wxStaticText* m_P_msSecHits;
146                 wxStaticText* m_P_msSecBHHits;
147                 wxStaticText* m_P_msSecHitPer;
148                 wxStaticText* m_P_msSecBHHitPer;
149                 wxStaticText* m_P_msAssists;
150
151                 wxChoice* m_GS_Players;
152                 wxTextCtrl* m_GS_msg;
153                 wxTextCtrl* m_GS_Messages;
154
155                 wxStaticText* m_D_State;
156
157                 void ResetAll();
158                 void Shutdown();
159
160                 void OnClose( wxCloseEvent& event );
161                 void OnShutdown( wxCommandEvent& event );
162                 void OnServerNameChange( wxCommandEvent& event );
163                 void OnHostPassChange( wxCommandEvent& event );
164                 void OnKick( wxCommandEvent& event );
165                 void OnMissionRefresh( wxCommandEvent& event );
166                 void OnResetAll( wxCommandEvent& event );
167                 void OnFPSSel( wxCommandEvent& event );
168                 void OnServerMsg( wxCommandEvent& event );
169                 void OnPinfoPlayer( wxCommandEvent& event );
170
171         public:
172
173                 Standalone( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Freespace Standalone"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxCLOSE_BOX|wxDIALOG_NO_PARENT );
174                 ~Standalone();
175
176                 bool startFreeSpace(int argc, wxCmdLineArgsArray& argv);
177
178                 bool wsInitialize();
179                 void wsDoFrame();
180                 void wsDisconnect();
181                 void wsMessage(const char *msg, size_t len);
182                 void wsSend(std::string &msg);
183
184                 std::list<std::string> &wsGetSendBuffer()
185                 {
186                         return send_buf;
187                 }
188 };
189
190 class StandaloneApp: public wxApp
191 {
192         private:
193                 Standalone *std_client;
194
195         public:
196                 virtual bool OnInit();
197
198                 StandaloneApp() : std_client(nullptr)
199                 {
200                 }
201
202                 Standalone &Client()
203                 {
204                         wxASSERT(std_client != nullptr);
205
206                         return *std_client;
207                 }
208 };
209
210
211 const char * goal_ord_xpm[] = {
212 "16 16 16 1",
213 "       c #000000",
214 ".      c #800000",
215 "+      c #008000",
216 "@      c #808000",
217 "#      c #000080",
218 "$      c #800080",
219 "%      c #008080",
220 "&      c #C0C0C0",
221 "*      c #808080",
222 "=      c #FF0000",
223 "-      c #00FF00",
224 ";      c #FFFF00",
225 ">      c #0000FF",
226 ",      c #FF00FF",
227 "'      c #00FFFF",
228 ")      c #FFFFFF",
229 ",,,,,,,,,,,,,,,,",
230 ",,,,*********,,,",
231 ",,,,*)))))))&*,,",
232 ",,,,*)))))))&)*,",
233 ",,,,*))   ))    ",
234 ",,,,*)))))))))& ",
235 ",,,,*))  )  ))& ",
236 ",,,,*)))))))))& ",
237 ",,,,*))   ) ))& ",
238 ",,,,*)))))))))& ",
239 ",,,,*)) )   ))& ",
240 ",,,,*)))))))))& ",
241 ",,,,*)))))))))& ",
242 ",,,,*&&&&&&&&&& ",
243 ",,,,            ",
244 ",,,,,,,,,,,,,,,,"};
245
246 const char * goal_none_xpm[] = {
247 "16 16 16 1",
248 "       c #000000",
249 ".      c #800000",
250 "+      c #008000",
251 "@      c #808000",
252 "#      c #000080",
253 "$      c #800080",
254 "%      c #008080",
255 "&      c #C0C0C0",
256 "*      c #808080",
257 "=      c #FF0000",
258 "-      c #00FF00",
259 ";      c #FFFF00",
260 ">      c #0000FF",
261 ",      c #FF00FF",
262 "'      c #00FFFF",
263 ")      c #FFFFFF",
264 "))))))****))))))",
265 ")))**********)))",
266 "))************))",
267 ")**************)",
268 ")**************)",
269 ")**************)",
270 "****************",
271 "****************",
272 "****************",
273 "****************",
274 ")**************)",
275 ")**************)",
276 ")**************)",
277 "))************))",
278 ")))**********)))",
279 "))))))****))))))"};
280
281 const char * goal_inc_xpm[] = {
282 "16 16 16 1",
283 "       c #000000",
284 ".      c #800000",
285 "+      c #008000",
286 "@      c #808000",
287 "#      c #000080",
288 "$      c #800080",
289 "%      c #008080",
290 "&      c #C0C0C0",
291 "*      c #808080",
292 "=      c #FF0000",
293 "-      c #00FF00",
294 ";      c #FFFF00",
295 ">      c #0000FF",
296 ",      c #FF00FF",
297 "'      c #00FFFF",
298 ")      c #FFFFFF",
299 "))))));;;;))))))",
300 ")));;;;;;;;;;)))",
301 "));;;;;;;;;;;;))",
302 ");;;;;;;;;;;;;;)",
303 ");;;;;;;;;;;;;;)",
304 ");;;;;;;;;;;;;;)",
305 ";;;;;;;;;;;;;;;;",
306 ";;;;;;;;;;;;;;;;",
307 ";;;;;;;;;;;;;;;;",
308 ";;;;;;;;;;;;;;;;",
309 ");;;;;;;;;;;;;;)",
310 ");;;;;;;;;;;;;;)",
311 ");;;;;;;;;;;;;;)",
312 "));;;;;;;;;;;;))",
313 ")));;;;;;;;;;)))",
314 "))))));;;;))))))"};
315
316 const char * goal_com_xpm[] = {
317 "16 16 16 1",
318 "       c #000000",
319 ".      c #800000",
320 "+      c #008000",
321 "@      c #808000",
322 "#      c #000080",
323 "$      c #800080",
324 "%      c #008080",
325 "&      c #C0C0C0",
326 "*      c #808080",
327 "=      c #FF0000",
328 "-      c #00FF00",
329 ";      c #FFFF00",
330 ">      c #0000FF",
331 ",      c #FF00FF",
332 "'      c #00FFFF",
333 ")      c #FFFFFF",
334 "))))))----))))))",
335 ")))----------)))",
336 "))------------))",
337 ")--------------)",
338 ")--------------)",
339 ")--------------)",
340 "----------------",
341 "----------------",
342 "----------------",
343 "----------------",
344 ")--------------)",
345 ")--------------)",
346 ")--------------)",
347 "))------------))",
348 ")))----------)))",
349 "))))))----))))))"};
350
351 const char * goal_fail_xpm[] = {
352 "16 16 16 1",
353 "       c #000000",
354 ".      c #800000",
355 "+      c #008000",
356 "@      c #808000",
357 "#      c #000080",
358 "$      c #800080",
359 "%      c #008080",
360 "&      c #C0C0C0",
361 "*      c #808080",
362 "=      c #FF0000",
363 "-      c #00FF00",
364 ";      c #FFFF00",
365 ">      c #0000FF",
366 ",      c #FF00FF",
367 "'      c #00FFFF",
368 ")      c #FFFFFF",
369 "))))))====))))))",
370 ")))==========)))",
371 "))============))",
372 ")==============)",
373 ")==============)",
374 ")==============)",
375 "================",
376 "================",
377 "================",
378 "================",
379 ")==============)",
380 ")==============)",
381 ")==============)",
382 "))============))",
383 ")))==========)))",
384 "))))))====))))))"};
385
386
387 #endif // STAND_GUI_H