]> icculus.org git repositories - taylor/freespace2.git/blob - include/stand_gui.h
add more functionality and fixes to standalone GUI
[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_MSG
96                 };
97
98                 StandPopup *m_popup;
99
100                 wxTextCtrl* m_S_ServerName;
101                 wxTextCtrl* m_S_HostPass;
102                 wxStaticText* m_S_NumConn;
103                 wxTextCtrl* m_S_Connections;
104                 wxButton* m_S_btnKick;
105                 wxButton* m_S_btnMRefresh;
106                 wxButton* m_S_btnResetAll;
107
108                 wxSlider* m_M_sliderFPS;
109                 wxStaticText* m_M_FPS;
110                 wxStaticText* m_M_FPSRel;
111                 wxStaticText* m_M_MissionName;
112                 wxStaticText* m_M_MissionTime;
113                 wxStaticText* m_M_ngMaxPlayers;
114                 wxStaticText* m_M_ngMaxObservers;
115                 wxStaticText* m_M_ngSecurity;
116                 wxStaticText* m_M_ngRespawns;
117                 wxTreeCtrl* m_M_Goals;
118
119                 wxChoice* m_P_Players;
120                 wxStaticText* m_P_ShipType;
121                 wxStaticText* m_P_AvgPing;
122                 wxStaticText* m_P_atsPriShots;
123                 wxStaticText* m_P_atsPriHits;
124                 wxStaticText* m_P_atsPriBHHits;
125                 wxStaticText* m_P_atsPriHitPer;
126                 wxStaticText* m_P_atsPriBHHitPer;
127                 wxStaticText* m_P_atsSecShots;
128                 wxStaticText* m_P_atsSecHits;
129                 wxStaticText* m_P_atsSecBHHits;
130                 wxStaticText* m_P_atsSecHitPer;
131                 wxStaticText* m_P_atsSecBHHitPer;
132                 wxStaticText* m_P_atsAssists;
133                 wxStaticText* m_P_msPriShots;
134                 wxStaticText* m_P_msPriHits;
135                 wxStaticText* m_P_msPriBHHits;
136                 wxStaticText* m_P_msPriHitPer;
137                 wxStaticText* m_P_msPriBHHitPer;
138                 wxStaticText* m_P_msSecShots;
139                 wxStaticText* m_P_msSecHits;
140                 wxStaticText* m_P_msSecBHHits;
141                 wxStaticText* m_P_msSecHitPer;
142                 wxStaticText* m_P_msSecBHHitPer;
143                 wxStaticText* m_P_msAssists;
144
145                 wxChoice* m_GS_Players;
146                 wxTextCtrl* m_GS_msg;
147                 wxTextCtrl* m_GS_Messages;
148
149                 wxStaticText* m_D_State;
150
151                 void ResetAll();
152                 void Shutdown();
153
154                 void OnClose( wxCloseEvent& event );
155                 void OnShutdown( wxCommandEvent& event );
156                 void OnKick( wxCommandEvent& event );
157                 void OnMissionRefresh( wxCommandEvent& event );
158                 void OnResetAll( wxCommandEvent& event );
159                 void OnFPSSel( wxCommandEvent& event );
160                 void OnServerMsg( wxCommandEvent& event );
161
162         public:
163
164                 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 );
165                 ~Standalone();
166
167                 bool startFreeSpace(int argc, wxCmdLineArgsArray& argv);
168
169                 bool wsInitialize();
170                 void wsDoFrame();
171                 void wsDisconnect();
172                 void wsMessage(const char *msg, size_t len);
173                 void wsSend(std::string &msg);
174
175                 std::list<std::string> &wsGetSendBuffer()
176                 {
177                         return send_buf;
178                 }
179 };
180
181 class StandaloneApp: public wxApp
182 {
183         private:
184                 Standalone *std_client;
185
186         public:
187                 virtual bool OnInit();
188
189                 StandaloneApp() : std_client(nullptr)
190                 {
191                 }
192
193                 Standalone &Client()
194                 {
195                         wxASSERT(std_client != nullptr);
196
197                         return *std_client;
198                 }
199 };
200
201 #endif // STAND_GUI_H