]> icculus.org git repositories - taylor/freespace2.git/blob - include/stand_gui.h
handle player info and player selection
[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
122                 wxChoice* m_P_Players;
123                 wxStaticText* m_P_ShipType;
124                 wxStaticText* m_P_AvgPing;
125                 wxStaticText* m_P_atsPriShots;
126                 wxStaticText* m_P_atsPriHits;
127                 wxStaticText* m_P_atsPriBHHits;
128                 wxStaticText* m_P_atsPriHitPer;
129                 wxStaticText* m_P_atsPriBHHitPer;
130                 wxStaticText* m_P_atsSecShots;
131                 wxStaticText* m_P_atsSecHits;
132                 wxStaticText* m_P_atsSecBHHits;
133                 wxStaticText* m_P_atsSecHitPer;
134                 wxStaticText* m_P_atsSecBHHitPer;
135                 wxStaticText* m_P_atsAssists;
136                 wxStaticText* m_P_msPriShots;
137                 wxStaticText* m_P_msPriHits;
138                 wxStaticText* m_P_msPriBHHits;
139                 wxStaticText* m_P_msPriHitPer;
140                 wxStaticText* m_P_msPriBHHitPer;
141                 wxStaticText* m_P_msSecShots;
142                 wxStaticText* m_P_msSecHits;
143                 wxStaticText* m_P_msSecBHHits;
144                 wxStaticText* m_P_msSecHitPer;
145                 wxStaticText* m_P_msSecBHHitPer;
146                 wxStaticText* m_P_msAssists;
147
148                 wxChoice* m_GS_Players;
149                 wxTextCtrl* m_GS_msg;
150                 wxTextCtrl* m_GS_Messages;
151
152                 wxStaticText* m_D_State;
153
154                 void ResetAll();
155                 void Shutdown();
156
157                 void OnClose( wxCloseEvent& event );
158                 void OnShutdown( wxCommandEvent& event );
159                 void OnServerNameChange( wxCommandEvent& event );
160                 void OnHostPassChange( wxCommandEvent& event );
161                 void OnKick( wxCommandEvent& event );
162                 void OnMissionRefresh( wxCommandEvent& event );
163                 void OnResetAll( wxCommandEvent& event );
164                 void OnFPSSel( wxCommandEvent& event );
165                 void OnServerMsg( wxCommandEvent& event );
166                 void OnPinfoPlayer( wxCommandEvent& event );
167
168         public:
169
170                 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 );
171                 ~Standalone();
172
173                 bool startFreeSpace(int argc, wxCmdLineArgsArray& argv);
174
175                 bool wsInitialize();
176                 void wsDoFrame();
177                 void wsDisconnect();
178                 void wsMessage(const char *msg, size_t len);
179                 void wsSend(std::string &msg);
180
181                 std::list<std::string> &wsGetSendBuffer()
182                 {
183                         return send_buf;
184                 }
185 };
186
187 class StandaloneApp: public wxApp
188 {
189         private:
190                 Standalone *std_client;
191
192         public:
193                 virtual bool OnInit();
194
195                 StandaloneApp() : std_client(nullptr)
196                 {
197                 }
198
199                 Standalone &Client()
200                 {
201                         wxASSERT(std_client != nullptr);
202
203                         return *std_client;
204                 }
205 };
206
207 #endif // STAND_GUI_H