-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcl_sbar.c
1824 lines (1552 loc) · 41.3 KB
/
cl_sbar.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-1997 Id Software, Inc.
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.
*/
// cl_sbar.c -- status bar code
#include "quakedef.h"
#ifdef PSP_HARDWARE_VIDEO
#include <pspgu.h>
#endif
#ifdef PROQUAKE_EXTENSION
cvar_t pq_teamscores = {"pq_teamscores", "1", false}; // JPG - show teamscores
cvar_t pq_timer = {"pq_timer", "1", false}; // JPG - show timer
cvar_t pq_scoreboard_pings = {"pq_scoreboard_pings", "1", false}; // JPG - show ping times in the scoreboard
#endif
cvar_t cl_sbar = {"cl_sbar", "0.6", true}; // Baker 3.97: transparent sbar capability
void SBAR_cl_sbar_f (void) {
// Baker 3.97: if transparent sbar is turned on/off
// we need a vid.recalc
if (host_initialized)
vid.recalc_refdef = 1;
}
int sb_updates; // if >= vid.numpages, no update needed
#define STAT_MINUS 10 // num frame for '-' stats digit
qpic_t *sb_nums[2][11];
qpic_t *sb_colon, *sb_slash;
qpic_t *sb_ibar;
qpic_t *sb_sbar;
qpic_t *sb_scorebar;
qpic_t *sb_weapons[7][8]; // 0 is active, 1 is owned, 2-5 are flashes
qpic_t *sb_ammo[4];
qpic_t *sb_sigil[4];
qpic_t *sb_armor[3];
qpic_t *sb_items[32];
qpic_t *sb_faces[7][2]; // 0 is gibbed, 1 is dead, 2-6 are alive
// 0 is static, 1 is temporary animation
qpic_t *sb_face_invis;
qpic_t *sb_face_quad;
qpic_t *sb_face_invuln;
qpic_t *sb_face_invis_invuln;
qboolean sb_showscores;
int sb_lines; // scan lines to draw
qpic_t *ksb_ammo[1];
qpic_t *rsb_invbar[2];
qpic_t *rsb_weapons[5];
qpic_t *rsb_items[2];
qpic_t *rsb_ammo[3];
qpic_t *rsb_teambord; // PGM 01/19/97 - team color border
//MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
qpic_t *hsb_weapons[7][5]; // 0 is active, 1 is owned, 2-5 are flashes
//MED 01/04/97 added array to simplify weapon parsing
int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
//MED 01/04/97 added hipnotic items array
qpic_t *hsb_items[2];
void Sbar_MiniDeathmatchOverlay (void);
void Sbar_TimeOverlay (void);
void Sbar_DeathmatchOverlay (void);
void Sbar_DeathmatchOverlay2 (void);
void M_DrawPic (int x, int y, qpic_t *pic);
/*
===============
Sbar_ShowScores
Tab key down
===============
*/
void Sbar_ShowScores_f (void)
{
if (sb_showscores)
return;
sb_showscores = true;
sb_updates = 0;
}
/*
===============
Sbar_DontShowScores
Tab key up
===============
*/
void Sbar_DontShowScores_f (void)
{
sb_showscores = false;
sb_updates = 0;
}
/*
===============
Sbar_Changed
===============
*/
void Sbar_Changed (void)
{
sb_updates = 0; // update next frame
}
/*
===============
Sbar_LoadPics -- johnfitz -- load all the sbar pics
===============
*/
void Sbar_LoadPics (void)
{
int i;
for (i=0 ; i<10 ; i++)
{
sb_nums[0][i] = Draw_PicFromWad (va("num_%i",i));
sb_nums[1][i] = Draw_PicFromWad (va("anum_%i",i));
}
sb_nums[0][10] = Draw_PicFromWad ("num_minus");
sb_nums[1][10] = Draw_PicFromWad ("anum_minus");
sb_colon = Draw_PicFromWad ("num_colon");
sb_slash = Draw_PicFromWad ("num_slash");
sb_weapons[0][0] = Draw_PicFromWad ("inv_shotgun");
sb_weapons[0][1] = Draw_PicFromWad ("inv_sshotgun");
sb_weapons[0][2] = Draw_PicFromWad ("inv_nailgun");
sb_weapons[0][3] = Draw_PicFromWad ("inv_snailgun");
sb_weapons[0][4] = Draw_PicFromWad ("inv_rlaunch");
sb_weapons[0][5] = Draw_PicFromWad ("inv_srlaunch");
sb_weapons[0][6] = Draw_PicFromWad ("inv_lightng");
sb_weapons[1][0] = Draw_PicFromWad ("inv2_shotgun");
sb_weapons[1][1] = Draw_PicFromWad ("inv2_sshotgun");
sb_weapons[1][2] = Draw_PicFromWad ("inv2_nailgun");
sb_weapons[1][3] = Draw_PicFromWad ("inv2_snailgun");
sb_weapons[1][4] = Draw_PicFromWad ("inv2_rlaunch");
sb_weapons[1][5] = Draw_PicFromWad ("inv2_srlaunch");
sb_weapons[1][6] = Draw_PicFromWad ("inv2_lightng");
for (i=0 ; i<5 ; i++)
{
sb_weapons[2+i][0] = Draw_PicFromWad (va("inva%i_shotgun",i+1));
sb_weapons[2+i][1] = Draw_PicFromWad (va("inva%i_sshotgun",i+1));
sb_weapons[2+i][2] = Draw_PicFromWad (va("inva%i_nailgun",i+1));
sb_weapons[2+i][3] = Draw_PicFromWad (va("inva%i_snailgun",i+1));
sb_weapons[2+i][4] = Draw_PicFromWad (va("inva%i_rlaunch",i+1));
sb_weapons[2+i][5] = Draw_PicFromWad (va("inva%i_srlaunch",i+1));
sb_weapons[2+i][6] = Draw_PicFromWad (va("inva%i_lightng",i+1));
}
sb_ammo[0] = Draw_PicFromWad ("sb_shells");
sb_ammo[1] = Draw_PicFromWad ("sb_nails");
sb_ammo[2] = Draw_PicFromWad ("sb_rocket");
sb_ammo[3] = Draw_PicFromWad ("sb_cells");
sb_armor[0] = Draw_PicFromWad ("sb_armor1");
sb_armor[1] = Draw_PicFromWad ("sb_armor2");
sb_armor[2] = Draw_PicFromWad ("sb_armor3");
sb_items[0] = Draw_PicFromWad ("sb_key1");
sb_items[1] = Draw_PicFromWad ("sb_key2");
sb_items[2] = Draw_PicFromWad ("sb_invis");
sb_items[3] = Draw_PicFromWad ("sb_invuln");
sb_items[4] = Draw_PicFromWad ("sb_suit");
sb_items[5] = Draw_PicFromWad ("sb_quad");
sb_sigil[0] = Draw_PicFromWad ("sb_sigil1");
sb_sigil[1] = Draw_PicFromWad ("sb_sigil2");
sb_sigil[2] = Draw_PicFromWad ("sb_sigil3");
sb_sigil[3] = Draw_PicFromWad ("sb_sigil4");
sb_faces[4][0] = Draw_PicFromWad ("face1");
sb_faces[4][1] = Draw_PicFromWad ("face_p1");
sb_faces[3][0] = Draw_PicFromWad ("face2");
sb_faces[3][1] = Draw_PicFromWad ("face_p2");
sb_faces[2][0] = Draw_PicFromWad ("face3");
sb_faces[2][1] = Draw_PicFromWad ("face_p3");
sb_faces[1][0] = Draw_PicFromWad ("face4");
sb_faces[1][1] = Draw_PicFromWad ("face_p4");
sb_faces[0][0] = Draw_PicFromWad ("face5");
sb_faces[0][1] = Draw_PicFromWad ("face_p5");
sb_face_invis = Draw_PicFromWad ("face_invis");
sb_face_invuln = Draw_PicFromWad ("face_invul2");
sb_face_invis_invuln = Draw_PicFromWad ("face_inv2");
sb_face_quad = Draw_PicFromWad ("face_quad");
sb_sbar = Draw_PicFromWad ("sbar");
sb_ibar = Draw_PicFromWad ("ibar");
sb_scorebar = Draw_PicFromWad ("scorebar");
//MED 01/04/97 added new hipnotic weapons
if (hipnotic)
{
hsb_weapons[0][0] = Draw_PicFromWad ("inv_laser");
hsb_weapons[0][1] = Draw_PicFromWad ("inv_mjolnir");
hsb_weapons[0][2] = Draw_PicFromWad ("inv_gren_prox");
hsb_weapons[0][3] = Draw_PicFromWad ("inv_prox_gren");
hsb_weapons[0][4] = Draw_PicFromWad ("inv_prox");
hsb_weapons[1][0] = Draw_PicFromWad ("inv2_laser");
hsb_weapons[1][1] = Draw_PicFromWad ("inv2_mjolnir");
hsb_weapons[1][2] = Draw_PicFromWad ("inv2_gren_prox");
hsb_weapons[1][3] = Draw_PicFromWad ("inv2_prox_gren");
hsb_weapons[1][4] = Draw_PicFromWad ("inv2_prox");
for (i=0 ; i<5 ; i++)
{
hsb_weapons[2+i][0] = Draw_PicFromWad (va("inva%i_laser",i+1));
hsb_weapons[2+i][1] = Draw_PicFromWad (va("inva%i_mjolnir",i+1));
hsb_weapons[2+i][2] = Draw_PicFromWad (va("inva%i_gren_prox",i+1));
hsb_weapons[2+i][3] = Draw_PicFromWad (va("inva%i_prox_gren",i+1));
hsb_weapons[2+i][4] = Draw_PicFromWad (va("inva%i_prox",i+1));
}
hsb_items[0] = Draw_PicFromWad ("sb_wsuit");
hsb_items[1] = Draw_PicFromWad ("sb_eshld");
}
if (rogue)
{
rsb_invbar[0] = Draw_PicFromWad ("r_invbar1");
rsb_invbar[1] = Draw_PicFromWad ("r_invbar2");
rsb_weapons[0] = Draw_PicFromWad ("r_lava");
rsb_weapons[1] = Draw_PicFromWad ("r_superlava");
rsb_weapons[2] = Draw_PicFromWad ("r_gren");
rsb_weapons[3] = Draw_PicFromWad ("r_multirock");
rsb_weapons[4] = Draw_PicFromWad ("r_plasma");
rsb_items[0] = Draw_PicFromWad ("r_shield1");
rsb_items[1] = Draw_PicFromWad ("r_agrav1");
// PGM 01/19/97 - team color border
rsb_teambord = Draw_PicFromWad ("r_teambord");
// PGM 01/19/97 - team color border
rsb_ammo[0] = Draw_PicFromWad ("r_ammolava");
rsb_ammo[1] = Draw_PicFromWad ("r_ammomulti");
rsb_ammo[2] = Draw_PicFromWad ("r_ammoplasma");
}
#ifdef SUPPORTS_KUROK
if (kurok)
{
ksb_ammo[0] = Draw_PicFromWad ("sb_50cal");
}
#endif
}
/*
===============
Sbar_Init -- johnfitz -- rewritten
===============
*/
void Sbar_Init (void)
{
Cmd_AddCommand ("+showscores", Sbar_ShowScores_f);
Cmd_AddCommand ("-showscores", Sbar_DontShowScores_f);
#ifdef PROQUAKE_EXTENSION
Cvar_RegisterVariable (&pq_teamscores, NULL); // JPG - status bar teamscores
Cvar_RegisterVariable (&pq_timer, NULL); // JPG - status bar timer
Cvar_RegisterVariable (&pq_scoreboard_pings, NULL); // JPG - ping times in the scoreboard
#endif
Cvar_RegisterVariable (&cl_sbar, SBAR_cl_sbar_f);
Sbar_LoadPics ();
}
//=============================================================================
// drawing routines are relative to the status bar location
/*
=============
Sbar_DrawPic
=============
*/
void Sbar_DrawPic (int x, int y, qpic_t *pic)
{
#ifdef SUPPORTS_KUROK
if(kurok)
Draw_Pic (x /* + ((vid.width - 320)>>1)*/, y + (vid.height-SBAR_HEIGHT), pic);
else
#endif
{
if (cl.gametype == GAME_DEATHMATCH)
Draw_Pic (x /* + ((vid.width - 320)>>1)*/, y + (vid.height-SBAR_HEIGHT), pic);
else
Draw_Pic (x + ((vid.width - 320)>>1), y + (vid.height-SBAR_HEIGHT), pic);
}
}
/*
=============
Sbar_DrawTransPic
=============
*/
#ifdef SUPPORTS_2DPICS_ALPHA
//void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha);
void Sbar_DrawAlphaPic (int x, int y, qpic_t *pic, float alpha)
{
if (cl.gametype == GAME_DEATHMATCH)
Draw_AlphaPic (x /*+ ((vid.width - 320)>>1)*/, y + (vid.height-SBAR_HEIGHT), pic, alpha);
else
Draw_AlphaPic (x + ((vid.width - 320)>>1), y + (vid.height-SBAR_HEIGHT), pic, alpha);
}
#endif
void Sbar_DrawTransPic (int x, int y, qpic_t *pic)
{
#ifdef SUPPORTS_KUROK
if(kurok)
Draw_TransPic (x /*+ ((vid.width - 320)>>1)*/, y + (vid.height-SBAR_HEIGHT), pic);
else
#endif
{
if (cl.gametype == GAME_DEATHMATCH)
Draw_TransPic (x /*+ ((vid.width - 320)>>1)*/, y + (vid.height-SBAR_HEIGHT), pic);
else
Draw_TransPic (x + ((vid.width - 320)>>1), y + (vid.height-SBAR_HEIGHT), pic);
}
}
/*
================
Sbar_DrawCharacter
Draws one solid graphics character
================
*/
void Sbar_DrawCharacter (int x, int y, int num)
{
#ifdef SUPPORTS_KUROK
if(kurok)
Draw_Character ( x /*+ ((vid.width - 320)>>1) */ + 4 , y + vid.height-SBAR_HEIGHT, num);
else
#endif
{
if (cl.gametype == GAME_DEATHMATCH)
Draw_Character ( x /*+ ((vid.width - 320)>>1) */ + 4 , y + vid.height-SBAR_HEIGHT, num);
else
Draw_Character ( x + ((vid.width - 320)>>1) + 4 , y + vid.height-SBAR_HEIGHT, num);
}
}
/*
================
Sbar_DrawString
================
*/
void Sbar_DrawString (int x, int y, char *str)
{
#ifdef SUPPORTS_KUROK
if(kurok)
Draw_String (x /*+ ((vid.width - 320)>>1)*/, y + vid.height-SBAR_HEIGHT, str);
else
#endif
{
if (cl.gametype == GAME_DEATHMATCH)
Draw_String (x /*+ ((vid.width - 320)>>1)*/, y+ vid.height-SBAR_HEIGHT, str);
else
Draw_String (x + ((vid.width - 320)>>1), y+ vid.height-SBAR_HEIGHT, str);
}
}
/*
===============
Sbar_DrawScrollString -- johnfitz
scroll the string inside a glscissor region
===============
*/
void Sbar_DrawScrollString (int x, int y, int width, char* str)
{
int len, ofs;
y += vid.height-SBAR_HEIGHT;
// if (cl.gametype != GAME_DEATHMATCH) x += ((vid.width - 320)>>1);
len = strlen(str)*8 + 40;
ofs = ((int)(realtime*30))%len;
// sceGuEnable(GU_SCISSOR_TEST);
// sceGuViewport (x, y, glwidth, glheight);
// sceGuScissor (x, vid.height - y - 8, 160, 8);
Draw_String (x - ofs, y, str);
Draw_String (x - ofs + len - 32, y, "///");
Draw_String (x - ofs + len, y, str);
// sceGuDisable(GU_SCISSOR_TEST);
}
/*
=============
Sbar_itoa
=============
*/
int Sbar_itoa (int num, char *buf)
{
char *str;
int pow10, dig;
str = buf;
if (num < 0)
{
*str++ = '-';
num = -num;
}
for (pow10 = 10 ; num >= pow10 ; pow10 *= 10)
;
do {
pow10 /= 10;
dig = num/pow10;
*str++ = '0'+dig;
num -= dig*pow10;
} while (pow10 != 1);
*str = 0;
return str-buf;
}
/*
=============
Sbar_DrawNum
=============
*/
void Sbar_DrawNum (int x, int y, int num, int digits, int color)
{
char str[12], *ptr;
int l, frame;
l = Sbar_itoa (num, str);
ptr = str;
if (l > digits)
ptr += (l-digits);
if (l < digits)
{
#ifdef SUPPORTS_KUROK
if (kurok)
x += (digits-l)*16;
else
#endif
x += (digits-l)*24;
}
while (*ptr)
{
frame = (*ptr == '-') ? STAT_MINUS : *ptr -'0';
Sbar_DrawTransPic (x,y,sb_nums[color][frame]);
#ifdef SUPPORTS_KUROK
if (kurok)
x += 16;
else
#endif
x += 24;
ptr++;
}
}
#ifdef SUPPORTS_KUROK
/*
=============
Sbar_DrawNum2
=============
*/
void Sbar_DrawNum2 (int x, int y, int num, int digits, int color)
{
char str[12];
char *ptr;
int l, frame;
l = Sbar_itoa (num, str);
ptr = str;
if (l > digits)
ptr += (l-digits);
if (l < digits)
x += (digits-l)*0;
while (*ptr)
{
if (*ptr == '-')
frame = STAT_MINUS;
else
frame = *ptr -'0';
Sbar_DrawTransPic (x,y,sb_nums[color][frame]);
x += 16;
ptr++;
}
}
#endif
//=============================================================================
int fragsort[MAX_SCOREBOARD];
char scoreboardtext[MAX_SCOREBOARD][20];
int scoreboardtop[MAX_SCOREBOARD];
int scoreboardbottom[MAX_SCOREBOARD];
int scoreboardcount[MAX_SCOREBOARD];
int scoreboardlines;
/*
===============
Sbar_SortFrags
===============
*/
void Sbar_SortFrags (void)
{
int i, j, k;
// sort by frags
scoreboardlines = 0;
for (i=0 ; i<cl.maxclients ; i++)
{
if (cl.scores[i].name[0])
{
fragsort[scoreboardlines] = i;
scoreboardlines++;
}
}
for (i=0 ; i<scoreboardlines ; i++)
for (j=0 ; j<scoreboardlines-1-i ; j++)
if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
{
k = fragsort[j];
fragsort[j] = fragsort[j+1];
fragsort[j+1] = k;
}
}
#ifdef PROQUAKE_EXTENSION
/* JPG - added this for teamscores in status bar
==================
Sbar_SortTeamFrags
==================
*/
void Sbar_SortTeamFrags (void)
{
int i, j, k;
// sort by frags
scoreboardlines = 0;
for (i=0 ; i<14 ; i++)
{
if (cl.teamscores[i].colors)
{
fragsort[scoreboardlines] = i;
scoreboardlines++;
}
}
for (i=0 ; i<scoreboardlines ; i++)
for (j=0 ; j<scoreboardlines-1-i ; j++)
if (cl.teamscores[fragsort[j]].frags < cl.teamscores[fragsort[j+1]].frags)
{
k = fragsort[j];
fragsort[j] = fragsort[j+1];
fragsort[j+1] = k;
}
}
#endif
int Sbar_ColorForMap (int m)
{
return m < 128 ? m + 8 : m + 8;
}
/*
===============
Sbar_UpdateScoreboard
===============
*/
void Sbar_UpdateScoreboard (void)
{
int i, k, top, bottom;
scoreboard_t *s;
Sbar_SortFrags ();
// draw the text
memset (scoreboardtext, 0, sizeof(scoreboardtext));
for (i=0 ; i<scoreboardlines; i++)
{
k = fragsort[i];
s = &cl.scores[k];
snprintf(&scoreboardtext[i][1], sizeof(&scoreboardtext[i][1]), "%3i %s", s->frags, s->name);
top = s->colors & 0xf0;
bottom = (s->colors & 15) <<4;
scoreboardtop[i] = Sbar_ColorForMap (top);
scoreboardbottom[i] = Sbar_ColorForMap (bottom);
}
}
/*
===============
Sbar_SoloScoreboard
===============
*/
void Sbar_SoloScoreboard (void)
{
char str[80];
int len, minutes, seconds, tens, units;
#ifdef SUPPORTS_KUROK
if(kurok)
snprintf(str, sizeof(str), "Enemies :%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
else
#endif
snprintf(str, sizeof(str), "Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
Sbar_DrawString (8, 4, str);
#ifdef SUPPORTS_KUROK
if(kurok)
snprintf(str, sizeof(str), "Objectives :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
else
#endif
snprintf(str, sizeof(str), "Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
Sbar_DrawString (8, 12, str);
// time
minutes = cl.time / 60;
seconds = cl.time - 60*minutes;
tens = seconds / 10;
units = seconds - 10*tens;
snprintf(str, sizeof(str), "Time :%3i:%i%i", minutes, tens, units);
Sbar_DrawString (184, 4, str);
// draw level name
//johnfitz -- scroll long levelnames
len = strlen (cl.levelname);
#ifdef PSP_HARDWARE_VIDEO
if (len > 22)
Sbar_DrawScrollString (184, 12, 160, cl.levelname);
else
#endif
// Sbar_DrawString (232 - len*4, 12, cl.levelname);
Sbar_DrawString (184, 12, cl.levelname);
//johnfitz
// l = strlen (cl.levelname);
// Sbar_DrawString (232 - l*4, 12, cl.levelname);
}
/*
===============
Sbar_DrawScoreboard
===============
*/
void Sbar_DrawScoreboard (void)
{
Sbar_SoloScoreboard ();
if (cl.gametype == GAME_DEATHMATCH)
Sbar_DeathmatchOverlay ();
}
//=============================================================================
/*
===============
Sbar_DrawInventory
===============
*/
void Sbar_DrawInventory (void)
{
int i, flashon, ystart;
char num[6];
float time;
{
if (rogue)
{
if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
#ifdef SUPPORTS_2DPICS_ALPHA
Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], cl_sbar.value);
#else
Sbar_DrawPic (0, -24, rsb_invbar[0]);
#endif
else
#ifdef SUPPORTS_2DPICS_ALPHA
Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], cl_sbar.value);
#else
Sbar_DrawPic (0, -24, rsb_invbar[1]);
#endif
}
else if (!kurok)
{
#ifdef SUPPORTS_2DPICS_ALPHA
Sbar_DrawAlphaPic (0, -24, sb_ibar, cl_sbar.value);
#else
Sbar_DrawPic (0, -24, sb_ibar);
#endif
}
}
// weapons
if (!kurok)
{
for (i=0 ; i<7 ; i++)
{
if (cl.items & (IT_SHOTGUN<<i) )
{
time = cl.item_gettime[i];
flashon = (int)((cl.time - time)*10);
if (flashon < 0)
flashon = 0;
if (flashon >= 10)
flashon = (cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN << i)) ? 1 : 0;
else
flashon = (flashon%5) + 2;
{
#ifdef SUPPORTS_2DPICS_ALPHA
Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], cl_sbar.value);
#else
Sbar_DrawPic (i*24, -16, sb_weapons[flashon][i]);
#endif
}
if (flashon > 1)
sb_updates = 0; // force update to remove flash
}
}
}
// MED 01/04/97
// hipnotic weapons
if (hipnotic)
{
int grenadeflashing=0;
for (i=0 ; i<4 ; i++)
{
if (cl.items & (1<<hipweapons[i]) )
{
time = cl.item_gettime[hipweapons[i]];
flashon = (int)((cl.time - time)*10);
if (flashon < 0)
flashon = 0;
if (flashon >= 10)
flashon = (cl.stats[STAT_ACTIVEWEAPON] == (1 << hipweapons[i])) ? 1 : 0;
else
flashon = (flashon%5) + 2;
// check grenade launcher
if (i==2)
{
if (cl.items & HIT_PROXIMITY_GUN)
{
if (flashon)
{
grenadeflashing = 1;
Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
}
}
}
else if (i==3)
{
if (cl.items & (IT_SHOTGUN<<4))
{
if (flashon && !grenadeflashing)
{
Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
}
else if (!grenadeflashing)
{
Sbar_DrawPic (96, -16, hsb_weapons[0][3]);
}
}
else
Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
}
else
Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
if (flashon > 1)
sb_updates = 0; // force update to remove flash
}
}
}
// rogue weapons
if (rogue)
{ // check for powered up weapon
if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
{
for (i=0;i<5;i++)
{
if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
}
}
}
if (!kurok)
{
// ammo counts
for (i=0 ; i<4 ; i++)
{
snprintf(num, sizeof(num), "%3i",cl.stats[STAT_SHELLS+i] );
{
if (num[0] != ' ')
Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
if (num[1] != ' ')
Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
if (num[2] != ' ')
Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
}
}
}
flashon = 0;
// items
for (i=0 ; i<6 ; i++) {
if (cl.items & (1<<(17+i)))
{
time = cl.item_gettime[17+i];
if (time && time > cl.time - 2 && flashon )
{ // flash frame
sb_updates = 0;
}
else
{ //MED 01/04/97 changed keys
if (!hipnotic || (i>1))
{
#ifdef SUPPORTS_KUROK
if(kurok)
Sbar_DrawAlphaPic (80 + i*16, 0, sb_items[i], cl_sbar.value);
else
#endif
Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
}
}
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
//MED 01/04/97 added hipnotic items
// hipnotic items
if (hipnotic) {
for (i=0 ; i<2 ; i++) {
if (cl.items & (1<<(24+i))) {
time = cl.item_gettime[24+i];
if (time && time > cl.time - 2 && flashon ) // flash frame
sb_updates = 0;
else
Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
}
// rogue items
if (rogue)
{
// new rogue items
for (i=0 ; i<2 ; i++)
{
if (cl.items & (1<<(29+i)))
{
time = cl.item_gettime[29+i];
if (time && time > cl.time - 2 && flashon )
{ // flash frame
sb_updates = 0;
}
else
{
Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
}
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
}
if (kurok)
{
}
else
{
// sigils
for (i=0 ; i<4 ; i++)
{
if (cl.items & (1<<(28+i)))
{
time = cl.item_gettime[28+i];
if (time && time > cl.time - 2 && flashon ) // flash frame
sb_updates = 0;
else
Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
}
}
//=============================================================================
/*
===============
Sbar_DrawFrags
===============
*/
void Sbar_DrawFrags (void)
{
int i, k, numscores;
int top, bottom;
int x, y, f;
int xofs;
char num[12];
scoreboard_t *s;
Sbar_SortFrags ();
// draw the text
numscores = scoreboardlines <= 4 ? scoreboardlines : 4;
x = 23;
if (kurok)
{
xofs = 0;
}
else
{
if (cl.gametype == GAME_DEATHMATCH)
xofs = 0;
else
xofs = (vid.width - 320)>>1;
}
y = vid.height - SBAR_HEIGHT - 23;
for (i=0 ; i<numscores ; i++)
{
k = fragsort[i];
s = &cl.scores[k];