]> icculus.org git repositories - taylor/freespace2.git/blob - include/stand_gui.h
add first stages of GUI for standalone
[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 Standalone : public wxDialog
44 {
45         private:
46                 void createTab_Server(wxNotebook *parent);
47                 void createTab_Multi(wxNotebook *parent);
48                 void createTab_Player(wxNotebook *parent);
49                 void createTab_GodStuff(wxNotebook *parent);
50                 void createTab_Debug(wxNotebook *parent);
51
52                 long fspid;
53                 int fsport;
54                 struct lws_context *stand_context;
55                 struct lws *wsi_standalone;
56                 struct lws_client_connect_info ccinfo;
57                 StandaloneTimer *m_timer;
58                 int m_rate_limit;
59                 std::list<std::string> send_buf;
60
61                 wxDECLARE_EVENT_TABLE();
62
63         protected:
64                 enum
65                 {
66                         ID_B_KICK = 1000,
67                         ID_B_MREFRESH,
68                         ID_B_RESET_ALL,
69                         ID_FPS_SLIDER,
70                         ID_B_SHUTDOWN,
71                         ID_T_MSG
72                 };
73
74                 wxTextCtrl* m_S_ServerName;
75                 wxTextCtrl* m_S_HostPass;
76                 wxStaticText* m_S_NumConn;
77                 wxTextCtrl* m_S_Connections;
78                 wxButton* m_S_btnKick;
79                 wxButton* m_S_btnMRefresh;
80                 wxButton* m_S_btnResetAll;
81
82                 wxSlider* m_M_sliderFPS;
83                 wxStaticText* m_M_FPS;
84                 wxStaticText* m_M_FPSRel;
85                 wxStaticText* m_M_MissionName;
86                 wxStaticText* m_M_MissionTime;
87                 wxStaticText* m_M_ngMaxPlayers;
88                 wxStaticText* m_M_ngMaxObservers;
89                 wxStaticText* m_M_ngSecurity;
90                 wxStaticText* m_M_ngRespawns;
91                 wxTreeCtrl* m_M_Goals;
92
93                 wxChoice* m_P_Players;
94                 wxStaticText* m_P_ShipType;
95                 wxStaticText* m_P_AvgPing;
96                 wxStaticText* m_P_atsPriShots;
97                 wxStaticText* m_P_atsPriHits;
98                 wxStaticText* m_P_atsPriBHHits;
99                 wxStaticText* m_P_atsPriHitPer;
100                 wxStaticText* m_P_atsPriBHHitPer;
101                 wxStaticText* m_P_atsSecShots;
102                 wxStaticText* m_P_atsSecHits;
103                 wxStaticText* m_P_atsSecBHHits;
104                 wxStaticText* m_P_atsSecHitPer;
105                 wxStaticText* m_P_atsSecBHHitPer;
106                 wxStaticText* m_P_atsAssists;
107                 wxStaticText* m_P_msPriShots;
108                 wxStaticText* m_P_msPriHits;
109                 wxStaticText* m_P_msPriBHHits;
110                 wxStaticText* m_P_msPriHitPer;
111                 wxStaticText* m_P_msPriBHHitPer;
112                 wxStaticText* m_P_msSecShots;
113                 wxStaticText* m_P_msSecHits;
114                 wxStaticText* m_P_msSecBHHits;
115                 wxStaticText* m_P_msSecHitPer;
116                 wxStaticText* m_P_msSecBHHitPer;
117                 wxStaticText* m_P_msAssists;
118
119                 wxChoice* m_GS_Players;
120                 wxTextCtrl* m_GS_Messages;
121
122                 wxStaticText* m_D_State;
123
124                 void Shutdown();
125                 void OnClose( wxCloseEvent& event );
126                 void OnShutdown( wxCommandEvent& event );
127
128         public:
129
130                 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 );
131                 ~Standalone();
132
133                 bool startFreeSpace();
134
135                 bool wsInitialize();
136                 void wsDoFrame();
137                 void wsDisconnect();
138                 void wsMessage(const char *msg, size_t len);
139                 void wsSend(std::string &msg);
140
141                 std::list<std::string> &wsGetSendBuffer()
142                 {
143                         return send_buf;
144                 }
145 };
146
147 class StandaloneApp: public wxApp
148 {
149         private:
150                 Standalone *std_client;
151
152         public:
153                 virtual bool OnInit();
154                 virtual void OnEventLoopEnter(wxEventLoopBase *loop);
155
156                 StandaloneApp() : std_client(nullptr)
157                 {
158                 }
159
160                 Standalone &Client()
161                 {
162                         wxASSERT(std_client != nullptr);
163
164                         return *std_client;
165                 }
166 };
167
168 #endif // STAND_GUI_H