This repository has been archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmSoldatMapEditor.pas
15751 lines (15356 loc) · 760 KB
/
frmSoldatMapEditor.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 frmSoldatMapEditor;
// DISCLAIMER!
// ==================================================================
// This source code has been automatically generated.
// It still requires extensive manual fixing, debugging and testing.
// IT IS NOT GUARANTEED TO COMPILE
// AND MUCH LESS TO BEHAVE EXACTLY LIKE THE ORIGINAL SOURCE CODE.
// Use it at your sole risk and discretion.
//
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ExtCtrls, ComCtrls, Direct3D8, DirectInput, D3DX8;
const
BufferSize: Longint = 10;
ColourKey: Longint = $FF00FF00;
FVF: Longint = 0;// = D3DFVF_XYZRHW or D3DFVF_TEX1 or D3DFVF_DIFFUSE;
FVF2: Longint = 0; // = D3DFVF_XYZ;
MAX_POLYS: Smallint = 4000;
MAX_ZOOM: Single = 16;
MIN_ZOOM: Single = 0.03125;
TOOL_MOVE: Byte = 0;
TOOL_CREATE: Byte = 1;
TOOL_VSELECT: Byte = 2;
TOOL_PSELECT: Byte = 3;
TOOL_VCOLOUR: Byte = 4;
TOOL_PCOLOUR: Byte = 5;
TOOL_TEXTURE: Byte = 6;
TOOL_SCENERY: Byte = 7;
TOOL_WAYPOINT: Byte = 8;
TOOL_OBJECTS: Byte = 9;
TOOL_CLRPICKER: Byte = 10;
TOOL_SKETCH: Byte = 11;
TOOL_LIGHTS: Byte = 12;
TOOL_DEPTHMAP: Byte = 13;
TOOL_HAND: Byte = 14;
TOOL_VSELADD: Byte = 15;
TOOL_VSELSUB: Byte = 16;
TOOL_PSELADD: Byte = 17;
TOOL_PSELSUB: Byte = 18;
TOOL_SCALE: Byte = 19;
TOOL_ROTATE: Byte = 20;
TOOL_CONNECT: Byte = 21;
TOOL_QUAD: Byte = 22;
TOOL_PIXPICKER: Byte = 23;
TOOL_LITPICKER: Byte = 24;
TOOL_ERASER: Byte = 25;
TOOL_SMUDGE: Byte = 26;
TOOL_NULL: Byte = 255;
KEY_SHIFT: Byte = 1;
KEY_CTRL: Byte = 2;
KEY_ALT: Byte = 4;
type
TfrmSoldatMapEditor = class(TForm)
//commonDialog: MSComDlg.CommonDialog; // TODO: finde replacement
frmSoldatMapEditor: TForm;
ImageList: TImageList; //ImageList: MSComctlLib.ImageList;
lblCurrentTool: TLabel;
lblFileName: TLabel;
lblMousePosition: TLabel;
lblZoom: TLabel;
mnuActualPixels: TMenuItem;
mnuApplyLight: TMenuItem;
mnuArrange: TMenuItem;
mnuAverage: TMenuItem;
mnuBlendPolys: TMenuItem;
mnuBlendWireframe: TMenuItem;
mnuBringForward: TMenuItem;
mnuBringToFront: TMenuItem;
mnuCenterRCenter: TMenuItem;
mnuClear: TMenuItem;
mnuClrSketch: TMenuItem;
mnuCollider: TMenuItem;
mnuCompile: TMenuItem;
mnuCompileAs: TMenuItem;
mnuCopy: TMenuItem;
mnuCreate: TMenuItem;
mnuCustomX: TMenuItem;
mnuCustomY: TMenuItem;
mnuDeselect: TMenuItem;
mnuDisplay: TMenuItem;
mnuDuplicate: TMenuItem;
mnuExit: TMenuItem;
mnuExport: TMenuItem;
mnuFitOnScreen: TMenuItem;
mnuFixedRCenter: TMenuItem;
mnuFixedTexture: TMenuItem;
mnuFixTexture: TMenuItem;
mnuFlip_1: TMenuItem;
mnuFlip_0: TMenuItem;
mnuFlipTexture_1: TMenuItem;
mnuFlipTexture_0: TMenuItem;
mnuGostek: TMenuItem;
mnuGrid: TMenuItem;
mnuHideAll: TMenuItem;
mnuImport: TMenuItem;
mnuInfo: TMenuItem;
mnuInvertSel: TMenuItem;
mnuJoinVertices: TMenuItem;
mnuLoadSpace: TMenuItem;
mnuMap: TMenuItem;
mnuMenu_4: TMenuItem;
mnuMenu_3: TMenuItem;
mnuMenu_2: TMenuItem;
mnuMenu_1: TMenuItem;
mnuMenu_0: TMenuItem;
mnuMove: TMenuItem;
mnuNew: TMenuItem;
mnuObjects: TMenuItem;
mnuOpen: TMenuItem;
mnuOpenCompiled: TMenuItem;
mnuPalette: TMenuItem;
mnuPaste: TMenuItem;
mnuPolyType_25: TMenuItem;
mnuPolyType_24: TMenuItem;
mnuPolyType_23: TMenuItem;
mnuPolyType_22: TMenuItem;
mnuPolyType_21: TMenuItem;
mnuPolyType_20: TMenuItem;
mnuPolyType_19: TMenuItem;
mnuPolyType_18: TMenuItem;
mnuPolyType_17: TMenuItem;
mnuPolyType_16: TMenuItem;
mnuPolyType_15: TMenuItem;
mnuPolyType_14: TMenuItem;
mnuPolyType_13: TMenuItem;
mnuPolyType_12: TMenuItem;
mnuPolyType_11: TMenuItem;
mnuPolyType_10: TMenuItem;
mnuPolyType_9: TMenuItem;
mnuPolyType_8: TMenuItem;
mnuPolyType_7: TMenuItem;
mnuPolyType_6: TMenuItem;
mnuPolyType_5: TMenuItem;
mnuPolyType_4: TMenuItem;
mnuPolyType_3: TMenuItem;
mnuPolyType_2: TMenuItem;
mnuPolyType_1: TMenuItem;
mnuPolyType_0: TMenuItem;
mnuPolyTypes: TMenuItem;
mnuPreferences: TMenuItem;
mnuQuad: TMenuItem;
mnuRecent_9: TMenuItem;
mnuRecent_8: TMenuItem;
mnuRecent_7: TMenuItem;
mnuRecent_6: TMenuItem;
mnuRecent_5: TMenuItem;
mnuRecent_4: TMenuItem;
mnuRecent_3: TMenuItem;
mnuRecent_2: TMenuItem;
mnuRecent_1: TMenuItem;
mnuRecent_0: TMenuItem;
mnuRecentFiles: TMenuItem;
mnuRedo: TMenuItem;
mnuRefreshBG: TMenuItem;
mnuResetView: TMenuItem;
mnuResetWindows: TMenuItem;
mnuRotate_2: TMenuItem;
mnuRotate_1: TMenuItem;
mnuRotate_0: TMenuItem;
mnuRotateTexture_2: TMenuItem;
mnuRotateTexture_1: TMenuItem;
mnuRotateTexture_0: TMenuItem;
mnuRunSoldat: TMenuItem;
mnuSave: TMenuItem;
mnuSaveAs: TMenuItem;
mnuSaveSpace: TMenuItem;
mnuScen: TMenuItem;
mnuScenery: TMenuItem;
mnuScenLevel_2: TMenuItem;
mnuScenLevel_1: TMenuItem;
mnuScenLevel_0: TMenuItem;
mnuScenList: TMenuItem;
mnuScenRemove: TMenuItem;
mnuScenSep: TMenuItem;
mnuScenTrans_1: TMenuItem;
mnuScenTrans_0: TMenuItem;
mnuScenTree: TMenuItem;
mnuSelColour: TMenuItem;
mnuSelectAll: TMenuItem;
mnuSendBackward: TMenuItem;
mnuSendToBack: TMenuItem;
mnuSep1: TMenuItem;
mnuSep10: TMenuItem;
mnuSep11: TMenuItem;
mnuSep12: TMenuItem;
mnuSep13: TMenuItem;
mnuSep14: TMenuItem;
mnuSep15: TMenuItem;
mnuSep16: TMenuItem;
mnuSep17: TMenuItem;
mnuSep18: TMenuItem;
mnuSep19: TMenuItem;
mnuSep2: TMenuItem;
mnuSep20: TMenuItem;
mnuSep21: TMenuItem;
mnuSep3: TMenuItem;
mnuSep30: TMenuItem;
mnuSep31: TMenuItem;
mnuSep32: TMenuItem;
mnuSep5: TMenuItem;
mnuSep6: TMenuItem;
mnuSep8: TMenuItem;
mnuSep9: TMenuItem;
mnuSepObj: TMenuItem;
mnuSepObj2: TMenuItem;
mnuSetRCenter: TMenuItem;
mnuSever: TMenuItem;
mnuShowAll: TMenuItem;
mnuShowSceneryLayer_2: TMenuItem;
mnuShowSceneryLayer_1: TMenuItem;
mnuShowSceneryLayer_0: TMenuItem;
mnuShowSceneryLayers: TMenuItem;
mnuSnapSelected: TMenuItem;
mnuSnapToGrid: TMenuItem;
mnuSnapToVerts: TMenuItem;
mnuSpawn_16: TMenuItem;
mnuSpawn_15: TMenuItem;
mnuSpawn_14: TMenuItem;
mnuSpawn_13: TMenuItem;
mnuSpawn_12: TMenuItem;
mnuSpawn_11: TMenuItem;
mnuSpawn_10: TMenuItem;
mnuSpawn_9: TMenuItem;
mnuSpawn_8: TMenuItem;
mnuSpawn_7: TMenuItem;
mnuSpawn_6: TMenuItem;
mnuSpawn_5: TMenuItem;
mnuSpawn_4: TMenuItem;
mnuSpawn_3: TMenuItem;
mnuSpawn_2: TMenuItem;
mnuSpawn_1: TMenuItem;
mnuSpawn_0: TMenuItem;
mnuSplit: TMenuItem;
mnuTexture: TMenuItem;
mnuTools: TMenuItem;
mnuTransform: TMenuItem;
mnuTransformTexture: TMenuItem;
mnuUndo: TMenuItem;
mnuUntexture: TMenuItem;
mnuVertexSelect: TMenuItem;
mnuVSel0: TMenuItem;
mnuVSelArrange: TMenuItem;
mnuVSelBringForward: TMenuItem;
mnuVSelBringToFront: TMenuItem;
mnuVSelClear: TMenuItem;
mnuVSelCopy: TMenuItem;
mnuVSelDuplicate: TMenuItem;
mnuVSelFlip_1: TMenuItem;
mnuVSelFlip_0: TMenuItem;
mnuVSelPaste: TMenuItem;
mnuVSelRotate_2: TMenuItem;
mnuVSelRotate_1: TMenuItem;
mnuVSelRotate_0: TMenuItem;
mnuVSelSendBackward: TMenuItem;
mnuVSelSendToBack: TMenuItem;
mnuVSelSep1: TMenuItem;
mnuVSelTransform: TMenuItem;
mnuWaypoint: TMenuItem;
mnuWaypoints: TMenuItem;
mnuWayType_4: TMenuItem;
mnuWayType_3: TMenuItem;
mnuWayType_2: TMenuItem;
mnuWayType_1: TMenuItem;
mnuWayType_0: TMenuItem;
mnuWorkspace: TMenuItem;
mnuZoomIn: TMenuItem;
mnuZoomOut: TMenuItem;
//MouseHelper: MBMouseHelper.MouseHelper; // TODO: find replacement
picButtonGfx: TPaintBox;
picExit: TPaintBox;
picGfx: TPaintBox;
picHelp: TPaintBox;
picMaximize: TPaintBox;
picMenu_0: TPaintBox;
picMenu_3: TPaintBox;
picMenu_1: TPaintBox;
picMenu_2: TPaintBox;
picMenu_4: TPaintBox;
picMenuBar: TPaintBox;
picMinimize: TPaintBox;
picProgress: TPaintBox;
picStatus: TPaintBox;
picTitle: TPaintBox;
tvwScenery: TTreeView; //MSComctlLib.TreeView;
txtZoom: TEdit;
private
DX: DirectX8; // TODO: replace
D3D: Direct3D8; // TODO: replace
D3DDevice: Direct3DDevice8;
DI: DirectInput8;
DIDevice: DirectInputDevice8;
DIState: DIKEYBOARDSTATE;
hEvent: Longint;
D3DX: D3DX8;
mapTexture: Direct3DTexture8;
particleTexture: Direct3DTexture8;
patternTexture: Direct3DTexture8;
objectsTexture: Direct3DTexture8;
lineTexture: Direct3DTexture8;
pathTexture: Direct3DTexture8;
rCenterTexture: Direct3DTexture8;
sketchTexture: Direct3DTexture8;
renderTarget: Direct3DTexture8;
renderSurface: Direct3DSurface8;
backBuffer: Direct3DSurface8;
scenerySprite: D3DXSprite;
//--------
Version: Longint;
Polys: array of TPolygon;
PolyCoords: array of TTriangle;
Scenery: array of TScenery;
SceneryTextures: array of TextureData;
Spawns: array of TSpawnPoint;
Colliders: array of TCollider;
Waypoints: array of TWaypoint;
Connections: array of TConnection;
Lights: array of TLightSource;
Options: TOptions;
polyCount: Longint;
sceneryCount: Longint;
sceneryElements: Longint;
spawnPoints: Longint;
colliderCount: Longint;
waypointCount: Longint;
conCount: Smallint;
lightCount: Smallint;
fmapTitle: widestring;
ftextureFile: widestring;
maxX: Single;
maxY: Single;
minX: Single;
minY: Single;
bgPolys: array[1..4] of TCustomVertex;
bgPolyCoords: array[1..4] of D3DVECTOR2;
bgColours: array[1..2] of TColour;
//--------
sketch: array of TSketchLine;
sketchLines: Smallint;
selectedSketch: array[1..2] of Smallint;
circleOn: Boolean;
leftMouseDown: Boolean;
initialized: Boolean;
initialized2: Boolean;
acquired: Boolean;
selectionChanged: Boolean;
clrPolys: Boolean;
clrWireframe: Boolean;
sslBack: Boolean;
sslMid: Boolean;
sslFront: Boolean;
fbackClr: Longint;
fpointClr: Longint;
fselectionClr: Longint;
fgridClr: Longint;
fgridClr2: Longint;
fpolyBlendSrc: Longint;
fpolyBlendDest: Longint;
fwireBlendSrc: Longint;
fwireBlendDest: Longint;
fsoldatDir: widestring;
funcompDir: widestring;
fprefabDir: widestring;
fgridSpacing: Smallint;
fgridDivisions: Smallint;
fgridOp1: Byte;
fgridOp2: Byte;
noRedraw: Boolean;
fsceneryVerts: Boolean;
ftopmost: Boolean;
fformHeight: Smallint;
fformWidth: Smallint;
fformLeft: Smallint;
fformTop: Smallint;
polyClr: TColour;
opacity: Single;
blendMode: Smallint;
scrollCoords: array[1..2] of D3DVECTOR2; //coordinates for scrolling
mouseCoords: D3DVECTOR2; //coordinates of mouse
moveCoords: array[1..2] of D3DVECTOR2; //coordinates for moving vertices
selectedCoords: array[1..2] of D3DVECTOR2; //coordinates of selected area
selectedPolys: TSmallIntDynArray; //list of selected polys and verts
vertexList: array of TVertexData; //list of polys with selected verts
numVerts: Smallint; //number of current vertex being created
numCorners: Smallint; //number of corner of scenery being created
numSelectedPolys: Smallint;
numSelectedScenery: Smallint; //number of currently selected scenery
numSelColliders: Smallint;
numSelSpawns: Smallint;
numSelWaypoints: Smallint;
numSelLights: Smallint;
fxTexture: Smallint;
fyTexture: Smallint;
creatingQuad: Boolean;
currentFileName: widestring;
prompt: Boolean;
toolAction: Boolean;
spaceDown: Boolean;
currentScenery: widestring;
zoomFactor: Single;
pointRadius: Smallint;
snapRadius: Smallint;
clrRadius: Smallint;
ohSnap: Boolean;
snapToGrid: Boolean;
fixedTexture: Boolean;
showBG: Boolean;
showPolys: Boolean;
showTexture: Boolean;
showWireframe: Boolean;
showPoints: Boolean;
showScenery: Boolean;
showObjects: Boolean;
showGrid: Boolean;
showWaypoints: Boolean;
showPath1: Boolean;
showPath2: Boolean;
showSketch: Boolean;
showLights: Boolean;
currentTool: Byte;
currentFunction: Byte;
particleSize: Single;
colourMode: Byte;
eraseCircle: Boolean;
eraseLines: Boolean;
polyType: Byte;
PolyTypeClrs: array[0..25] of Longint;
fshiftDown: Boolean;
fctrlDown: Boolean;
faltDown: Boolean;
rCenter: D3DVECTOR2;
selRect: array[0..3] of D3DVECTOR2; // RECT
xGridLines: array of TLine;
yGridLines: array of TLine;
inc: Single;
scaleDiff: D3DVECTOR2;
rDiff: Single;
gostek: D3DVECTOR2;
imageInfo: TImageInfo;
textureDesc: D3DSURFACE_DESC;
noneSelected: Boolean;
currentUndo: Smallint;
numUndo: Smallint;
numRedo: Smallint;
max_undo: Smallint;
lastCompiled: widestring;
currentWaypoint: Smallint;
objTexSize: D3DVECTOR2;
procedure Form_Load;
procedure SetCursor(var Index: Smallint);
procedure centerView;
procedure InitDInput;
function checkLoaded(var sceneryName: widestring): Smallint;
function getMapDimensions: widestring;
function getMapArea: Longint;
procedure SaveFile(var FileName: widestring);
procedure SaveUndo;
procedure loadUndo(var redo: Boolean);
function isInSector(var Index: Smallint; var X: Smallint; var Y: Smallint; div: Longint): Boolean;
function isInSector2(var Index: Smallint; var X: Smallint; var Y: Smallint; var div: Longint): Smallint;
function SegXHorizSeg(var A1: D3DVECTOR2; var B1: D3DVECTOR2; var A2: D3DVECTOR2; var length: Longint): Boolean;
function SegXVertSeg(var A1: D3DVECTOR2; var B1: D3DVECTOR2; var A2: D3DVECTOR2; var length: Longint): Boolean;
function segmentsIntersect(x1: Smallint; y1: Smallint; x2: Smallint; y2: Smallint; A1: Smallint; B1: Smallint; A2: Smallint; B2: Smallint): Boolean;
function SegXSeg(var A1: D3DVECTOR2; var B1: D3DVECTOR2; var A2: D3DVECTOR2; var B2: D3DVECTOR2): Boolean;
function isBetween(var p1: olevariant; var p2: olevariant; var p3: olevariant): Boolean;
procedure initGrid;
procedure setGrid;
function CreateCustomVertex(X: Single; Y: Single; var z: Single; var rhw: Single; var Color: Longint; var tu: Single; var tv: Single): TCustomVertex;
function ExModeActive: Boolean;
function getRGB(var DecValue: Longint): TColour;
function getAlpha(var tehColour: Longint): Byte;
function ARGB(alphaVal: Byte; var clrVal: Longint): Longint;
function makeColour(var red: Byte; var green: Byte; var blue: Byte): TColour;
procedure DirectXEvent8_DXCallback(eventid: Longint);
procedure TabPressed;
procedure findDragPoint(var X: Single; var Y: Single);
procedure findDragPoint2(var X: Single; var Y: Single);
function checkDragPoint(var x1: Single; var y1: Single; var x2: Single; var y2: Single): Boolean;
procedure Form_DblClick;
procedure Form_MouseDown(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure CreateLight(var X: Single; var Y: Single);
procedure applyLights(var toSel: Boolean{ = false});
procedure applyLightsToVert(var pIndex: Smallint; var vIndex: Smallint);
procedure SnapSelection;
function GetVertSnapCoord(var PolyNum: Smallint; var VertNum: Smallint; var GetXVal: Boolean): Smallint;
procedure AverageVerts;
procedure AverageVertices;
procedure MouseDownMove(var X: Single; var Y: Single);
procedure SelNearest(var X: Single; var Y: Single);
procedure CreatingPoly(var Shift: Smallint; var X: Single; var Y: Single);
procedure Form_MouseMove(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure CreatingScenery(var Shift: Smallint; var X: Single; var Y: Single);
function ConstrainAngle(var xDiff: Smallint; var yDiff: Smallint): D3DVECTOR2;
procedure Scrolling(var X: Single; var Y: Single);
procedure Moving(X: Single; Y: Single);
procedure Scaling(X: Single; Y: Single; var constrained: Boolean);
procedure ApplyTransform(var Rotating: Boolean);
function GetAngle(xVal: Single; yVal: Single): Single;
procedure Rotating(var X: Single; var Y: Single; var constrained: Boolean);
procedure PrecisionColouring(var X: Single; var Y: Single);
procedure VertexColouring(var X: Single; var Y: Single);
procedure EditDepthMap(var X: Single; var Y: Single);
procedure ColourPicker(var X: Single; var Y: Single);
procedure depthPicker(var X: Single; var Y: Single);
procedure lightPicker(var X: Single; var Y: Single);
procedure StretchingTexture(var X: Single; var Y: Single);
procedure Form_MouseUp(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure CreateConnection(var X: Single; var Y: Single);
procedure CreatePolys(var X: Single; var Y: Single);
procedure startSketch(var X: Single; var Y: Single);
procedure lineSketch(var X: Single; var Y: Single);
procedure linkSketch(var X: Single; var Y: Single);
procedure endSketch(var X: Single; var Y: Single);
procedure CreateScenery(var X: Single; var Y: Single);
procedure snapSelected(var X: Single; var Y: Single);
procedure regionSelection(var X: Single; var Y: Single);
function RegionSelPolys(var X: Single; var Y: Single): Boolean;
function RegionSelObjects(var xVal: Single; var yVal: Single; var skipSel: Boolean): Boolean;
function regionSelLights(var xVal: Single; var yVal: Single; var skipSel: Boolean): Boolean;
function RegionSelWaypoints(var xVal: Single; var yVal: Single; var skipSel: Boolean): Boolean;
function eraseSketch(var X: Single; var Y: Single): Byte;
function moveLines(var X: Single; var Y: Single; var xDiff: Single; var yDiff: Single): Byte;
procedure deleteSmallLines;
procedure VertexSelection(var X: Single; var Y: Single);
procedure VertexSelPolys;
procedure VertexSelScenery;
procedure VertexSelObjects;
procedure VertexSelLights;
procedure VertexSelWaypoints;
procedure getRCenter;
procedure compareRect(xVal: Smallint; yVal: Smallint);
procedure vertexSelAlt(var X: Single; var Y: Single);
procedure polySelection(var X: Single; var Y: Single);
function PointInProp(X: Single; Y: Single; var Index: Smallint): Boolean;
procedure ColourFill(var X: Single; var Y: Single);
function applyBlend(var dClr: TColour): TColour;
function diffVal(var val1: Byte; var val2: Byte): Byte;
function lowerVal(var val1: Byte; var val2: Byte): Byte;
function higherVal(var val1: Byte; var val2: Byte): Byte;
function snapVertexToGrid(coord: Single; var offset: Single): Single;
procedure deletePolys;
function nearCoord(mouseCoord: Single; polyCoord: Single; range: Single): Boolean;
function inSelRect(X: Single; Y: Single): Boolean;
procedure mnuClrSketch_Click;
procedure mnuCopy_Click;
procedure mnuVSelBringForward_Click;
procedure mnuVSelBringToFront_Click;
procedure mnuVSelClear_Click;
procedure mnuVSelCopy_Click;
procedure mnuFlip_Click(var Index: Smallint);
procedure mnuFlipTexture_Click(var Index: Smallint);
procedure mnuInvertSel_Click;
procedure mnuPaste_Click;
procedure mnuRecent_Click(var Index: Smallint);
procedure updateRecent(var FileName: widestring);
procedure mnuResetView_Click;
procedure mnuRotate_Click(var Index: Smallint);
procedure mnuRotateTexture_Click(var Index: Smallint);
procedure mnuSetRCenter_Click;
procedure mnuFixedRCenter_Click;
procedure mnuCenterRCenter_Click;
procedure mnuShowSceneryLayer_Click(var Index: Smallint);
procedure mnuSnapSelected_Click;
procedure mnuVSelDuplicate_Click;
procedure mnuVSelFlip_Click(var Index: Smallint);
procedure mnuVSelPaste_Click;
procedure mnuVSelRotate_Click(var Index: Smallint);
procedure mnuVSelSendBackward_Click;
procedure mnuVSelSendToBack_Click;
procedure mnuWayType_Click(var Index: Smallint);
procedure tvwScenery_Expand(Node: MSComctlLib.Node);
procedure tvwScenery_MouseDown(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure mnuScenList_Click;
procedure mnuScenRemove_Click;
function confirmExists(var FileName: widestring): Boolean;
procedure txtZoom_KeyPress(var KeyAscii: Smallint);
procedure txtZoom_LostFocus;
function getZoomDir(var zoomDir: Single): Single;
function pointInPoly(X: Single; Y: Single; i: Smallint): Boolean;
function isCW(i: Smallint): Boolean;
function Midpoint(p1: Single; p2: Single): Single;
procedure setLightsMode(var lightsOn: Boolean);
procedure Form_OLEDragDrop(var Data: DataObject; var Effect: Longint; var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure Form_Resize;
procedure MouseHelper_MouseWheel(var ctrl: olevariant; var Direction: MBMouseHelper.mbDirectionConstants; var Button: Longint; var Shift: Longint; var Cancel: Boolean);
procedure saveSettings;
procedure saveWindow(var sectionName: widestring; var window: TForm; var collapsed: Boolean; var FileName: widestring{ = 'current.ini'});
function SetIdePath: olevariant;
procedure loadINI;
function getNextValue(var sectionString: widestring; var eIndex: Smallint): widestring;
procedure loadWorkspace(var FileName: widestring{ = 'current.ini'});
procedure mnuExit_Click;
procedure mnuNew_Click;
procedure mnuOpen_Click;
procedure mnuOpenCompiled_Click;
procedure mnuSave_Click;
procedure mnuSaveAs_Click;
procedure mnuCompile_Click;
procedure mnuCompileAs_Click;
function recentFiles(var FileName: widestring): Boolean;
procedure mnuExport_Click;
procedure mnuImport_Click;
procedure savePrefab(var FileName: widestring);
procedure loadPrefab(var FileName: widestring);
procedure mnuRunSoldat_Click;
procedure SetMapList(var FileName: widestring);
procedure mnuUndo_Click;
procedure mnuRedo_Click;
procedure mnuDuplicate_Click;
procedure mnuClear_Click;
procedure mnuSelectAll_Click;
procedure mnuDeselect_Click;
procedure mnuSelColour_Click;
procedure mnuBringToFront_Click;
procedure mnuSendToBack_Click;
procedure mnuBringForward_Click;
procedure mnuSendBackward_Click;
procedure mnuFixTexture_Click;
procedure mnuUntexture_Click;
procedure mnuVisible_Click;
procedure mnuAverage_Click;
procedure mnuApplyLight_Click;
procedure mnuSplit_Click;
procedure mnuJoinVertices_Click;
procedure mnuCreate_Click;
procedure mnuSever_Click;
procedure mnuRefreshBG_Click;
procedure mnuPreferences_Click;
procedure mnuMap_Click;
procedure mnuZoomIn_Click;
procedure mnuZoomOut_Click;
procedure mnuGrid_Click;
procedure mnuSnapToGrid_Click;
procedure mnuRefresh_Click;
procedure mnuTools_Click;
procedure mnuDisplay_Click;
procedure mnuPalette_Click;
procedure mnuWaypoints_Click;
procedure mnuScenery_Click;
procedure mnuinfo_Click;
procedure mnuTexture_Click;
procedure mnuBlendWireframe_Click;
procedure mnuBlendPolys_Click;
procedure mnuFixedTexture_Click;
procedure mnuSnapToVerts_Click;
procedure mnuLoadSpace_Click;
procedure mnuSaveSpace_Click;
procedure mnuResetWindows_Click;
procedure mnuShowAll_Click;
procedure mnuHideAll_Click;
procedure mnuGostek_Click;
procedure mnuCollider_Click;
procedure mnuSpawn_Click(var Index: Smallint);
procedure mnuPolyType_Click(var Index: Smallint);
procedure mnuQuad_Click;
procedure mnuCustomX_Click;
procedure mnuCustomY_Click;
procedure mnuFitOnScreen_Click;
procedure mnuActualPixels_Click;
procedure mnuScenTrans_Click(var Index: Smallint);
procedure picMenu_MouseDown(var Index: Smallint; var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picMenu_MouseMove(var Index: Smallint; var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picHelp_MouseDown(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picHelp_MouseMove(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picHelp_MouseUp(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picMaximize_MouseDown(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picMaximize_MouseMove(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picMaximize_MouseUp(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picMinimize_MouseDown(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picMinimize_MouseMove(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picExit_MouseDown(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picExit_MouseMove(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picExit_MouseUp(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure picStatus_Click;
procedure picTitle_DblClick;
procedure picTitle_MouseDown(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
procedure AutoTexture;
procedure SetTextureCoords(var X: Single; var Y: Single; var z: Single; var tu: Single; var tv: Single);
public
procedure loadCursors;
procedure initGfx;
procedure Init;
procedure resetDevice;
procedure RegainFocus;
procedure newMap;
procedure LoadFile(var FileName: widestring);
procedure setMapData;
procedure setCurrentScenery(var styleVal: Smallint{ = -1}; var sceneryName: widestring{ = ''});
procedure setCurrentTexture(var sceneryName: widestring);
procedure setSceneryLevel(level: Byte);
procedure CreateSceneryTexture(var sceneryName: widestring);
procedure RefreshSceneryTextures(var Index: Smallint);
procedure SaveAndCompile(var FileName: widestring);
procedure Render;
function FtoDW(var f: Single): Longint;
procedure applyScale(var tehXvalue: Single; var tehYvalue: Single);
procedure applyRotate(var tehValue: Single);
procedure tvwScenery_NodeClick(Node: MSComctlLib.Node);
procedure Zoom(var zoomDir: Single);
procedure zoomScroll(var zoomDir: Single; X: Smallint; Y: Smallint);
procedure setDispOptions(var layerNum: Smallint; var value: Boolean);
procedure setColourMode(clrVal: Byte);
procedure setCurrentTool(Index: Smallint);
function setTempTool(var toolNum: Byte): Byte;
procedure setMapTexture(var texturePath: widestring);
procedure setPolyColour(var Index: Smallint; var value: Byte);
procedure setPaletteColour(var red: Byte; var green: Byte; var blue: Byte);
procedure setBlendMode(var Index: Smallint);
function getColour: Longint;
procedure getOptions;
procedure setOptions;
procedure Form_Paint;
procedure Terminate;
procedure setPreferences;
function setBGColour(var Index: Smallint): Longint;
procedure setLightColour;
procedure setRadius(var R: Smallint);
function setWayType(var Index: Smallint; var tehValue: Boolean): Boolean;
procedure setPathNum(var tehValue: Byte);
function setSpecial(var tehValue: Byte): Boolean;
procedure setShowPaths;
procedure ClearUnused;
procedure loadColours;
procedure getInfo;
procedure applyPolyType(Index: Smallint);
procedure applyTextureCoords(tehValue: Single; var Index: Smallint);
procedure applyVertexAlpha(var tehValue: Single);
procedure applyBounciness(var tehValue: Single);
procedure applySceneryProp(tehValue: Single; var Index: Smallint);
procedure applyLightProp(tehValue: Single; var Index: Smallint);
procedure SetColours;
procedure picMinimize_MouseUp(var Button: Smallint; var Shift: Smallint; var X: Single; var Y: Single);
property mapTitle: widestring read fmapTitle write fmapTitle;
property textureFile: widestring read ftextureFile write ftextureFile;
property backClr: Longint read fbackClr write fbackClr;
property pointClr: Longint read fpointClr write fpointClr;
property selectionClr: Longint read fselectionClr write fselectionClr;
property gridClr: Longint read fgridClr write fgridClr;
property gridClr2: Longint read fgridClr2 write fgridClr2;
property polyBlendSrc: Longint read fpolyBlendSrc write fpolyBlendSrc;
property polyBlendDest: Longint read fpolyBlendDest write fpolyBlendDest;
property wireBlendSrc: Longint read fwireBlendSrc write fwireBlendSrc;
property wireBlendDest: Longint read fwireBlendDest write fwireBlendDest;
property soldatDir: widestring read fsoldatDir write fsoldatDir;
property uncompDir: widestring read funcompDir write funcompDir;
property prefabDir: widestring read fprefabDir write fprefabDir;
property gridSpacing: Smallint read fgridSpacing write fgridSpacing;
property gridDivisions: Smallint read fgridDivisions write fgridDivisions;
property gridOp1: Byte read fgridOp1 write fgridOp1;
property gridOp2: Byte read fgridOp2 write fgridOp2;
property sceneryVerts: Boolean read fsceneryVerts write fsceneryVerts;
property topmost: Boolean read ftopmost write ftopmost;
property formHeight: Smallint read fformHeight write fformHeight;
property formWidth: Smallint read fformWidth write fformWidth;
property formLeft: Smallint read fformLeft write fformLeft;
property formTop: Smallint read fformTop write fformTop;
property xTexture: Smallint read fxTexture write fxTexture;
property yTexture: Smallint read fyTexture write fyTexture;
property shiftDown: Boolean read fshiftDown write fshiftDown;
property ctrlDown: Boolean read fctrlDown write fctrlDown;
property altDown: Boolean read faltDown write faltDown;
end;
implementation
{$R *.DFM}
type
//-------- TYPES --------
TImageInfo =
packed record
Width: Smallint;
miplevels: Smallint;
Height: Smallint;
depth: Smallint;
end;
TColour =
packed record
red: Byte;
green: Byte;
blue: Byte;
end;
TVertexData =
packed record
vertex: array[1..3] of Byte;
polyType: Byte;
colour: array[1..3] of TColour;
end;
TTriangle =
packed record
vertex: array[1..3] of D3DVECTOR2;
end;
TLightSource =
packed record
selected: Byte;
colour: TColour;
intensity: Single;
range: Smallint;
X: Single;
Y: Single;
z: Single;
end;
//-------- MAP TYPES --------
TCustomVertex =
packed record
X: Single;
Y: Single;
z: Single;
rhw: Single;
Color: Longint;
tu: Single;
tv: Single;
end;
TSketchVertex =
packed record
X: Single;
Y: Single;
z: Single;
end;
TSketchLine =
packed record
vertex: array[1..2] of TSketchVertex;
end;
TVertexHit =
packed record
X: Single; //sin of angle
Y: Single; //cos of angle
z: Single; //0
end;
TPolyHit =
packed record
vertex: array[1..3] of TVertexHit;
end;
TPolygon =
packed record
vertex: array[1..3] of TCustomVertex;
Perp: TPolyHit;
end;
TLine =
packed record
vertex: array[1..2] of TCustomVertex;
end;
TProp =
packed record
active: wordbool;
Style: Smallint;
Width: Longint;
Height: Longint;
X: Single;
Y: Single;
rotation: Single;
ScaleX: Single;
ScaleY: Single;
alpha: Longint;
Color: Longint;
level: Longint;
end;
TScenery =
packed record
Style: Smallint;
Translation: D3DVECTOR2;
rotation: Single;
Scaling: D3DVECTOR2;
alpha: Byte;
Color: Longint;
level: Byte;
selected: Byte;
screenTr: D3DVECTOR2;
end;
TSpawnPoint =
packed record
active: Longint; //Boolean
X: Single;
Y: Single;
Team: Longint;
end;
TSaveSpawnPoint =
packed record
active: Longint; //Boolean
X: Longint;
Y: Longint;
Team: Longint;
end;
TCollider =
packed record
active: Longint; //Boolean
X: Single;
Y: Single;
radius: Single;
end;
TOptions =
packed record
mapName: array[0..38] of Byte; //String * 39
textureName: array[0..24] of Byte; //String * 25
BackgroundColor: Longint;
BackgroundColor2: Longint;
StartJet: Longint;
GrenadePacks: Byte;
Medikits: Byte;
Weather: Byte;
Steps: Byte;
MapRandomID: Longint; //Integer
end;
TMapFile_Polygon =
packed record
Poly: TPolygon;
polyType: Byte;
end;
TMapFile_Scenery =
packed record
sceneryName: array[0..50] of Byte;
Date: Longint;
end;
TextureData =
packed record
Width: Smallint;
Height: Smallint;
reScale: D3DVECTOR2;
Texture: Direct3DTexture8;
end;
TNewWaypoint =
packed record
active: Longint;
id: Longint;
X: Longint;
Y: Longint;
left: Byte;
right: Byte;
up: Byte;
down: Byte;
m2: Byte;
pathNum: Byte;
special: Byte;
crap: array[1..5] of Byte;
connectionsNum: Longint;
Connections: array[1..20] of Longint;
end;
TWaypoint =
packed record
tempIndex: Smallint;
selected: wordbool;
X: Single;
Y: Single;
wayType: array[0..4] of wordbool;
special: Byte;
pathNum: Byte;
numConnections: Byte;
end;
TConnection =
packed record
point1: Smallint;
point2: Smallint;
end;
procedure TfrmSoldatMapEditor.Form_Load;
var
i: Smallint;
temp: widestring;
err: widestring;
label
ErrorHandler;
begin
//ON ERROR
initialized := false;
loadINI;
loadWorkspace;
loadColours;
err := 'Error setting colours';
self.SetColours;
self.Show;
err := 'Error setting directories';
if (length(Dir(uncompDir)) = 0) or (uncompDir = '') then