]> icculus.org git repositories - taylor/freespace2.git/blob - include/stand_gui.h
fix issue with looping audio streams
[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|wxCAPTION|wxFRAME_NO_TASKBAR );
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                 virtual void OnInitCmdLine(wxCmdLineParser& parser);
198                 virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
199
200                 StandaloneApp() : std_client(nullptr)
201                 {
202                 }
203
204                 Standalone &Client()
205                 {
206                         wxASSERT(std_client != nullptr);
207
208                         return *std_client;
209                 }
210 };
211
212
213 const char * goal_ord_xpm[] = {
214 "16 16 16 1",
215 "       c #000000",
216 ".      c #800000",
217 "+      c #008000",
218 "@      c #808000",
219 "#      c #000080",
220 "$      c #800080",
221 "%      c #008080",
222 "&      c #C0C0C0",
223 "*      c #808080",
224 "=      c #FF0000",
225 "-      c #00FF00",
226 ";      c #FFFF00",
227 ">      c #0000FF",
228 ",      c #FF00FF",
229 "'      c #00FFFF",
230 ")      c #FFFFFF",
231 ",,,,,,,,,,,,,,,,",
232 ",,,,*********,,,",
233 ",,,,*)))))))&*,,",
234 ",,,,*)))))))&)*,",
235 ",,,,*))   ))    ",
236 ",,,,*)))))))))& ",
237 ",,,,*))  )  ))& ",
238 ",,,,*)))))))))& ",
239 ",,,,*))   ) ))& ",
240 ",,,,*)))))))))& ",
241 ",,,,*)) )   ))& ",
242 ",,,,*)))))))))& ",
243 ",,,,*)))))))))& ",
244 ",,,,*&&&&&&&&&& ",
245 ",,,,            ",
246 ",,,,,,,,,,,,,,,,"};
247
248 const char * goal_none_xpm[] = {
249 "16 16 16 1",
250 "       c #000000",
251 ".      c #800000",
252 "+      c #008000",
253 "@      c #808000",
254 "#      c #000080",
255 "$      c #800080",
256 "%      c #008080",
257 "&      c #C0C0C0",
258 "*      c #808080",
259 "=      c #FF0000",
260 "-      c #00FF00",
261 ";      c #FFFF00",
262 ">      c #0000FF",
263 ",      c #FF00FF",
264 "'      c #00FFFF",
265 ")      c #FFFFFF",
266 "))))))****))))))",
267 ")))**********)))",
268 "))************))",
269 ")**************)",
270 ")**************)",
271 ")**************)",
272 "****************",
273 "****************",
274 "****************",
275 "****************",
276 ")**************)",
277 ")**************)",
278 ")**************)",
279 "))************))",
280 ")))**********)))",
281 "))))))****))))))"};
282
283 const char * goal_inc_xpm[] = {
284 "16 16 16 1",
285 "       c #000000",
286 ".      c #800000",
287 "+      c #008000",
288 "@      c #808000",
289 "#      c #000080",
290 "$      c #800080",
291 "%      c #008080",
292 "&      c #C0C0C0",
293 "*      c #808080",
294 "=      c #FF0000",
295 "-      c #00FF00",
296 ";      c #FFFF00",
297 ">      c #0000FF",
298 ",      c #FF00FF",
299 "'      c #00FFFF",
300 ")      c #FFFFFF",
301 "))))));;;;))))))",
302 ")));;;;;;;;;;)))",
303 "));;;;;;;;;;;;))",
304 ");;;;;;;;;;;;;;)",
305 ");;;;;;;;;;;;;;)",
306 ");;;;;;;;;;;;;;)",
307 ";;;;;;;;;;;;;;;;",
308 ";;;;;;;;;;;;;;;;",
309 ";;;;;;;;;;;;;;;;",
310 ";;;;;;;;;;;;;;;;",
311 ");;;;;;;;;;;;;;)",
312 ");;;;;;;;;;;;;;)",
313 ");;;;;;;;;;;;;;)",
314 "));;;;;;;;;;;;))",
315 ")));;;;;;;;;;)))",
316 "))))));;;;))))))"};
317
318 const char * goal_com_xpm[] = {
319 "16 16 16 1",
320 "       c #000000",
321 ".      c #800000",
322 "+      c #008000",
323 "@      c #808000",
324 "#      c #000080",
325 "$      c #800080",
326 "%      c #008080",
327 "&      c #C0C0C0",
328 "*      c #808080",
329 "=      c #FF0000",
330 "-      c #00FF00",
331 ";      c #FFFF00",
332 ">      c #0000FF",
333 ",      c #FF00FF",
334 "'      c #00FFFF",
335 ")      c #FFFFFF",
336 "))))))----))))))",
337 ")))----------)))",
338 "))------------))",
339 ")--------------)",
340 ")--------------)",
341 ")--------------)",
342 "----------------",
343 "----------------",
344 "----------------",
345 "----------------",
346 ")--------------)",
347 ")--------------)",
348 ")--------------)",
349 "))------------))",
350 ")))----------)))",
351 "))))))----))))))"};
352
353 const char * goal_fail_xpm[] = {
354 "16 16 16 1",
355 "       c #000000",
356 ".      c #800000",
357 "+      c #008000",
358 "@      c #808000",
359 "#      c #000080",
360 "$      c #800080",
361 "%      c #008080",
362 "&      c #C0C0C0",
363 "*      c #808080",
364 "=      c #FF0000",
365 "-      c #00FF00",
366 ";      c #FFFF00",
367 ">      c #0000FF",
368 ",      c #FF00FF",
369 "'      c #00FFFF",
370 ")      c #FFFFFF",
371 "))))))====))))))",
372 ")))==========)))",
373 "))============))",
374 ")==============)",
375 ")==============)",
376 ")==============)",
377 "================",
378 "================",
379 "================",
380 "================",
381 ")==============)",
382 ")==============)",
383 ")==============)",
384 "))============))",
385 ")))==========)))",
386 "))))))====))))))"};
387
388
389 #endif // STAND_GUI_H