-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathConFile.Reader.pas
More file actions
854 lines (660 loc) · 39 KB
/
ConFile.Reader.pas
File metadata and controls
854 lines (660 loc) · 39 KB
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
//
// Read binary .con file
//
unit ConFile.Reader;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Dialogs, winapi.ActiveX, ConEditPlus.Consts, Conversation.Classes, system.TypInfo,
vcl.ComCtrls, conEditPlus.Enums;
procedure LoadConFile(conFile: string);
procedure FillTables(ConRead: TBinaryReader);
procedure FillSpeech(ConRead: TBinaryReader; speechEvent: TConEventSpeech; eventLabel: string);
procedure FillChoice(ConRead: TBinaryReader; choiceEvent: TConEventChoice; eventLabel: string);
procedure FillSetFlag(ConRead: TBinaryReader; setFlagEvent: TConEventSetFlag; eventLabel: string);
procedure FillCheckFlag(ConRead: TBinaryReader; checkFlagEvent: TConEventCheckFlag; eventLabel: string);
procedure FillCheckObject(ConRead: TBinaryReader; checkObjectEvent: TConEventCheckObject; eventLabel: string);
procedure FillTransferObject(ConRead: TBinaryReader; transferObjectEvent: TConEventTransferObject; eventLabel: string);
procedure FillMoveCamera(ConRead: TBinaryReader; moveCameraEvent: TConEventMoveCamera; eventLabel: string);
procedure FillAnimation(ConRead: TBinaryReader; animEvent: TConEventAnimation; eventLabel: string);
procedure FillTrade(ConRead: TBinaryReader; eventTrade: TConEventTrade; eventLabel: string);
procedure FillJump(ConRead: TBinaryReader; eventJump: TConEventJump; eventLabel: string);
procedure FillRandom(ConRead: TBinaryReader; eventRandom: TConEventRandom; eventLabel: string);
procedure FillTrigger(ConRead: TBinaryReader; eventTrigger: TConEventTrigger; eventLabel: string);
procedure FillAddGoal(ConRead: TBinaryReader; eventAddGoal: TConEventAddGoal; eventLabel: string);
procedure FillAddNote(ConRead: TBinaryReader; eventAddNote: TConEventAddNote; eventLabel: string);
procedure FillAddSkillPoints(ConRead: TBinaryReader; eventAddSkillPts: TConEventAddSkillPoints; eventLabel: string);
procedure FillAddCredits(ConRead: TBinaryReader; eventAddCredits: TConEventAddCredits; eventLabel: string);
procedure FillCheckPersona(ConRead: TBinaryReader; eventCheckPersona: TConEventCheckPersona; eventLabel: string);
procedure FillComment(ConRead: TBinaryReader; eventComment: TConEventComment; eventLabel: string);
procedure FillEnd(ConRead: TBinaryReader; eventEnd: TConEventEnd; eventLabel: string);
function DoubleToDateTime(floatDateTime: Double): TDateTime;
function GetConString(conRead: TBinaryReader): string;
function GetConLongBool(conRead: TBinaryReader): Boolean;
implementation
uses MainWindow;
function DoubleToDateTime(floatDateTime: Double): TDateTime;
var
finalvalue: TSystemTime;
begin
VariantTimeToSystemTime(floatDateTime, finalvalue);
Result := SystemTimeToDateTime(finalvalue);
end;
function GetConString(conRead: TBinaryReader): string;
begin
var StringSize := ConRead.ReadInteger(); // get size of data
if StringSize = 0 then
Exit('');
var StringBytes := ConRead.ReadBytes(StringSize);
Result := TEncoding.ANSI.GetString(StringBytes); // convert to string
end;
function GetConLongBool(conRead: TBinaryReader): Boolean;
begin
var tempInteger := conRead.ReadInteger(); // LongBool,4 bytes
Result := tempInteger <> 0; //tempInteger.ToBoolean;
end;
procedure LoadConFile(conFile: string);
var
fileStr: TFileStream;
ConRead: TBinaryReader;
tempConvo: TConversation;
begin
fileStr := TFileStream.Create(conFile, fmOpenRead);
ConRead := TBinaryReader.Create(fileStr, TEncoding.ANSI, False);
var headerBytes := ConRead.ReadBytes(26);
if CompareMem(headerBytes, @conFileHeader, 26) = False then
begin
ConRead.Close(); // We have a problem, so kill objects.
ConRead.Free();
fileStr.Free();
frmMain.ToggleMenusPanels(False);
raise Exception.Create(strInvalidConFileHdr);
end;
try
with frmMain do
begin
mmoOutput.Clear();
AddLog('Loading .con file: ' + conFile);
conFileParameters.fpFileVersion := ConRead.ReadInteger();
AddLog('File version = ' + conFileParameters.fpFileVersion.ToString);
var CreatedOnDouble := ConRead.ReadDouble(); // CreatedOn
conFileParameters.fpCreatedByDate := DateTimeToStr(DoubleToDateTime(CreatedOnDouble));
AddLog('Created On Double: ' + CreatedOnDouble.ToString + ' converted to: ' + conFileParameters.fpCreatedByDate);
conFileParameters.fpCreatedByName := GetConString(ConRead); // CreatedBy
AddLog('Created By: ' + conFileParameters.fpCreatedByName);
var LastModifOnDouble := ConRead.ReadDouble(); // lastModifiedOn
conFileParameters.fpModifiedByDate := DateTimeToStr(DoubleToDateTime(LastModifOnDouble));
AddLog('Last modified on: ' + LastModifOnDouble.ToString + ' converted to: ' + conFileParameters.fpModifiedByDate);
conFileParameters.fpModifiedByName := GetConString(ConRead); // lastModifiedBy
AddLog('Last modified by: ' + conFileParameters.fpModifiedByName);
conFileParameters.fpAudioPackage := GetConString(ConRead); // audioPackageName
AddLog('Audio Package: ' + conFileParameters.fpAudioPackage);
conFileParameters.fpNotes := GetConString(ConRead); // notes
AddLog('Notes: ' + conFileParameters.fpNotes);
var numMissionList := ConRead.ReadInteger(); // of used missions
AddLog('Num missions: ' + numMissionList.ToString);
SetLength(conFileParameters.fpMissions, numMissionList);
for var NM := 0 to numMissionList -1 do // missionList
begin
conFileParameters.fpMissions[NM] := ConRead.ReadInteger();
AddLog('Used mission #' + conFileParameters.fpMissions[NM].ToString + ' added to array');
end;
FillTables(ConRead); // fill tables
var unknown4 := ConRead.ReadInteger(); // 006 uses unk3. Seems like same as numConversations
AddLog('unknown4 skipped, size = ' + unknown4.ToString);
var numConversations := ConRead.ReadInteger(); // numConversations
AddLog('Num conversations: ' + numConversations.ToString);
if numConversations > 0 then
AddLog(#13#10 + 'Conversations:');
for var NC := 0 to numConversations -1 do
begin
tempConvo := TConversation.Create();
tempConvo.unknown0 := ConRead.ReadInteger();
tempConvo.id := ConRead.ReadInteger();
tempConvo.conName := GetConString(ConRead);
AddLog(#13#10 + 'Conversation id = ' + tempConvo.id.ToString + ' name = ' + tempConvo.conName);
tempConvo.conDescription := GetConString(ConRead);
AddLog('Description: ' + tempConvo.conDescription);
var conCreatedOnDouble := ConRead.ReadDouble(); // createdOn
tempConvo.conCreatedByDate := DateTimeToStr(DoubleToDateTime(conCreatedOnDouble));
AddLog('Conversation createdOn: ' + conCreatedOnDouble.ToString + ' converted to: ' + tempConvo.conCreatedByDate);
tempConvo.conCreatedByName := GetConString(ConRead); // createdBy
AddLog('Conversation createdBy: ' + tempConvo.conCreatedByName);
var conLastModifOnDouble := ConRead.ReadDouble(); //lastModifiedOn
tempConvo.conModifiedByDate := DateTimeToStr(DoubleToDateTime(conLastModifOnDouble));
AddLog('Conversation lastModifiedOn: ' + conLastModifOnDouble.ToString + ' converted to: ' + tempConvo.conModifiedByDate);
tempConvo.conModifiedByName := GetConString(ConRead); // lastModifiedBy
AddLog('Conversation lastModifiedBy: ' + tempConvo.conModifiedByName);
var conOwnerIndexInt := ConRead.ReadInteger(); // ownerName index(id)
tempConvo.conOwnerIndex := conOwnerIndexInt;
tempConvo.conOwnerName := GetConString(ConRead); // ownerName
AddLog('Conversation Owner: ' + tempConvo.conOwnerName + ' index: ' + conOwnerIndexInt.ToString);
var bDataLinkCon := ConRead.ReadInteger(); // LongBool, 4 bytes
tempConvo.bInfoLink := bDataLinkCon.ToBoolean;
AddLog('bDataLinkCon = ' + BoolToStr(tempConvo.bInfoLink, True));
tempConvo.conNotes := GetConString(ConRead);
if tempConvo.conNotes = '' then
AddLog('Conversation Notes: ' + strEmptyValue)
else AddLog('Conversation Notes: ' + tempConvo.conNotes);
var bDisplayOnce := ConRead.ReadInteger();
tempConvo.bOnlyOnce := bDisplayOnce.ToBoolean;
AddLog('bDisplayOnce = ' + BoolToStr(tempConvo.bOnlyOnce, True));
var bFirstPerson := ConRead.ReadInteger();
tempConvo.bFirstPerson := bFirstPerson.ToBoolean;
AddLog('bFirstPerson = ' + BoolToStr(tempConvo.bFirstPerson, True));
var bNonInteractive := ConRead.ReadInteger();
tempConvo.bNonInteract := bNonInteractive.ToBoolean;
AddLog('bNonInteractive = ' + BoolToStr(tempConvo.bNonInteract, True));
var bRandomCam := ConRead.ReadInteger();
tempConvo.bRandomCamera := bRandomCam.ToBoolean;
AddLog('bRandomCamera = ' + BoolToStr(tempConvo.bRandomCamera, True));
var bCanbeInterrupted := ConRead.ReadInteger();
tempConvo.bCanInterrupt := bCanbeInterrupted.ToBoolean;
AddLog('bCanBeInterrupted = ' + BoolToStr(tempConvo.bCanInterrupt, True));
var bCannotBeInterrupted := ConRead.ReadInteger();
tempConvo.bCannotInterrupt := bCannotBeInterrupted.ToBoolean;
AddLog('bCannotBeInterrupted = ' + BoolToStr(tempConvo.bCannotInterrupt, True));
var bInvokeBump := ConRead.ReadInteger();
tempConvo.bPCBumps := bInvokeBump.ToBoolean;
AddLog('bInvokeBump = ' + BoolToStr(tempConvo.bPCBumps, True));
var bInvokeFrob := ConRead.ReadInteger();
tempConvo.bPCFrobs := bInvokeFrob.ToBoolean;
AddLog('bInvokeFrob = ' + BoolToStr(tempConvo.bPCFrobs, True));
var bInvokeSight := ConRead.ReadInteger();
tempConvo.bNPCSees := bInvokeSight.ToBoolean;
AddLog('bInvokeSight = ' + BoolToStr(tempConvo.bNPCSees, True));
var bInvokeRadius := ConRead.ReadInteger();
tempConvo.bNPCEnters := bInvokeRadius.ToBoolean;
AddLog('bInvokeRadius = ' + BoolToStr(tempConvo.bNPCEnters, True));
var InvokeRadiusInt := ConRead.ReadInteger();
tempConvo.distance := InvokeRadiusInt;
AddLog('InvokeRadius = ' + InvokeRadiusInt.ToString);
var numFlagRefList := ConRead.ReadInteger();
AddLog('numFlagRefList = ' + numFlagRefList.ToString);
SetLength(tempConvo.conDependsOnFlags, numFlagRefList); // set array length
for var fr := 0 to numFlagRefList -1 do
begin
//tempConvo.conDependsOnFlags[fr].flagIndex := ConRead.ReadInteger();
{tempConvo.conDependsOnFlags[fr].flagIndex := }ConRead.ReadInteger();
var cfRefNameSize := ConRead.ReadInteger();
var cfRefNameBytes := ConRead.ReadBytes(cfRefNameSize);
tempConvo.conDependsOnFlags[fr].flagName := TEncoding.ANSI.GetString(cfRefNameBytes);
tempConvo.conDependsOnFlags[fr].flagIndex := frmMain.FindTableIdByName(TM_Flags, tempConvo.conDependsOnFlags[fr].flagName); // set the new proper index
var cfRefValue := ConRead.ReadInteger();
tempConvo.conDependsOnFlags[fr].flagValue := cfRefValue.ToBoolean;
var cfRefExpiration := ConRead.ReadInteger();
AddLog(#9+'conFlagRef: index = ' + tempConvo.conDependsOnFlags[fr].flagIndex.ToString +
' Name = ' + tempConvo.conDependsOnFlags[fr].flagName +
' Value = ' + BoolToStr(tempConvo.conDependsOnFlags[fr].flagValue, True) +
' Expiration = ' + cfRefExpiration.ToString);
end;
tempConvo.numEventList := ConRead.ReadInteger(); // now events...
AddLog('numEventList = ' + tempConvo.numEventList.ToString);
SetLength(tempConvo.Events, tempConvo.numEventList); // set array length
AddLog('Events:');
for var NEL := 0 to tempConvo.numEventList -1 do
begin
var tempEvent: TConEvent;
var EventIdx := ConRead.ReadInteger();
var Unknown1 := ConRead.ReadInteger();
var intEventType := ConRead.ReadInteger();
var eventLabel := GetConString(ConRead);
if intEventType = Ord(ET_Speech) then
begin
AddLog('Reading event: ET_Speech, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventSpeech.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillSpeech(ConRead, TConEventSpeech(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_Choice) then
begin
AddLog('Reading event: ET_Choice, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventChoice.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillChoice(ConRead, TConEventChoice(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_SetFlag) then
begin
AddLog('Reading event: ET_SetFlag, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventSetFlag.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillSetFlag(ConRead, TConEventSetFlag(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_CheckFlag) then
begin
AddLog('Reading event: ET_CheckFlag, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventCheckFlag.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillCheckFlag(ConRead, TConEventCheckFlag(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_CheckObject) then
begin
AddLog('Reading event: ET_CheckObject, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventCheckObject.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillCheckObject(ConRead, TConEventCheckObject(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_TransferObject) then
begin
AddLog('Reading event: ET_TransferObject, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventTransferObject.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillTransferObject(ConRead, TConEventTransferObject(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_MoveCamera) then
begin
AddLog('Reading event: ET_MoveCamera, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventMoveCamera.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillMoveCamera(ConRead, TConEventMoveCamera(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_Animation) then
begin
AddLog('Reading event: ET_Animation, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventAnimation.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillAnimation(ConRead, TConEventAnimation(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_Trade) then
begin
AddLog('Reading event: ET_Trade, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventTrade.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillTrade(ConRead, TConEventTrade(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_Jump) then
begin
AddLog('Reading event: ET_Jump, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventJump.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillJump(ConRead, TConEventJump(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_Random) then
begin
AddLog('Reading event: ET_Random, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventRandom.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillRandom(ConRead, TConEventRandom(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_Trigger) then
begin
AddLog('Reading event: ET_Trigger, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventTrigger.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillTrigger(ConRead, TConEventTrigger(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_AddGoal) then
begin
AddLog('Reading event: ET_AddGoal, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventAddGoal.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillAddGoal(ConRead, TConEventAddGoal(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_AddNote) then
begin
AddLog('Reading event: ET_AddNote, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventAddNote.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillAddNote(ConRead, TConEventAddNote(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_AddSkillPoints) then
begin
AddLog('Reading event: ET_AddSkillPoints, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventAddSkillPoints.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillAddSkillPoints(ConRead, TConEventAddSkillPoints(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_AddCredits) then
begin
AddLog('Reading event: ET_AddCredits, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventAddCredits.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillAddCredits(ConRead, TConEventAddCredits(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_CheckPersona) then
begin
AddLog('Reading event: ET_CheckPersona, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventCheckPersona.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillCheckPersona(ConRead, TConEventCheckPersona(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_Comment) then
begin
AddLog('Reading event: ET_Comment, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventComment.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillComment(ConRead, TConEventComment(tempEvent), eventLabel);
end;
if intEventType = Ord(ET_End) then
begin
AddLog('Reading event: ET_End, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
tempEvent := TConEventEnd.Create();
tempEvent.EventIdx := EventIdx;
tempEvent.unknown1 := Unknown1;
FillEnd(ConRead, TConEventEnd(tempEvent), eventLabel);
end;
tempConvo.Events[NEL] := tempEvent;
end;
if (tempConvo <> nil) then // Äîïîëíèòåëüíîå óñëîâèå
frmMain.ConversationsList.Add(tempConvo);
end;
end;
ConRead.Close();
finally
ConRead.Free();
fileStr.Free();
frmMain.PostLoadConFile(); // ñîáûòèå êîãäà âñ¸ çàãðóæåíî.
end;
end;
procedure FillTables(ConRead: TBinaryReader);
begin
with frmMain do
begin
AddLog('Reading Tables, position: 0x'+ ConRead.BaseStream.Position.ToHexString(1));
conFileParameters.TablesSize := ConRead.ReadInteger(); // size of all tables
AddLog('Tables DataSize = ' + conFileParameters.TablesSize.ToString);
// Actors...
conFileParameters.fpActors.Clear();
var numActorRecords := ConRead.ReadInteger();
for var AR := 0 to numActorRecords -1 do
begin
{var ActorIdx := }ConRead.ReadInteger();
var ActorName := GetConString(ConRead);
conFileParameters.fpActors.Add(ActorName);
//conFileParameters.fpActors.Insert(ActorIdx, ActorName);
end;
// Flags...
conFileParameters.fpFlags.Clear();
var numFlagsRecords := ConRead.ReadInteger();
for var FR := 0 to numFlagsRecords -1 do
begin
{var FlagIdx := }ConRead.ReadInteger();
var FlagName := GetConString(ConRead);
conFileParameters.fpFlags.Add(FlagName);
//conFileParameters.fpFlags.Insert(FlagIdx, FlagName);
end;
// Skills...
conFileParameters.fpSkills.Clear();
var numSkillsRecords := ConRead.ReadInteger();
for var FR := 0 to numSkillsRecords -1 do
begin
{var SkillIdx := }ConRead.ReadInteger();
var SkillName := GetConString(ConRead);
conFileParameters.fpSkills.Add(SkillName);
//conFileParameters.fpSkills.Insert(SkillIdx, SkillName);
end;
// Objects...
conFileParameters.fpObjects.Clear();
var numObjectsRecords := ConRead.ReadInteger();
for var FR := 0 to numObjectsRecords -1 do
begin
{var ObjectIdx := }ConRead.ReadInteger();
var ObjectName := GetConString(ConRead);
conFileParameters.fpObjects.Add(ObjectName);
//conFileParameters.fpObjects.Insert(ObjectIdx, ObjectName);
end;
end;
end;
procedure FillSpeech(ConRead: TBinaryReader; speechEvent: TConEventSpeech; eventLabel: string);
begin
speechEvent.EventLabel := eventLabel;
{speechEvent.ActorIndex := }ConRead.ReadInteger(); // speakerId
speechEvent.ActorValue := GetConString(ConRead); // speakerName
speechEvent.ActorIndex := frmMain.FindTableIdByName(TM_ActorsPawns, speechEvent.ActorValue);
frmMain.AddLog('EventLabel:' + eventLabel + ' Speaker: '+ speechEvent.ActorValue + ' id: ' + speechEvent.ActorIndex.ToString);
{speechEvent.ActorToIndex := }ConRead.ReadInteger(); // speakingTo id
speechEvent.ActorToValue := GetConString(ConRead); // speakingTo Name
speechEvent.ActorToIndex := frmMain.FindTableIdByName(TM_ActorsPawns, speechEvent.ActorToValue);
frmMain.AddLog('SpeakingTo: '+ speechEvent.ActorToValue + ' id: ' + speechEvent.ActorToIndex.ToString);
speechEvent.TextLine := GetConString(ConRead); // speech text
speechEvent.LineWrapCount := frmMain.CountLineWraps(speechEvent.TextLine);
frmMain.AddLog('Speech Text: "' + speechEvent.TextLine + '"');
speechEvent.mp3File := GetConString(ConRead); // sound path
frmMain.AddLog('soundFile: "' + speechEvent.mp3File + '"');
speechEvent.bContinued := GetConLongBool(ConRead);
frmMain.AddLog('bContinued = ' + BoolToStr(speechEvent.bContinued, True));
speechEvent.bBold := GetConLongBool(ConRead);
frmMain.AddLog('bBold = ' + BoolToStr(speechEvent.bBold, True));
speechEvent.SpeechFont := ConRead.ReadInteger();
frmMain.AddLog('SpeechFont = ' + speechEvent.SpeechFont.ToString);
speechEvent.LineWrapCount := frmMain.CountLineWraps(speechEvent.TextLine);
end;
procedure FillChoice(ConRead: TBinaryReader; choiceEvent: TConEventChoice; eventLabel: string);
begin
choiceEvent.EventLabel := eventLabel;
frmMain.AddLog('choice Label = ' + choiceEvent.EventLabel);
choiceEvent.choice_unk0 := ConRead.ReadInteger(); // choice_unk0
frmMain.AddLog('choice unk0 = ' + choiceEvent.choice_unk0.ToString);
choiceEvent.bClearScreen := GetConLongBool(ConRead);
frmMain.AddLog('choice bClearScreen = ' + BoolToStr(choiceEvent.bClearScreen, True));
choiceEvent.NumChoices := ConRead.ReadInteger();
choiceEvent.NumFlagsRefs := choiceEvent.NumChoices; // for event item height
frmMain.AddLog('choice NumChoices = ' + choiceEvent.NumChoices.ToString);
SetLength(choiceEvent.Choices, choiceEvent.NumChoices);
for var cl := 0 to choiceEvent.NumChoices -1 do
begin
choiceEvent.Choices[cl] := TChoiceItemObject.Create(); // create choice item object
choiceEvent.Choices[cl].Index := ConRead.ReadInteger();
frmMain.AddLog('Choice item: index = ' + choiceEvent.Choices[cl].Index.ToString);
choiceEvent.Choices[cl].textline := GetConString(ConRead);
frmMain.AddLog('Choice item: text = ' + choiceEvent.Choices[cl].textline);
choiceEvent.Choices[cl].bDisplayAsSpeech := GetConLongBool(ConRead);
frmMain.AddLog('Choice item: bDisplayAsSpeech = ' + BoolToStr(choiceEvent.Choices[cl].bDisplayAsSpeech, True));
var skillNameId := ConRead.ReadInteger();
frmMain.AddLog('Choice item: SkillNameId = ' + skillnameid.ToString);
if skillNameId = -1 then // Skill is NOT required
begin
choiceEvent.Choices[cl].bSkillNeeded := skillNameId; // for XML version
frmMain.AddLog('bSkillNeeded = ' + choiceEvent.Choices[cl].bSkillNeeded.ToString);
choiceEvent.Choices[cl].GoToLabel := GetConString(ConRead); //choice Label
choiceEvent.Choices[cl].mp3 := GetConString(ConRead); // soundPath
var numFlagRefList := ConRead.ReadInteger(); // numFlagRefList
SetLength(choiceEvent.Choices[cl].RequiredFlags, numFlagRefList); // Set array size
for var FLR := 0 to numFlagRefList -1 do // flags, required by this choice
begin
choiceEvent.Choices[cl].RequiredFlags[FLR].flagIndex := ConRead.ReadInteger();
choiceEvent.Choices[cl].RequiredFlags[FLR].flagName := GetConString(ConRead);
choiceEvent.Choices[cl].RequiredFlags[FLR].flagValue := GetConLongBool(ConRead);
choiceEvent.Choices[cl].RequiredFlags[FLR].flagExpiration := ConRead.ReadInteger();
end;
end;
if skillNameId >= 0 then // Requires skill. Did anyone ever used this feature?
begin
choiceEvent.Choices[cl].Skill := GetConString(ConRead);
choiceEvent.Choices[cl].SkillLevel := ConRead.ReadInteger();
choiceEvent.Choices[cl].GoToLabel := GetConString(ConRead);
choiceEvent.Choices[cl].mp3 := GetConString(ConRead);
var numFlagRefList1 := ConRead.ReadInteger();
SetLength(choiceEvent.Choices[cl].RequiredFlags, numFlagRefList1);
for var FLR1 := 0 to numFlagRefList1 -1 do // flags, required by this choice
begin
choiceEvent.Choices[cl].RequiredFlags[FLR1].flagIndex := ConRead.ReadInteger();
choiceEvent.Choices[cl].RequiredFlags[FLR1].flagName := GetConString(ConRead);
choiceEvent.Choices[cl].RequiredFlags[FLR1].flagValue := GetConLongBool(ConRead);
choiceEvent.Choices[cl].RequiredFlags[FLR1].flagExpiration := ConRead.ReadInteger();
end;
end;
end;
end;
procedure FillSetFlag(ConRead: TBinaryReader; setFlagEvent: TConEventSetFlag; eventLabel: string);
begin
setFlagEvent.EventLabel := eventLabel;
var numFlags := ConRead.ReadInteger();
setFlagEvent.numFlags := numFlags;
SetLength(setFlagEvent.SetFlags, numFlags);
for var SF := 0 to numFlags -1 do
begin
{setFlagEvent.SetFlags[SF].flagIndex := }ConRead.ReadInteger();
setFlagEvent.SetFlags[SF].flagName := GetConString(ConRead);
setFlagEvent.SetFlags[SF].flagIndex := frmMain.FindTableIdByName(TM_Flags, setFlagEvent.SetFlags[SF].flagName);
setFlagEvent.SetFlags[SF].flagValue := GetConLongBool(ConRead);
setFlagEvent.SetFlags[SF].flagExpiration := ConRead.ReadInteger();
end;
end;
procedure FillCheckFlag(ConRead: TBinaryReader; checkFlagEvent: TConEventCheckFlag; eventLabel: string);
begin
checkFlagEvent.EventLabel := eventLabel;
var numFlags := ConRead.ReadInteger();
checkFlagEvent.numFlags := numFlags;
SetLength(checkFlagEvent.FlagsToCheck, numFlags);
for var CF := 0 to numFlags -1 do
begin
{checkFlagEvent.FlagsToCheck[CF].flagIndex := }ConRead.ReadInteger();
checkFlagEvent.FlagsToCheck[CF].flagName := GetConString(ConRead);
checkFlagEvent.FlagsToCheck[CF].flagIndex := frmMain.FindTableIdByName(TM_Flags, checkFlagEvent.FlagsToCheck[CF].flagName);
checkFlagEvent.FlagsToCheck[CF].flagValue := GetConLongBool(ConRead);
checkFlagEvent.FlagsToCheck[CF].flagExpiration := ConRead.ReadInteger();
end;
checkFlagEvent.GotoLabel := GetConString(ConRead);
end;
procedure FillCheckObject(ConRead: TBinaryReader; checkObjectEvent: TConEventCheckObject; eventLabel: string);
begin
checkObjectEvent.EventLabel := eventLabel;
{checkObjectEvent.ObjectIndex :=} ConRead.ReadInteger(); // id
checkObjectEvent.ObjectValue := GetConString(ConRead); // string: size and data
checkObjectEvent.ObjectIndex := frmMain.FindTableIdByName(TM_Objects, checkObjectEvent.ObjectValue);
checkObjectEvent.GoToLabel := GetConString(ConRead); // failLabel
end;
procedure FillTransferObject(ConRead: TBinaryReader; transferObjectEvent: TConEventTransferObject; eventLabel: string);
begin
transferObjectEvent.EventLabel := eventLabel;
{transferObjectEvent.ObjectIndex := }ConRead.ReadInteger(); //objectName/id
transferObjectEvent.ObjectValue := GetConString(ConRead); // objectName/name
transferObjectEvent.ObjectIndex := frmMain.FindTableIdByName(TM_Objects, transferObjectEvent.ObjectValue);
transferObjectEvent.Amount := ConRead.ReadInteger(); // TransferCountOpt (?)
frmMain.AddLog('TransferCountOpt = ' + transferObjectEvent.Amount.ToString);
{transferObjectEvent.ActorFromIndex := }ConRead.ReadInteger(); // fromName/id
transferObjectEvent.ActorFromValue := GetConString(ConRead); // fromName/name
transferObjectEvent.ActorFromIndex := frmMain.FindTableIdByName(TM_ActorsPawns, transferObjectEvent.ActorFromValue);
{transferObjectEvent.ActorToIndex := }ConRead.ReadInteger(); // toName/id
transferObjectEvent.ActorToValue := GetConString(ConRead); // toName/value
transferObjectEvent.ActorToIndex := frmMain.FindTableIdByName(TM_ActorsPawns, transferObjectEvent.ActorToValue);
transferObjectEvent.GotoLabel := GetConString(ConRead); // failLabel
frmMain.addlog('failLabel = ' + transferObjectEvent.GotoLabel);
end;
procedure FillMoveCamera(ConRead: TBinaryReader; moveCameraEvent: TConEventMoveCamera; eventLabel: string);
begin
moveCameraEvent.EventLabel := eventLabel;
moveCameraEvent.CameraType := TCameraTypes(ConRead.ReadInteger());
frmMain.AddLog('Camera Type: ' + GetEnumName(TypeInfo(TCameraTypes), Ord(moveCameraEvent.CameraType)));
moveCameraEvent.CameraAngle := TCameraPositions(ConRead.ReadInteger());
frmMain.AddLog('Camera Angle: ' + GetEnumName(TypeInfo(TCameraPositions), Ord(moveCameraEvent.CameraAngle)));
var CamTransitionStub := ConRead.ReadInteger();
frmMain.AddLog('CamTransitionStub = ' + CamTransitionStub.ToString);
end;
procedure FillAnimation(ConRead: TBinaryReader; animEvent: TConEventAnimation; eventLabel: string);
var
TempAnimPlayMode: LongBool;
begin
animEvent.EventLabel := eventLabel;
{animEvent.ActorIndex := }ConRead.ReadInteger();
animEvent.ActorValue := GetConString(ConRead);
animEvent.ActorIndex := frmMain.FindTableIdByName(TM_ActorsPawns, animEvent.ActorValue);
animEvent.AnimSequence := GetConString(ConRead);
// Once = 0, Loop = 1
//animEvent.bAnimPlayOnce := not GetConLongBool(ConRead); // Invert the value, so it will look correctly for user.
//animEvent.bAnimPlayOnce := GetConLongBool(ConRead);
TempAnimPlayMode := GetConLongBool(ConRead);
//var NewTemp := TempAnimPlayMode;
case TempAnimPlayMode of
False: animEvent.AnimPlayMode := AM_Loop;
True: animEvent.AnimPlayMode := AM_Once;
end;
//animEvent.AnimPlayMode := TAnimationModes(ConRead.ReadInteger());
animEvent.AnimPlayForSeconds := ConRead.ReadInteger();
animEvent.bAnimWaitToFinish := GetConLongBool(ConRead);
end;
procedure FillTrade(ConRead: TBinaryReader; eventTrade: TConEventTrade; eventLabel: string);
begin
eventTrade.EventLabel := eventLabel;
{eventTrade.TradeActorIndex := }ConRead.ReadInteger();
eventTrade.TradeActorValue := GetConString(ConRead);
eventTrade.TradeActorIndex := frmMain.FindTableIdByName(TM_ActorsPawns, eventTrade.TradeActorValue);
end;
procedure FillJump(ConRead: TBinaryReader; eventJump: TConEventJump; eventLabel: string);
begin
eventJump.EventLabel := eventLabel;
eventJump.gotoLabel := GetConString(ConRead);
eventJump.conversationId := ConRead.ReadInteger();
end;
procedure FillRandom(ConRead: TBinaryReader; eventRandom: TConEventRandom; eventLabel: string);
begin
eventRandom.EventLabel := eventLabel;
eventRandom.numLabels := ConRead.ReadInteger();
SetLength(eventRandom.GoToLabels, eventRandom.numLabels);
for var RL := 0 to eventRandom.numLabels -1 do // labels
begin
eventRandom.GoToLabels[RL] := GetConString(ConRead);
end;
eventRandom.bCycle := GetConLongBool(ConRead);
eventRandom.bCycleOnce := GetConLongBool(ConRead);
eventRandom.bCycleRandom := GetConLongBool(ConRead);
end;
procedure FillTrigger(ConRead: TBinaryReader; eventTrigger: TConEventTrigger; eventLabel: string);
begin
eventTrigger.EventLabel := eventLabel;
eventTrigger.TriggerTag := GetConString(ConRead);
end;
procedure FillAddGoal(ConRead: TBinaryReader; eventAddGoal: TConEventAddGoal; eventLabel: string);
begin
eventAddGoal.EventLabel := eventLabel;
eventAddGoal.GoalName := GetConString(ConRead); // goalNameString
eventAddGoal.bComplete := GetConLongBool(ConRead);
if eventAddGoal.bComplete = True then // Åñëè öåëü âûïîëíåíà, òî äàëüøå äàííûõ óæå íåò, âûõîäèì
Exit();
eventAddGoal.GoalText := GetConString(ConRead);
eventAddGoal.bPrimaryGoal := GetConLongBool(ConRead);
// eventAddGoal.LineWrapCount := frmMain.CountLineWraps(eventAddGoal.GoalText);
end;
procedure FillAddNote(ConRead: TBinaryReader; eventAddNote: TConEventAddNote; eventLabel: string);
begin
eventAddNote.EventLabel := eventLabel;
eventAddNote.TextLine := GetConString(ConRead);
end;
procedure FillAddSkillPoints(ConRead: TBinaryReader; eventAddSkillPts: TConEventAddSkillPoints; eventLabel: string);
begin
eventAddSkillPts.EventLabel := eventLabel;
eventAddSkillPts.Points := ConRead.ReadInteger(); // pointsToAdd
eventAddSkillPts.TextLine := GetConString(ConRead);
end;
procedure FillAddCredits(ConRead: TBinaryReader; eventAddCredits: TConEventAddCredits; eventLabel: string);
begin
eventAddCredits.EventLabel := eventLabel;
eventAddCredits.Credits := ConRead.ReadInteger(); // creditsToAdd
end;
procedure FillCheckPersona(ConRead: TBinaryReader; eventCheckPersona: TConEventCheckPersona; eventLabel: string);
begin
eventCheckPersona.EventLabel := eventLabel;
eventCheckPersona.AttrToCheck := TPersonaTypes(ConRead.ReadInteger()); // personaType
eventCheckPersona.Condition := TConditions(ConRead.ReadInteger());
eventCheckPersona.CheckValue := ConRead.ReadInteger();
eventCheckPersona.CheckGoToLabel := GetConString(ConRead); // jumpLabel
end;
procedure FillComment(ConRead: TBinaryReader; eventComment: TConEventComment; eventLabel: string);
begin
eventComment.EventLabel := eventLabel;
eventComment.TextLine := GetConString(ConRead);
end;
procedure FillEnd(ConRead: TBinaryReader; eventEnd: TConEventEnd; eventLabel: string);
begin
eventEnd.EventLabel := eventLabel;
end;
end.