-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsbar.pas
1335 lines (1123 loc) · 31.6 KB
/
sbar.pas
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
// ------------------------------------------------------------------------------
// DelphiQuake, Copyright (C) 2005-2011 by Jim Valavanis
// E-Mail: [email protected]
//
// 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.
//
// ------------------------------------------------------------------------------
{$I dquake.inc}
{$Z4}
unit sbar;
// the status bar is only redrawn if something has changed, but if anything
// does, the entire thing will be redrawn for the next vid.numpages frames.
// sbar.c -- status bar code
interface
const
SBAR_HEIGHT = 24;
procedure Sbar_Init;
procedure Sbar_Changed;
// call whenever any of the client stats represented on the sbar changes
procedure Sbar_Draw;
// called every frame by screen
procedure Sbar_IntermissionOverlay;
// called each frame after the level has been completed
procedure Sbar_FinaleOverlay;
procedure Sbar_DrawString(const x, y: integer; str: PChar);
var
sb_lines: integer; // scan lines to draw
implementation
uses
q_delphi,
wad,
quakedef,
gl_draw,
common,
cmd,
cl_main_h,
protocol,
gl_vidnt,
client,
host_h,
gl_screen,
menu;
var
sb_updates: integer; // if >= vid.numpages, no update needed
const
STAT_MINUS = 10; // num frame for '-' stats digit
var
sb_nums: array[0..1, 0..10] of Pqpic_t;
sb_colon, sb_slash: Pqpic_t;
sb_ibar: Pqpic_t;
sb_sbar: Pqpic_t;
sb_scorebar: Pqpic_t;
sb_weapons: array[0..6, 0..7] of Pqpic_t; // 0 is active, 1 is owned, 2-5 are flashes
sb_ammo: array[0..3] of Pqpic_t;
sb_sigil: array[0..3] of Pqpic_t;
sb_armor: array[0..2] of Pqpic_t;
sb_items: array[0..31] of Pqpic_t;
sb_faces: array[0..6, 0..1] of Pqpic_t; // 0 is gibbed, 1 is dead, 2-6 are alive
// 0 is static, 1 is temporary animation
sb_face_invis: Pqpic_t;
sb_face_quad: Pqpic_t;
sb_face_invuln: Pqpic_t;
sb_face_invis_invuln: Pqpic_t;
sb_showscores: qboolean;
rsb_invbar: array[0..1] of Pqpic_t;
rsb_weapons: array[0..4] of Pqpic_t;
rsb_items: array[0..1] of Pqpic_t;
rsb_ammo: array[0..2] of Pqpic_t;
rsb_teambord: Pqpic_t; // PGM 01/19/97 - team color border
//MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
hsb_weapons: array[0..6, 0..4] of Pqpic_t; // 0 is active, 1 is owned, 2-5 are flashes
//MED 01/04/97 added hipnotic items array
hsb_items: array[0..1] of Pqpic_t;
const
//MED 01/04/97 added array to simplify weapon parsing
hipweapons: array[0..3] of integer = (
HIT_LASER_CANNON_BIT,
HIT_MJOLNIR_BIT,
4,
HIT_PROXIMITY_GUN_BIT
);
procedure Sbar_MiniDeathmatchOverlay; forward;
procedure Sbar_DeathmatchOverlay; forward;
(*
===============
Sbar_ShowScores
Tab key down
===============
*)
procedure Sbar_ShowScores;
begin
if not sb_showscores then
begin
sb_showscores := true;
sb_updates := 0;
end;
end;
(*
===============
Sbar_DontShowScores
Tab key up
===============
*)
procedure Sbar_DontShowScores;
begin
sb_showscores := false;
sb_updates := 0;
end;
(*
===============
Sbar_Changed
===============
*)
procedure Sbar_Changed;
begin
sb_updates := 0; // update next frame
end;
(*
===============
Sbar_Init
===============
*)
procedure Sbar_Init;
var
i: integer;
begin
for i := 0 to 9 do
begin
sb_nums[0][i] := Draw_PicFromWad(va('num_%d', [i]));
sb_nums[1][i] := Draw_PicFromWad(va('anum_%d', [i]));
end;
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 to 4 do
begin
sb_weapons[2 + i][0] := Draw_PicFromWad(va('inva%d_shotgun', [i + 1]));
sb_weapons[2 + i][1] := Draw_PicFromWad(va('inva%d_sshotgun', [i + 1]));
sb_weapons[2 + i][2] := Draw_PicFromWad(va('inva%d_nailgun', [i + 1]));
sb_weapons[2 + i][3] := Draw_PicFromWad(va('inva%d_snailgun', [i + 1]));
sb_weapons[2 + i][4] := Draw_PicFromWad(va('inva%d_rlaunch', [i + 1]));
sb_weapons[2 + i][5] := Draw_PicFromWad(va('inva%d_srlaunch', [i + 1]));
sb_weapons[2 + i][6] := Draw_PicFromWad(va('inva%d_lightng', [i + 1]));
end;
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');
Cmd_AddCommand('+showscores', Sbar_ShowScores);
Cmd_AddCommand('-showscores', Sbar_DontShowScores);
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 then
begin
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 to 4 do
begin
hsb_weapons[2 + i][0] := Draw_PicFromWad(va('inva%d_laser', [i + 1]));
hsb_weapons[2 + i][1] := Draw_PicFromWad(va('inva%d_mjolnir', [i + 1]));
hsb_weapons[2 + i][2] := Draw_PicFromWad(va('inva%d_gren_prox', [i + 1]));
hsb_weapons[2 + i][3] := Draw_PicFromWad(va('inva%d_prox_gren', [i + 1]));
hsb_weapons[2 + i][4] := Draw_PicFromWad(va('inva%d_prox', [i + 1]));
end;
hsb_items[0] := Draw_PicFromWad('sb_wsuit');
hsb_items[1] := Draw_PicFromWad('sb_eshld');
end;
if rogue then
begin
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');
end;
end;
//=============================================================================
// drawing routines are relative to the status bar location
(*
=============
Sbar_DrawPic
=============
*)
procedure Sbar_DrawPic(const x, y: integer; pic: Pqpic_t);
begin
if cl.gametype = GAME_DEATHMATCH then
Draw_Pic(x (* + ((vid.width - 320)>>1)*), y + (vid.height - SBAR_HEIGHT), pic)
else
Draw_Pic(x + ((vid.width - 320) div 2), y + (vid.height - SBAR_HEIGHT), pic);
end;
(*
=============
Sbar_DrawTransPic
=============
*)
procedure Sbar_DrawTransPic(const x, y: integer; pic: Pqpic_t);
begin
if cl.gametype = GAME_DEATHMATCH then
Draw_TransPic(x (*+ ((vid.width - 320)>>1)*), y + (vid.height - SBAR_HEIGHT), pic)
else
Draw_TransPic(x + ((vid.width - 320) div 2), y + (vid.height - SBAR_HEIGHT), pic);
end;
(*
================
Sbar_DrawCharacter
Draws one solid graphics character
================
*)
procedure Sbar_DrawCharacter(const x, y: integer; const num: integer);
begin
if cl.gametype = GAME_DEATHMATCH then
Draw_Character(x (*+ ((vid.width - 320)>>1) *) + 4, y + vid.height - SBAR_HEIGHT, num)
else
Draw_Character(x + ((vid.width - 320) div 2) + 4, y + vid.height - SBAR_HEIGHT, num);
end;
(*
================
Sbar_DrawString
================
*)
procedure Sbar_DrawString(const x, y: integer; str: PChar);
begin
if cl.gametype = GAME_DEATHMATCH then
Draw_String(x (*+ ((vid.width - 320)>>1)*), y + vid.height - SBAR_HEIGHT, str)
else
Draw_String(x + ((vid.width - 320) div 2), y + vid.height - SBAR_HEIGHT, str);
end;
(*
=============
Sbar_itoa
=============
*)
function Sbar_itoa(num: integer; buf: PChar): integer;
var
str: PChar;
pow10: integer;
dig: integer;
begin
str := buf;
if num < 0 then
begin
str^ := '-';
inc(str);
num := -num;
end;
pow10 := 10;
while num >= pow10 do
pow10 := pow10 * 10;
repeat
pow10 := pow10 div 10;
dig := num div pow10;
str^ := Chr(Ord('0') + dig);
inc(str);
num := num - dig * pow10;
until pow10 = 1;
str^ := #0;
result := integer(str) - integer(buf);
end;
(*
=============
Sbar_DrawNum
=============
*)
procedure Sbar_DrawNum(x, y: integer; const num: integer; const digits: integer;
const color: integer);
var
str: array[0..11] of char;
ptr: PChar;
l, frame: integer;
begin
l := Sbar_itoa(num, str);
ptr := @str[0];
if l > digits then
inc(ptr, (l - digits));
if l < digits then
inc(x, (digits - l) * 24);
while ptr^ <> #0 do
begin
if ptr^ = '-' then
frame := STAT_MINUS
else
frame := Ord(ptr^) - Ord('0');
Sbar_DrawTransPic(x, y, sb_nums[color][frame]);
inc(x, 24);
inc(ptr);
end;
end;
//=============================================================================
var
fragsort: array[0..MAX_SCOREBOARD - 1] of integer;
scoreboardtext: array[0..MAX_SCOREBOARD - 1] of array[0..19] of char;
scoreboardtop: array[0..MAX_SCOREBOARD - 1] of integer;
scoreboardbottom: array[0..MAX_SCOREBOARD - 1] of integer;
scoreboardcount: array[0..MAX_SCOREBOARD - 1] of integer;
scoreboardlines: integer;
(*
===============
Sbar_SortFrags
===============
*)
procedure Sbar_SortFrags;
var
i, j, k: integer;
begin
// sort by frags
scoreboardlines := 0;
for i := 0 to cl.maxclients - 1 do
begin
if cl.scores[i].name[0] <> #0 then
begin
fragsort[scoreboardlines] := i;
inc(scoreboardlines);
end;
end;
for i := 0 to scoreboardlines - 1 do
for j := 0 to scoreboardlines - i - 2 do
if cl.scores[fragsort[j]].frags < cl.scores[fragsort[j + 1]].frags then
begin
k := fragsort[j];
fragsort[j] := fragsort[j + 1];
fragsort[j + 1] := k;
end;
end;
function Sbar_ColorForMap(m: integer): integer; // JVAL ???
begin
result := m + 8;
end;
(*
===============
Sbar_UpdateScoreboard
===============
*)
procedure Sbar_UpdateScoreboard;
var
i, k: integer;
top, bottom: integer;
s: Pscoreboard_t;
begin
Sbar_SortFrags;
// draw the text
ZeroMemory(@scoreboardtext, SizeOf(scoreboardtext));
for i := 0 to scoreboardlines - 1 do
begin
k := fragsort[i];
s := @cl.scores[k];
sprintf(@scoreboardtext[i][1], '%3d %s', [s.frags, s.name]);
top := s.colors and $F0;
bottom := (s.colors and 15) * 16;
scoreboardtop[i] := Sbar_ColorForMap(top);
scoreboardbottom[i] := Sbar_ColorForMap(bottom);
end;
end;
(*
===============
Sbar_SoloScoreboard
===============
*)
procedure Sbar_SoloScoreboard;
var
str: array[0..79] of char;
minutes, seconds, tens, units: integer;
l: integer;
begin
sprintf(str, 'Monsters:%3d /%3d', [cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]]);
Sbar_DrawString(8, 4, str);
sprintf(str, 'Secrets :%3d /%3d', [cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]]);
Sbar_DrawString(8, 12, str);
// time
minutes := intval(cl.time / 60);
seconds := intval(cl.time - 60 * minutes);
tens := seconds div 10;
units := seconds - 10 * tens;
sprintf(str, 'Time :%3d:%d%d', [minutes, tens, units]);
Sbar_DrawString(184, 4, str);
// draw level name
l := strlen(cl.levelname);
Sbar_DrawString(232 - l * 4, 12, cl.levelname);
end;
(*
===============
Sbar_DrawScoreboard
===============
*)
procedure Sbar_DrawScoreboard;
begin
Sbar_SoloScoreboard;
if cl.gametype = GAME_DEATHMATCH then
Sbar_DeathmatchOverlay;
end;
//=============================================================================
(*
===============
Sbar_DrawInventory
===============
*)
procedure Sbar_DrawInventory;
var
i: integer;
num: array[0..5] of char;
time: single;
flashon: integer;
grenadeflashing: integer;
begin
if rogue then
begin
if cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN then
Sbar_DrawPic(0, -24, rsb_invbar[0])
else
Sbar_DrawPic(0, -24, rsb_invbar[1]);
end
else
begin
Sbar_DrawPic(0, -24, sb_ibar);
end;
// weapons
for i := 0 to 6 do
begin
if cl.items and (IT_SHOTGUN shl i) <> 0 then
begin
time := cl.item_gettime[i];
flashon := intval((cl.time - time) * 10);
if flashon >= 10 then
begin
if cl.stats[STAT_ACTIVEWEAPON] = (IT_SHOTGUN shl i) then
flashon := 1
else
flashon := 0;
end
else
flashon := (flashon mod 5) + 2;
Sbar_DrawPic(i * 24, -16, sb_weapons[flashon][i]);
if flashon > 1 then
sb_updates := 0; // force update to remove flash
end;
end;
// MED 01/04/97
// hipnotic weapons
if hipnotic then
begin
grenadeflashing := 0;
for i := 0 to 3 do
begin
if cl.items and (1 shl hipweapons[i]) <> 0 then
begin
time := cl.item_gettime[hipweapons[i]];
flashon := intval((cl.time - time) * 10);
if flashon >= 10 then
begin
if cl.stats[STAT_ACTIVEWEAPON] = (1 shl hipweapons[i]) then
flashon := 1
else
flashon := 0;
end
else
flashon := (flashon mod 5) + 2;
// check grenade launcher
if i = 2 then
begin
if cl.items and HIT_PROXIMITY_GUN <> 0 then
begin
if flashon <> 0 then
begin
grenadeflashing := 1;
Sbar_DrawPic(96, -16, hsb_weapons[flashon][2]);
end;
end;
end
else if i = 3 then
begin
if cl.items and (IT_SHOTGUN shl 4) <> 0 then
begin
if (flashon <> 0) and (grenadeflashing = 0) then
begin
Sbar_DrawPic(96, -16, hsb_weapons[flashon][3]);
end
else if grenadeflashing = 0 then
begin
Sbar_DrawPic(96, -16, hsb_weapons[0][3]);
end
end
else
Sbar_DrawPic(96, -16, hsb_weapons[flashon][4]);
end
else
Sbar_DrawPic(176 + (i * 24), -16, hsb_weapons[flashon][i]);
if flashon > 1 then
sb_updates := 0; // force update to remove flash
end;
end;
end;
if rogue then
begin
// check for powered up weapon.
if cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN then
begin
for i := 0 to 4 do
begin
if cl.stats[STAT_ACTIVEWEAPON] = (RIT_LAVA_NAILGUN shl i) then
Sbar_DrawPic((i + 2) * 24, -16, rsb_weapons[i]);
end;
end;
end;
// ammo counts
for i := 0 to 3 do
begin
sprintf(num, '%3d', [cl.stats[STAT_SHELLS + i]]);
if num[0] <> ' ' then
Sbar_DrawCharacter((6 * i + 1) * 8 - 2, -24, 18 + Ord(num[0]) - Ord('0'));
if num[1] <> ' ' then
Sbar_DrawCharacter((6 * i + 2) * 8 - 2, -24, 18 + Ord(num[1]) - Ord('0'));
if num[2] <> ' ' then
Sbar_DrawCharacter((6 * i + 3) * 8 - 2, -24, 18 + Ord(num[2]) - Ord('0'));
end;
flashon := 0;
// items
for i := 0 to 5 do
if cl.items and (1 shl (17 + i)) <> 0 then
begin
time := cl.item_gettime[17 + i];
if (time <> 0) and (time > cl.time - 2) and (flashon <> 0) then
begin // flash frame
sb_updates := 0;
end
else
begin
//MED 01/04/97 changed keys
if not hipnotic or (i > 1) then
begin
Sbar_DrawPic(192 + i * 16, -16, sb_items[i]);
end;
end;
if (time <> 0) and (time > cl.time - 2) then
sb_updates := 0;
end;
//MED 01/04/97 added hipnotic items
// hipnotic items
if hipnotic then
for i := 0 to 1 do
if cl.items and (1 shl (24 + i)) <> 0 then
begin
time := cl.item_gettime[24 + i];
if (time <> 0) and (time > cl.time - 2) and (flashon <> 0) then
begin // flash frame
sb_updates := 0;
end
else
begin
Sbar_DrawPic(288 + i * 16, -16, hsb_items[i]);
end;
if (time <> 0) and (time > cl.time - 2) then
sb_updates := 0;
end;
if rogue then
begin
// new rogue items
for i := 0 to 1 do
begin
if cl.items and (1 shl (29 + i)) <> 0 then
begin
time := cl.item_gettime[29 + i];
if (time <> 0) and (time > cl.time - 2) and (flashon <> 0) then
begin // flash frame
sb_updates := 0;
end
else
begin
Sbar_DrawPic(288 + i * 16, -16, rsb_items[i]);
end;
if (time <> 0) and (time > cl.time - 2) then
sb_updates := 0;
end;
end;
end
else
begin
// sigils
for i := 0 to 3 do
begin
if cl.items and (1 shl (28 + i)) <> 0 then
begin
time := cl.item_gettime[28 + i];
if (time <> 0) and (time > cl.time - 2) and (flashon <> 0) then
begin // flash frame
sb_updates := 0;
end
else
Sbar_DrawPic(320 - 32 + i * 8, -16, sb_sigil[i]);
if (time <> 0) and (time > cl.time - 2) then
sb_updates := 0;
end;
end;
end;
end;
//=============================================================================
(*
===============
Sbar_DrawFrags
===============
*)
procedure Sbar_DrawFrags;
var
i, k, l: integer;
top, bottom: integer;
x, y, f: integer;
xofs: integer;
num: array[0..11] of char;
s: Pscoreboard_t;
begin
Sbar_SortFrags;
// draw the text
if scoreboardlines <= 4 then
l := scoreboardlines
else
l := 4;
x := 23;
if cl.gametype = GAME_DEATHMATCH then
xofs := 0
else
xofs := (vid.width - 320) div 2;
y := vid.height - SBAR_HEIGHT - 23;
for i := 0 to l - 1 do
begin
k := fragsort[i];
s := @cl.scores[k];
if s.name[0] = #0 then
continue;
// draw background
top := s.colors and $F0;
bottom := (s.colors and 15) * 16;
top := Sbar_ColorForMap(top);
bottom := Sbar_ColorForMap(bottom);
Draw_Fill(xofs + x * 8 + 10, y, 28, 4, top);
Draw_Fill(xofs + x * 8 + 10, y + 4, 28, 3, bottom);
// draw number
f := s.frags;
sprintf(num, '%3d', [f]);
Sbar_DrawCharacter((x + 1) * 8, -24, Ord(num[0]));
Sbar_DrawCharacter((x + 2) * 8, -24, Ord(num[1]));
Sbar_DrawCharacter((x + 3) * 8, -24, Ord(num[2]));
if k = cl.viewentity - 1 then
begin
Sbar_DrawCharacter(x * 8 + 2, -24, 16);
Sbar_DrawCharacter((x + 4) * 8 - 4, -24, 17);
end;
inc(x, 4);
end;
end;
//=============================================================================
(*
===============
Sbar_DrawFace
===============
*)
procedure Sbar_DrawFace;
var
f, anim: integer;
top, bottom: integer;
xofs: integer;
num: array[0..11] of char;
s: Pscoreboard_t;
begin
// PGM 01/19/97 - team color drawing
// PGM 03/02/97 - fixed so color swatch only appears in CTF modes
if rogue and
(cl.maxclients <> 1) and
(teamplay.value > 3) and
(teamplay.value < 7) then
begin
s := @cl.scores[cl.viewentity - 1];
// draw background
top := s.colors and $F0;
bottom := (s.colors and 15) * 16;
top := Sbar_ColorForMap(top);
bottom := Sbar_ColorForMap(bottom);
if cl.gametype = GAME_DEATHMATCH then
xofs := 113
else
xofs := ((vid.width - 320) div 2) + 113;
Sbar_DrawPic(112, 0, rsb_teambord);
Draw_Fill(xofs, vid.height - SBAR_HEIGHT + 3, 22, 9, top);
Draw_Fill(xofs, vid.height - SBAR_HEIGHT + 12, 22, 9, bottom);
// draw number
f := s.frags;
sprintf(num, '%3d', [f]);
if top = 8 then
begin
if num[0] <> ' ' then
Sbar_DrawCharacter(109, 3, 18 + Ord(num[0]) - Ord('0'));
if num[1] <> ' ' then
Sbar_DrawCharacter(116, 3, 18 + Ord(num[1]) - Ord('0'));
if num[2] <> ' ' then
Sbar_DrawCharacter(123, 3, 18 + Ord(num[2]) - Ord('0'));
end
else
begin
Sbar_DrawCharacter(109, 3, Ord(num[0]));
Sbar_DrawCharacter(116, 3, Ord(num[1]));
Sbar_DrawCharacter(123, 3, Ord(num[2]));
end;
exit;
end;
// PGM 01/19/97 - team color drawing
if cl.items and (IT_INVISIBILITY or IT_INVULNERABILITY) =
(IT_INVISIBILITY or IT_INVULNERABILITY) then
begin
Sbar_DrawPic(112, 0, sb_face_invis_invuln);
exit;
end;
if cl.items and IT_QUAD <> 0 then
begin
Sbar_DrawPic(112, 0, sb_face_quad);
exit;
end;
if cl.items and IT_INVISIBILITY <> 0 then
begin
Sbar_DrawPic(112, 0, sb_face_invis);
exit;
end;
if cl.items and IT_INVULNERABILITY <> 0 then
begin
Sbar_DrawPic(112, 0, sb_face_invuln);
exit;
end;
if cl.stats[STAT_HEALTH] >= 100 then
f := 4
else
f := cl.stats[STAT_HEALTH] div 20;
if cl.time <= cl.faceanimtime then
begin
anim := 1;
sb_updates := 0; // make sure the anim gets drawn over
end
else
anim := 0;
Sbar_DrawPic(112, 0, sb_faces[f][anim]);
end;
(*
===============
Sbar_Draw
===============
*)
procedure Sbar_Draw;
begin
if scr_con_current = vid.height then
exit; // console is full screen
if sb_updates >= vid.numpages then
exit;
scr_copyeverything := true;
inc(sb_updates);
if (sb_lines <> 0) and (vid.width > 320) then
Draw_TileClear(0, vid.height - sb_lines, vid.width, sb_lines);
if sb_lines > 24 then
begin
Sbar_DrawInventory;
if cl.maxclients <> 1 then
Sbar_DrawFrags;
end;
if sb_showscores or (cl.stats[STAT_HEALTH] <= 0) then
begin
Sbar_DrawPic(0, 0, sb_scorebar);
Sbar_DrawScoreboard;
sb_updates := 0;
end
else if sb_lines <> 0 then
begin
Sbar_DrawPic(0, 0, sb_sbar);
// keys (hipnotic only)
//MED 01/04/97 moved keys here so they would not be overwritten
if hipnotic then
begin
if cl.items and IT_KEY1 <> 0 then
Sbar_DrawPic(209, 3, sb_items[0]);