1 /*
2 Copyright (C) 2003-2006 Andrey Nazarov
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 
21 #define UI_APIVERSION	2
22 
23 #define MAX_LOCAL_SERVERS 16
24 
25 typedef enum uiMenu_e {
26 	UIMENU_NONE,
27 	UIMENU_MAIN,
28 	UIMENU_MAIN_FORCE,
29 	UIMENU_INGAME
30 } uiMenu_t;
31 
32 typedef enum connstate_e {
33 	ca_uninitialized,
34 	ca_disconnected, 	// not talking to a server
35 	ca_challenging,		// sending getchallenge packets to the server
36 	ca_connecting,		// sending connect packets to the server
37 	ca_connected,		// netchan_t established, waiting for svc_serverdata
38 	ca_loading,			// loading level data
39     ca_precached,       // loaded level data
40 	ca_active,			// game views should be displayed
41 	ca_cinematic		// playing cinematic or static pic, not a level
42 } connstate_t;
43 
44 typedef enum {
45 	dl_none,
46 	dl_model,
47 	dl_sound,
48 	dl_skin,
49 	dl_single
50 } dltype_t;		// download type
51 
52 typedef struct playerStatus_s {
53 	char name[MAX_CLIENT_NAME];
54 	int ping;
55 	int score;
56 } playerStatus_t;
57 
58 #define MAX_STATUS_PLAYERS	32
59 
60 typedef struct serverStatus_s {
61 	char	address[MAX_QPATH];
62 	char	infostring[MAX_STRING_CHARS]; // BIG infostring
63 	playerStatus_t	players[MAX_STATUS_PLAYERS];
64 	int	numPlayers;
65 	int ping;
66 } serverStatus_t;
67 
68 #define MAX_DEMOINFO_CLIENTS	20
69 
70 typedef struct demoInfo_s {
71 	qboolean mvd; // FIXME: can also use clientNum == -1
72 	int clientNum;
73 	char gamedir[MAX_QPATH];
74 	char mapname[MAX_QPATH];
75 	char fullLevelName[MAX_QPATH];
76 	char clients[MAX_DEMOINFO_CLIENTS][MAX_CLIENT_NAME];
77 } demoInfo_t;
78 
79 typedef struct uiClientState_s {
80 	connstate_t		connState;
81 	int				connectCount;
82 	qboolean		demoplayback;
83 	char	servername[MAX_QPATH];
84 	char	mapname[MAX_QPATH];
85 	char	fullname[MAX_QPATH];
86 	char	loadingString[MAX_STRING_CHARS];
87 } uiClientState_t;
88 
89 typedef struct clientAPI_s {
90 	void	(*StartLocalSound)( const char *name );
91 	void	(*StopAllSounds)( void );
92 
93 	qboolean	(*GetDemoInfo)( const char *path, demoInfo_t *info );
94 	qboolean	(*SendStatusRequest)( char *buffer, int bufferSize );
95 	void		(*GetClientState)( uiClientState_t *state );
96     void        (*UpdateScreen)( void );
97 } clientAPI_t;
98 
99 extern clientAPI_t client;
100 
101 typedef struct uiAPI_s {
102 	qboolean	(*Init)( void );
103 	void		(*Shutdown)( void );
104 
105 	void		(*Draw)( int realtime );
106 	void		(*DrawLoading)( int realtime );
107 	void		(*MouseMove)( int dx, int dy );
108 	void		(*Keydown)( int key );
109 	void		(*CharEvent)( int key );
110 	void		(*OpenMenu)( uiMenu_t menu );
111 	void		(*ErrorMenu)( comErrorType_t type, const char *text );
112 	void		(*AddToServerList)( const serverStatus_t *status );
113 	qboolean	(*IsTransparent)( void );
114 } uiAPI_t;
115 
116 extern uiAPI_t ui;
117 
118 qboolean	UI_Init( void );
119 void		UI_Shutdown( void );
120 void		UI_Keydown( int key );
121 void		UI_CharEvent( int key );
122 void		UI_Draw( int realtime );
123 void		UI_OpenMenu( uiMenu_t menu );
124 void		UI_ErrorMenu( comErrorType_t type, const char *text );
125 void		UI_AddToServerList( const serverStatus_t *status );
126 void		UI_MouseMove( int dx, int dy );
127 qboolean	UI_IsTransparent( void );
128 void		UI_DrawLoading( int realtime );
129 
130 
131 
132 
133