-
Notifications
You must be signed in to change notification settings - Fork 1
/
Menu_Lib.pas
1102 lines (971 loc) · 29.2 KB
/
Menu_Lib.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
unit Menu_Lib;
interface
uses
Windows, Messages, Engine_Reg, OpenGL, SysUtils,
ObjAnim_Lib, Math_Lib, Type_Lib, Graph_Lib, MyMenu,
Constants_Lib, Model_Lib,
Arena_Lib;
procedure Menu_Init;
procedure Menu_Free;
procedure Menu_Update;
procedure Menu_Draw;
procedure Menu_Message(Msg: DWORD; wParam: Longint; lParam: LongInt);
procedure Menu_Proc(ID : integer; Param : integer);
const
BTN_HOTSEAT = 1;
BTN_MULTI = 2;
BTN_SETUP = 3;
BTN_DEMOS = 4;
BTN_MODS = 5;
BTN_CREDITS = 6;
BTN_EXIT = 7;
BTN_BACK = 8; // Íàçàä â ãëàâíîå ìåíþ
BTN_FIGHT = 9; // Çàïóñê èãðû íà êàðòå êàðòû
BTN_PLAY = 10; // Êíîïêà ïðîèãðûâàíèÿ äåìêè
BTN_LOAD = 11; // Ñìåíà ìîäà
BTN_PLAYER1 = 12;
BTN_PLAYER2 = 13;
BTN_DISPLAY = 14;
BTN_SOUND = 15;
BTN_MULTICREATE = 16;
BTN_CONNECT = 20;
BTN_REFRESH = 21;
// BTN_SEARCH = 22;
BTN_ADDIP = 23;
BTN_ACCEPT = 24;
EDIT_NAME = 32;
EDIT_YESNO = 33;
EDIT_STRING = 34;
EDIT_BINDS = 40;
EDIT_BIND_LEFT = 41;
EDIT_BIND_RIGHT = 42;
EDIT_BIND_STRAFELEFT = 41;
EDIT_BIND_STRAFERIGHT = 42;
EDIT_BIND_CROUCH = 43;
EDIT_BIND_FIRE = 44;
EDIT_IP = 50;
BTN_RESTART = 100;
BTN_LEAVEARENA = 101;
FLB_MAP = 200;
FLB_DEMO = 201;
FLB_MODS = 202;
LB_MODELS = 205;
LB_SKINS = 206;
LB_SERVERS = 207;
DIS__MODE : array [0..4] of string = ('320x240', '640x480', '800x600', '1024x768', '1600x1200');
DIS__BPP : array [0..1] of string = ('16', '32');
DIS__FREQ : array [0..3] of string = ('60', '75', '85', '100');
var
WND_MAIN : TMyWindow;
WND_HOTSEAT : TMyWindow;
WND_SETUP : TMyWindow;
WND_PLAYER1 : TMyWindow;
WND_PLAYER2 : TMyWindow;
WND_DISPLAY : TMyWindow;
WND_SOUND : TMyWindow;
WND_DEMOS : TMyWindow;
WND_MODS : TMyWindow;
WND_GAME : TMyWindow;
WND_MP_INTERNET: TMyWindow;
WND_MULTICREATE: TMyWindow;
var
MP_lb: TListBox;
IPEdit: TEdit;
SayEdit : TEdit;
onSay : boolean;
type
TModelName = array of string;
var
inMenu : boolean;
ModelName : TModelName;
MenuBG : PaRGB;
MenuTex : TTexData;
dis_mode : Byte;
dis_bpp : Byte;
dis_freq : Byte;
const
MenuBg_X = 128;
MenuBg_Y = 128;
procedure CallWindow(window: TMyWindow);
procedure CallBack;
procedure CallGameMenuON;
procedure CallGameMenuOFF;
procedure CallMainMenu;
procedure Menu_SetModel(pl: integer);
procedure Menu_AddServer(IP: string; Port: word; HostName, MapName: string;
Ping: cardinal; players, max: integer; reason: string);
procedure Menu_RefreshServers;
procedure Menu_AddIP(str: string);
function Menu_MP: boolean;
procedure CalcMenuBG;
implementation
uses
TFK, Game_Lib, Func_Lib, Map_Lib;
var
MouseTex : TObjTex;
RefBtn : TMyControl;
RefLabel : TLabel;
procedure Menu_GetActive;
var
i : integer;
begin
with ActiveWindow do
for i := 0 to ChildCount - 1 do
with Childs[i] do
begin
if PointInRect(MousePos.X, MousePos.Y, Rect) then
begin
if not Active then
begin
if sound_off=0 then
snd_Play(MenuSnd_2, false, 0, 0, true);
Active := true;
break;
end;
end
else
if Active then
Active := false;
end;
end;
procedure CallWindow(window: TMyWindow);
begin
if ActiveWindow<>nil then
window.prevwindow:=ActiveWindow;
ActiveWindow := window;
ActiveWindow.Show;
if sound_off=0 then
snd_Play(MenuSnd_1, false, 0, 0, true);
Menu_GetActive;
end;
procedure CallBack;
var
wnd : TMyWindow;
begin
wnd:=ActiveWindow;
if ActiveWindow.prevwindow<>nil then
begin
ActiveWindow:=ActiveWindow.prevwindow;
ActiveWindow.Show;
end
else inMenu:=false;
wnd.prevwindow:=nil;
if sound_off=0 then
snd_Play(MenuSnd_3, false, 0, 0, true);
Menu_GetActive;
end;
procedure Menu_SetModel(pl: integer);
var
i : integer;
str : string;
s, n : string;
wnd : TMyWindow;
begin
if pl = 1 then
begin
str := p1model;
wnd := WND_PLAYER1;
end
else
begin
str := p2model;
wnd := WND_PLAYER2;
end;
//if (wnd = nil) or (wnd <> ActiveWindow) then Exit;
i := Pos('+', str);
if i <> 0 then
begin
n := AnsiLowerCase(Copy(str, 1, i - 1));
s := AnsiLowerCase(Copy(str, i + 1, Length(str)));
end
else
begin
s := 'default';
n := AnsiLowerCase(str);
end;
with TListBox(wnd.Childs[0]) do
for i := 1 to items.rowcount - 1 do
if AnsiLowerCase(items[0, i]) = n then
begin
index := i;
break;
end;
with TListBox(wnd.Childs[1]) do
for i := 1 to items.rowcount - 1 do
if AnsiLowerCase(items[0, i]) = s then
begin
index := i;
break;
end;
end;
function Menu_PlayerCreate(pl: integer): TMyWindow;
var
i : integer;
begin
Result := AddWindow(TMyWindow.Create);
with Result do
begin
with TListBox(AddChild(TListBox.Create(@Menu_Proc, LB_MODELS))) do
begin
SetSize(1, Length(ModelName) + 1);
Items[0, 0] := 'Model';
HAlign := ahNone;
X := 25;
Y := 250;
Width := 96;
Height := 116;
for i := 1 to Length(ModelName) do
items[0, i] := ModelName[i - 1];
Items.SortAsc(0, 0);
end;
with TListBox(AddChild(TListBox.Create(@Menu_Proc, LB_SKINS))) do
begin
HAlign := ahNone;
X := 121;
Y := 250;
Width := 96;
Height := 116;
SetSize(1, Length(Skins) + 2);
Items[0, 0] := 'Skin';
items[0, 1] := 'default';
for i := 2 to Length(Skins) + 1 do
items[0, i] := Skins[i - 1].Name;
index := 0;
end;
with TModelViewer(AddChild(TModelViewer.Create)) do
begin
X := 268;
Y := 320;
end;
AddChild(TTexLabel.Create(nil, 0, 'player' + IntToStr(pl)));
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
def_x := 32;
def_y := 64;
def_cx := 0;
def_cy := 20;
if pl = 1 then
with AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @p1name, 'Name', 'name', VT_STRING)) as TEdit do
begin
Tab := 8;
MaxLength := 24;
end
else
with AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @p2name, 'Name', 'p2name', VT_STRING)) as TEdit do
begin
Tab := 8;
MaxLength := 24;
end;
if pl = 1 then
begin
def_y:=def_y+def_cy;
TEdit(AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @mouse_sensitivity, 'Mouse sensitivity', 'mouse_sensitivity', VT_BYTE))).MaxLength := 1;
AddChild(TEnumEdit.Create(@Menu_Proc, EDIT_YESNO, @mouselook,
3, [0, 1, 2], ['off', 'simple', 'on'], ['0', '1', '2'],
'Mouse look', 'mouselook'));
TEdit(AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @mouselook_pitch, 'Look sensitivity x', 'mouselook_pitch', VT_BYTE))).MaxLength := 1;
TEdit(AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @mouselook_yaw, 'Look sensitivity y', 'mouselook_yaw', VT_BYTE))).MaxLength := 1;
TEdit(AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @mouselook_offset, 'Look offset', 'mouselook_offset', VT_BYTE))).MaxLength := 1;
AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO, @mouselook_strafe, 'Always use strafe', 'mouselook_strafe'));
end
else
begin
AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO, @p2disable, 'Disabled', 'p2disable'));
def_y:=def_y+def_cy;
TEdit(AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @keyb_sensitivity, 'Keyboard sensitivity', 'keyb_sensitivity', VT_BYTE)) ).MaxLength:=1;
end;
def_y:=224;
if pl = 1 then
AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO, @p1nextwpn_skipempty, 'Skip empty weapon', 'p1nextwpn_skipempty'))
else
AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO, @p2nextwpn_skipempty, 'Skip empty weapon', 'p2nextwpn_skipempty'));
def_x := 330; def_y := 50;
def_cx := 0; def_cy := 18;
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BIND_LEFT, pl, KEY_LEFT));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BIND_RIGHT, pl, KEY_RIGHT));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BIND_STRAFELEFT, pl, KEY_STRAFELEFT));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BIND_STRAFERIGHT, pl, KEY_STRAFERIGHT));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_UP));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BIND_CROUCH, pl, KEY_DOWN));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BIND_FIRE, pl, KEY_FIRE));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_NEXTWPN));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_PREVWPN));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_RUP));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_RDOWN));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_RCENTER));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+1));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+2));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+3));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+4));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+5));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+6));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+7));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_WEAPON+8));
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_USE));
if pl = 1 then
AddChild(TBindEdit.Create(@Menu_Proc, EDIT_BINDS, pl, KEY_SCOREBOARD));
Update;
end;
end;
procedure Menu_Init;
var
i, j : integer;
ModData : TMod;
md : TFindData;
sd : TFindData;
dir : string;
begin
dis_mode := 1; // 640x480
dis_bpp := 0; // 16
dis_freq := 0; // 60
SayEdit := TEdit.Create(nil, EDIT_STRING, nil, '^2Say:', '', VT_STRING);
with SayEdit do
begin
HAlign := ahLeft;
Tab := 5;
X := 0;
Y := 48;
MaxLength := 64;
end;
onSay := false;
GetMem(MenuBG, MenuBG_x*MenuBG_Y*3);
FillChar(MenuBG[0], MenuBG_x*MenuBG_Y*3, 0);
CalcMenuBG;
dir := Engine_Dir + Engine_ModDir + 'models\';
i := 0;
ModelName := nil;
if FindFirst(dir + '*', md) then
repeat
if md.Data.cFileName[0] = '.' then continue;
if DirectoryExists(dir + md.Data.cFileName) then
begin
if FindFirst(dir + md.Data.cFileName + '\*.tml', sd) then
begin
SetLength(ModelName, i + 1);
ModelName[i] := md.Data.cFileName;
inc(i);
end;
end;
until not FindNext(md);
InitWindows;
MousePos.X := 320;
MousePos.Y := 240;
MouseTex := TObjTex.Create('textures\menu\cursor', 1, 0, 5, true, false, nil, OWNER_MENU);
WND_MAIN := AddWindow(TMyWindow.Create);
with WND_MAIN do
begin
AddChild(TButton.Create(@Menu_Proc, BTN_HOTSEAT, 'hotseat')).Y := 200;
AddChild(TButton.Create(@Menu_Proc, BTN_MULTI, 'multiplayer')).Y := 233;
AddChild(TButton.Create(@Menu_Proc, BTN_SETUP, 'setup')).Y := 266;
AddChild(TButton.Create(@Menu_Proc, BTN_DEMOS, 'demos')).Y := 299;
AddChild(TButton.Create(@Menu_Proc, BTN_MODS, 'mods')).Y := 332;
AddChild(TButton.Create(@Menu_Proc, BTN_CREDITS, 'credits')).Y := 365;
AddChild(TButton.Create(@Menu_Proc, BTN_EXIT, 'exit')).Y := 398;
AddChild(TModel3D.Create(nil, 0, 'textures\menu\logo')).Y := 200;
Update;
end;
WND_GAME := AddWindow(TMyWindow.Create);
with WND_GAME do
begin
AddChild(TButton.Create(@Menu_Proc, BTN_RESTART, 'restart')).Y := 200;
AddChild(TButton.Create(@Menu_Proc, BTN_SETUP, 'setup')).Y := 233;
AddChild(TButton.Create(@Menu_Proc, BTN_LEAVEARENA, 'leavearena')).Y := 266;
AddChild(TModel3D.Create(nil, 0, 'textures\menu\logo')).Y := 200;
Update;
end;
WND_HOTSEAT := AddWindow(TMyWindow.Create);
with WND_HOTSEAT do
begin
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
AddChild(TGraphButton.Create(@Menu_Proc, BTN_FIGHT, 'fight')).HAlign := ahRight;
AddChild(TLevelShot.Create(400, 60));
with TFileListBox(AddChild(TFileListBox.Create(@Menu_Proc, FLB_MAP))) do
begin
Items[1, 0] := 'Select map file';
HAlign := ahLeft;
X := 25;
Y := 60;
Width := 320;
Height := 276;
Ext := '*.tm';
StartDir := ExtractFileDir(paramstr(0)) + '\' + Engine_ModDir + 'maps\';
ActiveWindow := WND_HOTSEAT;
Dir := StartDir;
ActiveWindow := nil;
end;
AddChild(TTexLabel.Create(nil, 0, 'hotseat'));
def_x:=400;def_cx:=0;
def_y:=200;def_cy:=20;
AddChild(TLabel.Create(nil, 0, '^2Game properties') );
def_x:=400;def_y:=230;
TEdit( AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @timelimit, 'Timelimit', 'timelimit', VT_WORD)) ).Tab:=14;
TEdit( AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @fraglimit, 'Fraglimit', 'fraglimit', VT_WORD)) ).Tab:=14;
TEdit( AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @forcerespawn, 'Forcerespawn', 'forcerespawn', VT_WORD)) ).Tab:=14;
with TYesNoEdit( AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO, @p2disable, 'player 2', 'p2disable')) ) do
begin
tab:=14;
Str_Yes:='Disabled';
Str_No:='Active';
end;
TEnumEdit(
AddChild(TEnumEdit.Create(@Menu_Proc, EDIT_YESNO, @gametype_c,
4, [GT_FFA, GT_TRIX, GT_RAIL, GT_TDM], ['Free For All', 'Trix', 'Rail Arena', 'Team DeathMatch'], ['FFA', 'TRIX', 'RAIL', 'TDM'],
'Game Type', 'gametype')) ).Tab:=14;
Update;
end;
WND_MULTICREATE := AddWindow(TMyWindow.Create);
with WND_MULTICREATE do
begin
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
AddChild(TGraphButton.Create(@Menu_Proc, BTN_FIGHT, 'fight')).HAlign := ahRight;
AddChild(TLevelShot.Create(400, 60));
with TFileListBox(AddChild(TFileListBox.Create(@Menu_Proc, FLB_MAP))) do
begin
Items[1, 0] := 'Select map file';
HAlign := ahLeft;
X := 25;
Y := 60;
Width := 320;
Height := 276;
Ext := '*.tm';
StartDir := ExtractFileDir(paramstr(0)) + '\' + Engine_ModDir + 'maps\';
ActiveWindow := WND_MULTICREATE;
Dir := StartDir;
ActiveWindow := nil;
end;
AddChild(TTexLabel.Create(nil, 0, 'multiplayer'));
def_x:=400;def_cx:=0;
def_y:=200;def_cy:=20;
AddChild(TLabel.Create(nil, 0, '^2Game properties') );
def_x:=350;def_y:=230;
with AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @sv_name, 'Server name', 'sv_name', VT_STRING)) as TEdit do
begin
Tab := 14;
MaxLength := 24;
end;
TEdit( AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @timelimit, 'Timelimit', 'timelimit', VT_WORD)) ).Tab:=14;
TEdit( AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @fraglimit, 'Fraglimit', 'fraglimit', VT_WORD)) ).Tab:=14;
TEdit( AddChild(TEdit.Create(@Menu_Proc, EDIT_STRING, @forcerespawn, 'Forcerespawn', 'forcerespawn', VT_WORD)) ).Tab:=14;
with TYesNoEdit( AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO, @p2disable, 'player 2', 'p2disable')) ) do
begin
tab:=14;
Str_Yes:='Disabled';
Str_No:='Active';
end;
TEnumEdit(
AddChild(TEnumEdit.Create(@Menu_Proc, EDIT_YESNO, @gametype_c,
4, [GT_FFA, GT_TRIX, GT_RAIL, GT_TDM], ['Free For All', 'Trix', 'Rail Arena', 'Team DeathMatch'], ['FFA', 'TRIX', 'RAIL', 'TDM'],
'Game Type', 'gametype')) ).Tab:=14;
Update;
end;
WND_SETUP := AddWindow(TMyWindow.Create);
with WND_SETUP do
begin
AddChild(TTexLabel.Create(nil, 0, 'setup'));
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
AddChild(TButton.Create(@Menu_Proc, BTN_PLAYER1, 'player1')).Y := 167;
AddChild(TButton.Create(@Menu_Proc, BTN_PLAYER2, 'player2')).Y := 200;
AddChild(TButton.Create(@Menu_Proc, BTN_DISPLAY, 'display')).Y := 233;
AddChild(TButton.Create(@Menu_Proc, BTN_SOUND, 'sound')).Y := 266;
Update;
end;
WND_DISPLAY := AddWindow(TMyWindow.Create);
with WND_DISPLAY do
begin
AddChild(TTexLabel.Create(nil, 0, 'display'));
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
def_x:=64; def_y:=96; def_cx:=0; def_cy:=20;
AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO, Console_GetVar('vsync'), 'VSync', 'vsync'));
AddChild(TEnumStrEdit.Create('Dysplay mode', @dis_mode, DIS__MODE));
AddChild(TEnumStrEdit.Create('Color depth', @dis_bpp, DIS__BPP));
AddChild(TEnumStrEdit.Create('Frequency', @dis_freq, DIS__FREQ));
AddChild(TGraphButton.Create(@Menu_Proc, BTN_ACCEPT, 'accept')).HAlign := ahRight;
Update;
end;
WND_SOUND:=AddWindow(TMyWindow.Create);
with WND_SOUND do
begin
AddChild(TTexLabel.Create(nil, 0, 'sound'));
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
def_x:=64; def_y:=96; def_cx:=0; def_cy:=20;
with AddChild(TYesNoEdit.Create(@Menu_Proc, EDIT_YESNO,
@sound_off, 'sound', 'sound_off')) as TYesNoEdit do
begin
str_Yes:='Off';
str_No:='On';
end;
Update;
end;
WND_PLAYER1 := Menu_PlayerCreate(1);
WND_PLAYER2 := Menu_PlayerCreate(2);
WND_DEMOS := AddWindow(TMyWindow.Create);
with WND_DEMOS do
begin
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
AddChild(TGraphButton.Create(@Menu_Proc, BTN_PLAY, 'play')).HAlign := ahRight;
with TFileListBox(AddChild(TFileListBox.Create(@Menu_Proc, FLB_DEMO))) do
begin
Items[1, 0] := 'Select demo file';
HAlign := ahCenter;
Y := 60;
Width := 500;
Height := 320;
Ext := '*.tdm';
StartDir := ExtractFileDir(paramstr(0)) + '\' + Engine_ModDir + 'demos\';
Dir := StartDir;
end;
AddChild(TTexLabel.Create(nil, 0, 'demos'));
Update;
end;
WND_MODS := AddWindow(TMyWindow.Create);
with WND_MODS do
begin
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).HAlign := ahLeft;
AddChild(TGraphButton.Create(@Menu_Proc, BTN_LOAD, 'load')).HAlign := ahRight;
with TListBox(AddChild(TListBox.Create(@Menu_Proc, FLB_MODS))) do
begin
HAlign := ahCenter;
Y := 60;
Width := 500;
Height := 320;
SetSize(2, 1);
Items[0, 0] := 'Mod';
Items[1, 0] := 'Folder';
for i := 0 to Engine_ModCount - 1 do
begin
Engine_GetMod(i, ModData);
j := items.AddRow;
items[0, j] := ModData.Name;
items[1, j] := ModData.Path;
end;
Index := 0;
end;
AddChild(TTexLabel.Create(nil, 0, 'mods'));
Update;
end;
WND_MP_INTERNET:= AddWindow(TMyWindow.Create);
with WND_MP_INTERNET do
begin
MP_lb:=TListBox.Create(@Menu_Proc, LB_SERVERS);
AddChild(MP_lb);
with MP_lb do
begin
HAlign := ahCenter;
Y := 60;
Width := 600;
Height := 300;
SetSize(6, 1);
Items[0, 0] := 'Hostname';
Items.colwidth[0] := 15;
Items[1, 0] := 'Map';
Items.colwidth[1] := 15;
Items[2, 0] := 'Load';
Items.colwidth[2] := 6;
Items[3, 0] := 'IP Port';
Items.colwidth[3] := 21;
Items[4, 0] := 'Ping';
Items.colwidth[4] := 4;
Items[5, 0] := 'Reason';
Items.colwidth[5] := 6;
end;
AddChild(TTexLabel.Create(nil, 0, 'multiplayer'));
AddChild(TGraphButton.Create(@Menu_Proc, BTN_BACK, 'back')).X := 0;
AddChild(TGraphButton.Create(@Menu_Proc, 0, 'specify')).X := 128;
RefBtn := AddChild(TGraphButton.Create(@Menu_Proc, BTN_REFRESH, 'refresh'));
RefBtn.X := 256;
AddChild(TGraphButton.Create(@Menu_Proc, BTN_MULTICREATE, 'create')).X := 384;
AddChild(TGraphButton.Create(@Menu_Proc, BTN_CONNECT, 'fight')).X := 512;
RefLabel := AddChild(TLabel.Create(nil, 0, 'hit refresh to update')) as TLabel;
with RefLabel do
begin
Halign := ahCenter;
Y := 380;
end;
def_x := 150; def_y := 320;
def_cx:= 150; def_cy := 0;
// AddChild(TLabel.Create(@Menu_Proc, BTN_REFRESH, 'Refresh')).Enabled:=true;
// AddChild(TLabel.Create(@Menu_Proc, BTN_SEARCH, 'Search')).Enabled:=true;
// AddChild(TLabel.Create(@Menu_Proc, BTN_CONNECT, 'Connect')).Enabled:=true;
// AddChild(TButton.Create(@Menu_Proc, BTN_REMOVESERV, '^6Remove'));
def_x := 200; def_y := 364;
def_cx := 250;
IPEdit:=AddChild(TEdit.Create(@Menu_Proc, EDIT_IP, nil, 'Choose IP', '', VT_STRING)) as TEdit;
IPEdit.MaxLength:=21;
IPEdit.Tab:=10;
AddChild(TLabel.Create(@Menu_Proc, BTN_ADDIP, 'Add')).Enabled:=true;
// AddChild(TButton.Create(@Menu_Proc, BTN_REMOVE));
end;
ActiveWindow := WND_MAIN;
end;
procedure Menu_Free;
begin
// XProger: Íðàâèòñÿ ìíå íàçâàíèå ýòîé ïðîöåäóðêè :)))
ModelName := nil;
SayEdit.Free;
DestroyWindows;
end;
procedure CalcMenuBG;
var
idx : Byte;
r, g : WORD;
procedure pix(x, y: integer);
begin
if (x > -1) and (x < MenuBG_X) and
(y > -1) and (y < MenuBG_Y) then
begin
r := r + MenuBG[y*MenuBG_X + x].R;
g := g + MenuBG[y*MenuBG_X + x].G;
end
else
dec(idx);
end;
var
x, y : integer;
i : integer;
MBG : PaRGB;
begin
GetMem(MBG, MenuBG_X * MenuBG_Y * 3);
for x := 1 to MenuBG_X do
begin
y := random(MenuBG_X);
i := (MenuBG_Y - 1) * MenuBG_X + y;
case random(4) of
0 : begin
MenuBG[i].R := 255;
MenuBG[i].G := 0;
end;
1 : begin
MenuBG[i].R := 255;
MenuBG[i].G := 255;
end;
else
begin
MenuBG[i].R := 0;
MenuBG[i].G := 0;
end;
end
end;
for y := 0 to MenuBG_Y - 1 do
for x := 0 to MenuBG_X - 1 do
begin
idx := 5;
r := 0;
g := 0;
pix(x, y + 1);
pix(x - 1, y);
pix(x + 1, y);
pix(x - 1, y + 1);
pix(x + 1, y + 1);
i := y*MenuBG_X + x;
MBG[i].R := r div idx;
MBG[i].G := g div idx;
MBG[i].B := 0;
end;
FreeMem(MenuBG);
MenuBG := MBG;
xglTex_Free(@MenuTex);
MenuTex.Data := PByteArray(MenuBG);
MenuTex.Width := MenuBG_X;
MenuTex.Height := MenuBG_Y;
MenuTex.BPP := 24;
MenuTex.Trans := false;
MenuTex.Filter := true;
MenuTex.MipMap := false;
MenuTex.Scale := false;
MenuTex.Clamp := true;
xglTex_Create(@MenuTex);
end;
procedure Menu_Update;
begin
if menu_fx {and not isGame }then
CalcMenuBG;
{
if sound_off = 0 then
snd_SetGlobalPos(Point2f(0, 0));
}
inc(MousePos.X, Input_MouseDelta.X);
inc(MousePos.Y, Input_MouseDelta.Y);
if MousePos.X < 0 then MousePos.X := 0;
if MousePos.Y < 0 then MousePos.Y := 0;
if MousePos.X > 640 then MousePos.X := 640;
if MousePos.Y > 480 then MousePos.Y := 480;
MouseTex.Update;
RefBtn.Enabled := not Arena_Refresh;
if Arena_Refresh then
RefLabel.Text := 'Scanning For Servers.'
else
RefLabel.Text := 'hit refresh to update';
ActiveWindow.Update;
end;
procedure Menu_Draw;
begin
// Set Viewport
glViewport(0, 0, xglWidth, xglHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
gluOrtho2D(0, 640, 480, 0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
if menu_fx {and not isGame} then
begin
xglTex_Enable(@MenuTex);
glColor4f(1, 1, 1, 1);
glBegin(GL_QUADS);
glTexCoord2f(0, 0.9); glVertex2f(0, 480);
glTexCoord2f(0, 0); glVertex2f(0, 0);
glTexCoord2f(1, 0); glVertex2f(640, 0);
glTexCoord2f(1, 0.9); glVertex2f(640, 480);
glEnd;
end;
ActiveWindow.Draw;
// Draw mouse cursor
xglAlphaBlend(1);
glColor4f(1, 1, 1, 1);
xglTex_Enable(MouseTex.CurFrame);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex2f(MousePos.X - 16, MousePos.Y - 16);
glTexCoord2f(1, 1); glVertex2f(MousePos.X + 16, MousePos.Y - 16);
glTexCoord2f(1, 0); glVertex2f(MousePos.X + 16, MousePos.Y + 16);
glTexCoord2f(0, 0); glVertex2f(MousePos.X - 16, MousePos.Y + 16);
glEnd;
end;
procedure Menu_Message(Msg: DWORD; wParam: Longint; lParam: LongInt);
var
M : TMessage;
begin
if (not Console.Show) and (ActiveWindow <> nil) then
begin
M.Msg := Msg;
M.wParam := wParam;
M.lParam := lParam;
if Msg = WM_KEYDOWN then
if wParam = 255 then
Exit;
ActiveWindow.onMessage(M);
end;
end;
procedure Menu_Proc(ID : integer; Param : integer);
var
s : string;
begin
case ID of
BTN_FIGHT:
with TFileListBox(activewindow.Childs[3]) do
if Items[0, Index] = 'F' then
begin
s := Dir;
Delete(s, 1, Length(StartDir));
s := 'maps\' + s + Items[1, Index] + '.tm';
inMenu := not LoadMap(s, false, 2-ord(activewindow=WND_HOTSEAT));
end;
BTN_PLAY:
with TFileListBox(WND_DEMOS.Childs[2]) do
if Items[0, Index] = 'F' then
begin
s := Dir;
Delete(s, 1, Length(StartDir));
s := 'demos\' + s + Items[1, Index] + '.tdm';
inMenu := not LoadMap(s, false);
end;
BTN_LOAD:
Engine_ChangeModQuery(TListBox(WND_MODS.Childs[2]).Index - 1);
BTN_BACK:
CallBack;
BTN_HOTSEAT:
CallWindow(WND_HOTSEAT);
BTN_SETUP:
CallWindow(WND_SETUP);
BTN_DEMOS:
CallWindow(WND_DEMOS);
BTN_MODS:
CallWindow(WND_MODS);
BTN_MULTI:
begin
CallWindow(WND_MP_INTERNET);
Menu_RefreshServers; // XProger: ñðàçó èùåì ñåðâàêè
end;
BTN_MULTICREATE:
CallWindow(WND_MULTICREATE);
BTN_EXIT:
begin
Engine_Quit;
if sound_off=0 then
snd_Play(MenuSnd_3, false, 0, 0, true);
end;
EDIT_NAME :
begin
if ActiveWindow = WND_Player1 then
Console_Cmd('name ' + PChar(Param))
else Console_Cmd('p2name ' + PChar(Param))
end;
BTN_PLAYER1:
begin
CallWindow(WND_PLAYER1);
Menu_SetModel(1);
end;
BTN_PLAYER2:
begin
CallWindow(WND_PLAYER2);
Menu_SetModel(2);
end;
BTN_DISPLAY:
CallWindow(WND_DISPLAY);
BTN_SOUND:
CallWindow(WND_SOUND);
BTN_RESTART:
Console_Cmd('restart');
BTN_ACCEPT :
begin
s := DIS__MODE[dis_mode];
s[pos('x', s)] := ' ';
Console_Cmd('display ' + s + ' ' + DIS__BPP[dis_bpp] + ' ' + DIS__FREQ[dis_freq]);
end;
BTN_LEAVEARENA:
begin
Map.ClearAll;
CallMainMenu;
end;
BTN_REFRESH:
Menu_RefreshServers;
// BTN_SEARCH:
// Console_CMD('net_search');
BTN_CONNECT:
if MP_lb.index>=0 then
Console_CMD('net_connect '+MP_lb.Items[3, MP_lb.index]);
BTN_ADDIP:
Menu_AddIP(IPEdit.Text);
FLB_MAP :
if (activewindow=WND_HOTSEAT) or
(activewindow=WND_MULTICREATE) and (WND_MULTICREATE<>nil) then
with activewindow do
begin
Childs[1].Enabled := (Param > 0) and (TFileListBox(Childs[3]).Items[0, Param] = 'F');
if Childs[1].Enabled then
TLevelShot(Childs[2]).LoadShot(TFileListBox(Childs[3]).Items[1, Param]);
end;
FLB_DEMO :
with WND_DEMOS do
Childs[1].Enabled := (Param > 0) and (TFileListBox(Childs[2]).Items[0, Param] = 'F');
FLB_MODS :
with WND_MODS do
Childs[1].Enabled := (Param > 0) and (Engine_CurMod <> Param - 1);
LB_MODELS :
if ActiveWindow <> nil then
with ActiveWindow do
if (Param > 0) and (ChildCount > 8) then
begin
s := TListBox(Childs[0]).items[0, Param];
TListBox(Childs[1]).index := 0;
end;
LB_SKINS :
if ActiveWindow <> nil then
with ActiveWindow do
if (Param > 0) and (ChildCount > 8) then
with TListBox(Childs[0]) do
begin
s := items[0, index] + '+' +
TListBox(Childs[1]).items[0, Param];
TModelViewer(Childs[2]).SetModel(s);
Log_ConWrite(false);
if ActiveWindow = WND_PLAYER1 then
Console_Cmd('model ' + s)
else
Console_Cmd('p2model ' + s);
Log_ConWrite(true);
end;
end;
end;
procedure Menu_AddServer(IP: string; Port: word; HostName, MapName: string;