-
Notifications
You must be signed in to change notification settings - Fork 8
/
MainWindowOverrides.cpp
980 lines (812 loc) · 29.9 KB
/
MainWindowOverrides.cpp
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
#include "MainWindowOverrides.h"
#include "Construction Set Extender_Resource.h"
#include "[Common]\CLIWrapper.h"
#include "WorkspaceManager.h"
#include "Achievements.h"
#include "HallOfFame.h"
#include "OldCSInteropManager.h"
#include "GlobalClipboard.h"
#include "FormUndoStack.h"
#include "DialogImposterManager.h"
#include "ObjectPaletteManager.h"
#include "ObjectPrefabManager.h"
#include "Render Window\AuxiliaryViewport.h"
#include "Render Window\RenderWindowManager.h"
#include "CustomDialogProcs.h"
#include "[BGSEEBase]\ToolBox.h"
#include "[BGSEEBase]\Script\CodaVM.h"
namespace cse
{
namespace uiManager
{
MainWindowMiscData::MainWindowMiscData() :
bgsee::WindowExtraData(kTypeID)
{
ToolbarExtras = Subwindow::CreateInstance();
}
MainWindowMiscData::~MainWindowMiscData()
{
if (ToolbarExtras)
{
ToolbarExtras->TearDown();
ToolbarExtras->DeleteInstance();
}
}
MainWindowToolbarData::MainWindowToolbarData() :
bgsee::WindowExtraData(kTypeID)
{
SettingTODSlider = false;
}
MainWindowToolbarData::~MainWindowToolbarData()
{
;//
}
void BatchGenerateLipSyncFiles(HWND hWnd)
{
if (*TESQuest::WindowHandle != NULL || *TESQuest::FilteredDialogWindowHandle != NULL)
{
// will cause a CTD if the tool is executed when either of the above windows are open
BGSEEUI->MsgBoxW("Please close any open Quest or Filtered Dialog windows before using this tool.");
return;
}
bool SkipInactiveTopicInfos = false;
bool OverwriteExisting = false;
if (BGSEEUI->MsgBoxI(hWnd,
MB_YESNO,
"Only process active topic infos?") == IDYES)
{
SkipInactiveTopicInfos = true;
}
if (BGSEEUI->MsgBoxI(hWnd,
MB_YESNO,
"Overwrite existing LIP files?") == IDYES)
{
OverwriteExisting = true;
}
HWND IdleWindow = CreateDialogParam(BGSEEMAIN->GetExtenderHandle(), MAKEINTRESOURCE(IDD_IDLE), hWnd, nullptr, NULL);
IFileStream ExistingFile;
int BatchGenCounter = 0, FailedCounter = 0;
bool HasError = false;
struct LipGenInput
{
std::string Path;
std::string ResponseText;
LipGenInput(const char* Path, const char* Text)
: Path(Path), ResponseText(Text) {}
};
std::vector<LipGenInput> CandidateInputs;
for (tList<TESTopic>::Iterator ItrTopic = _DATAHANDLER->topics.Begin(); ItrTopic.End() == false && ItrTopic.Get(); ++ItrTopic)
{
TESTopic* Topic = ItrTopic.Get();
SME_ASSERT(Topic);
for (TESTopic::TopicDataListT::Iterator ItrTopicData = Topic->topicData.Begin();
ItrTopicData.End() == false && ItrTopicData.Get();
++ItrTopicData)
{
TESQuest* Quest = ItrTopicData->parentQuest;
if (Quest == nullptr)
{
BGSEECONSOLE_MESSAGE("Topic %08X has an orphaned topic data; skipping", Topic->formID);
continue;
}
for (int i = 0; i < ItrTopicData->questInfos.numObjs; i++)
{
TESTopicInfo* Info = ItrTopicData->questInfos.data[i];
SME_ASSERT(Info);
TESFile* OverrideFile = Info->GetOverrideFile(-1);
if (OverrideFile)
{
if (SkipInactiveTopicInfos == false || (Info->formFlags & TESForm::kFormFlags_FromActiveFile))
{
for (tList<TESRace>::Iterator ItrRace = _DATAHANDLER->races.Begin();
ItrRace.End() == false && ItrRace.Get();
++ItrRace)
{
TESRace* Race = ItrRace.Get();
SME_ASSERT(Race);
for (TESTopicInfo::ResponseListT::Iterator ItrResponse = Info->responseList.Begin();
ItrResponse.End() == false && ItrResponse.Get();
++ItrResponse)
{
TESTopicInfo::ResponseData* Response = ItrResponse.Get();
SME_ASSERT(Response);
char VoiceFilePath[MAX_PATH] = { 0 };
for (int j = 0; j < 2; j++)
{
const char* Sex = "M";
if (j)
Sex = "F";
FORMAT_STR(VoiceFilePath, "Data\\Sound\\Voice\\%s\\%s\\%s\\%s_%s_%08X_%u",
OverrideFile->fileName,
Race->name.c_str(),
Sex,
Quest->editorID.c_str(),
Topic->editorID.c_str(),
(Info->formID & 0xFFFFFF),
Response->responseNumber);
CandidateInputs.emplace_back(VoiceFilePath, Response->responseText.c_str());
}
}
}
}
}
}
}
}
char Buffer[0x100];
int Processed = 0;
for (const auto& Input : CandidateInputs)
{
FORMAT_STR(Buffer, "Please Wait\nProcessing response %d/%d", Processed, CandidateInputs.size());
Static_SetText(GetDlgItem(IdleWindow, -1), Buffer);
std::string MP3Path(Input.Path); MP3Path += ".mp3";
std::string WAVPath(Input.Path); WAVPath += ".wav";
std::string LIPPath(Input.Path); LIPPath += ".lip";
if (ExistingFile.Open(MP3Path.c_str()) ||
ExistingFile.Open(WAVPath.c_str()))
{
if (OverwriteExisting || ExistingFile.Open(LIPPath.c_str()) == false)
{
if (CSIOM.GenerateLIPSyncFile(Input.Path.c_str(), Input.ResponseText.c_str()))
BatchGenCounter++;
else
{
HasError = true;
FailedCounter++;
}
}
}
++Processed;
}
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_GenerateLIP);
DestroyWindow(IdleWindow);
if (HasError)
BGSEEUI->MsgBoxW("Batch generation completed with some errors!\n\nGenerated: %d files\nFailed: %d Files",
BatchGenCounter, FailedCounter);
else
BGSEEUI->MsgBoxI("Batch generation completed successfully!\n\nGenerated: %d files.", BatchGenCounter);
}
LRESULT CALLBACK MainWindowMenuInitSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
bgsee::WindowSubclassProcCollection::SubclassProcExtraParams* SubclassParams)
{
LRESULT DlgProcResult = FALSE;
switch (uMsg)
{
case WM_INITMENUPOPUP:
{
if (HIWORD(lParam) == FALSE)
{
HMENU Popup = (HMENU)wParam;
for (int i = 0, j = GetMenuItemCount(Popup); i < j; i++)
{
MENUITEMINFO CurrentItem = { 0 };
CurrentItem.cbSize = sizeof(MENUITEMINFO);
CurrentItem.fMask = MIIM_ID | MIIM_STATE;
if (GetMenuItemInfo(Popup, i, TRUE, &CurrentItem) == TRUE)
{
bool UpdateItem = true;
bool CheckItem = false;
bool DisableItem = false;
switch (CurrentItem.wID)
{
case TESCSMain::kMainMenu_World_EditCellPathGrid:
if (*TESRenderWindow::PathGridEditFlag)
CheckItem = true;
break;
case IDC_MAINMENU_SAVEOPTIONS_SAVEESPMASTERS:
if (settings::plugins::kSaveLoadedESPsAsMasters.GetData().i)
CheckItem = true;
break;
case IDC_MAINMENU_SAVEOPTIONS_PREVENTCHANGESTOFILETIMESTAMPS:
if (settings::plugins::kPreventTimeStampChanges.GetData().i)
CheckItem = true;
break;
case IDC_MAINMENU_SAVEOPTIONS_CREATEBACKUPBEFORESAVING:
if (settings::versionControl::kBackupOnSave.GetData().i)
CheckItem = true;
break;
case IDC_MAINMENU_GLOBALUNDO:
if (BGSEEUNDOSTACK->IsUndoStackEmpty())
DisableItem = true;
break;
case IDC_MAINMENU_GLOBALREDO:
if (BGSEEUNDOSTACK->IsRedoStackEmpty())
DisableItem = true;
break;
case IDC_MAINMENU_CONSOLE:
if (BGSEECONSOLE->IsVisible())
CheckItem = true;
break;
case IDC_MAINMENU_AUXVIEWPORT:
if (AUXVIEWPORT->IsVisible())
CheckItem = true;
break;
case IDC_MAINMENU_HIDEUNMODIFIEDFORMS:
if (FormEnumerationManager::Instance.GetVisibleUnmodifiedForms() == false)
CheckItem = true;
break;
case IDC_MAINMENU_HIDEDELETEDFORMS:
if (FormEnumerationManager::Instance.GetVisibleDeletedForms() == false)
CheckItem = true;
break;
case IDC_MAINMENU_SORTACTIVEFORMSFIRST:
if (settings::dialogs::kSortFormListsByActiveForm.GetData().i)
CheckItem = true;
break;
case IDC_MAINMENU_COLORIZEACTIVEFORMS:
if (settings::dialogs::kColorizeActiveForms.GetData().i)
CheckItem = true;
break;
case IDC_MAINMENU_COLORIZEFORMOVERRIDES:
if (settings::dialogs::kColorizeFormOverrides.GetData().i)
CheckItem = true;
break;
case IDC_MAINMENU_CODABACKGROUNDER:
if (CODAVM->GetBackgroundDaemon()->IsEnabled())
CheckItem = true;
break;
case IDC_MAINMENU_INITIALLYDISABLEDREFERENCES:
if (_RENDERWIN_XSTATE.ShowInitiallyDisabledRefs)
CheckItem = true;
break;
case IDC_MAINMENU_CHILDREFERENCESOFTHEDISABLED:
if (_RENDERWIN_XSTATE.ShowInitiallyDisabledRefChildren)
CheckItem = true;
break;
case IDC_MAINMENU_MULTIPLEPREVIEWWINDOWS:
if (PreviewWindowImposterManager::Instance.GetEnabled())
CheckItem = true;
break;
case IDC_MAINMENU_PARENTCHILDINDICATORS:
if (settings::renderer::kParentChildVisualIndicator().i)
CheckItem = true;
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORS:
if (settings::renderer::kPathGridLinkedRefIndicator().i)
CheckItem = true;
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDEBOUNDINGBOX:
if ((settings::renderer::kPathGridLinkedRefIndicatorFlags().u &
settings::renderer::kPathGridLinkedRefIndicatorFlag_HidePointBoundingBox))
{
CheckItem = true;
}
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDELINKEDREFNODE:
if ((settings::renderer::kPathGridLinkedRefIndicatorFlags().u &
settings::renderer::kPathGridLinkedRefIndicatorFlag_HideLinkedRefNode))
{
CheckItem = true;
}
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDELINECONNECTOR:
if ((settings::renderer::kPathGridLinkedRefIndicatorFlags().u &
settings::renderer::kPathGridLinkedRefIndicatorFlag_HideLineConnector))
{
CheckItem = true;
}
break;
case IDC_MAINMENU_CUSTOMCOLORTHEMEMODE:
if (BGSEEUI->GetColorThemer()->IsEnabled())
CheckItem = true;
break;
case IDC_MAINMENU_ONEDITORSTARTUP_LOADSTARTUPPLUGIN:
if (settings::startup::kLoadPlugin().i)
CheckItem = true;
break;
case IDC_MAINMENU_ONEDITORSTARTUP_SETSTARTUPWORKSPACE:
if (settings::startup::kSetWorkspace().i)
CheckItem = true;
break;
case IDC_MAINMENU_ONEDITORSTARTUP_OPENSTARTUPSCRIPT:
if (settings::startup::kOpenScriptWindow().i)
CheckItem = true;
break;
default:
UpdateItem = false;
break;
}
if (UpdateItem)
{
if (CheckItem)
{
CurrentItem.fState &= ~MFS_UNCHECKED;
CurrentItem.fState |= MFS_CHECKED;
}
else
{
CurrentItem.fState &= ~MFS_CHECKED;
CurrentItem.fState |= MFS_UNCHECKED;
}
if (DisableItem)
{
CurrentItem.fState &= ~MFS_ENABLED;
CurrentItem.fState |= MFS_DISABLED;
}
else
{
CurrentItem.fState &= ~MFS_DISABLED;
CurrentItem.fState |= MFS_ENABLED;
}
CurrentItem.fMask = MIIM_STATE;
SetMenuItemInfo(Popup, i, TRUE, &CurrentItem);
}
}
}
}
SubclassParams->Out.MarkMessageAsHandled = true;
}
break;
}
return DlgProcResult;
}
LRESULT CALLBACK MainWindowMenuSelectSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
bgsee::WindowSubclassProcCollection::SubclassProcExtraParams* SubclassParams)
{
LRESULT DlgProcResult = FALSE;
switch (uMsg)
{
case WM_COMMAND:
SubclassParams->Out.MarkMessageAsHandled = true;
switch (LOWORD(wParam))
{
case TESCSMain::kMainMenu_View_PreviewWindow:
if (PreviewWindowImposterManager::Instance.GetEnabled())
BGSEEUI->MsgBoxI("Use the Object Window's context menu to preview objects when multiple preview windows are enabled.");
else
SubclassParams->Out.MarkMessageAsHandled = false;
break;
case TESCSMain::kMainMenu_Help_Contents:
case TESCSMain::kMainMenu_Character_ExportDialogue:
{
if (achievements::kOldestTrickInTheBook->GetUnlocked() == false)
{
ShellExecute(nullptr, "open", "http://www.youtube.com/watch?v=oHg5SJYRHA0", nullptr, nullptr, SW_SHOWNORMAL);
BGSEEACHIEVEMENTS->Unlock(achievements::kOldestTrickInTheBook);
}
else if (LOWORD(wParam) == TESCSMain::kMainMenu_Help_Contents)
ShellExecute(nullptr, "open", "https://cs.uesp.net/wiki/Main_Page", nullptr, nullptr, SW_SHOWNORMAL);
else
SubclassParams->Out.MarkMessageAsHandled = false;
}
break;
case IDC_MAINMENU_SAVEAS:
{
if (_DATAHANDLER->activeFile == nullptr)
{
BGSEEUI->MsgBoxE("An active plugin must be set before using this tool.");
break;
}
*TESCSMain::AllowAutoSaveFlag = 0;
char FileName[MAX_PATH] = { 0 };
if (TESDialog::SelectTESFileCommonDialog(hWnd,
INISettingCollection::Instance->LookupByName("sLocalMasterPath:General")->value.s,
0,
FileName,
sizeof(FileName)))
{
TESFile* SaveAsBuffer = _DATAHANDLER->activeFile;
SaveAsBuffer->SetActive(false);
SaveAsBuffer->SetLoaded(false);
_DATAHANDLER->activeFile = nullptr;
if (SendMessage(hWnd, TESCSMain::kWindowMessage_Save, NULL, (LPARAM)FileName))
TESCSMain::SetTitleModified(false);
else
{
_DATAHANDLER->activeFile = SaveAsBuffer;
SaveAsBuffer->SetActive(true);
SaveAsBuffer->SetLoaded(true);
}
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_SaveAs);
}
*TESCSMain::AllowAutoSaveFlag = 1;
}
break;
case IDC_MAINMENU_CONSOLE:
BGSEECONSOLE->ToggleVisibility();
break;
case IDC_MAINMENU_HIDEDELETEDFORMS:
FormEnumerationManager::Instance.ToggleVisibilityDeletedForms();
break;
case IDC_MAINMENU_HIDEUNMODIFIEDFORMS:
FormEnumerationManager::Instance.ToggleVisibilityUnmodifiedForms();
break;
case IDC_MAINMENU_CSEPREFERENCES:
BGSEEMAIN->ShowPreferencesGUI();
break;
case IDC_MAINMENU_LAUNCHGAME:
{
std::string AppPath = BGSEEMAIN->GetAPPPath();
AppPath += "\\";
IFileStream SteamLoader;
if (SteamLoader.Open((std::string(AppPath + "obse_steam_loader.dll")).c_str()) == false)
AppPath += "obse_loader.exe";
else
AppPath += "Oblivion.exe";
ShellExecute(nullptr, "open", (LPCSTR)AppPath.c_str(), nullptr, nullptr, SW_SHOW);
BGSEEACHIEVEMENTS->Unlock(achievements::kLazyBum);
}
break;
case IDC_MAINMENU_CREATEGLOBALSCRIPT:
BGSEEUI->ModelessDialog(BGSEEMAIN->GetExtenderHandle(), MAKEINTRESOURCE(IDD_GLOBALSCRIPT), hWnd, (DLGPROC)CreateGlobalScriptDlgProc);
break;
case IDC_MAINMENU_TAGBROWSER:
cliWrapper::interfaces::TAG->ShowTagBrowserDialog(nullptr);
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_TagBrowser);
break;
case IDC_MAINMENU_SETWORKSPACE:
BGSEEWORKSPACE->SelectCurrentWorkspace();
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_Workspace);
break;
case IDC_MAINMENU_TOOLS:
BGSEETOOLBOX->ShowToolListMenu(BGSEEMAIN->GetExtenderHandle(), hWnd);
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_Toolbox);
break;
case IDC_MAINMENU_CODAMANAGEGLOBALDATASTORE:
CODAVM->ShowGlobalStoreEditDialog(BGSEEMAIN->GetExtenderHandle(), hWnd);
break;
case IDC_MAINMENU_CODABACKGROUNDER:
if (CODAVM->GetBackgroundDaemon()->IsEnabled())
CODAVM->GetBackgroundDaemon()->Suspend();
else
CODAVM->GetBackgroundDaemon()->Resume();
break;
case IDC_MAINMENU_SAVEOPTIONS_SAVEESPMASTERS:
settings::plugins::kSaveLoadedESPsAsMasters.ToggleData();
break;
case IDC_MAINMENU_SAVEOPTIONS_PREVENTCHANGESTOFILETIMESTAMPS:
settings::plugins::kPreventTimeStampChanges.ToggleData();
break;
case IDC_MAINMENU_AUXVIEWPORT:
AUXVIEWPORT->ToggleVisibility();
break;
case IDC_MAINMENU_USEINFOLISTING:
cliWrapper::interfaces::USE->ShowUseInfoListDialog(nullptr);
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_UseInfoListing);
break;
case IDC_MAINMENU_BATCHLIPGENERATOR:
BatchGenerateLipSyncFiles(hWnd);
break;
case IDC_MAINMENU_SAVEOPTIONS_CREATEBACKUPBEFORESAVING:
settings::versionControl::kBackupOnSave.ToggleData();
break;
case IDC_MAINMENU_SORTACTIVEFORMSFIRST:
settings::dialogs::kSortFormListsByActiveForm.ToggleData();
break;
case IDC_MAINMENU_COLORIZEACTIVEFORMS:
settings::dialogs::kColorizeActiveForms.ToggleData();
break;
case IDC_MAINMENU_COLORIZEFORMOVERRIDES:
settings::dialogs::kColorizeFormOverrides.ToggleData();
break;
case IDC_MAINMENU_GLOBALCLIPBOARDCONTENTS:
BGSEECLIPBOARD->DisplayContents();
break;
case IDC_MAINMENU_PASTEFROMGLOBALCLIPBOARD:
BGSEECLIPBOARD->Paste();
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_GlobalClipboard);
break;
case IDC_MAINMENU_GLOBALUNDO:
BGSEEUNDOSTACK->PerformUndo();
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_GlobalUndo);
break;
case IDC_MAINMENU_GLOBALREDO:
BGSEEUNDOSTACK->PerformRedo();
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_GlobalUndo);
break;
case IDC_MAINMENU_PURGELOADEDRESOURCES:
{
BGSEECONSOLE_MESSAGE("Purging resources...");
BGSEECONSOLE->Indent();
PROCESS_MEMORY_COUNTERS_EX MemCounter = { 0 };
UInt32 RAMUsage = 0;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&MemCounter, sizeof(MemCounter));
RAMUsage = MemCounter.WorkingSetSize / (1024 * 1024);
BGSEECONSOLE_MESSAGE("Current RAM Usage: %d MB", RAMUsage);
_TES->PurgeLoadedResources();
BGSEECONSOLE_MESSAGE("Resources purged!");
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&MemCounter, sizeof(MemCounter));
RAMUsage = MemCounter.WorkingSetSize / (1024 * 1024);
BGSEECONSOLE_MESSAGE("Current RAM Usage: %d MB", RAMUsage);
BGSEECONSOLE->Outdent();
}
break;
case IDC_MAINMENU_INITIALLYDISABLEDREFERENCES:
_RENDERWIN_XSTATE.ShowInitiallyDisabledRefs = _RENDERWIN_XSTATE.ShowInitiallyDisabledRefs == false;
TESRenderWindow::Redraw();
break;
case IDC_MAINMENU_CHILDREFERENCESOFTHEDISABLED:
_RENDERWIN_XSTATE.ShowInitiallyDisabledRefChildren = _RENDERWIN_XSTATE.ShowInitiallyDisabledRefChildren == false;
TESRenderWindow::Redraw();
break;
case IDC_MAINMENU_CODAOPENSCRIPTREPOSITORY:
CODAVM->OpenScriptRepository();
break;
case IDC_MAINMENU_SPAWNEXTRAOBJECTWINDOW:
ObjectWindowImposterManager::Instance.SpawnImposter();
achievements::kPowerUser->UnlockTool(achievements::AchievementPowerUser::kTool_MultipleObjectWindows);
break;
case IDC_MAINMENU_MULTIPLEPREVIEWWINDOWS:
if (PreviewWindowImposterManager::Instance.GetEnabled())
{
PreviewWindowImposterManager::Instance.SetEnabled(false);
settings::dialogs::kMultiplePreviewWindows.SetInt(0);
}
else
{
PreviewWindowImposterManager::Instance.SetEnabled(true);
settings::dialogs::kMultiplePreviewWindows.SetInt(1);
}
break;
case IDC_MAINMENU_OBJECTPALETTE:
objectPalette::ObjectPaletteManager::Instance.Show();
break;
case IDC_MAINMENU_OBJECTPREFABS:
objectPrefabs::ObjectPrefabManager::Instance.Show();
break;
case IDC_MAINMENU_PARENTCHILDINDICATORS:
settings::renderer::kParentChildVisualIndicator.ToggleData();
TESRenderWindow::Redraw();
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORS:
settings::renderer::kPathGridLinkedRefIndicator.ToggleData();
TESRenderWindow::Redraw(true);
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDEBOUNDINGBOX:
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDELINKEDREFNODE:
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDELINECONNECTOR:
{
UInt32 Flags = settings::renderer::kPathGridLinkedRefIndicatorFlags().u;
UInt32 Comperand = 0;
switch (LOWORD(wParam))
{
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDEBOUNDINGBOX:
Comperand = settings::renderer::kPathGridLinkedRefIndicatorFlag_HidePointBoundingBox;
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDELINKEDREFNODE:
Comperand = settings::renderer::kPathGridLinkedRefIndicatorFlag_HideLinkedRefNode;
break;
case IDC_MAINMENU_PATHGRIDLINKEDREFINDICATORSETTINGS_HIDELINECONNECTOR:
Comperand = settings::renderer::kPathGridLinkedRefIndicatorFlag_HideLineConnector;
break;
}
if ((Flags & Comperand))
Flags &= ~Comperand;
else
Flags |= Comperand;
settings::renderer::kPathGridLinkedRefIndicatorFlags.SetUInt(Flags);
if (settings::renderer::kPathGridLinkedRefIndicator().i == 0)
TESRenderWindow::Redraw(true);
}
break;
case IDC_MAINMENU_CODARELOADBACKGROUNDSCRIPTS:
CODAVM->GetBackgroundDaemon()->Rebuild();
break;
case IDC_MAINMENU_CODARESETSCRIPTCACHE:
CODAVM->GetProgramCache()->Invalidate();
break;
case IDC_MAINMENU_SYNCSCRIPTSTODISK:
cliWrapper::interfaces::SE->ShowDiskSyncDialog();
break;
case IDC_MAINMENU_CUSTOMCOLORTHEMEMODE:
if (BGSEEUI->GetColorThemer()->IsEnabled())
BGSEEUI->GetColorThemer()->Disable();
else
BGSEEUI->GetColorThemer()->Enable();
break;
case IDC_MAINMENU_ONEDITORSTARTUP_LOADSTARTUPPLUGIN:
settings::startup::kLoadPlugin.ToggleData();
break;
case IDC_MAINMENU_ONEDITORSTARTUP_SETSTARTUPWORKSPACE:
settings::startup::kSetWorkspace.ToggleData();
break;
case IDC_MAINMENU_ONEDITORSTARTUP_OPENSTARTUPSCRIPT:
settings::startup::kOpenScriptWindow.ToggleData();
break;
case IDC_MAINMENU_CSEMANUAL:
case IDC_MAINMENU_CODAMANUAL:
{
std::string ManualPath = BGSEEMAIN->GetAPPPath();
ManualPath += "\\Data\\Docs\\Construction Set Extender\\";
if (LOWORD(wParam) == IDC_MAINMENU_CODAMANUAL)
ManualPath += "Coda Manual.pdf";
else
ManualPath += "Construction Set Extender Manual.pdf";
IFileStream File;
if (File.Open(ManualPath.c_str()) == false)
{
BGSEEUI->MsgBoxI(hWnd, NULL, "Could not find the manual file. Did you extract the bundled "
"documentation into the following directory?\n\n"
"Data\\Docs\\Construction Set Extender\\");
}
else
ShellExecute(nullptr, "open", ManualPath.c_str(), nullptr, nullptr, SW_SHOW);
}
break;
default:
SubclassParams->Out.MarkMessageAsHandled = false;
break;
}
break;
}
return DlgProcResult;
}
#define ID_PATHGRIDTOOLBARBUTTION_TIMERID 0x99
LRESULT CALLBACK MainWindowMiscSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
bgsee::WindowSubclassProcCollection::SubclassProcExtraParams* SubclassParams)
{
LRESULT DlgProcResult = FALSE;
switch (uMsg)
{
case TESCSMain::kWindowMessage_Unk413:
// if multiple editor instances are disabled, the secondary instance will send this message to the primary
// strangely, when the primary instance has an active/open preview control, the call crashes (presumably due to a corrupt lParam pointer)
// as far as I can tell, the corresponding code path is never executed, so we can consume this message entirely
SubclassParams->Out.MarkMessageAsHandled = true;
break;
case WM_MAINWINDOW_INIT_DIALOG:
{
SetTimer(hWnd, ID_PATHGRIDTOOLBARBUTTION_TIMERID, 500, nullptr);
SubclassParams->Out.MarkMessageAsHandled = true;
}
break;
case WM_DESTROY:
{
KillTimer(hWnd, ID_PATHGRIDTOOLBARBUTTION_TIMERID);
MainWindowMiscData* xData = BGSEE_GETWINDOWXDATA(MainWindowMiscData, SubclassParams->In.ExtraData);
if (xData)
{
SubclassParams->In.ExtraData->Remove(MainWindowMiscData::kTypeID);
delete xData;
}
}
break;
case WM_MAINWINDOW_INIT_EXTRADATA:
{
MainWindowMiscData* xData = BGSEE_GETWINDOWXDATA(MainWindowMiscData, SubclassParams->In.ExtraData);
if (xData == nullptr)
{
xData = new MainWindowMiscData();
SubclassParams->In.ExtraData->Add(xData);
xData->ToolbarExtras->hInstance = BGSEEMAIN->GetExtenderHandle();
xData->ToolbarExtras->hDialog = *TESCSMain::MainToolbarHandle;
xData->ToolbarExtras->hContainer = *TESCSMain::MainToolbarHandle;
xData->ToolbarExtras->position.x = 485;
xData->ToolbarExtras->position.y = 0;
if (xData->ToolbarExtras->Build(IDD_TOOLBAREXTRAS) == false)
BGSEECONSOLE_ERROR("Couldn't build main window toolbar subwindow!");
else
{
SubclassParams->In.Subclasser->RegisterSubclassForWindow(*TESCSMain::MainToolbarHandle, MainWindowToolbarSubClassProc);
SendMessage(*TESCSMain::MainToolbarHandle, WM_MAINTOOLBAR_INIT, NULL, NULL);
HWND TODSlider = GetDlgItem(hWnd, IDC_TOOLBAR_TODSLIDER);
HWND TODEdit = GetDlgItem(hWnd, IDC_TOOLBAR_TODCURRENT);
TESDialog::ClampDlgEditField(TODEdit, 0.0, 24.0);
SendMessage(TODSlider, TBM_SETRANGE, TRUE, MAKELONG(0, 23));
SendMessage(TODSlider, TBM_SETLINESIZE, NULL, 1);
SendMessage(TODSlider, TBM_SETPAGESIZE, NULL, 4);
SendMessage(*TESCSMain::MainToolbarHandle, WM_MAINTOOLBAR_SETTOD, _TES->GetSkyTOD() * 4.0, NULL);
}
}
}
break;
case WM_TIMER:
DlgProcResult = TRUE;
SubclassParams->Out.MarkMessageAsHandled = true;
switch (wParam)
{
case TESCSMain::kTimer_Autosave:
// autosave timer, needs to be handled here as the org wndproc doesn't compare the timerID
if (*TESCSMain::AllowAutoSaveFlag != 0 && *TESCSMain::ExittingCSFlag == 0)
TESCSMain::AutoSave();
break;
case ID_PATHGRIDTOOLBARBUTTION_TIMERID:
{
TBBUTTONINFO PathGridData = { 0 };
PathGridData.cbSize = sizeof(TBBUTTONINFO);
PathGridData.dwMask = TBIF_STATE;
SendMessage(*TESCSMain::MainToolbarHandle, TB_GETBUTTONINFO, TESCSMain::kToolbar_PathGridEdit, (LPARAM)&PathGridData);
if ((PathGridData.fsState & TBSTATE_CHECKED) == false && *TESRenderWindow::PathGridEditFlag)
{
PathGridData.fsState |= TBSTATE_CHECKED;
SendMessage(*TESCSMain::MainToolbarHandle, TB_SETBUTTONINFO, TESCSMain::kToolbar_PathGridEdit, (LPARAM)&PathGridData);
}
}
break;
}
break;
}
return DlgProcResult;
}
LRESULT CALLBACK MainWindowToolbarSubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
bgsee::WindowSubclassProcCollection::SubclassProcExtraParams* SubclassParams)
{
LRESULT DlgProcResult = FALSE;
HWND TODSlider = GetDlgItem(hWnd, IDC_TOOLBAR_TODSLIDER);
HWND TODEdit = GetDlgItem(hWnd, IDC_TOOLBAR_TODCURRENT);
switch (uMsg)
{
case WM_MAINTOOLBAR_INIT:
{
MainWindowToolbarData* xData = BGSEE_GETWINDOWXDATA(MainWindowToolbarData, SubclassParams->In.ExtraData);
if (xData == nullptr)
{
xData = new MainWindowToolbarData();
SubclassParams->In.ExtraData->Add(xData);
}
}
break;
case WM_DESTROY:
{
MainWindowToolbarData* xData = BGSEE_GETWINDOWXDATA(MainWindowToolbarData, SubclassParams->In.ExtraData);
if (xData)
{
SubclassParams->In.ExtraData->Remove(MainWindowToolbarData::kTypeID);
delete xData;
}
}
break;
case WM_COMMAND:
{
MainWindowToolbarData* xData = BGSEE_GETWINDOWXDATA(MainWindowToolbarData, SubclassParams->In.ExtraData);
SME_ASSERT(xData);
if (HIWORD(wParam) == EN_CHANGE &&
LOWORD(wParam) == IDC_TOOLBAR_TODCURRENT &&
xData->SettingTODSlider == false)
{
xData->SettingTODSlider = true;
float TOD = TESDialog::GetDlgItemFloat(hWnd, IDC_TOOLBAR_TODCURRENT);
SendMessage(hWnd, WM_MAINTOOLBAR_SETTOD, TOD * 4.0, NULL);
xData->SettingTODSlider = false;
}
}
break;
case WM_HSCROLL:
{
bool BreakOut = true;
switch (LOWORD(wParam))
{
case TB_BOTTOM:
case TB_ENDTRACK:
case TB_LINEDOWN:
case TB_LINEUP:
case TB_PAGEDOWN:
case TB_PAGEUP:
case TB_THUMBPOSITION:
case TB_THUMBTRACK:
case TB_TOP:
if ((HWND)lParam == TODSlider)
BreakOut = false;
break;
}
if (BreakOut)
break;
}
case WM_MAINTOOLBAR_SETTOD:
{
if (uMsg != WM_HSCROLL)
SendDlgItemMessage(hWnd, IDC_TOOLBAR_TODSLIDER, TBM_SETPOS, TRUE, (LPARAM)wParam);
int Position = SendMessage(TODSlider, TBM_GETPOS, NULL, NULL);
float TOD = Position / 4.0;
if (TOD > 24.0f)
TOD = 24.0f;
_TES->SetSkyTOD(TOD);
MainWindowToolbarData* xData = BGSEE_GETWINDOWXDATA(MainWindowToolbarData, SubclassParams->In.ExtraData);
SME_ASSERT(xData);
if (xData->SettingTODSlider == false)
TESDialog::SetDlgItemFloat(hWnd, IDC_TOOLBAR_TODCURRENT, TOD, 2);
TESPreviewControl::UpdatePreviewWindows();
}
break;
}
return DlgProcResult;
}
void InitializeMainWindowOverrides()
{
BGSEEUI->GetSubclasser()->RegisterSubclassForWindow(BGSEEUI->GetMainWindow(), uiManager::MainWindowMenuInitSubclassProc);
BGSEEUI->GetSubclasser()->RegisterSubclassForWindow(BGSEEUI->GetMainWindow(), uiManager::MainWindowMenuSelectSubclassProc);
BGSEEUI->GetSubclasser()->RegisterSubclassForWindow(BGSEEUI->GetMainWindow(), uiManager::MainWindowMiscSubclassProc);
SendMessage(BGSEEUI->GetMainWindow(), WM_MAINWINDOW_INIT_DIALOG, NULL, NULL);
}
}
}