This repository was archived by the owner on Mar 1, 2021. It is now read-only.
forked from FWGS/xash3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcl_scrn.c
740 lines (626 loc) · 18.1 KB
/
cl_scrn.c
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
/*
cl_scrn.c - refresh screen
Copyright (C) 2007 Uncle Mike
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#ifndef XASH_DEDICATED
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "vgui_draw.h"
#include "qfont.h"
#include "library.h"
convar_t *scr_centertime;
convar_t *scr_loading;
convar_t *scr_download;
convar_t *scr_width;
convar_t *scr_height;
convar_t *scr_viewsize;
convar_t *cl_testlights;
convar_t *cl_allow_levelshots;
convar_t *cl_levelshot_name;
convar_t *cl_envshot_size;
convar_t *scr_dark;
typedef struct
{
int x1, y1, x2, y2;
} dirty_t;
static dirty_t scr_dirty, scr_old_dirty[2];
static qboolean scr_init = false;
/*
==============
SCR_DrawFPS
==============
*/
void SCR_DrawFPS( void )
{
float calc;
rgba_t color;
static double nexttime = 0, lasttime = 0;
static double framerate = 0, avgrate = 0;
static int framecount = 0;
static int minfps = 9999;
static int maxfps = 0;
double newtime;
char fpsstring[64];
int offset;
if ( cls.state != ca_active )
return;
if ( !cl_showfps->integer || cl.background )
return;
switch ( cls.scrshot_action )
{
case scrshot_normal:
case scrshot_snapshot:
case scrshot_inactive:
break;
default:
return;
}
newtime = Sys_DoubleTime( );
if ( newtime >= nexttime )
{
framerate = framecount / ( newtime - lasttime );
lasttime = newtime;
nexttime = max( nexttime + 1, lasttime - 1 );
framecount = 0;
}
framecount++;
calc = framerate;
if ( calc == 0 )
return;
if ( calc < 1.0f )
{
Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i spf", (int)( 1.0f / calc + 0.5f ) );
MakeRGBA( color, 255, 0, 0, 255 );
}
else
{
int curfps = (int)( calc + 0.5f );
if ( curfps < minfps )
minfps = curfps;
if ( curfps > maxfps )
maxfps = curfps;
/*if( !avgrate ) avgrate = ( maxfps - minfps ) / 2.0f;
else */
avgrate += ( calc - avgrate ) / host.framecount;
switch ( cl_showfps->integer )
{
case 3:
Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max | ^3%.2f avg", minfps, curfps, maxfps, avgrate );
break;
case 2:
Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max", minfps, curfps, maxfps );
break;
case 1:
default:
Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps );
}
MakeRGBA( color, 255, 255, 255, 255 );
}
Con_DrawStringLen( fpsstring, &offset, NULL );
Con_DrawString( scr_width->integer - offset - 2, 4, fpsstring, color );
}
/*
==============
SCR_DrawPos
Draw local player position, angles and velocity
==============
*/
void SCR_DrawPos( void )
{
static char msg[MAX_SYSPATH];
float speed;
cl_entity_t *pPlayer;
rgba_t color;
if( cls.state != ca_active ) return;
if( !cl_showpos->integer || cl.background ) return;
pPlayer = CL_GetLocalPlayer();
speed = VectorLength( cl.frame.client.velocity );
Q_snprintf( msg, MAX_SYSPATH,
"pos: %.2f %.2f %.2f\n"
"ang: %.2f %.2f %.2f\n"
"velocity: %.2f", pPlayer->origin[0], pPlayer->origin[1], pPlayer->origin[2],
pPlayer->angles[0], pPlayer->angles[1], pPlayer->angles[2],
speed );
MakeRGBA( color, 255, 255, 255, 255 );
Con_DrawString( scr_width->integer / 2, 4, msg, color );
}
/*
==============
SCR_NetSpeeds
same as r_speeds but for network channel
==============
*/
void SCR_NetSpeeds( void )
{
static char msg[MAX_SYSPATH];
int x, y, height;
char *p, *start, *end;
float time = cl.mtime[0];
rgba_t color;
if( !net_speeds->integer ) return;
if( cls.state != ca_active ) return;
switch( net_speeds->integer )
{
case 1:
if( cls.netchan.compress )
{
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal received from server:\n Huffman %s\nUncompressed %s\nSplit %s\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_received ), Q_memprint( cls.netchan.total_received_uncompressed ),
Q_memprint( cls.netchan.netsplit.total_received ) );
}
else
{
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal received from server:\nUncompressed %s\nSplit %s/%s(%f)\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_received_uncompressed ),
Q_memprint( cls.netchan.netsplit.total_received ), Q_memprint( cls.netchan.netsplit.total_received_uncompressed ),
((float)cls.netchan.netsplit.total_received) / cls.netchan.netsplit.total_received_uncompressed );
}
break;
case 2:
if( cls.netchan.compress )
{
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal sended to server:\nHuffman %s\nUncompressed %s\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_sended ), Q_memprint( cls.netchan.total_sended_uncompressed ));
}
else
{
Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal sended to server:\nUncompressed %s\n",
(int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_sended_uncompressed ));
}
break;
default: return;
}
x = scr_width->integer - 320;
y = 256;
Con_DrawStringLen( NULL, NULL, &height );
MakeRGBA( color, 255, 255, 255, 255 );
p = start = msg;
do
{
end = Q_strchr( p, '\n' );
if( end ) msg[end-start] = '\0';
Con_DrawString( x, y, p, color );
y += height;
if( end ) p = end + 1;
else break;
} while( 1 );
}
/*
================
SCR_RSpeeds
================
*/
void SCR_RSpeeds( void )
{
char msg[MAX_SYSPATH];
if( R_SpeedsMessage( msg, sizeof( msg )))
{
int x, y, height;
char *p, *start, *end;
rgba_t color;
x = scr_width->integer - 340;
y = 64;
Con_DrawStringLen( NULL, NULL, &height );
MakeRGBA( color, 255, 255, 255, 255 );
p = start = msg;
do
{
end = Q_strchr( p, '\n' );
if( end ) msg[end-start] = '\0';
Con_DrawString( x, y, p, color );
y += height;
if( end ) p = end + 1;
else break;
} while( 1 );
}
}
void SCR_MakeLevelShot( void )
{
if( cls.scrshot_request != scrshot_plaque )
return;
// make levelshot at nextframe()
Cbuf_AddText( "levelshot\n" );
}
void SCR_MakeScreenShot( void )
{
qboolean iRet = false;
int viewsize;
if( cls.envshot_viewsize > 0 )
viewsize = cls.envshot_viewsize;
else viewsize = cl_envshot_size->integer;
switch( cls.scrshot_action )
{
case scrshot_normal:
iRet = VID_ScreenShot( cls.shotname, VID_SCREENSHOT );
break;
case scrshot_snapshot:
iRet = VID_ScreenShot( cls.shotname, VID_SNAPSHOT );
break;
case scrshot_plaque:
iRet = VID_ScreenShot( cls.shotname, VID_LEVELSHOT );
break;
case scrshot_savegame:
case scrshot_demoshot:
iRet = VID_ScreenShot( cls.shotname, VID_MINISHOT );
break;
case scrshot_envshot:
iRet = VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, false );
break;
case scrshot_skyshot:
iRet = VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, true );
break;
case scrshot_mapshot:
iRet = VID_ScreenShot( cls.shotname, VID_MAPSHOT );
break;
case scrshot_inactive:
return;
}
// report
if( iRet )
{
// snapshots don't writes message about image
if( cls.scrshot_action != scrshot_snapshot )
MsgDev( D_AICONSOLE, "Write %s\n", cls.shotname );
}
else MsgDev( D_ERROR, "Unable to write %s\n", cls.shotname );
cls.envshot_vieworg = NULL;
cls.scrshot_action = scrshot_inactive;
cls.envshot_disable_vis = false;
cls.envshot_viewsize = 0;
cls.shotname[0] = '\0';
}
void SCR_DrawPlaque( void )
{
int levelshot;
if(( cl_allow_levelshots->integer && !cls.changelevel ) || cl.background )
{
levelshot = GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE, NULL );
GL_SetRenderMode( kRenderNormal );
R_DrawStretchPic( 0, 0, scr_width->value, scr_height->value, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING );
}
}
/*
================
SCR_BeginLoadingPlaque
================
*/
void SCR_BeginLoadingPlaque( qboolean is_background )
{
S_StopAllSounds();
cl.audio_prepped = false; // don't play ambients
if( cls.disable_screen ) return; // already set
if( cls.state == ca_disconnected ) return; // if at console, don't bring up the plaque
if( cls.key_dest == key_console ) return;
cls.draw_changelevel = is_background ? false : true;
SCR_UpdateScreen();
cls.disable_screen = host.realtime;
cls.disable_servercount = cl.servercount;
cl.background = is_background; // set right state before svc_serverdata is came
}
/*
================
SCR_EndLoadingPlaque
================
*/
void SCR_EndLoadingPlaque( void )
{
cls.disable_screen = 0.0f;
Con_ClearNotify();
}
/*
=================
SCR_AddDirtyPoint
=================
*/
void SCR_AddDirtyPoint( int x, int y )
{
if( x < scr_dirty.x1 ) scr_dirty.x1 = x;
if( x > scr_dirty.x2 ) scr_dirty.x2 = x;
if( y < scr_dirty.y1 ) scr_dirty.y1 = y;
if( y > scr_dirty.y2 ) scr_dirty.y2 = y;
}
/*
================
SCR_DirtyScreen
================
*/
void SCR_DirtyScreen( void )
{
SCR_AddDirtyPoint( 0, 0 );
SCR_AddDirtyPoint( scr_width->integer - 1, scr_height->integer - 1 );
}
/*
================
SCR_TileClear
================
*/
void SCR_TileClear( void )
{
int i, top, bottom, left, right;
dirty_t clear;
if( scr_viewsize->integer >= 120 )
return; // full screen rendering
// erase rect will be the union of the past three frames
// so tripple buffering works properly
clear = scr_dirty;
for( i = 0; i < 2; i++ )
{
if( scr_old_dirty[i].x1 < clear.x1 )
clear.x1 = scr_old_dirty[i].x1;
if( scr_old_dirty[i].x2 > clear.x2 )
clear.x2 = scr_old_dirty[i].x2;
if( scr_old_dirty[i].y1 < clear.y1 )
clear.y1 = scr_old_dirty[i].y1;
if( scr_old_dirty[i].y2 > clear.y2 )
clear.y2 = scr_old_dirty[i].y2;
}
scr_old_dirty[1] = scr_old_dirty[0];
scr_old_dirty[0] = scr_dirty;
scr_dirty.x1 = 9999;
scr_dirty.x2 = -9999;
scr_dirty.y1 = 9999;
scr_dirty.y2 = -9999;
if( clear.y2 <= clear.y1 )
return; // nothing disturbed
top = cl.refdef.viewport[1];
bottom = top + cl.refdef.viewport[3] - 1;
left = cl.refdef.viewport[0];
right = left + cl.refdef.viewport[2] - 1;
if( clear.y1 < top )
{
// clear above view screen
i = clear.y2 < top-1 ? clear.y2 : top - 1;
R_DrawTileClear( clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1 );
clear.y1 = top;
}
if( clear.y2 > bottom )
{
// clear below view screen
i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1;
R_DrawTileClear( clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1 );
clear.y2 = bottom;
}
if( clear.x1 < left )
{
// clear left of view screen
i = clear.x2 < left - 1 ? clear.x2 : left - 1;
R_DrawTileClear( clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1 );
clear.x1 = left;
}
if( clear.x2 > right )
{
// clear left of view screen
i = clear.x1 > right + 1 ? clear.x1 : right + 1;
R_DrawTileClear( i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1 );
clear.x2 = right;
}
}
/*
==================
SCR_UpdateScreen
This is called every frame, and can also be called explicitly to flush
text to the screen.
==================
*/
void SCR_UpdateScreen( void )
{
if( !V_PreRender( )) return;
switch( cls.state )
{
case ca_disconnected:
break;
case ca_connecting:
case ca_connected:
SCR_DrawPlaque();
break;
case ca_active:
V_RenderView();
break;
case ca_cinematic:
SCR_DrawCinematic();
break;
default:
Host_Error( "SCR_UpdateScreen: bad cls.state\n" );
break;
}
V_PostRender();
}
void SCR_LoadCreditsFont( void )
{
int fontWidth;
dword crc = 0;
const char *path = "gfx/creditsfont.fnt";
byte *buffer;
fs_offset_t length;
qfont_t *src;
if( cls.creditsFont.valid ) return; // already loaded
// replace default gfx.wad textures by current charset's font
if( !CRC32_File( &crc, "gfx.wad" ) || crc == 0x49eb9f16 )
{
const char *path2 = va("creditsfont_%s.fnt", Cvar_VariableString( "con_charset" ) );
if( FS_FileExists( path2, false ) )
path = path2;
}
cls.creditsFont.hFontTexture = GL_LoadTexture( path, NULL, 0, TF_IMAGE, NULL );
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
if( fontWidth == 0 ) return;
// setup creditsfont
// half-life font with variable chars width
buffer = FS_LoadFile( path, &length, false );
if( buffer && length >= ( fs_offset_t )sizeof( qfont_t ))
{
int i;
src = (qfont_t *)buffer;
cls.creditsFont.charHeight = clgame.scrInfo.iCharHeight = src->rowheight;
// build rectangles
for( i = 0; i < NUM_GLYPHS; i++ )
{
cls.creditsFont.fontRc[i].left = (word)src->fontinfo[i].startoffset % fontWidth;
cls.creditsFont.fontRc[i].right = cls.creditsFont.fontRc[i].left + src->fontinfo[i].charwidth;
cls.creditsFont.fontRc[i].top = (word)src->fontinfo[i].startoffset / fontWidth;
cls.creditsFont.fontRc[i].bottom = cls.creditsFont.fontRc[i].top + src->rowheight;
cls.creditsFont.charWidths[i] = clgame.scrInfo.charWidths[i] = src->fontinfo[i].charwidth;
}
cls.creditsFont.valid = true;
}
if( buffer ) Mem_Free( buffer );
}
void SCR_InstallParticlePalette( void )
{
rgbdata_t *pic;
int i;
// first check 'palette.lmp' then 'palette.pal'
pic = FS_LoadImage( "gfx/palette.lmp", NULL, 0 );
if( !pic ) pic = FS_LoadImage( "gfx/palette.pal", NULL, 0 );
// NOTE: imagelib required this fakebuffer for loading internal palette
if( !pic ) pic = FS_LoadImage( "#valve.pal", ((byte *)&i), 768 );
if( pic )
{
for( i = 0; i < 256; i++ )
{
clgame.palette[i][0] = pic->palette[i*4+0];
clgame.palette[i][1] = pic->palette[i*4+1];
clgame.palette[i][2] = pic->palette[i*4+2];
}
FS_FreeImage( pic );
}
else
{
for( i = 0; i < 256; i++ )
{
clgame.palette[i][0] = i;
clgame.palette[i][1] = i;
clgame.palette[i][2] = i;
}
MsgDev( D_WARN, "CL_InstallParticlePalette: failed. Force to grayscale\n" );
}
}
void SCR_RegisterTextures( void )
{
cls.fillImage = GL_LoadTexture( "*white", NULL, 0, TF_IMAGE, NULL ); // used for FillRGBA
cls.particleImage = GL_LoadTexture( "*particle", NULL, 0, TF_IMAGE, NULL );
// register gfx.wad images
cls.oldParticleImage = GL_LoadTexture("*oldparticle", NULL, 0, TF_IMAGE, NULL);
cls.pauseIcon = GL_LoadTexture( "gfx.wad/paused.lmp", NULL, 0, TF_IMAGE, NULL );
if( cl_allow_levelshots->integer )
cls.loadingBar = GL_LoadTexture( "gfx.wad/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE, NULL );
else cls.loadingBar = GL_LoadTexture( "gfx.wad/lambda.lmp", NULL, 0, TF_IMAGE, NULL );
cls.tileImage = GL_LoadTexture( "gfx.wad/backtile.lmp", NULL, 0, TF_UNCOMPRESSED|TF_NOPICMIP|TF_NOMIPMAP, NULL );
cls.hChromeSprite = pfnSPR_Load( "sprites/shellchrome.spr" );
}
/*
=================
SCR_SizeUp_f
Keybinding command
=================
*/
void SCR_SizeUp_f( void )
{
Cvar_SetFloat( "viewsize", min( scr_viewsize->value + 10, 120 ));
}
/*
=================
SCR_SizeDown_f
Keybinding command
=================
*/
void SCR_SizeDown_f( void )
{
Cvar_SetFloat( "viewsize", max( scr_viewsize->value - 10, 30 ));
}
/*
==================
SCR_VidInit
==================
*/
void SCR_VidInit( void )
{
Q_memset( &clgame.ds, 0, sizeof( clgame.ds )); // reset a draw state
Q_memset( &menu.ds, 0, sizeof( menu.ds )); // reset a draw state
Q_memset( &clgame.centerPrint, 0, sizeof( clgame.centerPrint ));
if( menu.globals )
{
// update screen sizes for menu
menu.globals->scrWidth = scr_width->integer;
menu.globals->scrHeight = scr_height->integer;
}
SCR_RebuildGammaTable();
VGui_Startup (scr_width->integer, scr_height->integer);
clgame.load_sequence++; // now all hud sprites are invalid
// vid_state has changed
if( menu.hInstance ) menu.dllFuncs.pfnVidInit();
if( clgame.hInstance ) clgame.dllFuncs.pfnVidInit();
// restart console size
Con_VidInit ();
}
/*
==================
SCR_Init
==================
*/
void SCR_Init( void )
{
if( scr_init ) return;
MsgDev( D_NOTE, "SCR_Init()\n" );
scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" );
cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" );
cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", CVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" );
scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" );
scr_download = Cvar_Get( "scr_download", "0", 0, "downloading bar progress" );
cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" );
cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", CVAR_ARCHIVE, "envshot size of cube side" );
scr_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" );
scr_viewsize = Cvar_Get( "viewsize", "120", CVAR_ARCHIVE, "screen size" );
// register our commands
Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
Cmd_AddCommand( "viewpos", SCR_Viewpos_f, "prints current player origin" );
Cmd_AddCommand( "sizeup", SCR_SizeUp_f, "screen size up to 10 points" );
Cmd_AddCommand( "sizedown", SCR_SizeDown_f, "screen size down to 10 points" );
Com_ResetLibraryError();
if( host.state != HOST_RESTART && !UI_LoadProgs( ))
{
Sys_Warn( "can't initialize menu library:\n%s", Com_GetLibraryError() ); // this is not fatal for us
// console still can't be toggled in-game without extra cmd-line switch
if( !host.developer ) host.developer = 1; // we need console, because menu is missing
}
SCR_LoadCreditsFont ();
SCR_InstallParticlePalette ();
SCR_RegisterTextures ();
SCR_InitCinematic();
CL_InitNetgraph();
SCR_VidInit();
if( host.state != HOST_RESTART )
{
if( host.developer && Sys_CheckParm( "-toconsole" ))
Cbuf_AddText( "toggleconsole\n" );
else UI_SetActiveMenu( true );
}
scr_init = true;
}
void SCR_Shutdown( void )
{
if( !scr_init ) return;
MsgDev( D_NOTE, "SCR_Shutdown()\n" );
Cmd_RemoveCommand( "timerefresh" );
Cmd_RemoveCommand( "skyname" );
Cmd_RemoveCommand( "viewpos" );
Cmd_RemoveCommand( "sizeup" );
Cmd_RemoveCommand( "sizedown" );
UI_SetActiveMenu( false );
if( host.state != HOST_RESTART )
UI_UnloadProgs();
cls.creditsFont.valid = false;
scr_init = false;
}
#endif // XASH_DEDICATED