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