forked from QW-Group/ezquake-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cl_screen.c
4070 lines (3332 loc) · 102 KB
/
cl_screen.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
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 1996-2003 Id Software, Inc., A Nourai
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 2
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: cl_screen.c,v 1.156 2007-10-29 00:56:47 qqshka Exp $
*/
/// declarations may be found in screen.h
#include "quakedef.h"
#include <time.h>
#include "vx_tracker.h"
#include "gl_model.h"
#include "gl_local.h"
#include "mvd_utils.h"
#include "keys.h"
#include "hud.h"
#include "hud_common.h"
#include "hud_editor.h"
#include "utils.h"
#include "vx_stuff.h"
#include "gl_model.h"
#include "gl_local.h"
#include "teamplay.h"
#include "input.h"
#include "utils.h"
#include "sbar.h"
#include "menu.h"
#include "image.h"
#ifdef _WIN32
#include "movie.h" //joe: capturing to avi
#include "movie_avi.h" //
#endif
#include "Ctrl.h"
#include "qtv.h"
#include "demo_controls.h"
#ifndef CLIENTONLY
#include "server.h"
#endif
void WeaponStats_CommandInit(void);
int glx, gly, glwidth, glheight;
#define DEFAULT_SSHOT_FORMAT "png"
#define ALPHA_COLOR(x, y) RGBA_TO_COLOR((x)[0],(x)[1],(x)[2],(y))
extern byte current_pal[768]; // Tonik
int host_screenupdatecount; // kazik - HUD -> hexum
// only the refresh window will be updated unless these variables are flagged
int scr_copytop;
int scr_copyeverything;
float scr_con_current;
float scr_conlines; // lines of console to display
qbool scr_skipupdate;
qbool block_drawing;
float oldscreensize, oldfov, oldsbar;
#define ZOOMEDFOV 35
qbool zoomedin;
float unzoomedfov;
float unzoomedsensitivity;
void OnFovChange (cvar_t *var, char *value, qbool *cancel);
void OnDefaultFovChange (cvar_t *var, char *value, qbool *cancel);
void OnChange_scr_clock_format (cvar_t *var, char *value, qbool *cancel);
cvar_t scr_fov = {"fov", "90", CVAR_NONE, OnFovChange}; // 10 - 140
cvar_t default_fov = {"default_fov", "90", CVAR_NONE, OnDefaultFovChange};
cvar_t scr_viewsize = {"viewsize", "100", CVAR_NONE};
cvar_t scr_consize = {"scr_consize", "0.5"};
cvar_t scr_conspeed = {"scr_conspeed", "9999"};
cvar_t scr_centertime = {"scr_centertime", "2"};
cvar_t scr_centershift = {"scr_centershift", "0"};
cvar_t scr_showram = {"showram", "1"};
cvar_t scr_showturtle = {"showturtle", "0"};
cvar_t scr_showpause = {"showpause", "1"};
cvar_t scr_printspeed = {"scr_printspeed", "8"};
void OnChange_scr_allowsnap(cvar_t *, char *, qbool *);
cvar_t scr_allowsnap = {"scr_allowsnap", "1", 0, OnChange_scr_allowsnap};
cvar_t scr_newHud = {"scr_newhud", "0"};
cvar_t scr_newHudClear = {"scr_newhud_clear", "0"}; // force clearing screen on every frame (necessary with viewsize)
cvar_t scr_clock = {"cl_clock", "0"};
cvar_t scr_clock_format = {"cl_clock_format", "%H:%M:%S", 0, OnChange_scr_clock_format};
cvar_t scr_clock_x = {"cl_clock_x", "0"};
cvar_t scr_clock_y = {"cl_clock_y", "-1"};
cvar_t scr_gameclock = {"cl_gameclock", "0"};
cvar_t scr_gameclock_x = {"cl_gameclock_x", "0"};
cvar_t scr_gameclock_y = {"cl_gameclock_y", "-3"};
cvar_t scr_gameclock_offset = {"cl_gameclock_offset", "0"};
cvar_t scr_democlock = {"cl_democlock", "0"};
cvar_t scr_democlock_x = {"cl_democlock_x", "0"};
cvar_t scr_democlock_y = {"cl_democlock_y", "-2"};
cvar_t scr_qtvbuffer = {"scr_qtvbuffer", "0"};
cvar_t scr_qtvbuffer_x = {"scr_qtvbuffer_x", "0"};
cvar_t scr_qtvbuffer_y = {"scr_qtvbuffer_y", "-10"};
cvar_t show_speed = {"show_speed", "0"};
cvar_t show_speed_x = {"show_speed_x", "-1"};
cvar_t show_speed_y = {"show_speed_y", "1"};
cvar_t show_velocity_3d = {"show_velocity_3d", "0"};
cvar_t show_velocity_3d_offset_forward = {"show_velocity_3d_offset_forward", "2.5"};
cvar_t show_velocity_3d_offset_down = {"show_velocity_3d_offset_down", "5"};
cvar_t show_fps = {"show_fps", "0"};
cvar_t show_fps_x = {"show_fps_x", "-5"};
cvar_t show_fps_y = {"show_fps_y", "-1"};
cvar_t scr_sshot_autoname = {"sshot_autoname", "0"};
cvar_t scr_sshot_format = {"sshot_format", DEFAULT_SSHOT_FORMAT};
cvar_t scr_sshot_dir = {"sshot_dir", ""};
cvar_t cl_hud = {"cl_hud", "1"}; // QW262 HUD.
cvar_t gl_triplebuffer = {"gl_triplebuffer", "1"};
cvar_t r_chaticons_alpha = {"r_chaticons_alpha", "0.8"};
cvar_t scr_autoid = {"scr_autoid", "5"};
cvar_t scr_autoid_weapons = {"scr_autoid_weapons", "2"};
cvar_t scr_autoid_namelength = {"scr_autoid_namelength", "0"};
cvar_t scr_autoid_barlength = {"scr_autoid_barlength", "16"};
cvar_t scr_autoid_weaponicon = {"scr_autoid_weaponicon", "1"};
cvar_t scr_autoid_scale = {"scr_autoid_scale", "1"};
cvar_t scr_coloredfrags = {"scr_coloredfrags", "0"};
cvar_t scr_teaminfo_order = {"scr_teaminfo_order", "%p%n $x10%l$x11 %a/%H %w", CVAR_NONE, OnChange_scr_clock_format};
cvar_t scr_teaminfo_align_right = {"scr_teaminfo_align_right", "1"};
cvar_t scr_teaminfo_frame_color = {"scr_teaminfo_frame_color", "10 0 0 120", CVAR_COLOR};
cvar_t scr_teaminfo_scale = {"scr_teaminfo_scale", "1"};
cvar_t scr_teaminfo_y = {"scr_teaminfo_y", "0"};
cvar_t scr_teaminfo_x = {"scr_teaminfo_x", "0"};
cvar_t scr_teaminfo_loc_width = {"scr_teaminfo_loc_width", "5"};
cvar_t scr_teaminfo_name_width = {"scr_teaminfo_name_width", "6"};
cvar_t scr_teaminfo_low_health = {"scr_teaminfo_low_health", "25"};
cvar_t scr_teaminfo_armor_style = {"scr_teaminfo_armor_style", "3"};
cvar_t scr_teaminfo_powerup_style = {"scr_teaminfo_powerup_style", "1"};
cvar_t scr_teaminfo_weapon_style= {"scr_teaminfo_weapon_style","1"};
cvar_t scr_teaminfo_show_enemies= {"scr_teaminfo_show_enemies","0"};
cvar_t scr_teaminfo_show_self = {"scr_teaminfo_show_self", "2"};
cvar_t scr_teaminfo = {"scr_teaminfo", "1"};
cvar_t scr_shownick_order = {"scr_shownick_order", "%p%n %a/%H %w", CVAR_NONE, OnChange_scr_clock_format};
cvar_t scr_shownick_frame_color = {"scr_shownick_frame_color", "10 0 0 120", CVAR_COLOR};
cvar_t scr_shownick_scale = {"scr_shownick_scale", "1"};
cvar_t scr_shownick_y = {"scr_shownick_y", "0"};
cvar_t scr_shownick_x = {"scr_shownick_x", "0"};
cvar_t scr_shownick_name_width = {"scr_shownick_name_width", "6"};
cvar_t scr_shownick_time = {"scr_shownick_time", "0.8"};
cvar_t scr_coloredText = {"scr_coloredText", "1"};
// Tracking text.
cvar_t scr_tracking = {"scr_tracking", "\xD4\xF2\xE1\xE3\xEB\xE9\xEE\xE7\xBA %t %n, \xCA\xD5\xCD\xD0 for next"}; //"Tracking: [team] name, JUMP for next", "Tracking:" and "JUMP" are brown. default: "Tracking %t %n, [JUMP] for next"
cvar_t scr_spectatorMessage = {"scr_spectatorMessage", "1"};
cvar_t scr_cursor_scale = {"scr_cursor_scale", "0.2"}; // The mouse cursor scale.
cvar_t scr_cursor_iconoffset_x = {"scr_cursor_iconoffset_x", "10"}; // How much the cursor icon should be offseted from the cursor.
cvar_t scr_cursor_iconoffset_y = {"scr_cursor_iconoffset_y", "0"};
cvar_t scr_cursor_alpha = {"scr_cursor_alpha", "1"};
cvar_t scr_showcrosshair = {"scr_showcrosshair", "1"}; // so crosshair does't affected by +showscores, or vice versa
cvar_t scr_notifyalways = {"scr_notifyalways", "0"}; // don't hide notification messages in intermission
cvar_t scr_fovmode = {"scr_fovmode", "0"}; // When using reduced viewsize, reduce vertical fov or letterbox the screen
qbool scr_initialized; // Ready to draw.
mpic_t *scr_ram;
mpic_t *scr_net;
mpic_t *scr_turtle;
mpic_t *scr_cursor; // Cursor image.
mpic_t *scr_cursor_icon; // Cursor icon image (load icon or similar).
int scr_fullupdate;
int clearconsole;
int clearnotify;
viddef_t vid; // global video state
vrect_t scr_vrect;
qbool scr_skipupdate;
qbool scr_drawloading;
qbool scr_disabled_for_loading;
float scr_disabled_time;
qbool block_drawing;
double cursor_x = 0, cursor_y = 0;
static int scr_autosshot_countdown = 0;
char auto_matchname[2 * MAX_OSPATH];
static void SCR_CheckAutoScreenshot(void);
void SCR_DrawMultiviewBorders(void);
void SCR_DrawMVStatus(void);
void SCR_DrawMVStatusStrings(void);
void Draw_AlphaFill (int x, int y, int w, int h, byte c, float alpha);
void Draw_AlphaString (int x, int y, char *str, float alpha);
void Draw_AlphaPic (int x, int y, mpic_t *pic, float alpha);
qbool SCR_TakingAutoScreenshot(void)
{
return scr_autosshot_countdown > 0;
}
void OnChange_scr_allowsnap(cvar_t *var, char *s, qbool *cancel)
{
*cancel = (cls.state >= ca_connected && cbuf_current == &cbuf_svc);
}
/**************************** CENTER PRINTING ********************************/
char scr_centerstring[1024];
float scr_centertime_start; // for slow victory printing
float scr_centertime_off;
int scr_center_lines;
int scr_erase_lines;
int scr_erase_center;
// Called for important messages that should stay in the center of the screen for a few moments
void SCR_CenterPrint (char *str)
{
strlcpy (scr_centerstring, str, sizeof(scr_centerstring));
scr_centertime_off = scr_centertime.value;
scr_centertime_start = cl.time;
// count the number of lines for centering
scr_center_lines = 1;
while (*str)
{
if (*str == '\n')
scr_center_lines++;
str++;
}
}
void SCR_DrawCenterString (void)
{
char *start;
int l, j, x, y, remaining;
// the finale prints the characters one at a time
remaining = cl.intermission ? scr_printspeed.value * (cl.time - scr_centertime_start) : 9999;
scr_erase_center = 0;
start = scr_centerstring;
y = ((scr_center_lines <= 4) ? vid.height * 0.35 : 48);
// shift all centerprint but not proxy menu - more user-friendly way
if (m_state != m_proxy)
y += scr_centershift.value*8;
while (1) {
// scan the width of the line
for (l = 0; l < 40; l++) {
if (start[l] == '\n' || !start[l])
break;
}
x = (vid.width - l * 8) / 2;
for (j = 0; j < l; j++, x += 8) {
Draw_Character (x, y, start[j]);
if (!remaining--)
return;
}
y += 8;
while (*start && *start != '\n')
start++;
if (!*start)
break;
start++; // skip the \n
}
}
void SCR_CheckDrawCenterString (void) {
scr_copytop = 1;
if (scr_center_lines > scr_erase_lines)
scr_erase_lines = scr_center_lines;
scr_centertime_off -= cls.frametime;
if (scr_centertime_off <= 0 && !cl.intermission)
return;
// condition says: "Draw center string only when in game or in proxy menu, otherwise leave."
if (key_dest != key_game && ((key_dest != key_menu) || (m_state != m_proxy)))
return;
SCR_DrawCenterString ();
}
void SCR_EraseCenterString (void) {
int y;
if (scr_erase_center++ > vid.numpages) {
scr_erase_lines = 0;
return;
}
y = (scr_center_lines <= 4) ? vid.height * 0.35 : 48;
scr_copytop = 1;
Draw_TileClear (0, y, vid.width, min(8 * scr_erase_lines, vid.height - y - 1));
}
/************************************ FOV ************************************/
extern cvar_t v_idlescale;
qbool concussioned = false;
void OnFovChange (cvar_t *var, char *value, qbool *cancel)
{
float newfov = Q_atof(value);
if (newfov > 140)
newfov = 140;
else if (newfov < 10)
newfov = 10;
if (newfov == scr_fov.value) {
*cancel = true;
return;
}
if (cbuf_current != &cbuf_svc) {
if (concussioned && !cls.demoplayback) {
*cancel = true;
return;
}
} else {
if (newfov != 90 && cl.teamfortress && v_idlescale.value >= 20) {
concussioned = true;
if (v_idlescale.value == 100)
TP_ExecTrigger ("f_conc");
} else if (newfov == 90 && cl.teamfortress) {
concussioned = false;
}
if (cls.demoplayback) { // && !cl_fovfromdemo.value)
*cancel = true;
return;
}
}
vid.recalc_refdef = true;
if (newfov == 90) {
Cvar_Set (&scr_fov,default_fov.string);
*cancel = true;
return;
}
Cvar_SetValue (&scr_fov, newfov);
*cancel = true;
}
void OnDefaultFovChange (cvar_t *var, char *value, qbool *cancel)
{
float newfov = Q_atof(value);
if (newfov < 10.0 || newfov > 140.0){
Com_Printf("Invalid default_fov\n");
*cancel = true;
}
}
static void CalcFov(float fov, float *fov_x, float *fov_y, float width, float height, float view_width, float view_height, qbool reduce_vertfov)
{
float t;
float fovx;
float fovy;
if (fov < 10)
fov = 10;
else if (fov > 140)
fov = 140;
if (width / 4 < height /3)
{
fovx = fov;
t = width / tan(fovx / 360 * M_PI);
fovy = atan (height / t) * 360 / M_PI;
}
else
{
fovx = fov;
t = 4.0 / tan(fovx / 360 * M_PI);
fovy = atan (3.0 / t) * 360 / M_PI;
t = height / tan(fovy / 360 * M_PI);
fovx = atan (width / t) * 360 / M_PI;
if (reduce_vertfov) {
// Crop vertically when viewsize decreased
t = view_width / tan (fovx / 360 * M_PI);
fovy = atan (view_height / t) * 360 / M_PI;
}
}
if (fovx < 10 || fovx > 140)
{
if (fovx < 10)
fovx = 10;
else if (fovx > 140)
fovx = 140;
t = width / tan(fovx / 360 * M_PI);
fovy = atan (height / t) * 360 / M_PI;
}
if (fovy < 10 || fovy > 140)
{
if (fovy < 10)
fovy = 10;
else if (fovy > 140)
fovy = 140;
t = height / tan(fovy / 360 * M_PI);
fovx = atan (width / t) * 360 / M_PI;
}
if (fovx < 1 || fovx > 179 || fovy < 1 || fovy > 179)
Sys_Error ("CalcFov: Bad fov (%f, %f)", fovx, fovy);
*fov_x = fovx;
*fov_y = fovy;
}
//Must be called whenever vid changes
static void SCR_CalcRefdef (void) {
float size = 0;
qbool full = false;
int h;
float aspectratio = vid.height ? (float)vid.width / vid.height : 1;
qbool letterbox = scr_fovmode.integer == 1;
qbool height_reduced = false;
scr_fullupdate = 0; // force a background redraw
vid.recalc_refdef = 0;
// force the status bar to redraw
Sbar_Changed ();
// bound viewsize
if (scr_viewsize.value < 30)
Cvar_Set (&scr_viewsize, "30");
if (scr_viewsize.value > 120)
Cvar_Set (&scr_viewsize, "120");
// intermission is always full screen
size = cl.intermission ? 120 : scr_viewsize.value;
if (size >= 120)
sb_lines = 0; // no status bar at all
else if (size >= 110)
sb_lines = 24; // no inventory
else
sb_lines = 24 + 16 + 8;
if (scr_viewsize.value >= 100.0) {
full = true;
size = 100.0;
} else {
size = scr_viewsize.value;
}
if (cl.intermission) {
full = true;
size = 100.0;
sb_lines = 0;
}
size /= 100.0;
if (!cl_sbar.value && full)
h = vid.height;
else
h = vid.height - sb_lines;
r_refdef.vrect.width = vid.width * size;
if (r_refdef.vrect.width < 96) {
size = 96.0 / r_refdef.vrect.width;
r_refdef.vrect.width = 96; // min for icons
}
r_refdef.vrect.height = vid.height * size;
if (cl_sbar.value || !full) {
if (r_refdef.vrect.height > vid.height - sb_lines) {
r_refdef.vrect.height = vid.height - sb_lines;
height_reduced = true;
}
} else if (r_refdef.vrect.height > vid.height) {
r_refdef.vrect.height = vid.height;
}
// Reduce width to keep aspect ratio constant with monitor
if (letterbox) {
r_refdef.vrect.width = min (r_refdef.vrect.width, r_refdef.vrect.height * aspectratio);
height_reduced = false;
}
r_refdef.vrect.x = (vid.width - r_refdef.vrect.width) / 2;
if (full)
r_refdef.vrect.y = 0;
else
r_refdef.vrect.y = (h - r_refdef.vrect.height) / 2;
CalcFov (scr_fov.value, &r_refdef.fov_x, &r_refdef.fov_y, vid.width, vid.height, r_refdef.vrect.width, r_refdef.vrect.height, height_reduced);
scr_vrect = r_refdef.vrect;
}
//Keybinding command
void SCR_SizeUp_f (void) {
Cvar_SetValue (&scr_viewsize, scr_viewsize.value + 10);
vid.recalc_refdef = 1;
}
//Keybinding command
void SCR_SizeDown_f (void) {
Cvar_SetValue (&scr_viewsize,scr_viewsize.value - 10);
vid.recalc_refdef = 1;
}
void SCR_ZoomIn_f (void) {
if (zoomedin) return;
zoomedin = true;
unzoomedfov = scr_fov.value;
unzoomedsensitivity = sensitivity.value;
Cvar_SetValue(&scr_fov, ZOOMEDFOV);
Cvar_SetValue(&sensitivity, unzoomedsensitivity * ((double) ZOOMEDFOV / unzoomedfov));
}
void SCR_ZoomOut_f (void) {
if (!zoomedin) return;
zoomedin = false;
Cvar_SetValue(&scr_fov, unzoomedfov);
Cvar_SetValue(&sensitivity, unzoomedsensitivity);
}
/********************************** ELEMENTS **********************************/
void SCR_DrawRam (void) {
if (!scr_showram.value)
return;
if (!r_cache_thrash)
return;
Draw_Pic (scr_vrect.x + 32, scr_vrect.y, scr_ram);
}
#ifdef EXPERIMENTAL_SHOW_ACCELERATION
static void draw_accel_bar(int x, int y, int length, int charsize, int pos)
{
glPushAttrib(GL_TEXTURE_BIT);
glDisable(GL_TEXTURE_2D);
// draw the coloured indicator strip
//Draw_Fill(x, y, length, charsize, 184);
glColor3f(1.f, 1.f, 1.f);
glBegin(GL_QUADS);
glVertex2f (x, y);
glVertex2f (x + length, y);
glVertex2f (x + length, y + charsize);
glVertex2f (x, y + charsize);
glEnd();
//Draw_Fill(x + length/2 - 2, y, 5, charsize, 152);
glColor3f(0.f, 1.f, 0.f);
glBegin(GL_QUADS);
glVertex2f (x + length/2 - 2, y);
glVertex2f (x + length/2 - 2 + 5, y);
glVertex2f (x + length/2 - 2 + 5, y + charsize);
glVertex2f (x + length/2 - 2, y + charsize);
glEnd();
//Draw_Fill(x + pos - 1, y, 3, charsize, 192);
glColor3f(0.f, 0.f, 1.f);
glBegin(GL_QUADS);
glVertex2f (x + pos - 1, y);
glVertex2f (x + pos - 1 + 3, y);
glVertex2f (x + pos - 1 + 3, y + charsize);
glVertex2f (x + pos - 1, y + charsize);
glEnd();
glPopAttrib();
}
void SCR_DrawAccel (void) {
extern qbool player_in_air;
extern float cosinus_val;
int x, y, length, charsize, pos;
const float scale_factor = 10.f;
char cosinus_str[10];
if(!player_in_air) return;
charsize = (int) (8.f * vid.height / vid.conheight);
length = vid.width / 3;
x = (vid.width - length) / 2;
y = vid.height - sb_lines - charsize - 1;
pos = (int) ((cosinus_val + 1) * length / 2);
draw_accel_bar(x, y, length, charsize, pos);
//scale: show most interesting
pos = (int) ((cosinus_val * scale_factor + 1) * length / 2);
draw_accel_bar(x, y - 2 * charsize, length, charsize, pos);
cosinus_str[0] = '\0';
sprintf(cosinus_str,"%.3f", cosinus_val);
Draw_String(x, y - charsize, cosinus_str);
}
#endif
void SCR_DrawTurtle (void) {
static int count;
if (!scr_showturtle.value)
return;
if (cls.frametime < 0.1) {
count = 0;
return;
}
count++;
if (count < 3)
return;
Draw_Pic (scr_vrect.x, scr_vrect.y, scr_turtle);
}
void SCR_DrawNet (void) {
if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < UPDATE_BACKUP-1)
return;
if (cls.demoplayback || scr_newHud.value == 1)
return;
Draw_Pic (scr_vrect.x + 64, scr_vrect.y, scr_net);
}
void SCR_DrawFPS (void) {
int x, y;
char str[80];
extern double lastfps;
if (!show_fps.value || scr_newHud.value == 1) // HUD -> hexum - newHud has its own fps
return;
// Multiview
if (CL_MultiviewEnabled())
{
snprintf(str, sizeof(str), "%3.1f", (lastfps + 0.05)/CL_MultiviewNumberViews());
}
else
{
snprintf(str, sizeof(str), "%3.1f", lastfps + 0.05);
}
x = ELEMENT_X_COORD(show_fps);
y = ELEMENT_Y_COORD(show_fps);
Draw_String (x, y, str);
}
void SCR_DrawSpeed (void) {
double t;
int x, y, mynum;
char str[80];
vec3_t vel;
float speed;
static float maxspeed = 0, display_speed = -1;
static double lastframetime = 0;
static int lastmynum = -1;
if (!show_speed.value || scr_newHud.value == 1) // newHud has its own speed
return;
t = Sys_DoubleTime();
if (!cl.spectator || (mynum = Cam_TrackNum()) == -1)
mynum = cl.playernum;
if (mynum != lastmynum) {
lastmynum = mynum;
lastframetime = t;
display_speed = -1;
maxspeed = 0;
}
if (!cl.spectator || cls.demoplayback || mynum == cl.playernum)
VectorCopy (cl.simvel, vel);
else
VectorCopy (cl.frames[cl.validsequence & UPDATE_MASK].playerstate[mynum].velocity, vel);
vel[2] = 0;
speed = VectorLength(vel);
maxspeed = max(maxspeed, speed);
if (display_speed >= 0) {
snprintf(str, sizeof(str), "%3d%s", (int) display_speed, show_speed.value == 2 ? " SPD" : "");
x = ELEMENT_X_COORD(show_speed);
y = ELEMENT_Y_COORD(show_speed);
Draw_String (x, y, str);
}
if (t - lastframetime >= 0.1) {
lastframetime = t;
display_speed = maxspeed;
maxspeed = 0;
}
}
void OnChange_scr_clock_format (cvar_t *var, char *value, qbool *cancel) {
if (!host_initialized)
return; // we in progress of initialization, allow
if (cls.state == ca_active) {
Com_Printf("Can't change %s while connected\n", var->name);
*cancel = true; // prevent stick notes
return;
}
}
void SCR_DrawClock (void) {
int x, y;
time_t t;
struct tm *ptm;
char str[64];
if (!scr_clock.value || scr_newHud.value == 1) // newHud has its own clock
return;
if (scr_clock.value == 2) {
time (&t);
if ((ptm = localtime (&t))) {
strftime (str, sizeof (str) - 1, scr_clock_format.string[0] ? scr_clock_format.string : "%H:%M:%S", ptm);
} else {
strlcpy (str, "#bad date#", sizeof (str));
}
} else {
float time = (cl.servertime_works) ? cl.servertime : cls.realtime;
strlcpy (str, SecondsToHourString((int) time), sizeof (str));
}
x = ELEMENT_X_COORD(scr_clock);
y = ELEMENT_Y_COORD(scr_clock);
Draw_String (x, y, str);
}
void SCR_DrawGameClock (void) {
int x, y;
char str[80], *s;
float timelimit;
if (!scr_gameclock.value || scr_newHud.value == 1) // newHud has its own gameclock
return;
if (scr_gameclock.value == 2 || scr_gameclock.value == 4)
timelimit = 60 * Q_atof(Info_ValueForKey(cl.serverinfo, "timelimit")) + 1;
else
timelimit = 0;
if (cl.countdown || cl.standby)
strlcpy (str, SecondsToHourString(timelimit), sizeof(str));
else
strlcpy (str, SecondsToHourString((int) abs(timelimit - cl.gametime + scr_gameclock_offset.value)), sizeof(str));
if ((scr_gameclock.value == 3 || scr_gameclock.value == 4) && (s = strstr(str, ":")))
s++; // or just use SecondsToMinutesString() ...
else
s = str;
x = ELEMENT_X_COORD(scr_gameclock);
y = ELEMENT_Y_COORD(scr_gameclock);
Draw_String (x, y, s);
}
void SCR_DrawDemoClock (void) {
int x, y;
char str[80];
if (!cls.demoplayback || cls.mvdplayback == QTV_PLAYBACK || !scr_democlock.value || scr_newHud.value == 1) // newHud has its own democlock
return;
if (scr_democlock.value == 2)
strlcpy (str, SecondsToHourString((int) (cls.demotime)), sizeof(str));
else
strlcpy (str, SecondsToHourString((int) (cls.demotime - demostarttime)), sizeof(str));
x = ELEMENT_X_COORD(scr_democlock);
y = ELEMENT_Y_COORD(scr_democlock);
Draw_String (x, y, str);
}
void SCR_DrawQTVBuffer (void)
{
extern double Demo_GetSpeed(void);
extern unsigned char pb_buf[];
extern int pb_cnt;
int x, y;
int ms, len;
char str[64];
switch(scr_qtvbuffer.integer)
{
case 0:
return;
case 1:
if (cls.mvdplayback != QTV_PLAYBACK)
return; // not qtv, ignore
break;
default:
if (!cls.mvdplayback)
return; // not mvd(that include qtv), ignore
break;
}
len = ConsistantMVDDataEx(pb_buf, pb_cnt, &ms);
snprintf(str, sizeof(str), "%6dms %5db %2.3f", ms, len, Demo_GetSpeed());
x = ELEMENT_X_COORD(scr_qtvbuffer);
y = ELEMENT_Y_COORD(scr_qtvbuffer);
Draw_String (x, y, str);
}
void SCR_DrawPause (void) {
mpic_t *pic;
if (!scr_showpause.value) // turn off for screenshots
return;
if (!cl.paused)
return;
#ifndef CLIENTONLY
if (sv.paused == 2)
return; // auto-paused in single player
#endif
pic = Draw_CachePic ("gfx/pause.lmp");
Draw_Pic ((vid.width - pic->width) / 2, (vid.height - 48 - pic->height) / 2, pic);
}
void SCR_DrawLoading (void) {
mpic_t *pic;
if (!scr_drawloading)
return;
pic = Draw_CachePic ("gfx/loading.lmp");
Draw_Pic ( (vid.width - pic->width )/ 2, (vid.height - 48 - pic->height) / 2, pic);
}
void SCR_BeginLoadingPlaque (void) {
if (cls.state != ca_active)
return;
if (key_dest == key_console)
return;
// redraw with no console and the loading plaque
scr_fullupdate = 0;
Sbar_Changed ();
scr_drawloading = true;
SCR_UpdateScreen ();
scr_drawloading = false;
scr_disabled_for_loading = true;
scr_disabled_time = cls.realtime;
scr_fullupdate = 0;
}
void SCR_EndLoadingPlaque (void) {
if (!scr_disabled_for_loading)
return;
scr_disabled_for_loading = false;
scr_fullupdate = 0;
}
/********************************** CONSOLE **********************************/
void SCR_SetUpToDrawConsole (void) {
Con_CheckResize ();
// decide on the height of the console
if (SCR_NEED_CONSOLE_BACKGROUND) {
scr_conlines = vid.height; // full screen
scr_con_current = scr_conlines;
} else if (key_dest == key_console) {
scr_conlines = vid.height * scr_consize.value;
scr_conlines = bound(30, scr_conlines, vid.height);
} else {
scr_conlines = 0; // none visible
}
if (scr_conlines < scr_con_current) {
scr_con_current -= scr_conspeed.value * cls.trueframetime * vid.height / 320;
scr_con_current = max(scr_con_current, scr_conlines);
} else if (scr_conlines > scr_con_current) {
scr_con_current += scr_conspeed.value * cls.trueframetime * vid.height / 320;
scr_con_current = min(scr_con_current, scr_conlines);
}
if (clearconsole++ < vid.numpages)
{
Sbar_Changed ();
}
else
{
con_notifylines = 0;
}
clearnotify++;
}
void SCR_DrawConsole (void) {
if (scr_con_current) {
scr_copyeverything = 1;
Con_DrawConsole (scr_con_current);
clearconsole = 0;
} else {
if (key_dest == key_game || key_dest == key_message || (key_dest == key_menu && m_state == m_proxy))
Con_DrawNotify (); // only draw notify in game
}
}
/*********************************** AUTOID ***********************************/
cvar_t scr_autoid_healthbar_bg_color = { "scr_autoid_healthbar_bg_color", "180 115 115 100", CVAR_COLOR };
cvar_t scr_autoid_healthbar_normal_color = { "scr_autoid_healthbar_normal_color", "80 0 0 255", CVAR_COLOR };
cvar_t scr_autoid_healthbar_mega_color = { "scr_autoid_healthbar_mega_color", "255 0 0 255", CVAR_COLOR };
cvar_t scr_autoid_healthbar_two_mega_color = { "scr_autoid_healthbar_two_mega_color", "255 100 0 255", CVAR_COLOR };
cvar_t scr_autoid_healthbar_unnatural_color = { "scr_autoid_healthbar_unnatural_color", "255 255 255 255", CVAR_COLOR };
cvar_t scr_autoid_armorbar_green_armor = { "scr_autoid_armorbar_green_armor", "25 170 0 255", CVAR_COLOR };
cvar_t scr_autoid_armorbar_yellow_armor = { "scr_autoid_armorbar_yellow_armor", "255 220 0 255", CVAR_COLOR };
cvar_t scr_autoid_armorbar_red_armor = { "scr_autoid_armorbar_red_armor", "255 0 0 255", CVAR_COLOR };
#define AUTOID_HEALTHBAR_OFFSET_Y 16
#define AUTOID_ARMORBAR_OFFSET_Y (AUTOID_HEALTHBAR_OFFSET_Y + 5)
#define AUTOID_ARMORNAME_OFFSET_Y (AUTOID_ARMORBAR_OFFSET_Y + 8 + 2)
#define AUTOID_ARMORNAME_OFFSET_X 8
#define AUTOID_WEAPON_OFFSET_Y AUTOID_HEALTHBAR_OFFSET_Y
#define AUTOID_WEAPON_OFFSET_X 2
int qglProject (float objx, float objy, float objz, float *model, float *proj, int *view, float* winx, float* winy, float* winz) {
float in[4], out[4];
int i;