-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJED_OLE.PAS
3045 lines (2530 loc) · 61.7 KB
/
JED_OLE.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 JED_OLE;
interface
uses OleAuto, GlobalVars, J_Level, Classes, misc_utils,
lev_utils, Values, Windows, u_multisel, U_undo, U_templates,
Cons_Checker, Geometry, Menus;
type
TOLELevel=class;
TOleObjList=class
idxObjs:TList;
Objs:TList;
Constructor Create;
Destructor Destroy;override;
Procedure AddObj(idxObj:TObject;oleObj:TAutoObject);
Function GetObj(idxObj:TObject):TAutoObject;
Procedure ReleaseObj(idxobj:TObject);
Procedure DeleteObj(idxObj:TObject);
Procedure DeleteAll;
end;
TOLESector=class(TAutoObject)
Olelev:TOLELevel;
sec:TJKSector;
Constructor Create(olev:TOLELevel;sector:TJKSector);
Function GetNVertices:Integer;
Function GetNSurfaces:Integer;
Function GetFlags:Longint;
Procedure SetFlags(f:longint);
Function GetAmbient:double; // deprecated;
Procedure SetAmbient(amb:double); // deprecated;
Function GetAmbientBGR:UInt32; // SED 0.1.0
Procedure SetAmbientBGR(amb:UInt32); // SED 0.1.0
Function GetExtra:double; // deprecated;
Procedure SetExtra(ex:double); // deprecated;
Function GetExtraLightBGR:UInt32; // SED 0.1.0
Procedure SetExtraLightBGR(ex:UInt32); // SED 0.1.0
Function GetCMP:string;
Procedure SetCMP(const cmp:string);
Function GetSound:String;
Procedure SetSound(const snd:string);
Function GetVol:double;
Procedure SetVol(vol:double);
Function GetLayer:Integer;
Procedure SetLayer(l:integer);
// deprecated;
Function GetTintR:double;
Function GetTintG:double;
Function GetTintB:double;
// SED 0.1.0
Function GetTintBGR:UInt32;
Procedure SetTintBGR(ex:UInt32);
automated
Function AddSurface:Integer;
Function InsertSurface(n:integer):integer;
Procedure DeleteSurface(n:integer);
Function GetSurface(n:integer):Variant;
Function AddVertex(x,y,z:double):Integer;
Function FindVertex(x,y,z:double):Integer;
Procedure DeleteVertex(n:integer);
Procedure GetVertex(n:integer;var x,y,z:double);
Procedure SetVertex(n:integer;x,y,z:double);
Procedure Update;
Procedure Release;
Procedure GetTint(var r,g,b:double);
Procedure SetTint(r,g,b:double);
{JED 0.9}
Function IsConvex:WordBool;
Property NVertices:Integer read GetNVertices;
Property NSurfaces:Integer read GetNSurfaces;
Property Tinx_R:double read GetTintR;
Property Tinx_G:double read GetTintG;
Property Tinx_B:double read GetTintB;
Property Flags:longint read GetFlags write SetFlags;
Property Ambient:double read GetAmbient write SetAmbient; // deprecated
Property ExtraLight:double read GetExtra write SetExtra; // deprecated
Property ColorMap:String read GetCMP write SetCMP;
Property Sound:string read GetSound write SetSound;
Property Volume:double read GetVol write SetVol;
Property Layer:Integer read GetLayer write SetLayer;
{SED 0.1.0}
Property AmbientBGR:UInt32 read GetAmbientBGR write SetAmbientBGR;
Property ExtraLightBGR:UInt32 read GetExtraLightBGR write SetExtraLightBGR;
end;
TOLEThing=class(TAutoObject)
olelev:TOLELevel;
thing:TJKThing;
Constructor Create(olev:TOLELevel;th:TJKThing);
Function GetNValues:Integer;
Function GetSec:Integer;
Procedure SetSec(n:integer);
Function GetName:string;
Procedure setName(const name:string);
Function GetLayer:Integer;
Procedure SetLayer(n:integer);
Function GetX:double;
Function GetY:double;
Function GetZ:double;
Function GetPCH:double;
Function GetYAW:double;
Function GetROL:double;
automated
Procedure Release;
Procedure Update;
Procedure GetXYZ(var x,y,z:double);
Procedure SetXYZ(x,y,z:double);
Procedure GetOrient(var pch,yaw,rol:double);
Procedure SetOrient(pch,yaw,rol:double);
Procedure GetValue(n:Integer;var name,val:string);
Procedure SetValue(n:Integer;const name,val:string);
Function GetValueName(n:Integer):String;
Function GetValueData(n:integer):string;
Function AddValue(const name,val:string):integer;
Procedure InsertValue(n:Integer;const name,val:string);
Procedure DeleteValue(n:integer);
Property X:double read GetX;
Property Y:double read GetY;
Property Z:double read GetZ;
Property PCH:double read GetPCH;
Property YAW:double read GetYAW;
Property ROL:double read GetROL;
Property NValues:Integer read GetNValues;
Property Sector:Integer read GetSec write SetSec;
Property Template:string read GetName write setName;
Property layer:integer read GetLayer write SetLayer;
end;
TOLELight=class(TAutoObject)
olelev:TOLELevel;
lt:TSedLight;
Constructor Create(olev:TOLELevel;alt:TSedLight);
Function GetRange:double;
Procedure SetRange(d:double);
Function GetLayer:integer;
Procedure SetLayer(n:integer);
Function GetFlags:Integer;
Procedure SetFlags(f:integer);
Function GetR:double;
Function GetG:double;
Function GetB:double;
Function GetX:double;
Function GetY:double;
Function GetZ:double;
Function GetInt:double;
Function GetRGBInt:double;
automated
Procedure Update;
Procedure Release;
Procedure GetXYZ(var x,y,z:double);
Procedure SetXYZ(x,y,z:double);
Procedure GetRGB(var r,g,b:double);
Procedure SetRGB(r,g,b:double);
Procedure GetIntensity(var white,rgb:double);
Procedure SetIntensity(white,rgb:double);
Property R:double read GetR;
Property G:double read GetG;
Property B:double read GetB;
Property X:double read GetX;
Property Y:double read GetY;
Property Z:double read GetZ;
Property Intensity:double read GetInt;
Property RGBIntensity:double read GetRGBInt;
Property Range:double read GetRange write SetRange;
Property Layer:integer read GetLayer write SetLayer;
Property Flags:integer read GetFlags write SetFlags;
end;
TOLECOG=class(TAutoObject)
olelev:TOLELevel;
cog:TCOG;
Constructor Create(olev:TOLELevel;cg:TCOG);
Function GetNValues:Integer;
Function GetName:string;
Procedure setName(const name:string);
automated
Procedure Release;
Procedure Update;
Function GetValue(n:Integer):string;
Function SetValue(n:Integer;const val:string):WordBool;
Function GetValueName(n:Integer):String;
Function GetValueType(n:Integer):String;
Procedure SetValueType(n:Integer;vtype:string);
Procedure SetValueName(n:Integer;name:string);
Function AddValue(const name,val,vtype:string):integer;
Procedure InsertValue(n:Integer;const name,val,vtype:string);
Procedure DeleteValue(n:integer);
Property NValues:Integer read GetNValues;
Property FileName:string read GetName write setName;
end;
TOLESurface=class(TAutoObject)
olelev:TOLELevel;
surf:TJKSurface;
Constructor Create(olev:TOLELevel;asurf:TJKSurface);
Function GetMAT:string;
Procedure SetMat(const mat:string);
Function GetExtra:double; // deprecated
Procedure SetExtra(ex:double); // deprecated
Function GetExtraLightABGR:UInt32;
Procedure SetExtraLightABGR(ex:UInt32);
Function GetUScale:double;
Function GetVScale:double;
Procedure SetUScale(sc:double);
Procedure SetVScale(sc:double);
Procedure SetTXScale(sc:double);
Function GetNVertices:Integer;
Function GetAdjFlags:integer;
Procedure SetAdjFlags(f:integer);
Function GetSurfFlags:Integer;
Procedure SetSurfFlags(f:integer);
Function GetFaceFlags:Integer;
Procedure SetFaceFlags(f:integer);
Function GetGeo:integer;
Function GetLight:integer;
Function GetTex:integer;
Function GetNormX:double;
Function GetNormY:double;
Function GetNormZ:double;
Automated
Procedure Release;
Procedure Update;
Procedure UpdateSector;
Procedure GetNormal(var x,y,z:double);
Procedure GetAdjoin(var sc,sf:integer);
Procedure SetAdjoin(sc,sf:integer);
Procedure GetFlags(var AdjoinFlags, SurfFlags, FaceFlags:Longint);
Procedure SetFlags(AdjoinFlags, SurfFlags, FaceFlags:Longint);
Procedure GetGeoLightTex(var geo,light,tex:integer);
Procedure SetGeoLightTex(geo,light,tex:integer);
{Vertices}
Procedure InsertVertex(n:integer;nvx:integer);
Procedure DeleteVertex(n:integer);
Function GetVertex(n:integer):Integer;
Procedure SetVertex(n:integer;nvx:integer);
Procedure GetVertexUV(n:integer;var u,v:double);
Procedure SetVertexUV(n:integer;u,v:double);
Function GetVertexLight(n:integer):double;
Procedure SetVertexLight(n:integer;light:double);
Procedure GetVertexRGB(n:integer;var r,g,b:double);
Procedure SetVertexRGB(n:integer;r,g,b:double);
Function GetAdjoinSC:Integer;
Function GetAdjoinSF:Integer;
Function GetVertexU(n:integer):Double;
Function GetVertexV(n:integer):Double;
Function GetVertexR(n:integer):Double;
Function GetVertexG(n:integer):Double;
Function GetVertexB(n:integer):Double;
{JED 0.9}
Function IsConvex:Wordbool;
Function IsPlanar:Wordbool;
Property AdjoinFlags:Integer read GetAdjFlags write SetAdjFlags;
Property SurfFlags:Integer read GetSurfFlags write SetSurfFlags;
Property FaceFlags:Integer read GetFaceFlags write SetAdjFlags;
Property Geo:integer read GetGeo;
Property Light:integer read GetLight;
Property Tex:integer read GetTex;
Property Material:string read GetMAT write SetMat;
Property ExtraLight:double read GetExtra write SetExtra; // deprecated
Property TXScale:double read GetUScale write SetTXScale;
Property UScale:double read GetUScale write SetUScale;
Property VScale:double read GetVScale write SetVScale;
Property NormalX:double read GetNormX;
Property NormalY:double read GetNormY;
Property NormalZ:double read GetNormZ;
{JED 0.85}
Property Nvertices:Integer read GetNVertices;
{SED 0.1.0}
Property ExtraLightABGR:UInt32 read GetExtraLightABGR write SetExtraLightABGR;
end;
TOLELevel=class(TAutoObject)
scs,
surfs,
ths, lts,cogs:TOleObjList;
constructor Create; override;
Destructor Destroy; override;
Procedure ClearOLEObjs;
Function GetNSectors:integer;
Function GetNThings:integer;
Function GetNLights:integer;
Function GetMasterCMP:string;
Procedure SetMasterCMP(const cmp:String);
Function GetNLayers:Integer;
automated
Function GetSector(n:integer):variant;
Function GetSurface(sc,sf:integer):variant;
Function GetThing(n:integer):variant;
Function GetLight(n:integer):variant;
Function GetCOG(n:integer):variant; {JED 0.81}
Procedure DeleteSector(n:integer);
Procedure DeleteThing(n:integer);
Procedure DeleteLight(n:integer);
Procedure DeleteCOG(n:integer); {JED 0.81}
Function AddSector:Integer;
Function AddThing:Integer;
Function AddLight:Integer;
Function AddCOG(const name:string):Integer; {JED 0.81}
Function GetLayerName(n:integer):String;
Function AddLayer(const name:string):integer;
{JED 0.85}
Property NLayers:integer read GetNLayers;
Property NSectors:integer read GetNSectors;
Property NThings:integer read GetNThings;
Property NLights:integer read GetNLights;
Property MasterCMP:string read GetMasterCMP write SetMasterCMP;
end;
{JED 0.85}
TOLETemplates=class(TAutoObject)
automated
Procedure ClearTemplates;
Function NTemplates:integer;
Function GetTemplateName(n:integer):String;
Function GetTemplateParent(n:integer):string;
Function GetTemplateValues(n:integer):String;
Function GetTemplateDescription(n:integer):String;
Procedure SetTemplateDescription(n:integer;const desc:string);
Procedure GetTemplateBBox(n:integer;var x1,y1,z1,x2,y2,z2:double);
Function GetTemplateBBoxEx(n:integer;what:integer):double;
Procedure SetTemplateBBox(n:integer;x1,y1,z1,x2,y2,z2:double);
Procedure DeleteTemplate(n:integer);
Function AddTemplate(const name,parent,values:string):integer;
Function FindTemplate(const name:string):integer;
Procedure LoadTemplates(const filename:string);
Procedure SaveTemplates(const filename:string);
end;
TJEDApp = class(TAutoObject)
private
lev:TOLELevel;
tpls:TOLETemplates;
foreWnd:integer;
public
constructor Create; override;
Destructor Destroy; override;
Function GetMapMode:integer;
Procedure SetMapMode(mode:integer);
Function GetCurSC:integer;
Procedure SetCurSC(sc:integer);
Function GetCurTH:integer;
Procedure SetCurTH(th:integer);
Function GetCurLT:integer;
Procedure SetCurLT(sc:integer);
Function GetCurEX:integer;
Procedure SetCurEX(ex:integer);
Function GetLevel:Variant;
Function GetTemplates:Variant;
Function GetGameDir:String;
Function GetProjectDir:String;
Function GetJEDDir:String;
Function GetProjectType:Word;
Procedure SetProjectType(kind:Word);
Function GetIsMots:wordbool; // deprecated
Procedure SetIsMots(mots:wordbool); // deprecated
Function GetVersion:double;
Procedure SaveCurApp;
Procedure RestoreCurApp;
Function prGetCurSF:integer;
Function prGetCurED:integer;
Function prGetCurVX:integer;
Function prGetCurFR:integer;
Function GetGridX:double;
Function GetGridY:double;
Function GetGridZ:double;
Function GetCamX:double;
Function GetCamY:double;
Function GetCamZ:double;
Function getIsPreviewActive:WordBool;
Function GetLevelFile:String;
automated
{Functions}
Procedure Release;
Procedure NewLevel(mots:WordBool);
Procedure OpenLevel(const name:string);
Procedure SaveJED(const name:string);
Procedure SaveJKL(const name:string);
Procedure UpdateMap;
Procedure GetCurSF(var sc,sf:integer);
Procedure SetCurSF(sc,sf:integer);
Procedure GetCurVX(var sc,vx:integer);
Procedure SetCurVX(sc,vx:integer);
Procedure GetCurED(var sc,sf,ed:integer);
Procedure SetCurED(sc,sf,ed:integer);
Procedure GetCurFR(var th,fr:integer);
Procedure SetCurFR(th,fr:integer);
{Picking}
Function PickThing(const curThing:String):String;
Function PickTemplate(const curtpl:string):string;
Function PickCMP(const CurCMP:string):string;
Function PickWav(CurWav:string):string;
Function PickMAT(CurMAT:string):string;
Function PickCOG(CurCog:string):string;
{ Function PickLayer(CurLayer:string):string;}
Function Pick3DO(const cur3do:String):String;
Function PickAI(const CurAI:string):string;
Function PickKEY(const CurKEY:string):string;
Function PickSND(const CurSND:string):string;
Function PickPUP(const CurPUP:string):string;
{JED 0.81}
Function PickSPR(const CurSPR:string):string;
Function PickPAR(const CurPAR:string):string;
Function PickPER(const CurPER:string):string;
Procedure ReloadTemplates;
Procedure PanMessage(mtype:integer;const msg:string);
Procedure SendKey(shift:integer;key:integer);
Function ExecuteMenu(const itemref:string):WordBool;
{JED 0.81}
{JED 0.85}
Function EditSectorFlags(flags:LongInt):LongInt;
Function EditSurfaceFlags(flags:LongInt):LongInt;
Function EditAdjoinFlags(flags:LongInt):LongInt;
Function EditThingFlags(flags:LongInt):LongInt;
Function EditFaceFlags(flags:LongInt):LongInt;
Function EditLightFlags(flags:Longint):LongInt;
Function PickGeo(geo:integer):integer;
Function PickLightMode(lmode:integer):integer;
Function PickTEX(tex:integer):integer;
{Stuff}
Procedure GetCamXYZ(var x,y,z:double);
Procedure GetGridXYZ(var x,y,z:double);
{JED 0.81}
Procedure SetCamXYZ(x,y,z:double);
Procedure SetGridXYZ(x,y,z:double);
Procedure GetGridAxes(var xx,xy,xz,yx,yy,yz,zx,zy,zz:double);
Function GetGridAxis(naxis,ncoord:integer):double;
Procedure SetGridAxes(xx,xy,xz,yx,yy,yz:double);
Procedure GetCamAxes(var xx,xy,xz,yx,yy,yz,zx,zy,zz:double);
Function GetCamAxis(naxis,ncoord:integer):double;
Procedure SetCamAxes(xx,xy,xz,yx,yy,yz:double);
Procedure SetPreviewCamXYZ(x,y,z:double);
Procedure GetPreviewCamXYZ(var x,y,z:double);
Procedure SetPreviewCamPY(pch,yaw:double);
Procedure GetPreviewCamPY(var pch,yaw:double);
Function GetPreviewCamParam(what:integer):double;
Function NMultiSelected(what:integer):integer;
Procedure ClearMultiselection(what:integer);
Procedure RemoveFromMultiselection(what,n:integer);
Function GetSelectedSC(n:integer):integer;
Function GetSelectedTH(n:integer):integer;
Function GetSelectedLT(n:integer):integer;
procedure GetSelectedSF(n:integer;var sc,sf:integer);
procedure GetSelectedED(n:integer;var sc,sf,ed:integer);
procedure GetSelectedVX(n:integer;var sc,vx:integer);
procedure GetSelectedFR(n:integer;var th,fr:integer);
Function GetSelectedSFop(n:integer;what:integer):integer;
Function GetSelectedEDop(n:integer;what:integer):integer;
Function GetSelectedVXop(n:integer;what:integer):integer;
Function GetSelectedFRop(n:integer;what:integer):integer;
Function SelectSC(sc:integer):integer;
Function SelectSF(sc,sf:integer):integer;
Function SelectED(sc,sf,ed:integer):integer;
Function SelectVX(sc,vx:integer):integer;
Function SelectTH(th:integer):integer;
Function SelectFR(th,fr:integer):integer;
Function SelectLT(lt:integer):integer;
Function FindSelectedSC(sc:integer):integer;
Function FindSelectedSF(sc,sf:integer):integer;
Function FindSelectedED(sc,sf,ed:integer):integer;
Function FindSelectedVX(sc,vx:integer):integer;
Function FindSelectedTH(th:integer):integer;
Function FindSelectedFR(th,fr:integer):integer;
Function FindSelectedLT(lt:integer):integer;
{JED 0.85}
Procedure StartUndo(const name:string);
Procedure SaveUndoForThing(n:integer;change:integer);
Procedure SaveUndoForLight(n:integer;change:integer);
Procedure SaveUndoForSector(n:integer;change:integer;whatpart:integer);
Procedure ClearUndoBuffer;
Procedure ApplyUndo;
Function GetJEDSetting(const name:string):variant;
Function IsLayerVisible(n:integer):WordBool;
{JED 0.9}
procedure CheckConsistencyErrors;
procedure CheckResources;
Function NConsistencyErrors:integer;
Function GetConsErrorString(n:integer):String;
Function GetConsErrorType(n:integer):integer;
Function GetConsErrorSector(n:integer):integer;
Function GetConsErrorSurface(n:integer):integer;
Function GetConsErrorThing(n:integer):integer;
Function GetConsErrorCog(n:integer):integer;
Procedure ClearExtraObjects;
Function AddExtraVertex(x,y,z:double):integer;
Function AddExtraLine(x1,y1,z1,x2,y2,z2:double):Integer;
Procedure DeleteExtraObject(n:integer);
{Properties}
Property IsPreviewActive:WordBool read getIsPreviewActive;
Property Version:double read GetVersion;
Property MapMode:integer read GetMapMode write SetMapMode;
Property CurSC:integer read GetCurSC write SetCurSC;
Property CurTH:integer read GetCurTH write SetCurTH;
Property CurLT:integer read GetCurLT write SetCurLT;
Property CurSF:integer read prGetCurSF;
Property CurED:integer read prGetCurED;
Property CurVX:integer read prGetCurVX;
Property CurFR:integer read prGetCurFR;
Property Level:Variant read GetLevel;
Property GridX:double read GetGridX;
Property GridY:double read GetGridY;
Property GridZ:double read GetGridZ;
Property CamX:double read GetCamX;
Property CamY:double read GetCamY;
Property CamZ:double read GetCamZ;
Property GameDir:String read GetGameDir;
Property ProjectDir:String read GetProjectDir;
Property JEDDir:String read GetJedDir;
Property IsMots:WordBool read GetIsMots write SetIsMots; // deprecated
{JED 0.85}
Property LevelFile:String read GetLevelFile;
Property Templates:variant read GetTemplates;
{JED 0.9}
Property CurEX:integer read GetCurEX write SetCurEX;
{SED 0.1.0}
Property CurrentProject:Word read GetProjectType write SetProjectType;
end;
implementation
uses Jed_Main, ResourcePicker, U_CogForm, ListRes, SysUtils, U_preview,
FlagEditor, U_SCFEdit, U_options, U_tbar, JED_COM, math;
Constructor TOleObjList.Create;
begin
idxObjs:=TList.Create;
Objs:=TList.Create;
end;
Destructor TOleObjList.Destroy;
begin
DeleteAll;
Objs.free;
idxObjs.free;
end;
Procedure TOleObjList.DeleteAll;
var i:integer;
begin
for i:=0 to Objs.count-1 do
TAutoObject(Objs[i]).Free;
Objs.clear;
idxObjs.Clear;
end;
Procedure TOleObjList.AddObj(idxObj:TObject;oleObj:TAutoObject);
begin
Objs.Add(oleObj);
idxObjs.Add(idxObj);
end;
Function TOleObjList.GetObj(idxObj:TObject):TAutoObject;
var i:integer;
begin
result:=nil;
i:=idxObjs.IndexOf(idxObj);
if i=-1 then exit;
Result:=TAutoObject(Objs[i]);
Result.AddRef;
end;
Procedure TOleObjList.ReleaseObj(idxobj:TObject);
var i:integer;
au:TAutoObject;
begin
i:=idxObjs.IndexOf(idxObj);
if i=-1 then exit;
au:=TAutoObject(Objs[i]);
if au.Release=0 then
begin
idxObjs.Delete(i);
Objs.Delete(i);
end;
end;
Procedure TOleObjList.DeleteObj(idxObj:TObject);
var i:integer;
begin
i:=idxObjs.IndexOf(idxObj);
if i=-1 then exit;
TAutoObject(Objs[i]).Free;
idxObjs.Delete(i);
Objs.Delete(i);
end;
Constructor TOLESector.Create(olev:TOLELevel;sector:TJKSector);
begin
Inherited Create;
Olelev:=Olev;
sec:=sector;
end;
Function TOLESector.GetFlags:Longint;
begin
Result:=sec.Flags;
end;
Procedure TOLESector.SetFlags(f:longint);
begin
sec.Flags:=f;
end;
Function TOLESector.GetAmbient:double; deprecated
begin
Result:= RgbToIntensity(sec.Ambient);
end;
Procedure TOLESector.SetAmbient(amb:double); deprecated
begin
sec.Ambient:=IntensityToColor(amb);
sec.Ambient.a := 0.0;
end;
Function TOLESector.GetAmbientBGR:UInt32;
begin
Result:=EncodeBGR(sec.Ambient);
end;
Procedure TOLESector.SetAmbientBGR(amb:UInt32);
begin
sec.ambient:=DecodeBGR(amb);
end;
Function TOLESector.GetExtra:double; deprecated
begin
Result := RgbToIntensity(sec.ExtraLight);
end;
Procedure TOLESector.SetExtra(ex:double); deprecated
begin
sec.ExtraLight := IntensityToColor(ex);
sec.ExtraLight.a := 0.0;
end;
Function TOLESector.GetExtraLightBGR:UInt32;
begin
Result := EncodeBGR(sec.ExtraLight);
end;
Procedure TOLESector.SetExtraLightBGR(ex:UInt32);
begin
sec.ExtraLight := DecodeBGR(ex);
end;
Function TOLESector.GetCMP:string;
begin
Result:=sec.colormap;
end;
Procedure TOLESector.SetCMP(const cmp:string);
begin
sec.colormap:=cmp;
end;
Function TOLESector.GetSound:String;
begin
Result:=sec.Sound;
end;
Procedure TOLESector.SetSound(const snd:string);
begin
sec.Sound:=snd;
end;
Function TOLESector.GetVol:double;
begin
Result:=sec.soundVolume;
end;
Procedure TOLESector.SetVol(vol:double);
begin
sec.soundVolume:=vol;
end;
Function TOLESector.GetLayer:Integer;
begin
Result:=sec.Layer;
end;
Procedure TOLESector.SetLayer(l:integer);
begin
sec.Layer:=l;
end;
Function TOLESector.GetTintR:double;
begin
Result:=sec.tint.r;
end;
Function TOLESector.GetTintG:double;
begin
Result:=sec.tint.g;
end;
Function TOLESector.GetTintB:double;
begin
Result:=sec.tint.b;
end;
Function TOLESector.GetTintBGR:UInt32;
begin
Result := EncodeBGR(sec.Tint);
end;
Procedure TOLESector.SetTintBGR(ex:UInt32);
begin
sec.Tint := DecodeBGR(ex);
end;
Procedure TOLESector.GetTint(var r,g,b:double);
begin
r:=sec.tint.r;
g:=sec.tint.g;
b:=sec.tint.b;
end;
Procedure TOLESector.SetTint(r,g,b:double);
begin
sec.tint.r:=r;
sec.tint.g:=g;
sec.tint.b:=b;
end;
Function TOLESector.GetNVertices:Integer;
begin
Result:=sec.Vertices.Count;
end;
Function TOLESector.GetNSurfaces:Integer;
begin
Result:=sec.Surfaces.Count;
end;
Function TOLESector.GetSurface(n:integer):Variant;
begin
Result:=OleLev.GetSurface(sec.num,n);
end;
Function TOLESector.AddSurface:Integer;
var surf:TJKSurface;
begin
surf:=sec.NewSurface;
surf.Num:=sec.Surfaces.count;
Result:=sec.Surfaces.Add(surf);
end;
Function TOLESector.InsertSurface(n:integer):integer;
var surf:TJKSurface;
begin
surf:=sec.NewSurface;
Result:=n;
sec.Surfaces.Insert(n,surf);
sec.Renumber;
end;
Procedure TOLESector.DeleteSurface(n:integer);
var surf:TJKSurface;
begin
surf:=Sec.Surfaces[n];
Lev_Utils.RemoveSurfRefs(Level,surf);
sec.surfaces.Delete(n);
sec.Renumber;
end;
Function TOLESector.AddVertex(x,y,z:double):Integer;
var v:TJKVertex;
begin
v:=sec.NewVertex;
Result:=sec.Vertices.Count-1;
v.x:=x;
v.y:=y;
v.z:=z;
end;
Function TOLESector.FindVertex(x,y,z:double):Integer;
begin
Result:=sec.FindVX(x,y,z);
end;
Procedure TOLESector.GetVertex(n:integer;var x,y,z:double);
var v:TJKVertex;
begin
v:=sec.Vertices[n];
x:=v.x;
y:=v.y;
z:=v.z;
end;
Procedure TOLESector.SetVertex(n:integer;x,y,z:double);
var v:TJKVertex;
begin
v:=sec.Vertices[n];
v.x:=x;
v.y:=y;
v.z:=z;
end;
Procedure TOLESector.DeleteVertex(n:integer);
var v:TJKVertex;
j,i:integer;
begin
v:=sec.Vertices[n];
for i:=0 to sec.Surfaces.count-1 do
With sec.Surfaces[i] do
begin
j:=Vertices.IndexOf(v);
if j<>-1 then DeleteVertex(j);
end;
sec.Vertices.Delete(n);
v.free;
sec.Renumber;
end;
Procedure TOLESector.Update;
begin
Sec.Renumber;
JedMain.SectorChanged(sec);
end;
Function TOLESector.IsConvex:WordBool;
begin
result:=IsSectorConvex(sec);
end;
Procedure TOLESector.Release;
begin
olelev.scs.ReleaseObj(sec);
end;
{Surface}
Constructor TOLESurface.Create;
begin
Inherited Create;
olelev:=olev;
surf:=asurf;
end;
Procedure TOLESurface.Release;
begin
OleLev.surfs.ReleaseObj(surf);
end;
Procedure TOLESurface.Update;
begin
surf.RecalcAll;
end;
Procedure TOLESurface.UpdateSector;
begin
JedMain.SectorChanged(surf.sector);
end;
Function TOLESurface.GetAdjFlags:integer;
begin
Result:=surf.adjoinflags;
end;
Procedure TOLESurface.SetAdjFlags(f:integer);
begin
surf.adjoinflags:=f;
end;
Function TOLESurface.GetSurfFlags:Integer;
begin
Result:=surf.surfflags;
end;
Procedure TOLESurface.SetSurfFlags(f:integer);
begin
surf.surfflags:=f;
end;
Function TOLESurface.GetFaceFlags:Integer;
begin
Result:=surf.FaceFlags;
end;
Procedure TOLESurface.SetFaceFlags(f:integer);
begin
surf.FaceFlags:=f;
end;
Function TOLESurface.GetGeo:integer;
begin
Result:=surf.geo;
end;
Function TOLESurface.GetLight:integer;
begin
Result:=surf.light;
end;
Function TOLESurface.GetTex:integer;
begin
Result:=surf.tex;
end;
Function TOLESurface.GetNVertices:Integer;
begin
Result:=surf.vertices.count;
end;
Function TOLESurface.GetAdjoinSC:Integer;