forked from QW-Group/ezquake-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cl_multiview.c
1747 lines (1507 loc) · 45.3 KB
/
cl_multiview.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
// Multiview code
#include "quakedef.h"
#include "utils.h" // Reg expressions
#include "draw.h" // RGBA macros
#include "teamplay.h" // FPD_NO_FORCE_COLOR
// meag: for switching back to 3d resolution to draw the multiview outlines
#include "gl_model.h"
#include "gl_local.h"
extern int glx, gly, glwidth, glheight;
#define MV_VIEW1 0
#define MV_VIEW2 1
#define MV_VIEW3 2
#define MV_VIEW4 3
static int CURRVIEW; // The current view being drawn in multiview mode.
static qbool bExitmultiview; // Used when saving effect values on each frame.
static int nNumViews; // The number of views in multiview mode.
static int nPlayernum;
static int mv_trackslots[MV_VIEWS]; // The different track slots for each view.
static char currteam[MAX_INFO_STRING]; // The name of the current team being tracked in multiview mode.
static int nSwapPov; // Change in POV positive for next, negative for previous.
static int nTrack1duel; // When cl_multiview = 2 and mvinset is on this is the tracking slot for the main view.
static int nTrack2duel; // When cl_multiview = 2 and mvinset is on this is the tracking slot for the mvinset view.
// temporary storage (essentially caching OpenGL viewport state, can get rid of this in 3.5)
static int inset_x;
static int inset_y;
static int inset_width;
static int inset_height;
// Temporary storage so we keep same settings during demo rewind
static int rewind_trackslots[4];
static int rewind_duel_track1 = 0;
static int rewind_duel_track2 = 0;
static int next_spec_track = -1;
extern cvar_t gl_polyblend;
extern cvar_t gl_clear;
extern cvar_t scr_autoid_healthbar_bg_color;
extern cvar_t scr_autoid_healthbar_normal_color;
extern cvar_t scr_autoid_healthbar_mega_color;
extern cvar_t scr_autoid_healthbar_two_mega_color;
extern cvar_t scr_autoid_healthbar_unnatural_color;
extern cvar_t scr_autoid_armorbar_green_armor;
extern cvar_t scr_autoid_armorbar_yellow_armor;
extern cvar_t scr_autoid_armorbar_red_armor;
extern cvar_t cl_multiview_inset_offset_x, cl_multiview_inset_offset_y;
extern cvar_t cl_multiview_inset_size_x, cl_multiview_inset_size_y;
extern cvar_t cl_multiview_inset_top, cl_multiview_inset_right;
#define ALPHA_COLOR(x, y) RGBA_TO_COLOR((x)[0],(x)[1],(x)[2],(y))
typedef struct mv_viewrect_s
{
int x;
int y;
int width;
int height;
} mv_viewrect_t;
#define MV_HUD_POS_BOTTOM_CENTER 1
#define MV_HUD_POS_BOTTOM_LEFT 2
#define MV_HUD_POS_BOTTOM_RIGHT 3
#define MV_HUD_POS_TOP_CENTER 4
#define MV_HUD_POS_TOP_LEFT 5
#define MV_HUD_POS_TOP_RIGHT 6
#define MV_HUD_POS_GATHERED_CENTER 7
#define MV_HUDPOS(regexp, input, position, cvar) if(Utils_RegExpMatch(regexp, input)) { mv_hudpos = position; found = true; }
// true if the player in given slot is an existing player
#define VALID_PLAYER(i) (cl.players[i].name[0] && !cl.players[i].spectator)
int mv_hudpos = MV_HUD_POS_BOTTOM_CENTER;
mpic_t* SCR_GetWeaponIconByFlag (int flag);
void R_TranslatePlayerSkin (int playernum);
void CL_Track (int trackview);
static void CL_MultiviewOverrideValues (void);
static int CL_IncrLoop(int cview, int max)
{
return (cview >= max) ? 1 : ++cview;
}
int CL_NextPlayer(int plr)
{
do
{
plr++;
} while ((plr < MAX_CLIENTS) && (cl.players[plr].spectator || !cl.players[plr].name[0]));
if (plr >= MAX_CLIENTS)
{
plr = -1;
do
{
plr++;
} while ((plr < MAX_CLIENTS) && (cl.players[plr].spectator || !cl.players[plr].name[0]));
}
if (plr >= MAX_CLIENTS)
{
plr = 0;
}
return plr;
}
int CL_PrevPlayer(int plr)
{
do
{
plr--;
} while ((plr >= 0) && (cl.players[plr].spectator || !cl.players[plr].name[0]));
if (plr < 0)
{
plr = MAX_CLIENTS;
do
{
plr--;
} while ((plr >= 0) && (cl.players[plr].spectator || !cl.players[plr].name[0]));
}
if (plr < 0)
{
plr = 0;
}
return plr;
}
void SCR_OnChangeMVHudPos (cvar_t *var, char *newval, qbool *cancel)
{
qbool found = false;
MV_HUDPOS ("(top\\s*left|tl)", newval, MV_HUD_POS_TOP_LEFT, var);
MV_HUDPOS ("(top\\s*right|tr)", newval, MV_HUD_POS_TOP_RIGHT, var);
MV_HUDPOS ("(top\\s*center|tc)", newval, MV_HUD_POS_TOP_CENTER, var);
MV_HUDPOS ("(bottom\\s*left|bl)", newval, MV_HUD_POS_BOTTOM_LEFT, var);
MV_HUDPOS ("(bottom\\s*right|br)", newval, MV_HUD_POS_BOTTOM_RIGHT, var);
MV_HUDPOS ("(bottom\\s*center|bc)", newval, MV_HUD_POS_BOTTOM_CENTER, var);
MV_HUDPOS ("(gather|g)", newval, MV_HUD_POS_GATHERED_CENTER, var);
if (found) {
Cvar_Set (var, newval);
}
*cancel = found;
}
// SCR_SetMVStatusPosition calls SCR_SetMVStatusGatheredPosition and vice versa.
void SCR_SetMVStatusGatheredPosition (mv_viewrect_t *view, int hud_width, int hud_height, int *x, int *y);
void SCR_SetMVStatusPosition (int position, mv_viewrect_t *view, int hud_width, int hud_height, int *x, int *y)
{
switch (position) {
case MV_HUD_POS_BOTTOM_LEFT:
{
(*x) = 0;
(*y) = max (0, (view->height - hud_height));
break;
}
case MV_HUD_POS_BOTTOM_RIGHT:
{
(*x) = max (0, (view->width - hud_width));
(*y) = max (0, (view->height - hud_height));
break;
}
case MV_HUD_POS_TOP_CENTER:
{
(*x) = max (0, (view->width - hud_width) / 2);
(*y) = 0;
break;
}
case MV_HUD_POS_TOP_LEFT:
{
(*x) = 0;
(*y) = 0;
break;
}
case MV_HUD_POS_TOP_RIGHT:
{
(*x) = max (0, view->width - hud_width);
(*y) = 0;
break;
}
case MV_HUD_POS_GATHERED_CENTER:
{
SCR_SetMVStatusGatheredPosition (view, hud_width, hud_height, &(*x), &(*y));
break;
}
case MV_HUD_POS_BOTTOM_CENTER:
default:
{
(*x) = max (0, (view->width - hud_width) / 2);
(*y) = max (0, (view->height - hud_height));
break;
}
}
}
void SCR_SetMVStatusGatheredPosition (mv_viewrect_t *view, int hud_width, int hud_height, int *x, int *y)
{
//
// Position the huds towards the center of the screen for the different views
// so that all the HUD's are close to each other on the screen.
//
if (cl_multiview.value == 2) {
if (!cl_mvinset.value) {
if (CURRVIEW == 2) {
// Top view. (Put the hud at the bottom)
SCR_SetMVStatusPosition (MV_HUD_POS_BOTTOM_CENTER, view, hud_width, hud_height, x, y);
}
else if (CURRVIEW == 1) {
// Bottom view. (Put the hud at the top)
SCR_SetMVStatusPosition (MV_HUD_POS_TOP_CENTER, view, hud_width, hud_height, x, y);
}
}
}
else if (cl_multiview.value == 3) {
if (CURRVIEW == 2) {
// Top view. (Put the hud at the bottom)
SCR_SetMVStatusPosition (MV_HUD_POS_BOTTOM_CENTER, view, hud_width, hud_height, x, y);
}
else if (CURRVIEW == 3) {
// Bottom left view. (Put the hud at the top right)
SCR_SetMVStatusPosition (MV_HUD_POS_TOP_RIGHT, view, hud_width, hud_height, x, y);
}
else if (CURRVIEW == 1) {
// Bottom right view. (Put the hud at the top left)
SCR_SetMVStatusPosition (MV_HUD_POS_TOP_LEFT, view, hud_width, hud_height, x, y);
}
}
else if (cl_multiview.value == 4) {
if (CURRVIEW == 2) {
// Top left view. (Put the hud at the bottom right)
SCR_SetMVStatusPosition (MV_HUD_POS_BOTTOM_RIGHT, view, hud_width, hud_height, x, y);
}
else if (CURRVIEW == 3) {
// Top right view. (Put the hud at the bottom left)
SCR_SetMVStatusPosition (MV_HUD_POS_BOTTOM_LEFT, view, hud_width, hud_height, x, y);
}
else if (CURRVIEW == 4) {
// Bottom left view. (Put the hud at the top right)
SCR_SetMVStatusPosition (MV_HUD_POS_TOP_RIGHT, view, hud_width, hud_height, x, y);
}
else if (CURRVIEW == 1) {
// Bottom right view. (Put the hud at the top left)
SCR_SetMVStatusPosition (MV_HUD_POS_TOP_LEFT, view, hud_width, hud_height, x, y);
}
}
}
#define MV_HUD_ARMOR_WIDTH (5*8)
#define MV_HUD_HEALTH_WIDTH (5*8)
#define MV_HUD_CURRAMMO_WIDTH (5*8)
#define MV_HUD_CURRWEAP_WIDTH (3*8)
#define MV_HUD_POWERUPS_WIDTH (2*8)
#define MV_HUD_POWERUPS_HEIGHT (2*8)
#define MV_HUD_STYLE_ONLY_NAME 2
#define MV_HUD_STYLE_ALL 3
#define MV_HUD_STYLE_ALL_TEXT 4
#define MV_HUD_STYLE_ALL_FILL 5
void SCR_MV_SetBoundValue (int *var, int val)
{
if (var != NULL) {
(*var) = val;
}
}
void SCR_MV_DrawName (int x, int y, int *width, int *height)
{
char *name = cl.players[nPlayernum].name;
SCR_MV_SetBoundValue (width, 8 * (strlen (name) + 1));
SCR_MV_SetBoundValue (height, 8);
Draw_String (x, y, name);
}
void SCR_MV_DrawArmor (int x, int y, int *width, int *height, int style)
{
char armor_color_code[6] = "";
int armor_amount_width = 0;
byte armor_color[4] = { 0, 0, 0, 75 }; // RGBA.
//
// Set the armor text color based on what armor the player has.
//
if (cl.stats[STAT_ITEMS] & IT_ARMOR1) {
// Green armor.
strlcpy (armor_color_code, "&c0f0", sizeof (armor_color_code));
armor_amount_width = Q_rint (MV_HUD_ARMOR_WIDTH * cl.stats[STAT_ARMOR] / 100.0);
armor_color[0] = 80;
armor_color[1] = 190;
armor_color[2] = 80;
}
else if (cl.stats[STAT_ITEMS] & IT_ARMOR2) {
// Yellow armor.
strlcpy (armor_color_code, "&cff0", sizeof (armor_color_code));
armor_amount_width = Q_rint (MV_HUD_ARMOR_WIDTH * cl.stats[STAT_ARMOR] / 150.0);
armor_color[0] = 250;
armor_color[1] = 230;
armor_color[2] = 0;
}
else if (cl.stats[STAT_ITEMS] & IT_ARMOR3) {
// Red armor.
strlcpy (armor_color_code, "&cf00", sizeof (armor_color_code));
armor_amount_width = Q_rint (MV_HUD_ARMOR_WIDTH * cl.stats[STAT_ARMOR] / 200.0);
armor_color[0] = 190;
armor_color[1] = 50;
armor_color[2] = 0;
}
if (cl.stats[STAT_ARMOR] > 0) {
//
// Background fill for armor.
//
Draw_AlphaFillRGB (x, y, armor_amount_width, 8, RGBA_TO_COLOR (armor_color[0], armor_color[1], armor_color[2], armor_color[3]));
// Armor value.
if (style >= MV_HUD_STYLE_ALL_TEXT) {
Draw_ColoredString (x, y, va ("%s%4d", armor_color_code, cl.stats[STAT_ARMOR]), 0);
}
}
SCR_MV_SetBoundValue (width, MV_HUD_ARMOR_WIDTH);
SCR_MV_SetBoundValue (height, 8);
}
void SCR_MV_DrawHealth (int x, int y, int *width, int *height, int style)
{
#define MV_HEALTH_OPACITY 75
int health = cl.stats[STAT_HEALTH];
int health_amount_width = 0;
health = min (100, health);
health_amount_width = Q_rint (abs ((MV_HUD_HEALTH_WIDTH * health) / 100.0));
if (health > 0) {
Draw_AlphaFillRGB (x, y, health_amount_width, 8, ALPHA_COLOR (scr_autoid_healthbar_normal_color.color, 2 * MV_HEALTH_OPACITY));
}
health = cl.stats[STAT_HEALTH];
if (health > 100 && health <= 200) {
// Mega health.
health_amount_width = Q_rint ((MV_HUD_HEALTH_WIDTH / 100.0) * (health - 100));
Draw_AlphaFillRGB (x, y, health_amount_width, 8, ALPHA_COLOR (scr_autoid_healthbar_mega_color.color, MV_HEALTH_OPACITY));
}
else if (health > 200 && health <= 250) {
// Super health.
health_amount_width = Q_rint ((MV_HUD_HEALTH_WIDTH / 100.0) * (health - 200));
Draw_AlphaFillRGB (x, y, MV_HUD_HEALTH_WIDTH, 8, ALPHA_COLOR (scr_autoid_healthbar_mega_color.color, MV_HEALTH_OPACITY));
Draw_AlphaFillRGB (x, y, health_amount_width, 8, ALPHA_COLOR (scr_autoid_healthbar_two_mega_color.color, MV_HEALTH_OPACITY));
}
else if (health > 250) {
// Crazy health.
Draw_AlphaFillRGB (x, y, MV_HUD_HEALTH_WIDTH, 8, ALPHA_COLOR (scr_autoid_healthbar_unnatural_color.color, MV_HEALTH_OPACITY));
}
// No powerup.
if (style >= MV_HUD_STYLE_ALL_TEXT && !(cl.stats[STAT_ITEMS] & IT_INVULNERABILITY)) {
Draw_String (x, y, va ("%4d", health));
}
SCR_MV_SetBoundValue (width, MV_HUD_HEALTH_WIDTH);
SCR_MV_SetBoundValue (height, 8);
}
void SCR_MV_DrawPowerups (int x, int y)
{
extern mpic_t *sb_face_invis;
extern mpic_t *sb_face_quad;
extern mpic_t *sb_face_invuln;
extern mpic_t *sb_face_invis_invuln;
if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY
&& cl.stats[STAT_ITEMS] & IT_INVISIBILITY) {
// Pentagram + Ring.
Draw_AlphaPic (x + (MV_HUD_HEALTH_WIDTH - sb_face_invis_invuln->width) / 2,
y - sb_face_invis_invuln->height / 2,
sb_face_invis_invuln, 0.4);
}
else if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY) {
// Pentagram.
Draw_AlphaPic (x + (MV_HUD_HEALTH_WIDTH - sb_face_invuln->width) / 2,
y - sb_face_invuln->height / 2,
sb_face_invuln, 0.4);
}
else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY) {
// Ring.
Draw_AlphaPic (x + (MV_HUD_HEALTH_WIDTH - sb_face_invis->width) / 2,
y - sb_face_invis->height / 2,
sb_face_invis, 0.4);
}
if (cl.stats[STAT_ITEMS] & IT_QUAD) {
// Ring.
Draw_AlphaPic (x + (MV_HUD_HEALTH_WIDTH - sb_face_quad->width) / 2,
y - sb_face_quad->height / 2,
sb_face_quad, 0.4);
}
}
static mpic_t *SCR_GetActiveWeaponIcon (void)
{
return SCR_GetWeaponIconByFlag (cl.stats[STAT_ACTIVEWEAPON]);
}
static void SCR_MV_DrawCurrentWeapon (int x, int y, int *width, int *height)
{
mpic_t *current_weapon = NULL;
current_weapon = SCR_GetActiveWeaponIcon ();
if (current_weapon) {
Draw_Pic (x,
y - (current_weapon->height / 4),
current_weapon);
}
SCR_MV_SetBoundValue (width, MV_HUD_CURRWEAP_WIDTH);
SCR_MV_SetBoundValue (height, 8);
}
void SCR_MV_DrawCurrentAmmo (int x, int y, int *width, int *height)
{
// Draw the ammo count in blue/greyish color.
Draw_ColoredString (x, y, va ("&c5CE%4d", cl.stats[STAT_AMMO]), 0);
SCR_MV_SetBoundValue (width, MV_HUD_CURRAMMO_WIDTH);
SCR_MV_SetBoundValue (height, 8);
}
mpic_t *SCR_GetWeaponIconByWeaponNumber (int num)
{
extern mpic_t *sb_weapons[7][8]; // sbar.c Weapon pictures.
num -= 2;
if (num >= 0 && num < 8) {
return sb_weapons[0][num];
}
return NULL;
}
void SCR_MV_DrawWeapons (int x, int y, int *width, int *height, int hud_width, int hud_height, qbool vertical)
{
#define WEAPON_COUNT 8
mpic_t *weapon_pic = NULL;
int weapon = 0;
int weapon_flag = 0;
int weapon_x = 0;
int weapon_y = 0;
// Draw the weapons the user has.
for (weapon = 0; weapon < WEAPON_COUNT; weapon++) {
weapon_flag = IT_SHOTGUN << weapon;
if (cl.stats[STAT_ITEMS] & weapon_flag) {
// Get the weapon picture and draw it.
weapon_pic = SCR_GetWeaponIconByWeaponNumber (weapon + 2);
Draw_Pic (x + weapon_x, y + weapon_y, weapon_pic);
}
// Evenly distribute the weapons.
if (!vertical) {
weapon_x += Q_rint ((float)hud_width / WEAPON_COUNT);
}
else {
weapon_y += Q_rint ((float)hud_height / WEAPON_COUNT);
}
}
}
void SCR_DrawMVStatusView (mv_viewrect_t *view, int style, int position, qbool flip, qbool vertical)
{
int hud_x = 0;
int hud_y = 0;
int hud_width = 0;
int hud_height = 0;
char *name = cl.players[nPlayernum].name;
if (style == MV_HUD_STYLE_ONLY_NAME) {
// Only draw the players name.
hud_height = 2 * 8;
hud_width = 8 * (strlen (name) + 1);
//
// Get the position we should draw the hud at.
//
SCR_SetMVStatusPosition (position, view, hud_width, hud_height, &hud_x, &hud_y);
Draw_String (view->x + hud_x, view->y + hud_y, name);
}
else if (style >= MV_HUD_STYLE_ALL) {
#define MV_HUD_VERTICAL_GAP 4
int name_width = 0;
int name_height = 0;
int armor_width = 0;
int armor_height = 0;
int health_width = 0;
int health_height = 0;
int currweap_width = 0;
int currweap_height = 0;
int currammo_width = 0;
int currammo_height = 0;
//
// Calculate the total width and height of the hud.
//
if (!vertical) {
hud_height = 3 * 8;
hud_width =
8 * (strlen (name)) + // Name.
MV_HUD_ARMOR_WIDTH + // Armor + space.
MV_HUD_HEALTH_WIDTH + // Health.
MV_HUD_CURRWEAP_WIDTH + // Current weapon.
MV_HUD_CURRAMMO_WIDTH; // Current weapon ammo count.
}
else {
// Vertical.
hud_height = 5 * (8 + MV_HUD_VERTICAL_GAP);
hud_width = max (8 * strlen (name), MV_HUD_ARMOR_WIDTH) + MV_HUD_ARMOR_WIDTH;
}
//
// Get the position we should draw the hud at.
//
SCR_SetMVStatusPosition (position, view, hud_width, hud_height, &hud_x, &hud_y);
//
// Draw a fill background.
//
if (style >= MV_HUD_STYLE_ALL_FILL) {
Draw_AlphaFill (view->x + hud_x, view->y + hud_y, hud_width, hud_height, 0, 0.5);
}
// Draw powerups in the middle background of the hud.
SCR_MV_DrawPowerups (view->x + hud_x + (hud_width / 2), view->y + hud_y + (hud_height / 2));
// Draw the elements vertically? (Add a small gap between the items when
// drawing them vertically, otherwise they're too close together).
#define MV_FLIP(W,H) if(vertical) { hud_y += (H) + MV_HUD_VERTICAL_GAP; } else { hud_x += (W); }
if (!flip) {
// Name.
SCR_MV_DrawName (view->x + hud_x, view->y + hud_y, &name_width, &name_height);
MV_FLIP (name_width, name_height);
// Armor.
SCR_MV_DrawArmor (view->x + hud_x, view->y + hud_y, &armor_width, &armor_height, style);
MV_FLIP (armor_width, armor_height);
// Health.
SCR_MV_DrawHealth (view->x + hud_x, view->y + hud_y, &health_width, &health_height, style);
MV_FLIP (health_width, health_height);
// Current weapon.
SCR_MV_DrawCurrentWeapon (view->x + hud_x, view->y + hud_y, &currweap_width, &currweap_height);
MV_FLIP (currweap_width, currweap_height);
// Ammo for current weapon.
SCR_MV_DrawCurrentAmmo (view->x + hud_x, view->y + hud_y, &currammo_width, &currammo_height);
MV_FLIP (currammo_width, currammo_height);
}
else {
//
// Flipped horizontally.
//
// Ammo for current weapon.
SCR_MV_DrawCurrentAmmo (view->x + hud_x, view->y + hud_y, &currammo_width, &currammo_height);
MV_FLIP (currammo_width, currammo_height);
// Current weapon.
SCR_MV_DrawCurrentWeapon (view->x + hud_x, view->y + hud_y, &currweap_width, &currweap_height);
MV_FLIP (currweap_width, currweap_height);
// Health.
SCR_MV_DrawHealth (view->x + hud_x, view->y + hud_y, &health_width, &health_height, style);
MV_FLIP (health_width, health_height);
// Armor.
SCR_MV_DrawArmor (view->x + hud_x, view->y + hud_y, &armor_width, &armor_height, style);
MV_FLIP (armor_width, armor_height);
// Name.
SCR_MV_DrawName (view->x + hud_x, view->y + hud_y, &name_width, &name_height);
MV_FLIP (name_width, name_height);
}
if (vertical) {
// Start in the next column.
hud_x += max (8 * strlen (name), MV_HUD_ARMOR_WIDTH);
hud_y -= hud_height;
}
else {
// Start on the next row.
hud_x -= hud_width;
hud_y += hud_height / 2;
}
// Weapons.
SCR_MV_DrawWeapons (view->x + hud_x, view->y + hud_y, NULL, NULL, hud_width, hud_height, vertical);
}
}
void SCR_SetMVStatusTwoViewRect (mv_viewrect_t *view)
{
if (CURRVIEW == 2) {
// Top.
view->x = 0;
view->y = 0;
view->width = vid.width;
view->height = vid.height / 2;
}
else if (CURRVIEW == 1) {
// Bottom.
view->x = 0;
view->y = vid.height / 2;
view->width = vid.width;
view->height = vid.height / 2;
}
}
void SCR_SetMVStatusTwoInsetViewRect(mv_viewrect_t *view)
{
if (CURRVIEW == 2) {
// Main.
view->x = 0;
view->y = 0;
view->width = vid.width;
view->height = vid.height;
}
else if (CURRVIEW == 1) {
float ratio_x = (vid.width * 1.0f) / glwidth;
float ratio_y = (vid.height * 1.0f) / glheight;
// inset window
view->x = inset_x * ratio_x;
view->y = (glheight - (inset_y + inset_height)) * ratio_y; // reversed for 2d/3d rendering
view->width = ceil(inset_width * ratio_x);
view->height = ceil(inset_height * ratio_y);
}
}
void SCR_SetMVStatusThreeViewRect (mv_viewrect_t *view)
{
if (CURRVIEW == 2) {
// Top.
view->x = 0;
view->y = 0;
view->width = vid.width;
view->height = vid.height / 2;
}
else if (CURRVIEW == 3) {
// Bottom left.
view->x = 0;
view->y = vid.height / 2;
view->width = vid.width / 2;
view->height = vid.height / 2;
}
else if (CURRVIEW == 1) {
// Bottom right.
view->x = vid.width / 2;
view->y = vid.height / 2;
view->width = vid.width / 2;
view->height = vid.height / 2;
}
}
void SCR_SetMVStatusFourViewRect (mv_viewrect_t *view)
{
if (CURRVIEW == 2) {
// Top left.
view->x = 0;
view->y = 0;
view->width = vid.width / 2;
view->height = vid.height / 2;
}
else if (CURRVIEW == 3) {
// Top right.
view->x = vid.width / 2;
view->y = 0;
view->width = vid.width / 2;
view->height = vid.height / 2;
}
else if (CURRVIEW == 4) {
// Bottom left.
view->x = 0;
view->y = vid.height / 2;
view->width = vid.width / 2;
view->height = vid.height / 2;
}
else if (CURRVIEW == 1) {
// Bottom right.
view->x = vid.width / 2;
view->y = vid.height / 2;
view->width = vid.width / 2;
view->height = vid.height / 2;
}
}
void SCR_DrawMVStatus (void)
{
mv_viewrect_t view;
// Only draw mini hud when there are more than 1 views.
if (cl_multiview.value <= 1 || !cls.mvdplayback) {
return;
}
// Reset the view.
memset (&view, -1, sizeof (view));
//
// Get the view rect to draw the hud within based on the current
// multiview mode, and what view that is being drawn.
//
if (cl_multiview.value == 2) {
if (cl_mvinset.value) {
// Only draw the mini hud for the inset,
// since we probably want the full size hud
// for the main view.
if (CURRVIEW == 2) {
return;
}
SCR_SetMVStatusTwoInsetViewRect(&view);
}
else {
SCR_SetMVStatusTwoViewRect (&view);
}
}
else if (cl_multiview.value == 3) {
SCR_SetMVStatusThreeViewRect (&view);
}
else if (cl_multiview.value == 4) {
SCR_SetMVStatusFourViewRect (&view);
}
// Only draw if we the view rect was set properly.
if (view.x != -1) {
SCR_DrawMVStatusView (&view,
cl_mvdisplayhud.integer,
mv_hudpos,
(qbool)cl_mvhudflip.value,
(qbool)cl_mvhudvertical.value);
}
}
void SCR_DrawMVStatusStrings (void)
{
int xb = 0, yb = 0, xd = 0, yd = 0;
char strng[80];
char weapons[40];
char weapon[3];
char sAmmo[3];
char pups[4];
char armor;
char name[16];
int i;
extern int powerup_cam_active, cam_1, cam_2, cam_3, cam_4;
extern cvar_t mvd_pc_view_1, mvd_pc_view_2, mvd_pc_view_3, mvd_pc_view_4;
// Only in MVD.
if (!cl_multiview.value || !cls.mvdplayback) {
return;
}
//
// Get the current weapon.
//
if (cl.stats[STAT_ACTIVEWEAPON] & IT_LIGHTNING || cl.stats[STAT_ACTIVEWEAPON] & IT_SUPER_LIGHTNING) {
strlcpy (weapon, "lg", sizeof (weapon));
}
else if (cl.stats[STAT_ACTIVEWEAPON] & IT_ROCKET_LAUNCHER) {
strlcpy (weapon, "rl", sizeof (weapon));
}
else if (cl.stats[STAT_ACTIVEWEAPON] & IT_GRENADE_LAUNCHER) {
strlcpy (weapon, "gl", sizeof (weapon));
}
else if (cl.stats[STAT_ACTIVEWEAPON] & IT_SUPER_NAILGUN) {
strlcpy (weapon, "sn", sizeof (weapon));
}
else if (cl.stats[STAT_ACTIVEWEAPON] & IT_NAILGUN) {
strlcpy (weapon, "ng", sizeof (weapon));
}
else if (cl.stats[STAT_ACTIVEWEAPON] & IT_SUPER_SHOTGUN) {
strlcpy (weapon, "ss", sizeof (weapon));
}
else if (cl.stats[STAT_ACTIVEWEAPON] & IT_SHOTGUN) {
strlcpy (weapon, "sg", sizeof (weapon));
}
else if (cl.stats[STAT_ACTIVEWEAPON] & IT_AXE) {
strlcpy (weapon, "ax", sizeof (weapon));
}
else {
strlcpy (weapon, "??", sizeof (weapon));
}
weapon[0] |= 128;
weapon[1] |= 128;
//
// Get current powerups.
//
pups[0] = pups[1] = pups[2] = ' ';
pups[3] = '\0';
if (cl.stats[STAT_ITEMS] & IT_QUAD) {
pups[0] = 'Q';
pups[0] |= 128;
}
if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY) {
pups[1] = 'R';
pups[1] |= 128;
}
if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY) {
pups[2] = 'P';
pups[2] |= 128;
}
strng[0] = '\0';
for (i = 0; i < 8; i++) {
weapons[i] = ' ';
weapons[8] = '\0';
}
if (cl.stats[STAT_ITEMS] & IT_AXE) {
weapons[0] = '1' - '0' + 0x12;
}
if (cl.stats[STAT_ITEMS] & IT_SHOTGUN) {
weapons[1] = '2' - '0' + 0x12;
}
if (cl.stats[STAT_ITEMS] & IT_SUPER_SHOTGUN) {
weapons[2] = '3' - '0' + 0x12;
}
if (cl.stats[STAT_ITEMS] & IT_NAILGUN) {
weapons[3] = '4' - '0' + 0x12;
}
if (cl.stats[STAT_ITEMS] & IT_SUPER_NAILGUN) {
weapons[4] = '5' - '0' + 0x12;
}
if (cl.stats[STAT_ITEMS] & IT_GRENADE_LAUNCHER) {
weapons[5] = '6' - '0' + 0x12;
}
if (cl.stats[STAT_ITEMS] & IT_ROCKET_LAUNCHER) {
weapons[6] = '7' - '0' + 0x12;
}
if (cl.stats[STAT_ITEMS] & IT_SUPER_LIGHTNING || cl.stats[STAT_ITEMS] & IT_LIGHTNING) {
weapons[7] = '8' - '0' + 0x12;
}
armor = ' ';
if (cl.stats[STAT_ITEMS] & IT_ARMOR1) {
armor = 'g';
armor |= 128;
}
else if (cl.stats[STAT_ITEMS] & IT_ARMOR2) {
armor = 'y';
armor |= 128;
}
else if (cl.stats[STAT_ITEMS] & IT_ARMOR3) {
armor = 'r';
armor |= 128;
}
//
// Get the player's name.
//
strlcpy (name, cl.players[nPlayernum].name, sizeof (name));
if (strcmp (cl.players[nPlayernum].name, "") && !cl.players[nPlayernum].spectator) {
if ((cl.players[nPlayernum].stats[STAT_HEALTH] <= 0) && (cl_multiview.value == 2) && cl_mvinset.integer) {
// mvinset and dead
snprintf (sAmmo, sizeof (sAmmo), "%02d", cl.players[nPlayernum].stats[STAT_AMMO]);
snprintf (strng, sizeof (strng), "%.5s %s %s:%-3s", name,
"dead ",
weapon,
sAmmo);
}
else if ((cl.players[nPlayernum].stats[STAT_HEALTH] <= 0) && (vid.width <= 400)) {
// Resolution width <= 400 and dead
snprintf (sAmmo, sizeof (sAmmo), "%02d", cl.players[nPlayernum].stats[STAT_AMMO]);
snprintf (strng, sizeof (strng), "%.4s %s %s:%-3s", name,
"dead ",
weapon,
sAmmo);
}
else if (cl.players[nPlayernum].stats[STAT_HEALTH] <= 0) {
// > 512 and dead
snprintf (sAmmo, sizeof (sAmmo), "%02d", cl.players[nPlayernum].stats[STAT_AMMO]);
snprintf (strng, sizeof (strng), "%s %s %s:%-3s", name,
"dead ",
weapon,
sAmmo);
}
else if ((cl_multiview.integer == 2) && cl_mvinset.integer && (CURRVIEW == 1)) {
// mvinset
snprintf (sAmmo, sizeof (sAmmo), "%02d", cl.players[nPlayernum].stats[STAT_AMMO]);
snprintf (strng, sizeof (strng), "%s %.5s %c%03d %03d %s:%-3s", pups,
name,
armor,
cl.players[nPlayernum].stats[STAT_ARMOR],
cl.players[nPlayernum].stats[STAT_HEALTH],
weapon,
sAmmo);
}
else if (cl_multiview.value && vid.width <= 400) {
// <= 400 and alive
snprintf (sAmmo, sizeof (sAmmo), "%02d", cl.players[nPlayernum].stats[STAT_AMMO]);
snprintf (strng, sizeof (strng), "%s %.4s %c%03d %03d %s:%-3s", pups,
name,
armor,
cl.players[nPlayernum].stats[STAT_ARMOR],
cl.players[nPlayernum].stats[STAT_HEALTH],
weapon,
sAmmo);
}
else {
snprintf (sAmmo, sizeof (sAmmo), "%02d", cl.players[nPlayernum].stats[STAT_AMMO]); // > 512 and alive
snprintf (strng, sizeof (strng), "%s %s %c%03d %03d %s:%-3s", pups,
name,
armor,
cl.players[nPlayernum].stats[STAT_ARMOR],
cl.players[nPlayernum].stats[STAT_HEALTH],
weapon,
sAmmo);
}
}
//
// Powerup cam stuff.
//
if (CURRVIEW == 1 && mvd_pc_view_1.string && strlen (mvd_pc_view_1.string) && powerup_cam_active && cam_1) {
sAmmo[0] = '\0';
strng[0] = '\0';
weapons[0] = '\0';
}
else if (CURRVIEW == 2 && mvd_pc_view_2.string && strlen (mvd_pc_view_2.string) && powerup_cam_active && cam_2) {
sAmmo[0] = '\0';
strng[0] = '\0';
weapons[0] = '\0';
}
else if (CURRVIEW == 3 && mvd_pc_view_3.string && strlen (mvd_pc_view_3.string) && powerup_cam_active && cam_3) {
sAmmo[0] = '\0';
strng[0] = '\0';
weapons[0] = '\0';
}
else if (CURRVIEW == 4 && mvd_pc_view_4.string && strlen (mvd_pc_view_4.string) && powerup_cam_active && cam_4) {
sAmmo[0] = '\0';
strng[0] = '\0';
weapons[0] = '\0';
}
//
// Placement.
//
if (cl_multiview.value == 1) {
xb = vid.width - strlen (strng) * 8 - 12;
yb = vid.height - sb_lines - 16;
xd = vid.width - strlen (weapons) * 8 - 84;
yd = vid.height - sb_lines - 8;
}
else if (cl_multiview.value == 2) {
if (!cl_mvinset.value) {
if (CURRVIEW == 2) {
// Top