summaryrefslogtreecommitdiff
path: root/src/ui/ui_local.h
blob: 222942cbbe23d6af0f3a769a4590db95719d5285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
Copyright (C) 2000-2006 Tim Angus
 
This file is part of Tremulous.
 
Tremulous is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
 
Tremulous is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with Tremulous; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

#ifndef UI_LOCAL_H
#define UI_LOCAL_H

#include "../qcommon/q_shared.h"
#include "../renderer/tr_types.h"
#include "ui_public.h"
#include "../client/keycodes.h"
#include "../game/bg_public.h"
#include "ui_shared.h"

//
// ui_main.c
//
void UI_Report( void );
void UI_Load( void );
void UI_LoadMenus( const char *menuFile, qboolean reset );
int UI_AdjustTimeByGame( int time );
void UI_ClearScores( void );
void UI_LoadArenas( void );
void UI_ServerInfo( void );

void UI_RegisterCvars( void );
void UI_UpdateCvars( void );
void UI_DrawConnectScreen( qboolean overlay );

// new ui stuff
#define MAX_MAPS 128
#define MAX_PINGREQUESTS 32
#define MAX_ADDRESSLENGTH 64
#define MAX_DISPLAY_SERVERS 2048
#define MAX_SERVERSTATUS_LINES 128
#define MAX_SERVERSTATUS_TEXT 1024
#define MAX_FOUNDPLAYER_SERVERS 16
#define MAX_MODS 64
#define MAX_DEMOS 256
#define MAX_MOVIES 256
#define MAX_HELP_INFOPANES 32

typedef struct
{
  const char *mapName;
  const char *mapLoadName;
  const char *imageName;
  int cinematic;
  qhandle_t levelShot;
}
mapInfo;

typedef struct serverFilter_s
{
  const char *description;
  const char *basedir;
}
serverFilter_t;

typedef struct
{
  char  adrstr[MAX_ADDRESSLENGTH];
  int    start;
}
pinglist_t;


typedef struct serverStatus_s
{
  pinglist_t pingList[MAX_PINGREQUESTS];
  int    numqueriedservers;
  int    currentping;
  int    nextpingtime;
  int    maxservers;
  int    refreshtime;
  int    numServers;
  int    sortKey;
  int    sortDir;
  qboolean sorted;
  int    lastCount;
  qboolean refreshActive;
  int    currentServer;
  int    displayServers[MAX_DISPLAY_SERVERS];
  int    numDisplayServers;
  int    numPlayersOnServers;
  int    nextDisplayRefresh;
  int    nextSortTime;
  qhandle_t currentServerPreview;
  int    currentServerCinematic;
  int    motdLen;
  int    motdWidth;
  int    motdPaintX;
  int    motdPaintX2;
  int    motdOffset;
  int    motdTime;
  char  motd[MAX_STRING_CHARS];
}
serverStatus_t;


typedef struct
{
  char    adrstr[MAX_ADDRESSLENGTH];
  char    name[MAX_ADDRESSLENGTH];
  int      startTime;
  int      serverNum;
  qboolean  valid;
}
pendingServer_t;

typedef struct
{
  int num;
  pendingServer_t server[MAX_SERVERSTATUSREQUESTS];
}
pendingServerStatus_t;

typedef struct
{
  char address[MAX_ADDRESSLENGTH];
  char *lines[MAX_SERVERSTATUS_LINES][4];
  char text[MAX_SERVERSTATUS_TEXT];
  char pings[MAX_CLIENTS * 3];
  int numLines;
}
serverStatusInfo_t;

typedef struct
{
  const char *modName;
  const char *modDescr;
}
modInfo_t;

typedef enum
{
  INFOTYPE_TEXT,
  INFOTYPE_BUILDABLE,
  INFOTYPE_CLASS,
  INFOTYPE_WEAPON,
  INFOTYPE_UPGRADE
} infoType_t;

typedef struct
{
  const char    *text;
  const char    *cmd;
  infoType_t    type;
  union
  {
    const char  *text;
    buildable_t buildable;
    pClass_t    pclass;
    weapon_t    weapon;
    upgrade_t   upgrade;
  } v;
}
menuItem_t;

typedef struct
{
  displayContextDef_t uiDC;

  int playerCount;
  int myTeamCount;
  int teamPlayerIndex;
  int playerRefresh;
  int playerIndex;
  int playerNumber;
  int myPlayerIndex;
  int ignoreIndex;
  char playerNames[MAX_CLIENTS][MAX_NAME_LENGTH];
  char rawPlayerNames[MAX_CLIENTS][MAX_NAME_LENGTH];
  char teamNames[MAX_CLIENTS][MAX_NAME_LENGTH];
  char rawTeamNames[MAX_CLIENTS][MAX_NAME_LENGTH];
  int clientNums[MAX_CLIENTS];
  int teamClientNums[MAX_CLIENTS];
  clientList_t ignoreList[MAX_CLIENTS];

  int mapCount;
  mapInfo mapList[MAX_MAPS];

  modInfo_t modList[MAX_MODS];
  int modCount;
  int modIndex;

  const char *demoList[MAX_DEMOS];
  int demoCount;
  int demoIndex;

  const char *movieList[MAX_MOVIES];
  int movieCount;
  int movieIndex;
  int previewMovie;

  menuItem_t  teamList[ 4 ];
  int         teamCount;
  int         teamIndex;

  menuItem_t  alienClassList[ 3 ];
  int         alienClassCount;
  int         alienClassIndex;

  menuItem_t  humanItemList[ 3 ];
  int         humanItemCount;
  int         humanItemIndex;

  menuItem_t  humanArmouryBuyList[ 32 ];
  int         humanArmouryBuyCount;
  int         humanArmouryBuyIndex;

  menuItem_t  humanArmourySellList[ 32 ];
  int         humanArmourySellCount;
  int         humanArmourySellIndex;

  menuItem_t  alienUpgradeList[ 16 ];
  int         alienUpgradeCount;
  int         alienUpgradeIndex;

  menuItem_t  alienBuildList[ 32 ];
  int         alienBuildCount;
  int         alienBuildIndex;

  menuItem_t  humanBuildList[ 32 ];
  int         humanBuildCount;
  int         humanBuildIndex;

  menuItem_t  helpList[ MAX_HELP_INFOPANES ];
  int         helpCount;
  int         helpIndex;

  int         weapons;
  int         upgrades;

  serverStatus_t serverStatus;

  // for the showing the status of a server
  char serverStatusAddress[MAX_ADDRESSLENGTH];
  serverStatusInfo_t serverStatusInfo;
  int nextServerStatusRefresh;

  // to retrieve the status of server to find a player
  pendingServerStatus_t pendingServerStatus;
  char findPlayerName[MAX_STRING_CHARS];
  char foundPlayerServerAddresses[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH];
  char foundPlayerServerNames[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH];
  int currentFoundPlayerServer;
  int numFoundPlayerServers;
  int nextFindPlayerRefresh;

  qboolean inGameLoad;

  qboolean  chatTeam;
  int       chatTargetClientNum;
}
uiInfo_t;

extern uiInfo_t uiInfo;


qboolean UI_ConsoleCommand( int realTime );
char      *UI_Cvar_VariableString( const char *var_name );
void      UI_SetColor( const float *rgba );
void      UI_AdjustFrom640( float *x, float *y, float *w, float *h );
void      UI_Refresh( int time );
void      UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader );
void      UI_FillRect( float x, float y, float width, float height, const float *color );

//
// ui_syscalls.c
//
void      trap_Print( const char *string );
void      trap_Error( const char *string );
int        trap_Milliseconds( void );
void      trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
void      trap_Cvar_Update( vmCvar_t *vmCvar );
void      trap_Cvar_Set( const char *var_name, const char *value );
float      trap_Cvar_VariableValue( const char *var_name );
void      trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
void      trap_Cvar_SetValue( const char *var_name, float value );
void      trap_Cvar_Reset( const char *name );
void      trap_Cvar_Create( const char *var_name, const char *var_value, int flags );
void      trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize );
int        trap_Argc( void );
void      trap_Argv( int n, char *buffer, int bufferLength );
void      trap_Cmd_ExecuteText( int exec_when, const char *text );  // don't use EXEC_NOW!
int        trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
void      trap_FS_Read( void *buffer, int len, fileHandle_t f );
void      trap_FS_Write( const void *buffer, int len, fileHandle_t f );
void      trap_FS_FCloseFile( fileHandle_t f );
int        trap_FS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize );
int       trap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t
qhandle_t    trap_R_RegisterModel( const char *name );
qhandle_t    trap_R_RegisterSkin( const char *name );
qhandle_t    trap_R_RegisterShaderNoMip( const char *name );
void      trap_R_ClearScene( void );
void      trap_R_AddRefEntityToScene( const refEntity_t *re );
void      trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts );
void      trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );
void      trap_R_RenderScene( const refdef_t *fd );
void      trap_R_SetColor( const float *rgba );
void      trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void      trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
void      trap_UpdateScreen( void );
int        trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName );
void      trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );
sfxHandle_t    trap_S_RegisterSound( const char *sample, qboolean compressed );
void      trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen );
void      trap_Key_GetBindingBuf( int keynum, char *buf, int buflen );
void      trap_Key_SetBinding( int keynum, const char *binding );
qboolean    trap_Key_IsDown( int keynum );
qboolean    trap_Key_GetOverstrikeMode( void );
void      trap_Key_SetOverstrikeMode( qboolean state );
void      trap_Key_ClearStates( void );
int        trap_Key_GetCatcher( void );
void      trap_Key_SetCatcher( int catcher );
void      trap_GetClipboardData( char *buf, int bufsize );
void      trap_GetClientState( uiClientState_t *state );
void      trap_GetGlconfig( glconfig_t *glconfig );
int        trap_GetConfigString( int index, char* buff, int buffsize );
int        trap_LAN_GetServerCount( int source );
void      trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen );
void      trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen );
int        trap_LAN_GetServerPing( int source, int n );
int        trap_LAN_GetPingQueueCount( void );
void      trap_LAN_ClearPing( int n );
void      trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime );
void      trap_LAN_GetPingInfo( int n, char *buf, int buflen );
void      trap_LAN_LoadCachedServers( void );
void      trap_LAN_SaveCachedServers( void );
void      trap_LAN_MarkServerVisible( int source, int n, qboolean visible );
int        trap_LAN_ServerIsVisible( int source, int n );
qboolean    trap_LAN_UpdateVisiblePings( int source );
int        trap_LAN_AddServer( int source, const char *name, const char *addr );
void      trap_LAN_RemoveServer( int source, const char *addr );
void      trap_LAN_ResetPings( int n );
int        trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen );
int        trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 );
int        trap_MemoryRemaining( void );
void      trap_R_RegisterFont( const char *pFontname, int pointSize, fontInfo_t *font );
void      trap_S_StopBackgroundTrack( void );
void      trap_S_StartBackgroundTrack( const char *intro, const char *loop );
int        trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits );
e_status    trap_CIN_StopCinematic( int handle );
e_status    trap_CIN_RunCinematic ( int handle );
void      trap_CIN_DrawCinematic ( int handle );
void      trap_CIN_SetExtents ( int handle, int x, int y, int w, int h );
int        trap_RealTime( qtime_t *qtime );
void      trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );

void      trap_SetPbClStatus( int status );

#endif