-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmenu.pas
3456 lines (2880 loc) · 79.5 KB
/
menu.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 menu;
//
// the net drivers should just set the apropriate bits in m_activenet,
// instead of having the menu code look through their internal tables
//
//
// the net drivers should just set the apropriate bits in m_activenet,
// instead of having the menu code look through their internal tables
//
interface
uses
q_delphi,
wad;
const
MNET_IPX = 1;
MNET_TCP = 2;
//
// menus
//
procedure M_Init;
procedure M_Keydown(key: integer);
procedure M_Draw;
procedure M_ToggleMenu_f;
procedure M_DrawPic(x, y: integer; pic: Pqpic_t);
procedure M_Menu_Quit_f;
procedure M_Menu_Main_f;
procedure M_Menu_Options_f;
procedure M_Print(cx, cy: integer; str: PChar); // VJ mayby common proc for M_Print and M_PrintWhite
procedure M_PrintWhite(cx, cy: integer; str: PChar);
type
state_t = (
m_none,
m_main,
m_singleplayer,
m_load,
m_save,
m_multiplayer,
m_setup,
m_net,
m_options,
m_video,
m_keys,
m_help,
m_quit,
m_serialconfig,
m_modemconfig,
m_lanconfig,
m_gameoptions,
m_search,
m_slist
);
var
m_state: state_t;
m_return_state: state_t;
m_return_onerror: qboolean;
m_return_reason: array[0..31] of char;
var
vid_menudrawfn: procedure;
vid_menukeyfn: procedure(i: integer);
implementation
uses
quakedef,
net_main,
gl_draw,
gl_vidnt,
render_h,
keys,
keys_h,
console,
cl_main,
cl_main_h,
host_h,
common,
client,
snd_dma,
sv_main,
gl_screen,
cmd,
cvar,
view,
snd_dma_h,
cl_input,
host_cmd,
net;
procedure M_Menu_SinglePlayer_f; forward;
procedure M_Menu_Load_f; forward;
procedure M_Menu_Save_f; forward;
procedure M_Menu_MultiPlayer_f; forward;
procedure M_Menu_Setup_f; forward;
procedure M_Menu_Net_f; forward;
procedure M_Menu_Keys_f; forward;
procedure M_Menu_Video_f; forward;
procedure M_Menu_Help_f; forward;
procedure M_Menu_SerialConfig_f; forward;
// procedure M_Menu_ModemConfig_f; forward;
procedure M_Menu_LanConfig_f; forward;
procedure M_Menu_GameOptions_f; forward;
procedure M_Menu_Search_f; forward;
procedure M_Menu_ServerList_f; forward;
procedure M_Main_Draw; forward;
procedure M_SinglePlayer_Draw; forward;
procedure M_Load_Draw; forward;
procedure M_Save_Draw; forward;
procedure M_MultiPlayer_Draw; forward;
procedure M_Setup_Draw; forward;
procedure M_Net_Draw; forward;
procedure M_Options_Draw; forward;
procedure M_Keys_Draw; forward;
procedure M_Video_Draw; forward;
procedure M_Help_Draw; forward;
procedure M_Quit_Draw; forward;
procedure M_SerialConfig_Draw; forward;
procedure M_ModemConfig_Draw; forward;
procedure M_LanConfig_Draw; forward;
procedure M_GameOptions_Draw; forward;
procedure M_Search_Draw; forward;
procedure M_ServerList_Draw; forward;
procedure M_Main_Key(key: integer); forward;
procedure M_SinglePlayer_Key(key: integer); forward;
procedure M_Load_Key(k: integer); forward;
procedure M_Save_Key(k: integer); forward;
procedure M_MultiPlayer_Key(key: integer); forward;
procedure M_Setup_Key(k: integer); forward;
procedure M_Net_Key(k: integer); forward;
procedure M_Options_Key(k: integer); forward;
procedure M_Keys_Key(k: integer); forward;
procedure M_Video_Key(key: integer); forward;
procedure M_Help_Key(key: integer); forward;
procedure M_Quit_Key(key: integer); forward;
procedure M_SerialConfig_Key(key: integer); forward;
procedure M_ModemConfig_Key(key: integer); forward;
procedure M_LanConfig_Key(key: integer); forward;
procedure M_GameOptions_Key(key: integer); forward;
procedure M_Search_Key(key: integer); forward;
procedure M_ServerList_Key(k: integer); forward;
var
m_entersound: qboolean = false; // play after drawing a frame, so caching
// won't disrupt the sound
m_recursiveDraw: qboolean;
m_multiplayer_cursor: integer;
m_net_cursor: integer;
function StartingGame: boolean;
begin
result := m_multiplayer_cursor = 1
end;
function JoiningGame: boolean;
begin
result := m_multiplayer_cursor = 0;
end;
function SerialConfig: boolean;
begin
result := m_net_cursor = 0;
end;
function DirectConfig: boolean;
begin
result := m_net_cursor = 1;
end;
function IPXConfig: boolean;
begin
result := m_net_cursor = 2;
end;
function TCPIPConfig: boolean;
begin
result := m_net_cursor = 3
end;
procedure M_ConfigureNetSubsystem; forward;
(*
================
M_DrawCharacter
Draws one solid graphics character
================
*)
procedure M_DrawCharacter(cx: integer; line: integer; num: integer);
begin
Draw_Character(cx + ((vid.width - 320) div 2), line, num);
end;
procedure M_Print(cx, cy: integer; str: PChar); // VJ mayby common proc for M_Print and M_PrintWhite
begin
while str^ <> #0 do
begin
M_DrawCharacter(cx, cy, Ord(str^) + 128);
inc(str);
inc(cx, 8);
end;
end;
procedure M_PrintWhite(cx, cy: integer; str: PChar);
begin
while str^ <> #0 do
begin
M_DrawCharacter(cx, cy, Ord(str^));
inc(str);
inc(cx, 8);
end;
end;
procedure M_DrawTransPic(x, y: integer; pic: Pqpic_t);
begin
Draw_TransPic(x + ((vid.width - 320) div 2), y, pic);
end;
procedure M_DrawPic(x, y: integer; pic: Pqpic_t);
begin
Draw_Pic(x + ((vid.width - 320) div 2), y, pic);
end;
var
identityTable: array[0..255] of byte;
translationTable: array[0..255] of byte;
procedure M_BuildTranslationTable(top, bottom: integer);
var
j: integer;
dest, source: PByteArray;
begin
for j := 0 to 255 do
identityTable[j] := j;
dest := @translationTable;
source := @identityTable;
memcpy(dest, source, 256);
if top < 128 then // the artists made some backwards ranges. sigh.
memcpy(@dest[TOP_RANGE], @source[top], 16)
else
for j := 0 to 15 do
dest[TOP_RANGE + j] := source[top + 15 - j];
if bottom < 128 then
memcpy(@dest[BOTTOM_RANGE], @source[bottom], 16)
else
for j := 0 to 15 do
dest[BOTTOM_RANGE + j] := source[bottom + 15 - j];
end;
procedure M_DrawTransPicTranslate(x, y: integer; pic: Pqpic_t);
begin
Draw_TransPicTranslate(x + ((vid.width - 320) div 2), y, pic, @translationTable);
end;
procedure M_DrawTextBox(x, y: integer; width: integer; lines: integer);
var
p: Pqpic_t;
cx, cy: integer;
n: integer;
begin
// draw left side
cx := x;
cy := y;
p := Draw_CachePic('gfx/box_tl.lmp');
M_DrawTransPic(cx, cy, p);
p := Draw_CachePic('gfx/box_ml.lmp');
for n := 0 to lines - 1 do
begin
inc(cy, 8);
M_DrawTransPic(cx, cy, p);
end;
p := Draw_CachePic('gfx/box_bl.lmp');
M_DrawTransPic(cx, cy + 8, p);
// draw middle
inc(cx, 8);
while width > 0 do
begin
cy := y;
p := Draw_CachePic('gfx/box_tm.lmp');
M_DrawTransPic(cx, cy, p);
p := Draw_CachePic('gfx/box_mm.lmp');
for n := 0 to lines - 1 do
begin
inc(cy, 8);
if n = 1 then
p := Draw_CachePic('gfx/box_mm2.lmp');
M_DrawTransPic(cx, cy, p);
end;
p := Draw_CachePic('gfx/box_bm.lmp');
M_DrawTransPic(cx, cy + 8, p);
dec(width, 2);
inc(cx, 16);
end;
// draw right side
cy := y;
p := Draw_CachePic('gfx/box_tr.lmp');
M_DrawTransPic(cx, cy, p);
p := Draw_CachePic('gfx/box_mr.lmp');
for n := 0 to lines - 1 do
begin
inc(cy, 8);
M_DrawTransPic(cx, cy, p);
end;
p := Draw_CachePic('gfx/box_br.lmp');
M_DrawTransPic(cx, cy + 8, p);
end;
//=============================================================================
var
m_save_demonum: integer;
(*
================
M_ToggleMenu_f
================
*)
procedure M_ToggleMenu_f;
begin
m_entersound := true;
if key_dest = key_menu then
begin
if m_state <> m_main then
begin
M_Menu_Main_f;
exit;
end;
key_dest := key_game;
m_state := m_none;
exit;
end;
if key_dest = key_console then
Con_ToggleConsole_f
else
M_Menu_Main_f
end;
//=============================================================================
(* MAIN MENU *)
var
m_main_cursor: integer;
const
MAIN_ITEMS = 5;
procedure M_Menu_Main_f;
begin
if key_dest <> key_menu then
begin
m_save_demonum := cls.demonum;
cls.demonum := -1;
end;
key_dest := key_menu;
m_state := m_main;
m_entersound := true;
end;
procedure M_Main_Draw;
var
f: integer;
p: Pqpic_t;
begin
M_DrawTransPic(16, 4, Draw_CachePic('gfx/qplaque.lmp'));
p := Draw_CachePic('gfx/ttl_main.lmp');
M_DrawPic((320 - p.width) div 2, 4, p);
M_DrawTransPic(72, 32, Draw_CachePic('gfx/mainmenu.lmp'));
f := intval(host_time * 10) mod 6;
M_DrawTransPic(54, 32 + m_main_cursor * 20, Draw_CachePic(va('gfx/menudot%d.lmp', [f + 1])));
end;
procedure M_Main_Key(key: integer);
begin
case key of
K_ESCAPE:
begin
key_dest := key_game;
m_state := m_none;
cls.demonum := m_save_demonum;
if (cls.demonum <> -1) and not cls.demoplayback and (cls.state <> ca_connected) then
CL_NextDemo;
end;
K_DOWNARROW:
begin
S_LocalSound('misc/menu1.wav');
inc(m_main_cursor); // VJ check this (++)
if m_main_cursor >= MAIN_ITEMS then
m_main_cursor := 0;
end;
K_UPARROW:
begin
S_LocalSound('misc/menu1.wav');
dec(m_main_cursor); // VJ check (--)
if m_main_cursor < 0 then
m_main_cursor := MAIN_ITEMS - 1;
end;
K_ENTER:
begin
m_entersound := true;
case m_main_cursor of
0: M_Menu_SinglePlayer_f;
1: M_Menu_MultiPlayer_f;
2: M_Menu_Options_f;
3: M_Menu_Help_f;
4: M_Menu_Quit_f;
end;
end;
end;
end;
//=============================================================================
(* SINGLE PLAYER MENU *)
var
m_singleplayer_cursor: integer;
const
SINGLEPLAYER_ITEMS = 3;
procedure M_Menu_SinglePlayer_f;
begin
key_dest := key_menu;
m_state := m_singleplayer;
m_entersound := true;
end;
procedure M_SinglePlayer_Draw;
var
f: integer;
p: Pqpic_t;
begin
M_DrawTransPic(16, 4, Draw_CachePic('gfx/qplaque.lmp'));
p := Draw_CachePic('gfx/ttl_sgl.lmp');
M_DrawPic((320 - p.width) div 2, 4, p);
M_DrawTransPic(72, 32, Draw_CachePic('gfx/sp_menu.lmp'));
f := intval(host_time * 10) mod 6;
M_DrawTransPic(54, 32 + m_singleplayer_cursor * 20, Draw_CachePic(va('gfx/menudot%d.lmp', [f + 1])));
end;
procedure M_SinglePlayer_Key(key: integer);
label
label1;
begin
case key of
K_ESCAPE:
begin
M_Menu_Main_f;
end;
K_DOWNARROW:
begin
S_LocalSound('misc/menu1.wav');
inc(m_singleplayer_cursor); // VJ check --
if m_singleplayer_cursor >= SINGLEPLAYER_ITEMS then
m_singleplayer_cursor := 0;
end;
K_UPARROW:
begin
S_LocalSound('misc/menu1.wav');
dec(m_singleplayer_cursor); // VJ check --
if m_singleplayer_cursor < 0 then
m_singleplayer_cursor := SINGLEPLAYER_ITEMS - 1;
end;
K_ENTER:
begin
m_entersound := true;
case m_singleplayer_cursor of
0:
begin
if sv.active then
if not SCR_ModalMessage('Are you sure you want to'#10'start a new game?'#10) then
goto label1;
key_dest := key_game;
if sv.active then
Cbuf_AddText('disconnect'#10);
Cbuf_AddText('maxplayers 1'#10);
Cbuf_AddText('map start'#10);
label1:
end;
1: M_Menu_Load_f;
2: M_Menu_Save_f;
end;
end;
end;
end;
//=============================================================================
(* LOAD/SAVE MENU *)
var
load_cursor: integer; // 0 < load_cursor < MAX_SAVEGAMES
const
MAX_SAVEGAMES = 12;
var
m_filenames: array[0..MAX_SAVEGAMES - 1] of array [0..SAVEGAME_COMMENT_LENGTH] of char;
loadable: array[0..MAX_SAVEGAMES - 1] of qboolean;
procedure M_ScanSaves;
var
i, j: integer;
name: array[0..MAX_OSPATH - 1] of char;
f: text;
version: integer;
begin
for i := 0 to MAX_SAVEGAMES - 1 do
begin
strcpy(m_filenames[i], '--- UNUSED SLOT ---');
loadable[i] := false;
sprintf(name, '%s/s%d.sav', [com_gamedir, i]);
if fopen(name, 'r', f) then
begin
fscanf(f, version);
fscanf(f, name);
strncpy(m_filenames[i], name, SizeOf(m_filenames[i]) - 1);
// change _ back to space
for j := 0 to SAVEGAME_COMMENT_LENGTH - 1 do
if m_filenames[i][j] = '_' then
m_filenames[i][j] := ' ';
loadable[i] := true;
fclose(f);
end;
end;
end;
procedure M_Menu_Load_f;
begin
m_entersound := true;
m_state := m_load;
key_dest := key_menu;
M_ScanSaves;
end;
procedure M_Menu_Save_f;
begin
if not sv.active then
exit;
if cl.intermission <> 0 then
exit;
if svs.maxclients <> 1 then
exit;
m_entersound := true;
m_state := m_save;
key_dest := key_menu;
M_ScanSaves;
end;
procedure M_LoadSave_Draw(pic: PChar);
var
i: integer;
p: Pqpic_t;
begin
p := Draw_CachePic(pic);
M_DrawPic((320 - p.width) div 2, 4, p);
for i := 0 to MAX_SAVEGAMES - 1 do
M_Print(16, 32 + 8 * i, m_filenames[i]);
// line cursor
M_DrawCharacter(8, 32 + load_cursor * 8, 12 + (intval(realtime * 4) and 1));
end;
procedure M_Load_Draw;
begin
M_LoadSave_Draw('gfx/p_load.lmp');
end;
procedure M_Save_Draw;
begin
M_LoadSave_Draw('gfx/p_save.lmp');
end;
procedure M_Load_Key(k: integer);
begin
case k of
K_ESCAPE:
begin
M_Menu_SinglePlayer_f;
end;
K_ENTER:
begin
S_LocalSound('misc/menu2.wav');
if not loadable[load_cursor] then
exit;
m_state := m_none;
key_dest := key_game;
// Host_Loadgame_f can't bring up the loading plaque because too much
// stack space has been used, so do it now
SCR_BeginLoadingPlaque;
// issue the load command
Cbuf_AddText(va('load s%d'#10, [load_cursor]));
end;
K_UPARROW,
K_LEFTARROW:
begin
S_LocalSound('misc/menu1.wav');
dec(load_cursor);
if load_cursor < 0 then
load_cursor := MAX_SAVEGAMES - 1;
end;
K_DOWNARROW,
K_RIGHTARROW:
begin
S_LocalSound('misc/menu1.wav');
inc(load_cursor);
if load_cursor >= MAX_SAVEGAMES then
load_cursor := 0;
end;
end;
end;
procedure M_Save_Key(k: integer);
begin
case k of
K_ESCAPE:
begin
M_Menu_SinglePlayer_f;
end;
K_ENTER:
begin
m_state := m_none;
key_dest := key_game;
Cbuf_AddText(va('save s%d'#10, [load_cursor]));
end;
K_UPARROW,
K_LEFTARROW:
begin
S_LocalSound('misc/menu1.wav');
dec(load_cursor);
if load_cursor < 0 then
load_cursor := MAX_SAVEGAMES - 1;
end;
K_DOWNARROW,
K_RIGHTARROW:
begin
S_LocalSound('misc/menu1.wav');
inc(load_cursor);
if load_cursor >= MAX_SAVEGAMES then
load_cursor := 0;
end;
end;
end;
//=============================================================================
(* MULTIPLAYER MENU *)
const
MULTIPLAYER_ITEMS = 3;
procedure M_Menu_MultiPlayer_f;
begin
key_dest := key_menu;
m_state := m_multiplayer;
m_entersound := true;
end;
procedure M_MultiPlayer_Draw;
var
f: integer;
p: Pqpic_t;
begin
M_DrawTransPic(16, 4, Draw_CachePic('gfx/qplaque.lmp'));
p := Draw_CachePic('gfx/p_multi.lmp');
M_DrawPic((320 - p.width) div 2, 4, p);
M_DrawTransPic(72, 32, Draw_CachePic('gfx/mp_menu.lmp'));
f := intval(host_time * 10) mod 6;
M_DrawTransPic(54, 32 + m_multiplayer_cursor * 20, Draw_CachePic(va('gfx/menudot%d.lmp', [f + 1])));
if serialAvailable or ipxAvailable or tcpipAvailable then
exit;
M_PrintWhite((320 div 2) - ((27 * 8) div 2), 148, 'No Communications Available');
end;
procedure M_MultiPlayer_Key(key: integer);
begin
case key of
K_ESCAPE:
begin
M_Menu_Main_f;
end;
K_DOWNARROW:
begin
S_LocalSound('misc/menu1.wav');
inc(m_multiplayer_cursor); // VJ check!
if m_multiplayer_cursor >= MULTIPLAYER_ITEMS then
m_multiplayer_cursor := 0;
end;
K_UPARROW:
begin
S_LocalSound('misc/menu1.wav');
dec(m_multiplayer_cursor); // VJ check!
if m_multiplayer_cursor < 0 then
m_multiplayer_cursor := MULTIPLAYER_ITEMS - 1;
end;
K_ENTER:
begin
m_entersound := true;
case m_multiplayer_cursor of
0: // VJ mayby 0, 1: // same code for 0 and 1
begin
if serialAvailable or ipxAvailable or tcpipAvailable then
M_Menu_Net_f;
end;
1:
begin
if serialAvailable or ipxAvailable or tcpipAvailable then
M_Menu_Net_f;
end;
2:
begin
M_Menu_Setup_f;
end;
end;
end;
end;
end;
//=============================================================================
(* SETUP MENU *)
var
setup_cursor: integer = 4;
setup_cursor_table: array[0..4] of integer = (40, 56, 80, 104, 140);
setup_hostname: array[0..15] of char;
setup_myname: array[0..15] of char;
setup_oldtop: integer;
setup_oldbottom: integer;
setup_top: integer;
setup_bottom: integer;
const
NUM_SETUP_CMDS = 5;
procedure M_Menu_Setup_f;
begin
key_dest := key_menu;
m_state := m_setup;
m_entersound := true;
Q_strcpy(setup_myname, cl_name.text);
Q_strcpy(setup_hostname, hostname.text);
setup_oldtop := intval(cl_color.value) div 16;
setup_top := setup_oldtop;
setup_oldbottom := intval(cl_color.value) and 15;
setup_bottom := setup_oldbottom;
end;
procedure M_Setup_Draw;
var
p: Pqpic_t;
begin
M_DrawTransPic(16, 4, Draw_CachePic('gfx/qplaque.lmp'));
p := Draw_CachePic('gfx/p_multi.lmp');
M_DrawPic((320 - p.width) div 2, 4, p);
M_Print(64, 40, 'Hostname');
M_DrawTextBox(160, 32, 16, 1);
M_Print(168, 40, setup_hostname);
M_Print(64, 56, 'Your name');
M_DrawTextBox(160, 48, 16, 1);
M_Print(168, 56, setup_myname);
M_Print(64, 80, 'Shirt color');
M_Print(64, 104, 'Pants color');
M_DrawTextBox(64, 140 - 8, 14, 1);
M_Print(72, 140, 'Accept Changes');
p := Draw_CachePic('gfx/bigbox.lmp');
M_DrawTransPic(160, 64, p);
p := Draw_CachePic('gfx/menuplyr.lmp');
M_BuildTranslationTable(setup_top * 16, setup_bottom * 16);
M_DrawTransPicTranslate(172, 72, p);
M_DrawCharacter(56, setup_cursor_table[setup_cursor], 12 + (intval(realtime * 4) and 1));
if setup_cursor = 0 then
M_DrawCharacter(168 + 8 * strlen(setup_hostname), setup_cursor_table[setup_cursor], 10 + (intval(realtime * 4) and 1));
if setup_cursor = 1 then
M_DrawCharacter(168 + 8 * strlen(setup_myname), setup_cursor_table [setup_cursor], 10 + (intval(realtime * 4) and 1));
end;
procedure M_Setup_Key(k: integer);
var
l: integer;
procedure forward1;
begin
S_LocalSound('misc/menu3.wav');
if setup_cursor = 2 then
inc(setup_top);
if setup_cursor = 3 then
inc(setup_bottom);
end;
begin
case k of
K_ESCAPE:
begin
M_Menu_MultiPlayer_f;
end;
K_UPARROW:
begin
S_LocalSound('misc/menu1.wav');
dec(setup_cursor);
if setup_cursor < 0 then
setup_cursor := NUM_SETUP_CMDS - 1;
end;
K_DOWNARROW:
begin
S_LocalSound('misc/menu1.wav');
inc(setup_cursor);
if setup_cursor >= NUM_SETUP_CMDS then
setup_cursor := 0;
end;
K_LEFTARROW:
begin
if setup_cursor < 2 then
exit;
S_LocalSound('misc/menu3.wav');
if setup_cursor = 2 then
dec(setup_top);
if setup_cursor = 3 then
dec(setup_bottom);
end;
K_RIGHTARROW:
begin
if setup_cursor < 2 then
exit;
forward1;
end;
K_ENTER:
begin
if setup_cursor in [0, 1] then
exit;
if setup_cursor in [2, 3] then
forward1
else
begin
// setup_cursor == 4 (OK)
if Q_strcmp(cl_name.text, setup_myname) <> 0 then
Cbuf_AddText(va('name "%s"'#10, [setup_myname]));
if Q_strcmp(hostname.text, setup_hostname) <> 0 then
Cvar_Set('hostname', setup_hostname);
if (setup_top <> setup_oldtop) or (setup_bottom <> setup_oldbottom) then
Cbuf_AddText(va('color %d %d'#10, [setup_top, setup_bottom]));
m_entersound := true;
M_Menu_MultiPlayer_f;
end;
end;
K_BACKSPACE:
begin
if setup_cursor = 0 then
begin
l := strlen(setup_hostname);
if l > 0 then
setup_hostname[l - 1] := #0;
end;
if setup_cursor = 1 then
begin
l := strlen(setup_myname);
if l > 0 then
setup_myname[l - 1] := #0;
end;
end;
else
begin
if (k >= 32) or (k <= 127) then
begin
if setup_cursor = 0 then
begin
l := strlen(setup_hostname);
if l < 15 then
begin
setup_hostname[l + 1] := #0;
setup_hostname[l] := Chr(k);
end;
end;
if setup_cursor = 1 then
begin
l := strlen(setup_myname);
if l < 15 then
begin
setup_myname[l + 1] := #0;
setup_myname[l] := Chr(k);
end;
end;
end;
end;
end;