-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhu_stuff.c
1620 lines (1460 loc) · 51.9 KB
/
hu_stuff.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
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id: hu_stuff.c,v 1.3 2000-08-12 21:29:25 fraggle Exp $
//
// Copyright (C) 1993-1996 by 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
//
// DESCRIPTION: Heads-up displays
//
//-----------------------------------------------------------------------------
static const char
rcsid[] = "$Id: hu_stuff.c,v 1.3 2000-08-12 21:29:25 fraggle Exp $";
// killough 5/3/98: remove unnecessary headers
#include "doomstat.h"
#include "hu_stuff.h"
#include "hu_lib.h"
#include "st_stuff.h" /* jff 2/16/98 need loc of status bar */
#include "w_wad.h"
#include "s_sound.h"
#include "dstrings.h"
#include "sounds.h"
#include "d_deh.h" /* Ty 03/27/98 - externalization of mapnamesx arrays */
#include "r_draw.h"
// global heads up display controls
int hud_active; //jff 2/17/98 controls heads-up display mode
int hud_displayed; //jff 2/23/98 turns heads-up display on/off
int hud_nosecrets; //jff 2/18/98 allows secrets line to be disabled in HUD
int hud_distributed; //jff 3/4/98 display HUD in different places on screen
int hud_graph_keys=1; //jff 3/7/98 display HUD keys as graphics
//
// Locally used constants, shortcuts.
//
// Ty 03/28/98 -
// These four shortcuts modifed to reflect char ** of mapnamesx[]
#define HU_TITLE (*mapnames[(gameepisode-1)*9+gamemap-1])
#define HU_TITLE2 (*mapnames2[gamemap-1])
#define HU_TITLEM (*mapnamesm[gamemap-1])
#define HU_TITLEN (*mapnamesn[gamemap-1])
#define HU_TITLEP (*mapnamesp[gamemap-1])
#define HU_TITLET (*mapnamest[gamemap-1])
#define HU_TITLEHEIGHT 1
#define HU_TITLEX 0
//jff 2/16/98 change 167 to ST_Y-1
#define HU_TITLEY (ST_Y - 1 - SHORT(hu_font[0]->height))
//jff 2/16/98 add coord text widget coordinates
#define HU_COORDX (SCREENWIDTH - 13*SHORT(hu_font2['A'-HU_FONTSTART]->width))
//jff 3/3/98 split coord widget into three lines in upper right of screen
#define HU_COORDX_Y (1 + 0*SHORT(hu_font['A'-HU_FONTSTART]->height))
#define HU_COORDY_Y (2 + 1*SHORT(hu_font['A'-HU_FONTSTART]->height))
#define HU_COORDZ_Y (3 + 2*SHORT(hu_font['A'-HU_FONTSTART]->height))
//jff 2/16/98 add ammo, health, armor widgets, 2/22/98 less gap
#define HU_GAPY 8
#define HU_HUDHEIGHT (6*HU_GAPY)
#define HU_HUDX 2
#define HU_HUDY (SCREENHEIGHT-HU_HUDHEIGHT-1)
#define HU_MONSECX (HU_HUDX)
#define HU_MONSECY (HU_HUDY+0*HU_GAPY)
#define HU_KEYSX (HU_HUDX)
//jff 3/7/98 add offset for graphic key widget
#define HU_KEYSGX (HU_HUDX+4*SHORT(hu_font2['A'-HU_FONTSTART]->width))
#define HU_KEYSY (HU_HUDY+1*HU_GAPY)
#define HU_WEAPX (HU_HUDX)
#define HU_WEAPY (HU_HUDY+2*HU_GAPY)
#define HU_AMMOX (HU_HUDX)
#define HU_AMMOY (HU_HUDY+3*HU_GAPY)
#define HU_HEALTHX (HU_HUDX)
#define HU_HEALTHY (HU_HUDY+4*HU_GAPY)
#define HU_ARMORX (HU_HUDX)
#define HU_ARMORY (HU_HUDY+5*HU_GAPY)
//jff 3/4/98 distributed HUD positions
#define HU_HUDX_LL 2
#define HU_HUDY_LL (SCREENHEIGHT-2*HU_GAPY-1)
#define HU_HUDX_LR 200
#define HU_HUDY_LR (SCREENHEIGHT-2*HU_GAPY-1)
#define HU_HUDX_UR 224
#define HU_HUDY_UR 2
#define HU_MONSECX_D (HU_HUDX_LL)
#define HU_MONSECY_D (HU_HUDY_LL+0*HU_GAPY)
#define HU_KEYSX_D (HU_HUDX_LL)
#define HU_KEYSGX_D (HU_HUDX_LL+4*SHORT(hu_font2['A'-HU_FONTSTART]->width))
#define HU_KEYSY_D (HU_HUDY_LL+1*HU_GAPY)
#define HU_WEAPX_D (HU_HUDX_LR)
#define HU_WEAPY_D (HU_HUDY_LR+0*HU_GAPY)
#define HU_AMMOX_D (HU_HUDX_LR)
#define HU_AMMOY_D (HU_HUDY_LR+1*HU_GAPY)
#define HU_HEALTHX_D (HU_HUDX_UR)
#define HU_HEALTHY_D (HU_HUDY_UR+0*HU_GAPY)
#define HU_ARMORX_D (HU_HUDX_UR)
#define HU_ARMORY_D (HU_HUDY_UR+1*HU_GAPY)
//#define HU_INPUTTOGGLE 't' // not used // phares
#define HU_INPUTX HU_MSGX
#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(SHORT(hu_font[0]->height) +1))
#define HU_INPUTWIDTH 64
#define HU_INPUTHEIGHT 1
#define key_alt key_strafe // phares
#define key_shift key_speed
extern int key_chat;
extern int key_escape;
extern int key_enter;
extern int key_shift;
extern int key_alt;
extern int destination_keys[MAXPLAYERS]; // phares
char* chat_macros[] = // Ty 03/27/98 - *not* externalized
{
HUSTR_CHATMACRO0,
HUSTR_CHATMACRO1,
HUSTR_CHATMACRO2,
HUSTR_CHATMACRO3,
HUSTR_CHATMACRO4,
HUSTR_CHATMACRO5,
HUSTR_CHATMACRO6,
HUSTR_CHATMACRO7,
HUSTR_CHATMACRO8,
HUSTR_CHATMACRO9
};
char* player_names[] = // Ty 03/27/98 - *not* externalized
{
HUSTR_PLRGREEN,
HUSTR_PLRINDIGO,
HUSTR_PLRBROWN,
HUSTR_PLRRED
};
//jff 3/17/98 translate player colmap to text color ranges
int plyrcoltran[MAXPLAYERS]={CR_GREEN,CR_GRAY,CR_BROWN,CR_RED};
char chat_char; // remove later.
static player_t* plr;
// font sets
patch_t* hu_font[HU_FONTSIZE];
patch_t* hu_font2[HU_FONTSIZE];
patch_t* hu_fontk[HU_FONTSIZE];//jff 3/7/98 added for graphic key indicators
patch_t* hu_msgbg[9]; //jff 2/26/98 add patches for message background
// widgets
static hu_textline_t w_title;
static hu_stext_t w_message;
static hu_itext_t w_chat;
static hu_itext_t w_inputbuffer[MAXPLAYERS];
static hu_textline_t w_coordx; //jff 2/16/98 new coord widget for automap
static hu_textline_t w_coordy; //jff 3/3/98 split coord widgets automap
static hu_textline_t w_coordz; //jff 3/3/98 split coord widgets automap
static hu_textline_t w_ammo; //jff 2/16/98 new ammo widget for hud
static hu_textline_t w_health; //jff 2/16/98 new health widget for hud
static hu_textline_t w_armor; //jff 2/16/98 new armor widget for hud
static hu_textline_t w_weapon; //jff 2/16/98 new weapon widget for hud
static hu_textline_t w_keys; //jff 2/16/98 new keys widget for hud
static hu_textline_t w_gkeys; //jff 3/7/98 graphic keys widget for hud
static hu_textline_t w_monsec; //jff 2/16/98 new kill/secret widget for hud
static hu_mtext_t w_rtext; //jff 2/26/98 text message refresh widget
static boolean always_off = false;
static char chat_dest[MAXPLAYERS];
boolean chat_on;
static boolean message_on;
static boolean message_list_on; // killough 11/98
static boolean has_message; // killough 12/98
static boolean reviewing_message; // killough 11/98
boolean message_dontfuckwithme;
static boolean message_nottobefuckedwith;
static int message_counter;
static int message_list_counter; // killough 11/98
static int hud_msg_count; // killough 11/98
static int message_count; // killough 11/98
static int chat_count; // killough 11/98
extern int showMessages;
extern boolean automapactive;
static boolean headsupactive = false;
//jff 2/16/98 hud supported automap colors added
int hudcolor_titl; // color range of automap level title
int hudcolor_xyco; // color range of new coords on automap
//jff 2/16/98 hud text colors, controls added
int hudcolor_mesg; // color range of scrolling messages
int hudcolor_chat; // color range of chat lines
int hud_msg_lines; // number of message lines in window
//jff 2/26/98 hud text colors, controls added
int hudcolor_list; // list of messages color
int hud_list_bgon; // enable for solid window background for message list
int hud_msg_scrollup; // killough 11/98: allow messages to scroll upwards
int hud_msg_timed; // killough 11/98: allow > 1 messages to time out
int message_list; // killough 11/98: made global
int hud_msg_timer = HU_MSGTIMEOUT * (1000/TICRATE); // killough 11/98
int message_timer = HU_MSGTIMEOUT * (1000/TICRATE); // killough 11/98
int chat_msg_timer = HU_MSGTIMEOUT * (1000/TICRATE); // killough 11/98
//jff 2/16/98 initialization strings for ammo, health, armor widgets
static char hud_coordstrx[32];
static char hud_coordstry[32];
static char hud_coordstrz[32];
static char hud_ammostr[80];
static char hud_healthstr[80];
static char hud_armorstr[80];
static char hud_weapstr[80];
static char hud_keysstr[80];
static char hud_gkeysstr[80]; //jff 3/7/98 add support for graphic key display
static char hud_monsecstr[80];
//jff 2/16/98 declaration of color switch points
extern int ammo_red;
extern int ammo_yellow;
extern int health_red;
extern int health_yellow;
extern int health_green;
extern int armor_red;
extern int armor_yellow;
extern int armor_green;
//
// Builtin map names.
// The actual names can be found in DStrings.h.
//
// Ty 03/27/98 - externalized map name arrays - now in d_deh.c
// and converted to arrays of pointers to char *
// See modified HUTITLEx macros
extern char **mapnames[];
extern char **mapnames2[];
extern char **mapnamesm[];
extern char **mapnamesn[];
extern char **mapnamesp[];
extern char **mapnamest[];
// key tables
// jff 5/10/98 french support removed,
// as it was not being used and couldn't be easily tested
//
const char* shiftxform;
const char english_shiftxform[] =
{
0,
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,
' ', '!', '"', '#', '$', '%', '&',
'"', // shift-'
'(', ')', '*', '+',
'<', // shift-,
'_', // shift--
'>', // shift-.
'?', // shift-/
')', // shift-0
'!', // shift-1
'@', // shift-2
'#', // shift-3
'$', // shift-4
'%', // shift-5
'^', // shift-6
'&', // shift-7
'*', // shift-8
'(', // shift-9
':',
':', // shift-;
'<',
'+', // shift-=
'>', '?', '@',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'[', // shift-[
'!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
']', // shift-]
'"', '_',
'\'', // shift-`
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'{', '|', '}', '~', 127
};
//
// HU_Init()
//
// Initialize the heads-up display, text that overwrites the primary display
//
// Passed nothing, returns nothing
//
void HU_Init(void)
{
int i, j;
char buffer[9];
shiftxform = english_shiftxform;
// load the heads-up font
j = HU_FONTSTART;
for (i=0;i<HU_FONTSIZE;i++,j++)
{
if ('0'<=j && j<='9')
{
sprintf(buffer, "DIG%.1d",j-48);
hu_font2[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
sprintf(buffer, "STCFN%.3d",j);
hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
}
else
if ('A'<=j && j<='Z')
{
sprintf(buffer, "DIG%c",j);
hu_font2[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
sprintf(buffer, "STCFN%.3d",j);
hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
}
else
if (j=='-')
{
hu_font2[i] = (patch_t *) W_CacheLumpName("DIG45", PU_STATIC);
hu_font[i] = (patch_t *) W_CacheLumpName("STCFN045", PU_STATIC);
}
else
if (j=='/')
{
hu_font2[i] = (patch_t *) W_CacheLumpName("DIG47", PU_STATIC);
hu_font[i] = (patch_t *) W_CacheLumpName("STCFN047", PU_STATIC);
}
else
if (j==':')
{
hu_font2[i] = (patch_t *) W_CacheLumpName("DIG58", PU_STATIC);
hu_font[i] = (patch_t *) W_CacheLumpName("STCFN058", PU_STATIC);
}
else
if (j=='[')
{
hu_font2[i] = (patch_t *) W_CacheLumpName("DIG91", PU_STATIC);
hu_font[i] = (patch_t *) W_CacheLumpName("STCFN091", PU_STATIC);
}
else
if (j==']')
{
hu_font2[i] = (patch_t *) W_CacheLumpName("DIG93", PU_STATIC);
hu_font[i] = (patch_t *) W_CacheLumpName("STCFN093", PU_STATIC);
}
else
if (j<97)
{
sprintf(buffer, "STCFN%.3d",j);
hu_font2[i] = hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC);
//jff 2/23/98 make all font chars defined, useful or not
}
else
if (j>122)
{
sprintf(buffer, "STBR%.3d",j);
hu_font2[i] = hu_font[i] =
(patch_t *) W_CacheLumpName(buffer, PU_STATIC);
}
else
hu_font[i] = hu_font[0]; //jff 2/16/98 account for gap
}
//jff 2/26/98 load patches for message background
hu_msgbg[0] = (patch_t *) W_CacheLumpName("BOXUL", PU_STATIC);
hu_msgbg[1] = (patch_t *) W_CacheLumpName("BOXUC", PU_STATIC);
hu_msgbg[2] = (patch_t *) W_CacheLumpName("BOXUR", PU_STATIC);
hu_msgbg[3] = (patch_t *) W_CacheLumpName("BOXCL", PU_STATIC);
hu_msgbg[4] = (patch_t *) W_CacheLumpName("BOXCC", PU_STATIC);
hu_msgbg[5] = (patch_t *) W_CacheLumpName("BOXCR", PU_STATIC);
hu_msgbg[6] = (patch_t *) W_CacheLumpName("BOXLL", PU_STATIC);
hu_msgbg[7] = (patch_t *) W_CacheLumpName("BOXLC", PU_STATIC);
hu_msgbg[8] = (patch_t *) W_CacheLumpName("BOXLR", PU_STATIC);
//jff 2/26/98 load patches for keys and double keys
hu_fontk[0] = (patch_t *) W_CacheLumpName("STKEYS0", PU_STATIC);
hu_fontk[1] = (patch_t *) W_CacheLumpName("STKEYS1", PU_STATIC);
hu_fontk[2] = (patch_t *) W_CacheLumpName("STKEYS2", PU_STATIC);
hu_fontk[3] = (patch_t *) W_CacheLumpName("STKEYS3", PU_STATIC);
hu_fontk[4] = (patch_t *) W_CacheLumpName("STKEYS4", PU_STATIC);
hu_fontk[5] = (patch_t *) W_CacheLumpName("STKEYS5", PU_STATIC);
}
//
// HU_Stop()
//
// Make the heads-up displays inactive
//
// Passed nothing, returns nothing
//
void HU_Stop(void)
{
headsupactive = false;
}
//
// HU_Start(void)
//
// Create and initialize the heads-up widgets, software machines to
// maintain, update, and display information over the primary display
//
// This routine must be called after any change to the heads up configuration
// in order for the changes to take effect in the actual displays
//
// Passed nothing, returns nothing
//
void HU_Start(void)
{
int i;
char* s;
if (headsupactive) // stop before starting
HU_Stop();
plr = &players[displayplayer]; // killough 3/7/98
message_on = false;
message_dontfuckwithme = false;
message_nottobefuckedwith = false;
chat_on = false;
// killough 11/98:
reviewing_message = message_list_on = false;
message_counter = message_list_counter = 0;
hud_msg_count = (hud_msg_timer * TICRATE) / 1000 + 1;
message_count = (message_timer * TICRATE) / 1000 + 1;
chat_count = (chat_msg_timer * TICRATE) / 1000 + 1;
// create the message widget
// messages to player in upper-left of screen
HUlib_initSText(&w_message, HU_MSGX, HU_MSGY, HU_MSGHEIGHT, hu_font,
HU_FONTSTART, colrngs[hudcolor_mesg], &message_on);
//jff 2/16/98 added some HUD widgets
// create the map title widget - map title display in lower left of automap
HUlib_initTextLine(&w_title, HU_TITLEX, HU_TITLEY, hu_font,
HU_FONTSTART, colrngs[hudcolor_titl]);
// create the hud health widget
// bargraph and number for amount of health,
// lower left or upper right of screen
HUlib_initTextLine(&w_health, hud_distributed ? HU_HEALTHX_D : HU_HEALTHX,
hud_distributed ? HU_HEALTHY_D : HU_HEALTHY, hu_font2,
HU_FONTSTART, colrngs[CR_GREEN]);
// create the hud armor widget
// bargraph and number for amount of armor,
// lower left or upper right of screen
HUlib_initTextLine(&w_armor, hud_distributed? HU_ARMORX_D : HU_ARMORX,
hud_distributed ? HU_ARMORY_D : HU_ARMORY, hu_font2,
HU_FONTSTART, colrngs[CR_GREEN]);
// create the hud ammo widget
// bargraph and number for amount of ammo for current weapon,
// lower left or lower right of screen
HUlib_initTextLine(&w_ammo, hud_distributed ? HU_AMMOX_D : HU_AMMOX,
hud_distributed ? HU_AMMOY_D : HU_AMMOY, hu_font2,
HU_FONTSTART, colrngs[CR_GOLD]);
// create the hud weapons widget
// list of numbers of weapons possessed
// lower left or lower right of screen
HUlib_initTextLine(&w_weapon, hud_distributed ? HU_WEAPX_D : HU_WEAPX,
hud_distributed ? HU_WEAPY_D : HU_WEAPY, hu_font2,
HU_FONTSTART, colrngs[CR_GRAY]);
// create the hud keys widget
// display of key letters possessed
// lower left of screen
HUlib_initTextLine(&w_keys, hud_distributed ? HU_KEYSX_D : HU_KEYSX,
hud_distributed ? HU_KEYSY_D : HU_KEYSY, hu_font2,
HU_FONTSTART, colrngs[CR_GRAY]);
// create the hud graphic keys widget
// display of key graphics possessed
// lower left of screen
HUlib_initTextLine(&w_gkeys, hud_distributed ? HU_KEYSGX_D : HU_KEYSGX,
hud_distributed? HU_KEYSY_D : HU_KEYSY, hu_fontk,
HU_FONTSTART, colrngs[CR_RED]);
// create the hud monster/secret widget
// totals and current values for kills, items, secrets
// lower left of screen
HUlib_initTextLine(&w_monsec, hud_distributed ? HU_MONSECX_D : HU_MONSECX,
hud_distributed? HU_MONSECY_D : HU_MONSECY, hu_font2,
HU_FONTSTART, colrngs[CR_GRAY]);
// create the hud text refresh widget
// scrolling display of last hud_msg_lines messages received
if (hud_msg_lines>HU_MAXMESSAGES)
hud_msg_lines=HU_MAXMESSAGES;
//jff 2/26/98 add the text refresh widget initialization
HUlib_initMText(&w_rtext, 0, 0, SCREENWIDTH,
(hud_msg_lines+2)*HU_REFRESHSPACING, hu_font,
HU_FONTSTART, colrngs[hudcolor_list],
hu_msgbg, &message_list_on); // killough 11/98
// initialize the automap's level title widget
s = gamemode != commercial ? HU_TITLE :
gamemission == pack_tnt ? HU_TITLET :
gamemission == pack_plut ? HU_TITLEP :
gamemission == pack_nerve ? HU_TITLEN :
gamemission == pack_master ? HU_TITLEM : HU_TITLE2;
while (*s)
HUlib_addCharToTextLine(&w_title, *s++);
// create the automaps coordinate widget
// jff 3/3/98 split coord widget into three lines: x,y,z
HUlib_initTextLine(&w_coordx, HU_COORDX, HU_COORDX_Y, hu_font,
HU_FONTSTART, colrngs[hudcolor_xyco]);
HUlib_initTextLine(&w_coordy, HU_COORDX, HU_COORDY_Y, hu_font,
HU_FONTSTART, colrngs[hudcolor_xyco]);
HUlib_initTextLine(&w_coordz, HU_COORDX, HU_COORDZ_Y, hu_font,
HU_FONTSTART, colrngs[hudcolor_xyco]);
// initialize the automaps coordinate widget
//jff 3/3/98 split coordstr widget into 3 parts
sprintf(hud_coordstrx,"X: %-5d",0); //jff 2/22/98 added z
s = hud_coordstrx;
while (*s)
HUlib_addCharToTextLine(&w_coordx, *s++);
sprintf(hud_coordstry,"Y: %-5d",0); //jff 3/3/98 split x,y,z
s = hud_coordstry;
while (*s)
HUlib_addCharToTextLine(&w_coordy, *s++);
sprintf(hud_coordstrz,"Z: %-5d",0); //jff 3/3/98 split x,y,z
s = hud_coordstrz;
while (*s)
HUlib_addCharToTextLine(&w_coordz, *s++);
//jff 2/16/98 initialize ammo widget
sprintf(hud_ammostr,"AMM ");
s = hud_ammostr;
while (*s)
HUlib_addCharToTextLine(&w_ammo, *s++);
//jff 2/16/98 initialize health widget
sprintf(hud_healthstr,"HEL ");
s = hud_healthstr;
while (*s)
HUlib_addCharToTextLine(&w_health, *s++);
//jff 2/16/98 initialize armor widget
sprintf(hud_armorstr,"ARM ");
s = hud_armorstr;
while (*s)
HUlib_addCharToTextLine(&w_armor, *s++);
//jff 2/17/98 initialize weapons widget
sprintf(hud_weapstr,"WEA ");
s = hud_weapstr;
while (*s)
HUlib_addCharToTextLine(&w_weapon, *s++);
//jff 2/17/98 initialize keys widget
if (!deathmatch) //jff 3/17/98 show frags in deathmatch mode
sprintf(hud_keysstr,"KEY ");
else
sprintf(hud_keysstr,"FRG ");
s = hud_keysstr;
while (*s)
HUlib_addCharToTextLine(&w_keys, *s++);
//jff 2/17/98 initialize graphic keys widget
sprintf(hud_gkeysstr," ");
s = hud_gkeysstr;
while (*s)
HUlib_addCharToTextLine(&w_gkeys, *s++);
//jff 2/17/98 initialize kills/items/secret widget
sprintf(hud_monsecstr,"STS ");
s = hud_monsecstr;
while (*s)
HUlib_addCharToTextLine(&w_monsec, *s++);
// create the chat widget
HUlib_initIText
(
&w_chat,
HU_INPUTX,
HU_INPUTY,
hu_font,
HU_FONTSTART,
colrngs[hudcolor_chat],
&chat_on
);
// create the inputbuffer widgets, one per player
for (i=0 ; i<MAXPLAYERS ; i++)
HUlib_initIText(&w_inputbuffer[i], 0, 0, 0, 0, colrngs[hudcolor_chat],
&always_off);
// now allow the heads-up display to run
headsupactive = true;
}
//
// HU_MoveHud()
//
// Move the HUD display from distributed to compact mode or vice-versa
//
// Passed nothing, returns nothing
//
//jff 3/9/98 create this externally callable to avoid glitch
// when menu scatter's HUD due to delay in change of position
//
void HU_MoveHud(void)
{
static int ohud_distributed=-1;
//jff 3/4/98 move displays around on F5 changing hud_distributed
if (hud_distributed!=ohud_distributed)
{
w_ammo.x = hud_distributed? HU_AMMOX_D : HU_AMMOX;
w_ammo.y = hud_distributed? HU_AMMOY_D : HU_AMMOY;
w_weapon.x = hud_distributed? HU_WEAPX_D : HU_WEAPX;
w_weapon.y = hud_distributed? HU_WEAPY_D : HU_WEAPY;
w_keys.x = hud_distributed? HU_KEYSX_D : HU_KEYSX;
w_keys.y = hud_distributed? HU_KEYSY_D : HU_KEYSY;
w_gkeys.x = hud_distributed? HU_KEYSGX_D : HU_KEYSGX;
w_gkeys.y = hud_distributed? HU_KEYSY_D : HU_KEYSY;
w_monsec.x = hud_distributed? HU_MONSECX_D : HU_MONSECX;
w_monsec.y = hud_distributed? HU_MONSECY_D : HU_MONSECY;
w_health.x = hud_distributed? HU_HEALTHX_D : HU_HEALTHX;
w_health.y = hud_distributed? HU_HEALTHY_D : HU_HEALTHY;
w_armor.x = hud_distributed? HU_ARMORX_D : HU_ARMORX;
w_armor.y = hud_distributed? HU_ARMORY_D : HU_ARMORY;
}
ohud_distributed = hud_distributed;
}
static int HU_top(int i, int idx1, int top1)
{
if (idx1 > -1)
{
char numbuf[32], *s;
sprintf(numbuf,"%5d",top1);
// make frag count in player's color via escape code
hud_keysstr[i++] = '\x1b'; //jff 3/26/98 use ESC not '\' for paths
hud_keysstr[i++] = '0' + plyrcoltran[idx1 & 3];
s = numbuf;
while (*s)
hud_keysstr[i++] = *s++;
}
return i;
}
//
// HU_Drawer()
//
// Draw all the pieces of the heads-up display
//
// Passed nothing, returns nothing
//
int map_show_coordinates;
void HU_Drawer(void)
{
char *s;
player_t *plr;
char ammostr[80]; //jff 3/8/98 allow plenty room for dehacked mods
char healthstr[80];//jff
char armorstr[80]; //jff
int i;
plr = &players[displayplayer]; // killough 3/7/98
// draw the automap widgets if automap is displayed
if (automapactive)
{
// map title
HUlib_drawTextLine(&w_title, false);
if (map_show_coordinates)
{
fixed_t x,y,z; // killough 10/98:
void AM_Coordinates(const mobj_t *, fixed_t *, fixed_t *, fixed_t *);
// killough 10/98: allow coordinates to display non-following pointer
AM_Coordinates(plr->mo, &x, &y, &z);
//jff 2/16/98 output new coord display
// x-coord
sprintf(hud_coordstrx,"X: %-5d", x>>FRACBITS); // killough 10/98
HUlib_clearTextLine(&w_coordx);
s = hud_coordstrx;
while (*s)
HUlib_addCharToTextLine(&w_coordx, *s++);
HUlib_drawTextLine(&w_coordx, false);
//jff 3/3/98 split coord display into x,y,z lines
// y-coord
sprintf(hud_coordstry,"Y: %-5d", y>>FRACBITS); // killough 10/98
HUlib_clearTextLine(&w_coordy);
s = hud_coordstry;
while (*s)
HUlib_addCharToTextLine(&w_coordy, *s++);
HUlib_drawTextLine(&w_coordy, false);
//jff 3/3/98 split coord display into x,y,z lines
//jff 2/22/98 added z
// z-coord
sprintf(hud_coordstrz,"Z: %-5d", z>>FRACBITS); // killough 10/98
HUlib_clearTextLine(&w_coordz);
s = hud_coordstrz;
while (*s)
HUlib_addCharToTextLine(&w_coordz, *s++);
HUlib_drawTextLine(&w_coordz, false);
}
}
// draw the weapon/health/ammo/armor/kills/keys displays if optioned
//jff 2/17/98 allow new hud stuff to be turned off
// killough 2/21/98: really allow new hud stuff to be turned off COMPLETELY
if
(
hud_active>0 && // hud optioned on
hud_displayed && // hud on from fullscreen key
scaledviewheight==SCREENHEIGHT &&// fullscreen mode is active
!automapactive // automap is not active
)
{
HU_MoveHud(); // insure HUD display coords are correct
// do the hud ammo display
// clear the widgets internal line
HUlib_clearTextLine(&w_ammo);
strcpy(hud_ammostr,"AMM ");
if (weaponinfo[plr->readyweapon].ammo == am_noammo)
{ // special case for weapon with no ammo selected - blank bargraph + N/A
strcat(hud_ammostr,"\x7f\x7f\x7f\x7f\x7f\x7f\x7f N/A");
w_ammo.cr = colrngs[CR_GRAY];
}
else
{
int ammo = plr->ammo[weaponinfo[plr->readyweapon].ammo];
int fullammo = plr->maxammo[weaponinfo[plr->readyweapon].ammo];
int ammopct = (100*ammo)/fullammo;
int ammobars = ammopct/4;
// build the numeric amount init string
sprintf(ammostr,"%d/%d",ammo,fullammo);
// build the bargraph string
// full bargraph chars
for (i=4;i<4+ammobars/4;)
hud_ammostr[i++] = 123;
// plus one last character with 0,1,2,3 bars
switch(ammobars%4)
{
case 0:
break;
case 1:
hud_ammostr[i++] = 126;
break;
case 2:
hud_ammostr[i++] = 125;
break;
case 3:
hud_ammostr[i++] = 124;
break;
}
// pad string with blank bar characters
while(i<4+7)
hud_ammostr[i++] = 127;
hud_ammostr[i] = '\0';
strcat(hud_ammostr,ammostr);
// set the display color from the percentage of total ammo held
if (ammopct<ammo_red)
w_ammo.cr = colrngs[CR_RED];
else
if (ammopct<ammo_yellow)
w_ammo.cr = colrngs[CR_GOLD];
else
w_ammo.cr = colrngs[CR_GREEN];
}
// transfer the init string to the widget
s = hud_ammostr;
while (*s)
HUlib_addCharToTextLine(&w_ammo, *s++);
// display the ammo widget every frame
HUlib_drawTextLine(&w_ammo, false);
// do the hud health display
{
int health = plr->health;
int healthbars = health>100? 25 : health/4;
// clear the widgets internal line
HUlib_clearTextLine(&w_health);
// build the numeric amount init string
sprintf(healthstr,"%3d",health);
// build the bargraph string
// full bargraph chars
for (i=4;i<4+healthbars/4;)
hud_healthstr[i++] = 123;
// plus one last character with 0,1,2,3 bars
switch(healthbars%4)
{
case 0:
break;
case 1:
hud_healthstr[i++] = 126;
break;
case 2:
hud_healthstr[i++] = 125;
break;
case 3:
hud_healthstr[i++] = 124;
break;
}
// pad string with blank bar characters
while(i<4+7)
hud_healthstr[i++] = 127;
hud_healthstr[i] = '\0';
strcat(hud_healthstr,healthstr);
// set the display color from the amount of health posessed
if (health<health_red)
w_health.cr = colrngs[CR_RED];
else
if (health<health_yellow)
w_health.cr = colrngs[CR_GOLD];
else
if (health<=health_green)
w_health.cr = colrngs[CR_GREEN];
else
w_health.cr = colrngs[CR_BLUE];
// transfer the init string to the widget
s = hud_healthstr;
while (*s)
HUlib_addCharToTextLine(&w_health, *s++);
}
// display the health widget every frame
HUlib_drawTextLine(&w_health, false);
// do the hud armor display
{
int armor = plr->armorpoints;
int armorbars = armor>100? 25 : armor/4;
// clear the widgets internal line
HUlib_clearTextLine(&w_armor);
// build the numeric amount init string
sprintf(armorstr,"%3d",armor);
// build the bargraph string
// full bargraph chars
for (i=4;i<4+armorbars/4;)
hud_armorstr[i++] = 123;
// plus one last character with 0,1,2,3 bars
switch(armorbars%4)
{
case 0:
break;
case 1:
hud_armorstr[i++] = 126;
break;
case 2:
hud_armorstr[i++] = 125;
break;
case 3:
hud_armorstr[i++] = 124;
break;
}
// pad string with blank bar characters
while(i<4+7)
hud_armorstr[i++] = 127;
hud_armorstr[i] = '\0';
strcat(hud_armorstr,armorstr);
// set the display color from the amount of armor posessed
w_armor.cr =
armor<armor_red ? colrngs[CR_RED] :
armor<armor_yellow ? colrngs[CR_GOLD] :
armor<=armor_green ? colrngs[CR_GREEN] : colrngs[CR_BLUE];
// transfer the init string to the widget
s = hud_armorstr;
while (*s)
HUlib_addCharToTextLine(&w_armor, *s++);
}
// display the armor widget every frame
HUlib_drawTextLine(&w_armor, false);
// do the hud weapon display
{
int w, ammo, fullammo, ammopct;
// clear the widgets internal line
HUlib_clearTextLine(&w_weapon);
i=4; hud_weapstr[i] = '\0'; //jff 3/7/98 make sure ammo goes away
// do each weapon that exists in current gamemode
for (w=0;w<=wp_supershotgun;w++) //jff 3/4/98 show fists too, why not?
{
int ok=1;
//jff avoid executing for weapons that do not exist
switch (gamemode)
{
case shareware:
if (w>=wp_plasma && w!=wp_chainsaw)
ok=0;
break;
case retail:
case registered:
if (w>=wp_supershotgun)
ok=0;
break;
default:
case commercial:
break;
}
if (!ok) continue;
ammo = plr->ammo[weaponinfo[w].ammo];
fullammo = plr->maxammo[weaponinfo[w].ammo];
ammopct=0;
// skip weapons not currently posessed
if (!plr->weaponowned[w])
continue;
ammopct = fullammo? (100*ammo)/fullammo : 100;
// display each weapon number in a color related to the ammo for it
hud_weapstr[i++] = '\x1b'; //jff 3/26/98 use ESC not '\' for paths
if (weaponinfo[w].ammo==am_noammo) //jff 3/14/98 show berserk on HUD
hud_weapstr[i++] = plr->powers[pw_strength]? '0'+CR_GREEN : '0'+CR_GRAY;
else
if (ammopct<ammo_red)
hud_weapstr[i++] = '0'+CR_RED;
else
if (ammopct<ammo_yellow)
hud_weapstr[i++] = '0'+CR_GOLD;
else
hud_weapstr[i++] = '0'+CR_GREEN;
hud_weapstr[i++] = '0'+w+1;
hud_weapstr[i++] = ' ';
hud_weapstr[i] = '\0';
}
// transfer the init string to the widget
s = hud_weapstr;
while (*s)
HUlib_addCharToTextLine(&w_weapon, *s++);
}
// display the weapon widget every frame
HUlib_drawTextLine(&w_weapon, false);
if (hud_active>1)
{
int k;
hud_keysstr[4] = '\0'; //jff 3/7/98 make sure deleted keys go away
//jff add case for graphic key display
if (!deathmatch && hud_graph_keys)
{
i=0;
hud_gkeysstr[i] = '\0'; //jff 3/7/98 init graphic keys widget string
// build text string whose characters call out graphic keys from fontk
for (k=0;k<6;k++)
{
// skip keys not possessed
if (!plr->cards[k])
continue;
hud_gkeysstr[i++] = '!'+k; // key number plus '!' is char for key
hud_gkeysstr[i++] = ' '; // spacing
hud_gkeysstr[i++] = ' ';
}
hud_gkeysstr[i]='\0';
}
else // not possible in current code, unless deathmatching,
{
i=4;