-
Notifications
You must be signed in to change notification settings - Fork 3
/
MainWindow.pas
8017 lines (6628 loc) · 309 KB
/
MainWindow.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 MainWindow;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Forms, Vcl.Controls, Vcl.Dialogs, Vcl.Menus, Vcl.ExtCtrls, Vcl.StdCtrls, ConEditPlus.Consts,
system.UITypes, Vcl.ComCtrls, System.Types, Vcl.Buttons, Vcl.ToolWin, System.IniFiles, System.IOUtils,
Conversation.Classes, System.ImageList, Vcl.ImgList, Table, Vcl.GraphUtil, ES.BaseControls, ES.Layouts,
System.Actions, Vcl.ActnList, System.Generics.Collections, System.TypInfo, xml.VerySimple, System.StrUtils,
system.Math, Vcl.MPlayer, ConEditPlus.Enums, Winapi.ShellAPI, ConEditPlus.Helpers, Vcl.Clipbrd, system.Rtti,
ConEditPlus.Clipboard.Helper, ConEditPlus.Templates.Factory, Vcl.AppEvnts, System.Threading,
system.DateUtils, vcl.Styles, vcl.Themes, ConEditPlus.Colors;
type
TfrmMain = class(TForm)
PopupTree: TPopupMenu;
MenuMain: TMainMenu;
File1: TMenuItem;
TablesMenu: TMenuItem;
View1: TMenuItem;
mnuHelp: TMenuItem;
Open1: TMenuItem;
New1: TMenuItem;
Close1: TMenuItem;
N1: TMenuItem;
Save1: TMenuItem;
SaveAs1: TMenuItem;
N2: TMenuItem;
ConvoProperties: TMenuItem;
mniRecent: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
Exit1: TMenuItem;
ActorsPawns1: TMenuItem;
Flags1: TMenuItem;
Skills1: TMenuItem;
Objects1: TMenuItem;
mnuToggleMainToolBar: TMenuItem;
mnuStatusbar: TMenuItem;
mnuShowAudioFiles1: TMenuItem;
PopupConvoEventList: TPopupMenu;
pnlConvoTree: TEsPanel;
Splitter1: TSplitter;
ConvoTree: TTreeView;
Add2: TMenuItem;
Insert2: TMenuItem;
Edit1: TMenuItem;
Delete1: TMenuItem;
N11: TMenuItem;
Cut3: TMenuItem;
Copy3: TMenuItem;
PasteConvoEvent: TMenuItem;
Speech1: TMenuItem;
Choice1: TMenuItem;
Setflag1: TMenuItem;
Checkflag1: TMenuItem;
CheckObject1: TMenuItem;
TransferObject1: TMenuItem;
MoveCamera1: TMenuItem;
PlayAnimation1: TMenuItem;
BuySellTrade1: TMenuItem;
Jump1: TMenuItem;
Random1: TMenuItem;
Trigger1: TMenuItem;
AddCompleteGoal1: TMenuItem;
AddNote1: TMenuItem;
AddSkillPoints1: TMenuItem;
AddCredits1: TMenuItem;
CheckPersona1: TMenuItem;
Comment1: TMenuItem;
End1: TMenuItem;
Speech2: TMenuItem;
Choice2: TMenuItem;
Setflag2: TMenuItem;
Checkflag2: TMenuItem;
CheckObject2: TMenuItem;
TransferObject2: TMenuItem;
MoveCamera2: TMenuItem;
PlayAnimation2: TMenuItem;
BuySellTrade2: TMenuItem;
Jump2: TMenuItem;
Random2: TMenuItem;
Trigger2: TMenuItem;
AddCompleteGoal2: TMenuItem;
AddNote2: TMenuItem;
AddSkillPoints2: TMenuItem;
AddCredits2: TMenuItem;
CheckPersona2: TMenuItem;
Comment2: TMenuItem;
End2: TMenuItem;
Add3: TMenuItem;
Delete2: TMenuItem;
N12: TMenuItem;
Cut4: TMenuItem;
Copy4: TMenuItem;
Paste4: TMenuItem;
N13: TMenuItem;
menuConvoProperties: TMenuItem;
N14: TMenuItem;
TreeExpandAll: TMenuItem;
CollapseAll2: TMenuItem;
ImageListToolbar: TImageList;
N15: TMenuItem;
About1: TMenuItem;
StatusBar: TStatusBar;
MenusImageList: TImageList;
N16: TMenuItem;
Darkmode1: TMenuItem;
FileOpenDialog: TFileOpenDialog;
TreeImages: TImageList;
ConEventList: TListBox;
HeaderControl1: THeaderControl;
Options1: TMenuItem;
RecentFile0: TMenuItem;
RecentFile1: TMenuItem;
RecentFile2: TMenuItem;
RecentFile3: TMenuItem;
RecentFile4: TMenuItem;
RecentFile5: TMenuItem;
RecentFile6: TMenuItem;
RecentFile7: TMenuItem;
mnuGithub: TMenuItem;
pnlEventList: TEsPanel;
ActionList1: TActionList;
FileOpen: TAction;
FileNew: TAction;
FileClose: TAction;
FileSave: TAction;
FileSaveAs: TAction;
FileGenerateAudioNames: TAction;
FileProperties: TAction;
AddConversation: TAction;
Conversation_Delete: TAction;
Conversation_Cut: TAction;
Conversation_Copy: TAction;
Conversation_Paste: TAction;
Conversation_Properties: TAction;
Conversation_Find: TAction;
Event_Add: TAction;
Event_Insert: TAction;
Event_Cut: TAction;
Event_Copy: TAction;
Event_Paste: TAction;
Event_Delete: TAction;
ShowOptions: TAction;
FileSaveDialog: TFileSaveDialog;
N18: TMenuItem;
ViewoutputTMemo1: TMenuItem;
mmoOutput: TMemo;
pmOutput: TPopupMenu;
ConFileParameters1: TMenuItem;
Clear1: TMenuItem;
ConversationsListCount1: TMenuItem;
IndexEvents1: TMenuItem;
btnCloseLog: TButton;
N19: TMenuItem;
ClearForNewFile1: TMenuItem;
CreateTestFile1: TMenuItem;
tmrEventWinPosSync: TTimer;
DateTimeToDouble1: TMenuItem;
EventListItems1: TMenuItem;
CurrentConversationEvents1: TMenuItem;
SelectDirDialog: TFileOpenDialog;
mainToolBar: TToolBar;
tbNewConversationFile: TToolButton;
tbOpenFile: TToolButton;
tbSaveFile: TToolButton;
ToolButton4: TToolButton;
tbCloseFile: TToolButton;
ToolButton8: TToolButton;
tbPrint: TToolButton;
ToolButton9: TToolButton;
tbSearch: TToolButton;
ToolButton11: TToolButton;
tbProperties: TToolButton;
ToolButton7: TToolButton;
tbGenAudio: TToolButton;
tbGenerateAudioDirs: TToolButton;
ToolButton6: TToolButton;
tbSettings: TToolButton;
ToolButton2: TToolButton;
btnReorder: TToolButton;
ToolButton3: TToolButton;
tbStickyWindow: TToolButton;
ToolButton1: TToolButton;
btnViewLog: TToolButton;
StaticText1: TStaticText;
EsPanel1: TEsPanel;
edtSearchBox: TEdit;
Conversation_CheckLabels: TAction;
tbVerifyLabels: TToolButton;
ToolButton12: TToolButton;
lblQSearch: TLabel;
N5: TMenuItem;
Duplicate1: TMenuItem;
Event_Duplicate: TAction;
N6: TMenuItem;
ExpandTreeWithoutFlags: TMenuItem;
Conversation_Rename: TAction;
ConversationRename1: TMenuItem;
ImageListToolbar_Hot: TImageList;
ImageList_Toolbar_Disabled: TImageList;
N7: TMenuItem;
GenAudiofilenames: TMenuItem;
AutoSaveTimer: TTimer;
lblSelectedEvent: TLabel;
mnuAITools: TMenuItem;
CopySpeechtext1: TMenuItem;
Event_CopySpeechText: TAction;
Event_CopyMp3FileAndPath: TAction;
Copymp3filepath1: TMenuItem;
Event_CopyMp3FilePath: TAction;
Event_CopyMp3File: TAction;
EventCopyMp3File1: TMenuItem;
Copymp3path1: TMenuItem;
N9: TMenuItem;
OpenExplorerforthisevent1: TMenuItem;
Event_BrowseTo: TAction;
CheckDpiRatio: TMenuItem;
N10: TMenuItem;
Copyalltext1: TMenuItem;
SimulateDEED: TMenuItem;
edtConvoTreeQSearch: TEdit;
N20: TMenuItem;
mnuChoiceItemSub0: TMenuItem;
mnuChoiceItemSub1: TMenuItem;
mnuChoiceItemSub2: TMenuItem;
mnuChoiceItemSub3: TMenuItem;
mnuChoiceItemSub4: TMenuItem;
mnuChoiceItemSub5: TMenuItem;
mnuChoiceItemSub6: TMenuItem;
mnuChoiceItemSub7: TMenuItem;
mnuChoiceItemSub8: TMenuItem;
mnuChoiceItemSub9: TMenuItem;
Copymp3pathfilename1: TMenuItem;
CopyonlyPathtomp31: TMenuItem;
Copyonlymp3filename1: TMenuItem;
Copymp3pathfilename2: TMenuItem;
CopyonlyPathtomp32: TMenuItem;
Copyonlymp3filename2: TMenuItem;
Copymp3pathfilename3: TMenuItem;
CopyonlyPathtomp33: TMenuItem;
Copyonlymp3filename3: TMenuItem;
Copymp3pathfilename4: TMenuItem;
CopyonlyPathtomp34: TMenuItem;
Copyonlymp3filename4: TMenuItem;
Copymp3pathfilename5: TMenuItem;
CopyonlyPathtomp35: TMenuItem;
Copyonlymp3filename5: TMenuItem;
Copymp3pathfilename6: TMenuItem;
CopyonlyPathtomp36: TMenuItem;
Copyonlymp3filename6: TMenuItem;
Copymp3pathfilename7: TMenuItem;
CopyonlyPathtomp37: TMenuItem;
Copyonlymp3filename7: TMenuItem;
Copymp3pathfilename8: TMenuItem;
CopyonlyPathtomp38: TMenuItem;
Copyonlymp3filename8: TMenuItem;
Copymp3pathfilename9: TMenuItem;
CopyonlyPathtomp39: TMenuItem;
Copyonlymp3filename9: TMenuItem;
Copymp3pathfilename10: TMenuItem;
CopyonlyPathtomp310: TMenuItem;
Copyonlymp3filename10: TMenuItem;
N21: TMenuItem;
CopyChoicetext1: TMenuItem;
CopyChoicetext2: TMenuItem;
N22: TMenuItem;
CopyChoicetext3: TMenuItem;
N23: TMenuItem;
CopyChoicetext4: TMenuItem;
N24: TMenuItem;
CopyChoicetext5: TMenuItem;
N25: TMenuItem;
CopyChoicetext6: TMenuItem;
N26: TMenuItem;
CopyChoicetext7: TMenuItem;
N27: TMenuItem;
CopyChoicetext8: TMenuItem;
N28: TMenuItem;
CopyChoicetext9: TMenuItem;
N29: TMenuItem;
CopyChoicetext10: TMenuItem;
N30: TMenuItem;
btnStartSearch: TButton;
mnuCharcoalDarkSlate: TMenuItem;
mnuLunaTheme: TMenuItem;
mnuSilverTheme: TMenuItem;
mnuSystemTheme: TMenuItem;
mnuOnyxBlueTheme: TMenuItem;
N31: TMenuItem;
N32: TMenuItem;
N33: TMenuItem;
SpeechGeneratortest1: TMenuItem;
ApplicationEvents1: TApplicationEvents;
mnuChoiceItemSub10: TMenuItem;
Copyonlymp3filename11: TMenuItem;
CopyonlyPathtomp311: TMenuItem;
Copymp3pathfilename11: TMenuItem;
N34: TMenuItem;
CopyChoicetext11: TMenuItem;
mnuChoiceItemSub11: TMenuItem;
Copyonlymp3filename12: TMenuItem;
CopyonlyPathtomp312: TMenuItem;
Copymp3pathfilename12: TMenuItem;
N35: TMenuItem;
CopyChoicetext12: TMenuItem;
mnuChoiceItemSub12: TMenuItem;
Copyonlymp3filename13: TMenuItem;
CopyonlyPathtomp313: TMenuItem;
Copymp3pathfilename13: TMenuItem;
N36: TMenuItem;
CopyChoicetext13: TMenuItem;
mnuChoiceItemSub13: TMenuItem;
Copyonlymp3filename14: TMenuItem;
CopyonlyPathtomp314: TMenuItem;
Copymp3pathfilename14: TMenuItem;
N37: TMenuItem;
CopyChoicetext14: TMenuItem;
mnuChoiceItemSub14: TMenuItem;
Copyonlymp3filename15: TMenuItem;
CopyonlyPathtomp315: TMenuItem;
Copymp3pathfilename15: TMenuItem;
N38: TMenuItem;
CopyChoicetext15: TMenuItem;
mnuCopyConvoTextSub: TMenuItem;
Wholeconversation1: TMenuItem;
Withchoicesifany1: TMenuItem;
Wholeconversation2: TMenuItem;
Partial1: TMenuItem;
Alllinesofselectedspeaker1: TMenuItem;
tbViewConeventJump: TToolButton;
pnlTreeSearch: TEsPanel;
lbTreeSearchResults: TListBox;
chkTreeSearchExactMatch: TCheckBox;
Conversation_Create_AIBark_Template: TAction;
AddTemplateConversation1: TMenuItem;
AddAIBarktemplateconversation1: TMenuItem;
Conversation_Create_AIBarkFutz_Template: TAction;
emplateforAIBarkFutz1: TMenuItem;
N8: TMenuItem;
Testfactory1: TMenuItem;
Defaultrecordvalue1: TMenuItem;
pnlEventFilter: TEsPanel;
grpEventFilter: TGroupBox;
chkSpeech: TCheckBox;
chkChoice: TCheckBox;
chkComment: TCheckBox;
chkTransferObject: TCheckBox;
chkTrigger: TCheckBox;
chkRandom: TCheckBox;
chkCheckObject: TCheckBox;
chkTrade: TCheckBox;
chkAnimation: TCheckBox;
chkAddGoal: TCheckBox;
chkSetFlag: TCheckBox;
chkAddCredits: TCheckBox;
chkCheckPersona: TCheckBox;
chkCheckFlag: TCheckBox;
chkMoveCamera: TCheckBox;
chkJump: TCheckBox;
chkAddSkillPoints: TCheckBox;
chkAddNote: TCheckBox;
btnDisplayAllEvents: TButton;
btnOnlyTextEvents: TButton;
chkEnd: TCheckBox;
chkEventIdx: TCheckBox;
Setfilter1: TMenuItem;
btnApplyFilter: TButton;
procedure mnuToggleMainToolBarClick(Sender: TObject);
procedure mnuStatusbarClick(Sender: TObject);
procedure PopupTreePopup(Sender: TObject);
procedure PopupConvoEventListPopup(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure AddEvent(TargetPage: Integer); // Add event to end
procedure InsertEvent(TargetPage: Integer); // Insert event at current position in the list
procedure EditCurrentEvent(EventToEdit: TConEvent);
procedure ToggleLV_FlagValue(lstv: TListView);
procedure ApplyStyle(styleName: string);
procedure SetEventsListScrollbars();
procedure SendStringToEditValue(control: TControl);
procedure FillEventLabels(const con: TConversation; listToFill: TCustomListControl);
function GetAppVersionStr(): string; //https://delphihaven.wordpress.com/2012/12/08/retrieving-the-applications-version-string/
function HasConvoEventToPaste(): Boolean;
function HasConversationToPaste(): Boolean;
function GetReorderButtonHint(): string;
function CountLineWraps(str: string): Integer;
function CanRenameConversation(convoName: string): Boolean;
function GetSetFlagsItemHeight(events: array of TConEvent): Integer;
function GetCheckFlagsItemHeight(events: array of TConEvent): Integer;
function GetSpeechEventItemHeight(events: array of TConEvent): Integer;
function GetChoiceItemHeight(events: array of TConEvent): Integer;
function GetRandomEventItemHeight(events: array of TConEvent): Integer;
function GetAddGoalItemHeight(events: array of TConEvent): Integer;
function GetAddNoteItemHeight(events: array of TConEvent): Integer;
function GetAddSkillPtsItemHeight(events: array of TConEvent): Integer;
function GetCommentItemHeight(events: array of TConEvent): Integer;
function FindConversationObjByString(conName: string): TConversation; // Find conversation by name return as TObject
function FindConversationObjById(idToLookFor: Integer): TConversation; // Returns object
function FindConversationById(id: Integer): string; // Find conversation by id and return it's name as string;
function FindTableIdByName(tableMode: TTableMode; NameToLookFor: string): Integer;
function FindTableNameById(tableMode: TTableMode; idToLookFor: Integer): String;
function TreeHasItemsOfLevel(Tree: TTreeView; LevelToCheck: Integer): Boolean;
function ItemExistsInTreeView(TreeView: TTreeView; ItemText: string): Boolean;
function FindConvoOwnerInTree(OwnerName: string): TTreeNode;
function FindConversationInTree(ConName: string): TTreeNode;
function CheckLabelExistInConversation(labelName: string): Boolean; // Check if event label already exists
function bIsEventFilterActive(): Boolean;
procedure SelectTreeItemByObject(TreeView: TTreeView; Obj: TObject);
procedure SelectEventByObject(obj: TObject);
procedure SetMemoFont(FontSize: Integer; FontName: string);
procedure PickTableObject(newTableMode: TTableMode; control: TControl);
procedure FirstTimeLaunch();
procedure CreateConFile(bCreatingNew: Boolean);
procedure ClearForNewFile();
procedure GenerateAudioFileNames();
procedure SetEventIndexes();
// loading and saving configuration file
procedure LoadCfg();
procedure SaveCfg();
procedure AddRecentFile(aFile: string); // add opened file to "recent" list
procedure ClearRecentFiles();
procedure OpenRecentFile(aFile: string);
procedure LoadConXMLFile(aFileName: string);
procedure BuildConvoTree();
procedure ProcessCommandline(const cmdLine: string);
procedure UpdateEventListHeights();
procedure UpdateEventListFixedHeights();
// Events Filter
procedure ResetEventFilter();
procedure ApplyEventFilter();
procedure LoadFilters(); // Set checkboxes.Checked from variables
procedure AddLog(msg: string);
procedure DeleteCurrentEvent();
procedure DeleteCurrentConversation();
procedure CreateObjectLists();
procedure ToggleMenusPanels(bVisible: Boolean);
// to draw special items...
procedure DrawET_Speech(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_Choice(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_SetFlag(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_CheckFlag(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_CheckObject(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_TransferObject(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_MoveCamera(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_Animation(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_Trade(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_Jump(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_Random(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_Trigger(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_AddGoal(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_AddNote(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_AddSkillPoints(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_AddCredits(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_CheckPersona(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_Comment(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure DrawET_End(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure ToggleEventIdx();
// to highlight events
procedure HighlightSelectedEvent(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure HighlightEvents(labelStr: string);
procedure HighlightRelatedEvents();
procedure UnhighlightRelatedEvents();
// To copy/paste events
procedure CopyEventToClipboard(var Event: TConEvent);
procedure PasteEventFromClipboard();
// to copy/paste conversations
procedure CopyConversationToClipboard(const Convo: TConversation);
procedure PasteConversationFromClipboard();
// To duplicate selected event
procedure CopyEventFields(Source, Dest: TConEvent);
procedure CopyChoiceItems(Source, Dest: TConEventChoice);
// To expand tree without flags
procedure ExpandTreeViewToLevel(TreeView: TTreeView; Level: Integer);
// to load file using drag and drop
procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
procedure CopyChoiceMp3Path(ChoiceMP3CopyMode: TChoiceMP3CopyMode; idx: Integer);
procedure CreateAIBarksExample(bBarkFutz: Boolean);
procedure FormResize(Sender: TObject);
procedure CollapseAll2Click(Sender: TObject);
procedure ConvoTreeEditing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean);
procedure Speech1Click(Sender: TObject);
procedure Choice1Click(Sender: TObject);
procedure Setflag1Click(Sender: TObject);
procedure Checkflag1Click(Sender: TObject);
procedure CheckObject1Click(Sender: TObject);
procedure TransferObject1Click(Sender: TObject);
procedure MoveCamera1Click(Sender: TObject);
procedure PlayAnimation1Click(Sender: TObject);
procedure BuySellTrade1Click(Sender: TObject);
procedure Jump1Click(Sender: TObject);
procedure Random1Click(Sender: TObject);
procedure Trigger1Click(Sender: TObject);
procedure AddCompleteGoal1Click(Sender: TObject);
procedure AddNote1Click(Sender: TObject);
procedure AddSkillPoints1Click(Sender: TObject);
procedure AddCredits1Click(Sender: TObject);
procedure CheckPersona1Click(Sender: TObject);
procedure Comment1Click(Sender: TObject);
procedure End1Click(Sender: TObject);
procedure Speech2Click(Sender: TObject);
procedure Choice2Click(Sender: TObject);
procedure Setflag2Click(Sender: TObject);
procedure Checkflag2Click(Sender: TObject);
procedure CheckObject2Click(Sender: TObject);
procedure TransferObject2Click(Sender: TObject);
procedure MoveCamera2Click(Sender: TObject);
procedure PlayAnimation2Click(Sender: TObject);
procedure BuySellTrade2Click(Sender: TObject);
procedure Jump2Click(Sender: TObject);
procedure Random2Click(Sender: TObject);
procedure Trigger2Click(Sender: TObject);
procedure AddCompleteGoal2Click(Sender: TObject);
procedure AddNote2Click(Sender: TObject);
procedure AddSkillPoints2Click(Sender: TObject);
procedure AddCredits2Click(Sender: TObject);
procedure CheckPersona2Click(Sender: TObject);
procedure Comment2Click(Sender: TObject);
procedure End2Click(Sender: TObject);
procedure ActorsPawns1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Flags1Click(Sender: TObject);
procedure Skills1Click(Sender: TObject);
procedure Objects1Click(Sender: TObject);
procedure Add3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure MenuMainChange(Sender: TObject; Source: TMenuItem; Rebuild: Boolean);
procedure About1Click(Sender: TObject);
procedure HeaderControl1DrawSection(HeaderControl: THeaderControl; Section: THeaderSection; const Rect: TRect;Pressed: Boolean);
procedure HeaderControl1SectionResize(HeaderControl: THeaderControl; Section: THeaderSection);
procedure ConEventListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure ConEventListMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer);
procedure Splitter1Moved(Sender: TObject);
procedure ConEventListClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure mnuShowAudioFiles1Click(Sender: TObject);
procedure RecentFile0Click(Sender: TObject);
procedure ConEventListDblClick(Sender: TObject);
procedure Splitter1CanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
procedure ShowOptionsExecute(Sender: TObject);
procedure FilePropertiesExecute(Sender: TObject);
procedure FileOpenExecute(Sender: TObject);
procedure FileSaveAsExecute(Sender: TObject);
procedure ConvoTreeChange(Sender: TObject; Node: TTreeNode);
procedure ConEventListMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure ViewoutputTMemo1Click(Sender: TObject);
procedure ConFileParameters1Click(Sender: TObject);
procedure Clear1Click(Sender: TObject);
procedure ConversationsListCount1Click(Sender: TObject);
procedure Event_DeleteExecute(Sender: TObject);
procedure AddConversationExecute(Sender: TObject);
procedure Conversation_DeleteExecute(Sender: TObject);
procedure ConEventListDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
procedure ConEventListDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure btnReorderClick(Sender: TObject);
procedure tbStickyWindowClick(Sender: TObject);
procedure ClearForNewFile1Click(Sender: TObject);
procedure CreateTestFile1Click(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure Conversation_PropertiesExecute(Sender: TObject);
procedure ConvoTreeEdited(Sender: TObject; Node: TTreeNode; var S: string);
procedure FileGenerateAudioNamesExecute(Sender: TObject);
procedure FileCloseExecute(Sender: TObject);
procedure FileNewExecute(Sender: TObject);
procedure FileSaveExecute(Sender: TObject);
procedure tmrEventWinPosSyncTimer(Sender: TObject);
procedure DateTimeToDouble1Click(Sender: TObject);
procedure EventListItems1Click(Sender: TObject);
procedure CurrentConversationEvents1Click(Sender: TObject);
procedure tbGenerateAudioDirsClick(Sender: TObject);
procedure Conversation_CheckLabelsExecute(Sender: TObject);
procedure mainToolBarCustomDrawButton(Sender: TToolBar; Button: TToolButton;
State: TCustomDrawState; var DefaultDraw: Boolean);
procedure mnuGithubClick(Sender: TObject);
procedure edtSearchBoxKeyPress(Sender: TObject; var Key: Char);
procedure Event_DuplicateExecute(Sender: TObject);
procedure IndexEvents1Click(Sender: TObject);
procedure Event_CutExecute(Sender: TObject);
procedure Event_CopyExecute(Sender: TObject);
procedure Event_PasteExecute(Sender: TObject);
procedure ConvoTreeDblClick(Sender: TObject);
procedure ExpandTreeWithoutFlagsClick(Sender: TObject);
procedure TreeExpandAllClick(Sender: TObject);
procedure FileOpenDialogTypeChange(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure ConEventListEndDrag(Sender, Target: TObject; X, Y: Integer);
procedure ConvoTreeDeletion(Sender: TObject; Node: TTreeNode);
procedure Conversation_RenameExecute(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Conversation_FindExecute(Sender: TObject);
procedure AutoSaveTimerTimer(Sender: TObject);
procedure Conversation_CutExecute(Sender: TObject);
procedure Conversation_CopyExecute(Sender: TObject);
procedure Conversation_PasteExecute(Sender: TObject);
procedure ConvoTreeMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Event_CopySpeechTextExecute(Sender: TObject);
procedure Event_CopyMp3FileAndPathExecute(Sender: TObject);
procedure Event_CopyMp3FilePathExecute(Sender: TObject);
procedure Event_CopyMp3FileExecute(Sender: TObject);
procedure Event_BrowseToExecute(Sender: TObject);
procedure CheckDpiRatioClick(Sender: TObject);
procedure Copyalltext1Click(Sender: TObject);
procedure SimulateDEEDClick(Sender: TObject);
procedure edtConvoTreeQSearchChange(Sender: TObject);
procedure CopyChoicetext1Click(Sender: TObject);
procedure CopyChoiceItemObj_Path_Filename(Sender: TObject);
procedure CopyChoiceItemObj_Path(Sender: TObject);
procedure CopyChoiceItemObj_Filename(Sender: TObject);
procedure btnStartSearchClick(Sender: TObject);
procedure mnuCharcoalDarkSlateClick(Sender: TObject);
procedure mnuLunaThemeClick(Sender: TObject);
procedure mnuSilverThemeClick(Sender: TObject);
procedure mnuSystemThemeClick(Sender: TObject);
procedure mnuOnyxBlueThemeClick(Sender: TObject);
procedure ApplicationEvents1ShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
procedure ConEventListKeyPress(Sender: TObject; var Key: Char);
procedure Wholeconversation1Click(Sender: TObject);
procedure Withchoicesifany1Click(Sender: TObject);
procedure Alllinesofselectedspeaker1Click(Sender: TObject);
procedure SpeechGeneratortest1Click(Sender: TObject);
procedure tbViewConeventJumpClick(Sender: TObject);
procedure edtConvoTreeQSearchEnter(Sender: TObject);
procedure lbTreeSearchResultsDblClick(Sender: TObject);
procedure lbTreeSearchResultsExit(Sender: TObject);
procedure ConvoTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Conversation_Create_AIBark_TemplateExecute(Sender: TObject);
procedure Conversation_Create_AIBarkFutz_TemplateExecute(Sender: TObject);
procedure Testfactory1Click(Sender: TObject);
procedure Defaultrecordvalue1Click(Sender: TObject);
procedure btnDisplayAllEventsClick(Sender: TObject);
procedure btnOnlyTextEventsClick(Sender: TObject);
procedure Setfilter1Click(Sender: TObject);
procedure btnApplyFilterClick(Sender: TObject);
private
{ Private declarations }
FFileModified: Boolean;
FAutoSaveEnabled: Boolean;
function GetFileModified(): Boolean; // Getter function
procedure SetFileModified(const Value: Boolean); // Setter procedure
function GetAutoSaveEnabled(): Boolean;
procedure SetAutoSaveEnabled(const Value: Boolean);
procedure WMEnterSizeMove(var Msg: TMessage); message WM_ENTERSIZEMOVE;
procedure WMExitSizeMove(var Msg: TMessage); message WM_EXITSIZEMOVE;
// For autosave.
procedure AutoSaveFile(const aFileName: string);
public
{ Public declarations }
var conFileParameters: TConFileParameters; // To store basic data (header)
var ConversationsList: TObjectList<TConversation>; // To store conversations and their events
var CurrentConversation: TConversation; // Conversation currently selected in ConvoTree
var CurrentEvent: TConEvent; // Current (selected) event in event list
// sets of strings to store Tables
var listPawnsActors: TStringList;
var listFlags: TStringList;
var listSkills: TStringList;
var listObjects: TStringList;
// Configuration file variables begin
// color variables for configuration file (clrGrid is color of separators between events)
var clrHighlightEvent, clrHighlightEventFrom, clrHighlightEventTo, clrGrid: TColor;
// Events colors
var EventListColors: ConEditPlus.Colors.TEventListColors;
var clSpeechBG, clSpeechNoAudioBG, clSpeechText: TColor;
var clChoiceBG, clChoiceNoAudioBG, clChoiceText: TColor;
var clPlayerBindNameColor: TColor;
var clPlayerSpeechBGColor: TColor;
// variables for Event Filter
var bchkSpeech: Boolean;
var bchkChoice: Boolean;
var bchkComment: Boolean;
var bchkTransferObject: Boolean;
var bchkTrigger: Boolean;
var bchkRandom: Boolean;
var bchkCheckObject: Boolean;
var bchkTrade: Boolean;
var bchkAnimation: Boolean;
var bchkAddGoal: Boolean;
var bchkSetFlag: Boolean;
var bchkAddCredits: Boolean;
var bchkCheckPersona: Boolean;
var bchkCheckFlag: Boolean;
var bchkMoveCamera: Boolean;
var bchkJump: Boolean;
var bchkAddSkillPoints: Boolean;
var bchkAddNote: Boolean;
var bchkEnd: Boolean;
// boolean variables for configuration file
var bShowAudioFiles, bShowStatusBar, bShowToolbar, bExpandedEventList,
bHighlightRelatedEvents,
bAskForConvoDelete, bAskForEventDelete, bHglEventWithNoAudio,
bHglEventsGradient, bFlatToolbar,
bUse3DSelectionFrame, bUseWhiteSelectedText, bDrawEventIdx, bUseLogging,
bUsePlayerBindNameColor, bUsePlayerSpeechBGColor : Boolean;
property bAutoSaveEnabled: Boolean read GetAutoSaveEnabled write SetAutoSaveEnabled;
// strings
var ConversationUserName, ConFilePath, ConFileBakPath, ConFileAudioPath: string;
var CurrentTheme: string; // save and restore theme (skin).
// Integer values
var AutoSaveMinutes: Integer;
var OpenFileFilterIndex, SaveFileFilterIndex: Integer; // save last selected file filter when opening/saving file.
// to store recent files!
var RecentFiles: array[0..CEP_MAX_RECENT_FILES] of string;
// Hold xxx key to reorder events
var ReorderModKey: TReorderEventsModKey;
// Events list mode (regular/dark)
var EventListColorsMode: TEventListColorsMode;
var bEnableDblClickTreeFlag: Boolean;
// Configuration file variables end
var MainFormIni: TIniFile; // ini file
var currentConFile: string; // global variable, so I can use it anywhere...
// set to True when file has been modified. Converted to property
property bFileModified: Boolean read GetFileModified write SetFileModified;
var SysScrollBarWidth: Integer;
var CF_ConEditPlus: Word; // Custom clipboard format
var TreeBuildTask: ITask;
var AutoSaveTask: ITask;
var frmEventInsAddOffset: TPoint;
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
{$R SoundResources.res} // contains final.mp3
uses frmSettings1, EditValueDialog, ConFileProperties, AboutBox1, ConvoProperties, frmFind1, AddInsertEvent,
ConXml.Reader, ConXML.Writer, confile.Reader, conFile.Writer, uFrmLabelErrors, ufrmAudioDirectories,
UfrmConversationPlayer, uFrmFindRefs;
function TfrmMain.GetFileModified: Boolean;
begin
Result := FFileModified;
end;
procedure TfrmMain.SetFileModified(const Value: Boolean);
begin
FFileModified := Value;
case Value of
True: Caption := strAppTitle + strFileModiefied;
False: Caption := strAppTitle;
end;
FileSave.Enabled := Value;
end;
function TfrmMain.GetAutoSaveEnabled(): Boolean;
begin
Result := FAutoSaveEnabled;
end;
procedure TfrmMain.SetAutoSaveEnabled(const Value: Boolean);
begin
FAutoSaveEnabled := Value;
AutoSaveTimer.Enabled := Value;
end;
procedure TfrmMain.Wholeconversation1Click(Sender: TObject);
var
TextToCopy: TStringList;
begin
TextToCopy := TStringList.Create();
try
for var Event in CurrentConversation.Events do
begin
if Assigned(event) and (Event is TConEventSpeech) then
TextToCopy.Add(Format(strClipboardConversationV1, [TConEventSpeech(event).ActorValue, TConEventSpeech(event).TextLine]));
end;
Clipboard.AsText := TextToCopy.Text;
finally
TextToCopy.Free();
end;
end;
procedure TfrmMain.Withchoicesifany1Click(Sender: TObject);
var
TextToCopy: TStringList;
begin
TextToCopy := TStringList.Create();
try
for var Event in CurrentConversation.Events do
begin
if Assigned(event) then
begin
if (Event is TConEventSpeech) then
TextToCopy.Add(Format('%s: %s', [TConEventSpeech(event).ActorValue, TConEventSpeech(event).TextLine]));
if (Event is TConEventChoice) then
begin
for var i:= 0 to High(TConEventChoice(Event).Choices) do
TextToCopy.Add(Format(PLAYER_BINDNAME + strClipboardConversationV2, [i, TConEventChoice(Event).Choices[i].textline]));
end;
end;
end;
Clipboard.AsText := TextToCopy.Text;
finally
TextToCopy.Free();
end;
end;
procedure TfrmMain.WMDropFiles(var Msg: TWMDropFiles);
var
FileName: array[0..MAX_PATH] of Char;
begin
try
for var i := 0 to Screen.FormCount - 1 do
begin
if (Screen.Forms[i] <> Application.MainForm) and (Screen.Forms[i].Visible) then
begin
Exit();
end;
end;
if DragQueryFile(Msg.Drop, 0, FileName, MAX_PATH) > 0 then
begin
// Close current file first!
FileCloseExecute(Self);
if UpperCase(ExtractFileExt(FileName)) = '.XML' then
begin
LoadConXMLFile(FileName);
BuildConvoTree();
end else
if UpperCase(ExtractFileExt(FileName)) = '.CON' then
begin
LoadConFile(FileName);
BuildConvoTree();
end else
begin
MessageDlg(strSelectConXML, mtError, [mbOK], 0);
Exit();
end;
currentConFile := FileName; // Assign filename to global variable
StatusBar.Panels[0].Text := '';
StatusBar.Panels[1].Text := FileName; // filename in StatusBar
AddRecentFile(FileName); // Add to recent
ToggleMenusPanels(True);
Caption := strAppTitle;
end;
finally
DragFinish(Msg.Drop);
end;
// Note we handled message
Msg.Result := 0;
inherited;
end;
procedure TfrmMain.WMEnterSizeMove(var Msg: TMessage);
begin
tmrEventWinPosSync.Enabled := True;
frmEventInsAddOffset.X := frmEventInsAdd.Left - Self.Left;
frmEventInsAddOffset.Y := frmEventInsAdd.Top - Self.Top;
inherited;
end;
procedure TfrmMain.WMExitSizeMove(var Msg: TMessage);
begin
tmrEventWinPosSync.Enabled := False;
inherited;
end;
function TfrmMain.GetSetFlagsItemHeight(events: array of TConEvent): Integer;
begin
var aLength, dResult: Integer;
aLength := 0;
for var L:= 0 to Length(events) -1 do
begin
if events[L] is TConEventSetFlag then
aLength := TConEventSetFlag(events[L]).numFlags; //ArrayLength;
end;
if bchkSetFlag = True then
dResult := 20 + (17 * aLength) // 20 for name and 17 for each flag string
else
dResult := FILTER_ITEM_HEIGHT;
//dResult := Round(20 * GetDPIAsRatio()) + Round(17 * GetDpiAsRatio()) * aLength; // 20 for name and 17 for each flag string
if dResult > 254 then dResult:= 254; // We are reached the limit!
Result := dResult;
end;
function TfrmMain.GetCheckFlagsItemHeight(events: array of TConEvent): Integer;
begin
var aLength, dResult: Integer;
aLength := 0;
for var L:= 0 to Length(events) -1 do
begin
if events[L] is TConEventCheckFlag then
aLength := TConEventCheckFlag(events[L]).numFlags; //ArrayLength;
end;
if bchkCheckFlag = True then
dResult := 20 + (17 * aLength) // 20 for name and 17 for each flag string
else
dResult := FILTER_ITEM_HEIGHT;
//dResult := Round(20 * GetDPIAsRatio()) + (Round(17 * GetDPIAsRatio()) * aLength); // 20 for name and 17 for each flag string
//dResult := Round(20 * GetDPIAsRatio()) + (Round(17 * GetDPIAsRatio()) * aLength);
if dResult > 254 then dResult:= 254; // We are reached the limit!
Result := dResult;
end;
function TfrmMain.GetChoiceItemHeight(events: array of TConEvent): Integer;
begin
var dResult: Integer;
var fLength := 0;