-
Notifications
You must be signed in to change notification settings - Fork 5
/
hu_stuff.pas
1117 lines (995 loc) · 29.1 KB
/
hu_stuff.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
//------------------------------------------------------------------------------
//
// FPCDoom - Port of Doom to Free Pascal Compiler
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2004-2007 by Jim Valavanis
// Copyright (C) 2017-2022 by Jim Valavanis
//
// 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.
//
//------------------------------------------------------------------------------
// E-Mail: [email protected]
// Site : https://sourceforge.net/projects/fpcdoom/
//------------------------------------------------------------------------------
{$I FPCDoom.inc}
unit hu_stuff;
interface
uses
doomdef,
d_event,
r_defs;
const
//
// Globally visible constants.
//
HU_FONTSTART = '!'; // the first font characters
HU_FONTEND = '_'; // the last font characters
// Calculate # of glyphs in font.
HU_FONTSIZE = (Ord(HU_FONTEND) - Ord(HU_FONTSTART)) + 1;
HU_BROADCAST = 5;
HU_MSGREFRESH = KEY_ENTER;
HU_MSGX = 0;
HU_MSGY = 0;
HU_MSGHEIGHT = 1; // in lines
HU_MSGTIMEOUT = 4 * TICRATE;
//==============================================================================
// HU_Init
//
// HEADS UP TEXT
//
//==============================================================================
procedure HU_Init;
//==============================================================================
//
// HU_Start
//
//==============================================================================
procedure HU_Start;
//==============================================================================
//
// HU_Responder
//
//==============================================================================
function HU_Responder(ev: Pevent_t): boolean;
//==============================================================================
//
// HU_Ticker
//
//==============================================================================
procedure HU_Ticker;
//==============================================================================
//
// HU_Drawer
//
//==============================================================================
procedure HU_Drawer;
//==============================================================================
//
// HU_dequeueChatChar
//
//==============================================================================
function HU_dequeueChatChar: char;
//==============================================================================
//
// HU_Erase
//
//==============================================================================
procedure HU_Erase;
var
hu_font: array[0..HU_FONTSIZE - 1] of Ppatch_t;
chat_on: boolean;
message_on: boolean;
message_dontfuckwithme: boolean;
message_nottobefuckedwith: boolean;
var
// DOOM shareware/registered/retail (Ultimate) names.
mapnames: array[0..44] of string;
// DOOM 2 map names.
mapnames2: array[0..31] of string;
// Plutonia WAD map names.
mapnamesp: array[0..31] of string;
// TNT WAD map names.
mapnamest: array[0..31] of string;
player_names: array[0..3] of string;
var
chat_macros: array[0..9] of string;
var
destination_keys: array[0..MAXPLAYERS - 1] of string;
var
shiftxform: array[0..127] of char;
//==============================================================================
//
// HU_DoFPSStuff
//
//==============================================================================
procedure HU_DoFPSStuff;
//==============================================================================
//
// HU_FPS
//
//==============================================================================
function HU_FPS: integer;
var
drawfps: boolean;
implementation
uses
d_fpc,
c_cmds,
z_memory,
w_wad,
i_system,
doomstat,
am_map,
d_english,
d_player,
g_game,
hu_lib,
m_menu,
m_fixed,
p_tick,
r_draw,
s_sound,
sounds,
v_video;
// FPS Stuff
const
FPSSIZE = 128;
var
FPSHISTORY: array[0..FPSSIZE - 1] of integer;
fpshead: integer = -1;
//==============================================================================
//
// HU_DoFPSStuff
//
//==============================================================================
procedure HU_DoFPSStuff;
begin
fpshead := (fpshead + 1) mod FPSSIZE;
FPSHISTORY[fpshead] := I_GetFracTime;
end;
//==============================================================================
//
// HU_FPS
//
//==============================================================================
function HU_FPS: integer;
var
fpsdiff: integer;
begin
fpsdiff := FPSHISTORY[fpshead] - FPSHISTORY[(fpshead + 1) mod FPSSIZE] + 1;
if fpsdiff > 0 then
result := TICRATE * FPSSIZE * FRACUNIT div fpsdiff
else
result := TICRATE;
end;
//==============================================================================
//
// HU_CmdFPS
//
//==============================================================================
procedure HU_CmdFPS;
begin
printf('%d fps'#13#10, [HU_FPS]);
end;
//==============================================================================
//
// HU_CmdPlayerMessage
//
//==============================================================================
procedure HU_CmdPlayerMessage(const parm1, parm2: string);
begin
players[consoleplayer]._message := parm1 + ' ' + parm2;
end;
//==============================================================================
//
// HU_TITLE
//
//==============================================================================
function HU_TITLE: string;
begin
result := mapnames[(gameepisode - 1) * 9 + gamemap - 1];
end;
//==============================================================================
//
// HU_TITLE2
//
//==============================================================================
function HU_TITLE2: string;
begin
result := mapnames2[gamemap - 1];
end;
//==============================================================================
//
// HU_TITLEP
//
//==============================================================================
function HU_TITLEP: string;
begin
result := mapnamesp[gamemap - 1];
end;
//==============================================================================
//
// HU_TITLET
//
//==============================================================================
function HU_TITLET: string;
begin
result := mapnamest[gamemap - 1];
end;
var
plr: Pplayer_t;
w_title: hu_textline_t;
w_leveltime: hu_textline_t;
w_chat: hu_itext_t;
always_off: boolean = false;
chat_dest: array[0..MAXPLAYERS - 1] of char;
w_inputbuffer: array[0..MAXPLAYERS - 1] of hu_itext_t;
w_message: hu_stext_t;
message_counter: integer;
headsupactive: boolean = false;
const
HU_TITLEHEIGHT = 1;
HU_TITLEX = 0;
HU_LEVELTIMEX = 0;
//==============================================================================
//
// HU_TITLEY
//
//==============================================================================
function HU_TITLEY: integer;
begin
result := 167 - hu_font[0].height;
end;
//==============================================================================
//
// HU_LEVELTIMEY
//
//==============================================================================
function HU_LEVELTIMEY: integer;
begin
result := 167 - 2 * hu_font[0].height;
end;
const
HU_INPUTTOGGLE: char = 't';
//==============================================================================
//
// HU_INPUTX
//
//==============================================================================
function HU_INPUTX: integer;
begin
result := HU_MSGX;
end;
//==============================================================================
//
// HU_INPUTY
//
//==============================================================================
function HU_INPUTY: integer;
begin
result := HU_MSGY + HU_MSGHEIGHT * (hu_font[0].height + 1)
end;
const
HU_INPUTWIDTH = 64;
HU_INPUTHEIGHT = 1;
const
french_shiftxform: array[0..127] of char = (
#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-/
'0', // shift-0
'1', // shift-1
'2', // shift-2
'3', // shift-3
'4', // shift-4
'5', // shift-5
'6', // shift-6
'7', // shift-7
'8', // shift-8
'9', // 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
);
const
english_shiftxform: array[0..127] of char = (
#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
);
const
frenchKeyMap: array[0..127] of char = (
#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,
' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!',
'0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?',
'@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
'P','A','R','S','T','U','V','Z','X','Y','W','^','\','$','^','_',
'@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
'P','A','R','S','T','U','V','Z','X','Y','W','^','\','$','^',#127
);
//==============================================================================
//
// ForeignTranslation
//
//==============================================================================
function ForeignTranslation(ch: char): char;
begin
if ch < #128 then
result := frenchKeyMap[Ord(ch)]
else
result := ch;
end;
//==============================================================================
//
// HU_Init
//
//==============================================================================
procedure HU_Init;
var
i: integer;
j: integer;
buffer: string;
begin
if language = french then
begin
for i := 0 to 127 do
shiftxform[i] := french_shiftxform[i];
end
else
begin
for i := 0 to 127 do
shiftxform[i] := english_shiftxform[i];
end;
// load the heads-up font
j := Ord(HU_FONTSTART);
for i := 0 to HU_FONTSIZE - 1 do
begin
buffer := 'STCFN' + IntToStrZfill(3, j);
inc(j);
hu_font[i] := Ppatch_t(W_CacheLumpName(buffer, PU_STATIC));
end;
for i := 0 to FPSSIZE - 1 do
FPSHISTORY[i] := 0;
C_AddCmd('fps', @HU_CmdFPS);
C_AddCmd('playermessage', @HU_CmdPlayerMessage);
end;
//==============================================================================
//
// HU_Stop
//
//==============================================================================
procedure HU_Stop;
begin
headsupactive := false;
end;
//==============================================================================
//
// HU_Start
//
//==============================================================================
procedure HU_Start;
var
i: integer;
s: string;
begin
if headsupactive then
HU_Stop;
plr := @players[consoleplayer];
message_on := false;
message_dontfuckwithme := false;
message_nottobefuckedwith := false;
chat_on := false;
// create the message widget
HUlib_initSText(@w_message,
HU_MSGX, HU_MSGY, HU_MSGHEIGHT,
@hu_font,
Ord(HU_FONTSTART), @message_on);
// create the map title widget
HUlib_initTextLine(@w_title,
HU_TITLEX, HU_TITLEY,
@hu_font,
Ord(HU_FONTSTART));
HUlib_initTextLine(@w_leveltime,
HU_LEVELTIMEX, HU_LEVELTIMEY,
@hu_font,
Ord(HU_FONTSTART));
case gamemode of
shareware,
registered,
retail: s := HU_TITLE;
else
begin
case gamemission of
pack_tnt: s := HU_TITLET;
pack_plutonia: s := HU_TITLEP;
else
s := HU_TITLE2;
end;
end;
end;
for i := 1 to Length(s) do
HUlib_addCharToTextLine(@w_title, s[i]);
// create the chat widget
HUlib_initIText(@w_chat,
HU_INPUTX, HU_INPUTY,
@hu_font,
Ord(HU_FONTSTART), @chat_on);
// create the inputbuffer widgets
for i := 0 to MAXPLAYERS - 1 do
HUlib_initIText(@w_inputbuffer[i], 0, 0, nil, 0, @always_off);
headsupactive := true;
end;
var
m_fps: string = '';
fps_ticker: integer = 0;
//==============================================================================
//
// HU_DrawFPS
//
//==============================================================================
procedure HU_DrawFPS;
var
i: integer;
x, y: integer;
c: integer;
begin
if amstate = am_only then
begin
x := 311;
y := 1;
end
else
begin
x := (viewwindowx + viewwidth) * 320 div SCREENWIDTH - 9;
y := viewwindowy * 200 div SCREENHEIGHT + 1;
end;
for i := length(m_fps) downto 1 do
begin
if m_fps[i] <> ' ' then
begin
c := Ord(toupper(m_fps[i])) - Ord(HU_FONTSTART);
V_DrawPatch(x, y, SCN_FG, hu_font[c], true);
x := x - 8;
end
else
x := x - 4;
end;
end;
//==============================================================================
//
// HU_Drawer
//
//==============================================================================
procedure HU_Drawer;
var
i, t: integer;
lt: string;
begin
if drawfps then
HU_DrawFPS;
HUlib_drawSText(@w_message);
HUlib_drawIText(@w_chat);
if amstate = am_only then
begin
repeat
until not HUlib_delCharFromTextLine(@w_leveltime);
t := leveltime div TICRATE;
lt := IntToStrZFill(2, t mod 60);
t := t div 60;
lt := IntToStrZFill(2, t mod 60) + ':' + lt;
t := t div 60;
lt := 'Time: ' + IntToStrZFill(2, t) + ':' + lt;
for i := 1 to Length(lt) do
HUlib_addCharToTextLine(@w_leveltime, lt[i]);
HUlib_drawTextLine(@w_leveltime, false);
HUlib_drawTextLine(@w_title, false);
end;
end;
//==============================================================================
//
// HU_Erase
//
//==============================================================================
procedure HU_Erase;
begin
HUlib_eraseSText(@w_message);
HUlib_eraseIText(@w_chat);
HUlib_eraseTextLine(@w_title);
end;
//==============================================================================
//
// HU_Ticker
//
//==============================================================================
procedure HU_Ticker;
var
i: integer;
rc: boolean;
c: char;
begin
dec(fps_ticker);
if fps_ticker <= 0 then
begin
m_fps := itoa(HU_FPS) + ' fps';
fps_ticker := TICRATE div 2;
end;
// tick down message counter if message is up
if message_counter <> 0 then
begin
dec(message_counter);
if message_counter = 0 then
begin
HUlib_removeLineFromSText(@w_message);
message_on := w_message.lines[w_message.curline].len > 0;
if message_on then
message_counter := HU_MSGTIMEOUT;
message_nottobefuckedwith := false;
end;
end;
if (showMessages <> 0) or message_dontfuckwithme then
begin
// display message if necessary
if ((plr._message <> '') and not message_nottobefuckedwith) or
((plr._message <> '') and message_dontfuckwithme) then
begin
HUlib_addMessageToSText2(@w_message, '', plr._message);
plr._message := '';
message_on := true;
message_counter := HU_MSGTIMEOUT;
message_nottobefuckedwith := message_dontfuckwithme;
message_dontfuckwithme := false;
end;
end; // else message_on = false;
// check for incoming chat characters
if netgame then
begin
for i := 0 to MAXPLAYERS - 1 do
begin
if not playeringame[i] then
continue;
c := Chr(players[i].cmd.chatchar);
if (i <> consoleplayer) and (c <> #0) then
begin
if c <= Chr(HU_BROADCAST) then
chat_dest[i] := c
else
begin
if (c >= 'a') and (c <= 'z') then
c := shiftxform[Ord(c)];
rc := HUlib_keyInIText(@w_inputbuffer[i], Ord(c));
if rc and (Ord(c) = KEY_ENTER) then
begin
if (w_inputbuffer[i].line.len <> 0) and
((Ord(chat_dest[i]) = consoleplayer + 1) or (Ord(chat_dest[i]) = HU_BROADCAST)) then
begin
HUlib_addMessageToSText(@w_message,
player_names[i],
w_inputbuffer[i].line.line);
message_nottobefuckedwith := true;
message_on := true;
message_counter := HU_MSGTIMEOUT;
if gamemode = commercial then
S_StartSound(nil, Ord(sfx_radio))
else
S_StartSound(nil, Ord(sfx_tink));
end;
HUlib_resetIText(@w_inputbuffer[i]);
end;
end;
players[i].cmd.chatchar := 0;
end;
end;
end;
end;
const
QUEUESIZE = 128;
var
chatchars: array[0..QUEUESIZE - 1] of char;
head: integer = 0;
tail: integer = 0;
//==============================================================================
//
// HU_queueChatChar
//
//==============================================================================
procedure HU_queueChatChar(c: char);
begin
if ((head + 1) and (QUEUESIZE - 1)) = tail then
plr._message := HUSTR_MSGU
else
begin
chatchars[head] := c;
head := (head + 1) and (QUEUESIZE - 1);
end;
end;
//==============================================================================
//
// HU_dequeueChatChar
//
//==============================================================================
function HU_dequeueChatChar: char;
begin
if head <> tail then
begin
result := chatchars[tail];
tail := (tail + 1) and (QUEUESIZE - 1);
end
else
result := #0;
end;
var
lastmessage: string;
shiftdown: boolean = false;
altdown: boolean = false;
num_nobrainers: integer = 0;
//==============================================================================
//
// HU_Responder
//
//==============================================================================
function HU_Responder(ev: Pevent_t): boolean;
var
macromessage: string;
c: char;
i: integer;
numplayers: integer;
begin
result := false;
if ev.data1 = KEY_RSHIFT then
begin
shiftdown := ev._type = ev_keydown;
exit;
end
else if (ev.data1 = KEY_RALT) or (ev.data1 = KEY_LALT) then
begin
altdown := ev._type = ev_keydown;
exit;
end;
if ev._type <> ev_keydown then
exit;
numplayers := 0;
for i := 0 to MAXPLAYERS - 1 do
if playeringame[i] then
inc(numplayers);
if not chat_on then
begin
if ev.data1 = HU_MSGREFRESH then
begin
message_on := true;
message_counter := HU_MSGTIMEOUT;
result := true;
end
else if netgame and (ev.data1 = Ord(HU_INPUTTOGGLE)) then
begin
result := true;
chat_on := true;
HUlib_resetIText(@w_chat);
HU_queueChatChar(Chr(HU_BROADCAST));
end
else if netgame and (numplayers > 2) then
begin
for i := 0 to MAXPLAYERS - 1 do
begin
if destination_keys[i] <> '' then
begin
if ev.data1 = Ord(destination_keys[i][1]) then
begin
if playeringame[i] and (i <> consoleplayer) then
begin
result := true;
chat_on := true;
HUlib_resetIText(@w_chat);
HU_queueChatChar(Chr(i + 1));
break;
end
else if i = consoleplayer then
begin
inc(num_nobrainers);
if num_nobrainers < 3 then
plr._message := HUSTR_TALKTOSELF1
else if num_nobrainers < 6 then
plr._message := HUSTR_TALKTOSELF2
else if num_nobrainers < 9 then
plr._message := HUSTR_TALKTOSELF3
else if num_nobrainers < 32 then
plr._message := HUSTR_TALKTOSELF4
else
plr._message := HUSTR_TALKTOSELF5;
end
end;
end;
end;
end;
end
else
begin
c := Chr(ev.data1);
// send a macro
if altdown then
begin
c := Chr(Ord(c) - Ord('0'));
if c > Chr(9) then
exit;
macromessage := chat_macros[Ord(c)];
// kill last message with a '\n'
HU_queueChatChar(Chr(KEY_ENTER)); // DEBUG!!!
// send the macro message
for i := 1 to Length(macromessage) do
HU_queueChatChar(macromessage[i]);
HU_queueChatChar(Chr(KEY_ENTER));
// leave chat mode and notify that it was sent
chat_on := false;
lastmessage := chat_macros[Ord(c)];
plr._message := lastmessage;
result := true;
end
else
begin
if language = french then
c := ForeignTranslation(c);
if shiftdown or ((c >= 'a') and (c <= 'z')) then
c := shiftxform[Ord(c)];
result := HUlib_keyInIText(@w_chat, Ord(c));
if result then
HU_queueChatChar(c);
if Ord(c) = KEY_ENTER then
begin
chat_on := false;
if w_chat.line.len <> 0 then
begin
lastmessage := w_chat.line.line;
plr._message := lastmessage;
end
end
else if Ord(c) = KEY_ESCAPE then
chat_on := false;
end;
end;
end;
initialization
chat_macros[0] := HUSTR_CHATMACRO0;
chat_macros[1] := HUSTR_CHATMACRO1;
chat_macros[2] := HUSTR_CHATMACRO2;
chat_macros[3] := HUSTR_CHATMACRO3;
chat_macros[4] := HUSTR_CHATMACRO4;
chat_macros[5] := HUSTR_CHATMACRO5;
chat_macros[6] := HUSTR_CHATMACRO6;
chat_macros[7] := HUSTR_CHATMACRO7;
chat_macros[8] := HUSTR_CHATMACRO8;
chat_macros[9] := HUSTR_CHATMACRO9;
player_names[0] := HUSTR_PLRGREEN;
player_names[1] := HUSTR_PLRINDIGO;
player_names[2] := HUSTR_PLRBROWN;
player_names[3] := HUSTR_PLRRED;
////////////////////////////////////////////////////////////////////////////////
//
// Builtin map names.
// The actual names can be found in DStrings.h.
//
////////////////////////////////////////////////////////////////////////////////
// DOOM shareware/registered/retail (Ultimate) names.
mapnames[0] := HUSTR_E1M1;
mapnames[1] := HUSTR_E1M2;
mapnames[2] := HUSTR_E1M3;
mapnames[3] := HUSTR_E1M4;
mapnames[4] := HUSTR_E1M5;
mapnames[5] := HUSTR_E1M6;
mapnames[6] := HUSTR_E1M7;
mapnames[7] := HUSTR_E1M8;
mapnames[8] := HUSTR_E1M9;
mapnames[9] := HUSTR_E2M1;
mapnames[10] := HUSTR_E2M2;
mapnames[11] := HUSTR_E2M3;
mapnames[12] := HUSTR_E2M4;
mapnames[13] := HUSTR_E2M5;
mapnames[14] := HUSTR_E2M6;
mapnames[15] := HUSTR_E2M7;
mapnames[16] := HUSTR_E2M8;
mapnames[17] := HUSTR_E2M9;
mapnames[18] := HUSTR_E3M1;
mapnames[19] := HUSTR_E3M2;
mapnames[20] := HUSTR_E3M3;
mapnames[21] := HUSTR_E3M4;
mapnames[22] := HUSTR_E3M5;
mapnames[23] := HUSTR_E3M6;
mapnames[24] := HUSTR_E3M7;
mapnames[25] := HUSTR_E3M8;
mapnames[26] := HUSTR_E3M9;
mapnames[27] := HUSTR_E4M1;
mapnames[28] := HUSTR_E4M2;
mapnames[29] := HUSTR_E4M3;
mapnames[30] := HUSTR_E4M4;
mapnames[31] := HUSTR_E4M5;
mapnames[32] := HUSTR_E4M6;
mapnames[33] := HUSTR_E4M7;
mapnames[34] := HUSTR_E4M8;
mapnames[35] := HUSTR_E4M9;
mapnames[36] := 'NEWLEVEL';
mapnames[37] := mapnames[36];
mapnames[38] := mapnames[36];
mapnames[39] := mapnames[36];
mapnames[40] := mapnames[36];
mapnames[41] := mapnames[36];
mapnames[42] := mapnames[36];
mapnames[43] := mapnames[36];
mapnames[44] := mapnames[36];
////////////////////////////////////////////////////////////////////////////////
// DOOM 2 map names.
mapnames2[0] := HUSTR_1;
mapnames2[1] := HUSTR_2;
mapnames2[2] := HUSTR_3;
mapnames2[3] := HUSTR_4;
mapnames2[4] := HUSTR_5;