-
Notifications
You must be signed in to change notification settings - Fork 5
/
ExtensionsMenu.cpp
772 lines (677 loc) · 23.7 KB
/
ExtensionsMenu.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
#pragma comment(lib, "comctl32.lib")
#include <CommCtrl.h>
#include "GECKUtility.h"
#include "ExtensionsMenu.h"
#include "resource.h"
#include "FormSearch.h"
#include "ModifiedFormViewer.h"
#include "Settings.h"
#include "NavMeshPickPreventer.h"
#include "LaunchGame.h"
#include "Events/MainWindowLoadEvent.h"
#include "MultiBoundsAdder.h"
#define UI_EXTMENU_ID 51001
#define UI_EXTMENU_SHOWLOG 51002
#define UI_EXTMENU_CLEARLOG 51003
#define UI_EXTMENU_AUTOSCROLL 51004
#define UI_EXTMENU_SPACER 51005
#define UI_EXTMENU_SPELLCHECK 51006
#define UI_EXTMENU_RENDER 51007
#define UI_EXTMENU_PREVIEW 51008
#define UI_EXTMENU_LAUNCHGAME 51009
#define UI_EXTMENU_SAVEPOSITION 51010
#define UI_EXTMENU_LOADPOSITION 51011
#define ID_TRACKBAR 51012
#define ID_TIMEOFDAYTEXT 51013
#define ID_RENDERWINDOWCELLLOADS_CHECKBOX 51014
#define ID_RENDERWINDOW_SHOWWATER_CHECKBOX 51015
#define ID_RENDERWINDOW_SHOWPORTALS_CHECKBOX 51016
#define UI_EXTMENU_OBJECTWINDOW_TOGGLESHOWUNEDITED 51017
#define UI_EXTMENU_TOGGLENAVEMESHBISECT 51018
#define UI_EXTMENU_LOOKUPFORM 51019
#define UI_EXTMENU_VIEW_MODIFIED_FORMS 51020
#define UI_EXTMENU_VIEW_NAVMESH_IGNORED_FORMS 51021
#define UI_EXTMENU_AUTO_ADD_TO_MULTIBOUNDS 51022
#define UI_EXTMENU_READD_TO_MULTIBOUNDS 51023
#define MAIN_WINDOW_CALLBACK 0xFEED
// unused button in vanilla menu
#define MENUOPTION_RENDER_WINDOW 0x9D06
#define MENUOPTION_RECOMPILE_ALL 0x9ECE
HWND g_MainHwnd;
extern HWND g_ConsoleHwnd;
HMENU g_ExtensionMenu;
HMENU g_MainMenu;
WNDPROC originalMainWindowCallback;
NiPoint3 savedRenderPos;
NiMatrix33 savedRenderDirection;
HWND g_trackBarHwnd;
HWND g_timeOfDayTextHwnd;
HWND g_allowCellWindowLoadsButtonHwnd;
HWND g_renderWindowShowWaterButtonHwnd;
HWND g_renderWindowShowPortalsButtonHwnd;
static HANDLE fontHandle;
static LOGFONT fontInfo;
extern LOGFONT editorFont;
extern HMODULE ZeGaryHaxHandle;
LPLOGFONT GetEditorFont();
void ToggleNavmeshPlaceAboveOthers(bool isAllowed)
{
// Patch Navmesh editing to allow placing vertices over existing navmesh (disables line bisection)
SafeWrite16(0x0045C590, isAllowed ? 0x9090 : 0x4675);
config.bNavmeshAllowPlaceAboveOthers = isAllowed;
}
_declspec(naked) void ObjectWindowListFilterUneditedHook()
{
static const UInt32 skipAddr = 0x439793;
static const UInt32 retnAddr = 0x43973F;
_asm {
// esi contains TESForm
test byte ptr ss : [esi + 8] , 2 /// form->flags & kModified
jne editedForm
jmp skipAddr
editedForm :
mov eax, dword ptr ss : [esp + 0x1C]
test eax, eax
jmp retnAddr
}
}
void ToggleObjectWindowFilterUnedited(bool show)
{
if (show)
{
SafeWriteBuf(0x439739, "\x8B\x44\x24\x1C\x85\xC0", 6);
}
else
{
WriteRelJump(0x439739, UInt32(ObjectWindowListFilterUneditedHook));
}
}
bool CreateExtensionMenu(HWND MainWindow, HMENU MainMenu)
{
// Create extended menu options
g_ExtensionMenu = CreateMenu();
BOOL result = TRUE;
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_SAVEPOSITION, "Save Position");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_LOADPOSITION, "Load Position");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_SHOWLOG, "Show Log");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_CLEARLOG, "Clear Log");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_AUTOSCROLL, "Autoscroll Log");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_SEPARATOR, (UINT_PTR)UI_EXTMENU_SPACER, "");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_SPELLCHECK, "Enable Spell Check");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_RENDER, "Render Window Uncap (requires restart)");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_PREVIEW, "Preview Window Uncap (requires restart)");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_OBJECTWINDOW_TOGGLESHOWUNEDITED, "Object Window - Only Show Edited");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_TOGGLENAVEMESHBISECT, "Allow Placement Of Navmesh Node Above Others");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_SEPARATOR, (UINT_PTR)UI_EXTMENU_SPACER, "");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_LOOKUPFORM, "Lookup Form");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_VIEW_MODIFIED_FORMS, "View Modified Forms");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_VIEW_NAVMESH_IGNORED_FORMS, "View Navmesh Ignored Forms");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_AUTO_ADD_TO_MULTIBOUNDS, "Attach Objects to Multibounds");
result = result && InsertMenu(g_ExtensionMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_READD_TO_MULTIBOUNDS, "Reattach All Objects to Multibounds");
MENUITEMINFO menuInfo;
memset(&menuInfo, 0, sizeof(MENUITEMINFO));
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_SUBMENU | MIIM_ID | MIIM_STRING;
menuInfo.hSubMenu = g_ExtensionMenu;
menuInfo.wID = UI_EXTMENU_ID;
menuInfo.dwTypeData = (char*)"Extensions";
menuInfo.cch = (uint32_t)strlen(menuInfo.dwTypeData);
result = result && InsertMenuItem(MainMenu, -1, TRUE, &menuInfo);
return result ? true : false;
}
void EditorUI_AddSliderToToolbar(HWND MainWindow, HINSTANCE hInstance) {
g_trackBarHwnd = CreateWindowEx(
NULL,
TRACKBAR_CLASSA,
"Trackbar Control",
(WS_CHILD | WS_VISIBLE | TBS_NOTICKS),
898, 2, // x, y
200, 24, // width, height
MainWindow,
(HMENU)ID_TRACKBAR,
hInstance,
NULL
);
SendMessageA(g_trackBarHwnd, TBM_SETRANGE, TRUE, MAKELONG(0, 24 * 4));
SendMessageA(g_trackBarHwnd, TBM_SETTICFREQ, 10, 0);
SendMessageA(g_trackBarHwnd, TBM_SETPOS, TRUE, 10 * 4);
}
void EditorUI_AddTimeOfDayTextToToolbar(HWND MainWindow, HINSTANCE hInstance) {
g_timeOfDayTextHwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
"Edit",
"10.00",
(WS_CHILD | WS_VISIBLE | ES_LEFT),
1105, 5, // x, y
45, 20, // width, height
MainWindow,
(HMENU)ID_TIMEOFDAYTEXT,
hInstance,
NULL
);
// try something nice, otherwise fall back on SYSTEM_FIXED_FONT
fontHandle = CreateFontIndirect(GetEditorFont());
if (fontHandle)
{
fontInfo = *GetEditorFont();
}
else
{
fontHandle = GetStockObject(SYSTEM_FIXED_FONT);
GetObject(fontHandle, sizeof(fontInfo), &fontInfo);
}
SendMessageA(g_timeOfDayTextHwnd, WM_SETFONT, (WPARAM)fontHandle, 1);
SendMessageA(g_timeOfDayTextHwnd, EM_LIMITTEXT, 8, 0);
}
void EditorUI_AddAllowRenderWindowCellLoadsCheckbox(HWND MainWindow, HINSTANCE hInstance) {
g_allowCellWindowLoadsButtonHwnd = CreateWindowEx(
NULL,
"BUTTON",
"Allow Render Window Cell Loads",
BS_PUSHLIKE | BS_CHECKBOX | WS_CHILD | WS_VISIBLE | BS_NOTIFY | BS_BITMAP,
1160, 4, // x, y
24, 21, // width, height
MainWindow,
(HMENU)ID_RENDERWINDOWCELLLOADS_CHECKBOX,
hInstance,
NULL
);
SendMessageA(g_allowCellWindowLoadsButtonHwnd, BM_SETCHECK, GetIsRenderWindowAllowCellLoads(), NULL);
HBITMAP hBitmap = (HBITMAP)LoadImage(ZeGaryHaxHandle, MAKEINTRESOURCE(IDB_ALLOW_CELL_LOADS_ICON), IMAGE_BITMAP, NULL, NULL, LR_LOADTRANSPARENT);
if (hBitmap)
{
SendMessageA(g_allowCellWindowLoadsButtonHwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
}
else
{
MessageBox(MainWindow, "Could not load icon resource.", "Error", MB_OK | MB_ICONERROR);
}
}
void EditorUI_AddRenderWindowShowPortalsCheckbox(HWND MainWindow, HINSTANCE hInstance) {
g_renderWindowShowPortalsButtonHwnd = CreateWindowEx(
NULL,
"BUTTON",
"Render Window Show Portals",
BS_PUSHLIKE | BS_CHECKBOX | WS_CHILD | WS_VISIBLE | BS_NOTIFY | BS_BITMAP,
1185, 4, // x, y
24, 21, // width, height
MainWindow,
(HMENU)ID_RENDERWINDOW_SHOWPORTALS_CHECKBOX,
hInstance,
NULL
);
SendMessageA(g_renderWindowShowPortalsButtonHwnd, BM_SETCHECK, GetIsShowPortalsAndRooms(), NULL);
HBITMAP hBitmap = (HBITMAP)LoadImage(ZeGaryHaxHandle, MAKEINTRESOURCE(IDB_SHOW_PORTALS_ICON), IMAGE_BITMAP, NULL, NULL, NULL);
SendMessageA(g_renderWindowShowPortalsButtonHwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
}
void EditorUI_AddRenderWindowShowWaterCheckbox(HWND MainWindow, HINSTANCE hInstance) {
g_renderWindowShowWaterButtonHwnd = CreateWindowEx(
NULL,
"BUTTON",
"Render Window Show Water",
BS_PUSHLIKE | BS_CHECKBOX | WS_CHILD | WS_VISIBLE | BS_NOTIFY | BS_BITMAP,
1210, 4, // x, y
24, 21, // width, height
MainWindow,
(HMENU)ID_RENDERWINDOW_SHOWWATER_CHECKBOX,
hInstance,
NULL
);
SendMessageA(g_renderWindowShowWaterButtonHwnd, BM_SETCHECK, GetIsShowWater(), NULL);
HBITMAP hBitmap = (HBITMAP)LoadImage(ZeGaryHaxHandle, MAKEINTRESOURCE(IDB_SHOW_WATER_ICON), IMAGE_BITMAP, NULL, NULL, NULL);
SendMessageA(g_renderWindowShowWaterButtonHwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);
}
void AddExtraButtonsAndSliders(HWND hWnd, HINSTANCE hInstance)
{
if (config.bShowTimeOfDaySlider) {
EditorUI_AddSliderToToolbar(hWnd, hInstance);
EditorUI_AddTimeOfDayTextToToolbar(hWnd, hInstance);
}
if (config.bShowAdditionalToolbarButtons) {
EditorUI_AddAllowRenderWindowCellLoadsCheckbox(hWnd, hInstance);
EditorUI_AddRenderWindowShowWaterCheckbox(hWnd, hInstance);
EditorUI_AddRenderWindowShowPortalsCheckbox(hWnd, hInstance);
}
}
void MoveChildWindow(HWND hwndChild, LPPOINT offset)
{
// Get the current position of the child window
RECT rcChild;
GetWindowRect(hwndChild, &rcChild);
MapWindowPoints(HWND_DESKTOP, GetParent(hwndChild), (LPPOINT)&rcChild, 2); // Convert to parent-relative coordinates
// Calculate the new position
int newX = rcChild.left + offset->x;
int newY = rcChild.top + offset->y;
// Move the child window to the new position
SetWindowPos(hwndChild, NULL, newX, newY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
void OpenExtenderPreferences()
{
ShellExecuteA(0, "open", IniPath, 0, 0, SW_NORMAL);
}
void InjectOpenSettingsMenuItem(HMENU hMenu)
{
HMENU hSubMenu = GetSubMenu(hMenu, 0);
if (hSubMenu != nullptr)
{
ModifyMenu(hSubMenu, 40620, MF_BYCOMMAND | MF_STRING, 40620, "Extender Preferences...");
WriteRelCall(0x44408E, UInt32(OpenExtenderPreferences));
}
}
LRESULT CALLBACK MainWindowCallback(HWND Hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
if (Message == WM_CREATE)
{
static bool editorUIInit = false;
if (!editorUIInit)
{
const CREATESTRUCT* createInfo = (CREATESTRUCT*)lParam;
if (_stricmp(createInfo->lpszName, "Garden of Eden Creation Kit") != 0 || _stricmp(createInfo->lpszName, "Garden of Eden Creation Kit") != 0)
{
ExitProcess(0);
}
editorUIInit = true;
g_MainHwnd = Hwnd;
InjectOpenSettingsMenuItem(createInfo->hMenu);
CreateExtensionMenu(Hwnd, createInfo->hMenu);
AddExtraButtonsAndSliders(Hwnd, createInfo->hInstance);
if (*config.sLaunchExeName)
{
InsertMenu(createInfo->hMenu, -1, MF_BYPOSITION | MF_STRING, (UINT_PTR)UI_EXTMENU_LAUNCHGAME, "Launch Game");
}
g_MainMenu = createInfo->hMenu;
EnableMenuItem(g_MainMenu, MENUOPTION_RENDER_WINDOW, MF_ENABLED);
CheckMenuItem(g_MainMenu, MENUOPTION_RENDER_WINDOW, MF_CHECKED);
if (!config.bAllowRecompileAll)
{
EnableMenuItem(g_MainMenu, MENUOPTION_RECOMPILE_ALL, MF_DISABLED | MF_GRAYED);
// patch switch table offset for recompile all menu button
SafeWrite8(0x4455E0, 0xE8);
// patch switch table for script edit recompile all button
SafeWrite16(0x5C4E3C, 0x4D6B);
}
if (config.bObjectWindowOnlyShowEditedByDefault)
{
ToggleObjectWindowFilterUnedited(false);
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_OBJECTWINDOW_TOGGLESHOWUNEDITED, FALSE, &menuInfo);
}
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
if (!config.bAutoScroll == 0)
{
// Enable scroll
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_AUTOSCROLL, FALSE, &menuInfo);
PostMessageA(g_ConsoleHwnd, UI_CMD_AUTOSCROLL, (WPARAM)true, 0);
}
if (!config.bEnableSpellChecker == 0)
{
// Enable spellchecker
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_SPELLCHECK, FALSE, &menuInfo);
PostMessageA(g_ConsoleHwnd, UI_EXTMENU_SPELLCHECK, (WPARAM)true, 0);
}
if (!config.bRenderWindowUncap == 0)
{
// Enable Render Uncap
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_RENDER, FALSE, &menuInfo);
PostMessageA(g_ConsoleHwnd, UI_EXTMENU_RENDER, (WPARAM)true, 0);
}
if (!config.bPreviewWindowUncap == 0)
{
// Enable Preview Uncap
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_PREVIEW, FALSE, &menuInfo);
PostMessageA(g_ConsoleHwnd, UI_EXTMENU_PREVIEW, (WPARAM)true, 0);
}
if (!config.bShowLoadFilesAtStartup == 0) {
// open esm/esp selection window at startup
if (*(BYTE*)(0xECFE16) != 1) { // is not NIF mode
PostMessageA(g_MainHwnd, WM_COMMAND, 0x9CD1, 0);
}
}
if (!config.bNavmeshAllowPlaceAboveOthers == 0)
{
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_TOGGLENAVEMESHBISECT, FALSE, &menuInfo);
PostMessageA(g_ConsoleHwnd, UI_EXTMENU_TOGGLENAVEMESHBISECT, (WPARAM)true, 0);
ToggleNavmeshPlaceAboveOthers(true);
}
}
}
else if (Message == WM_COMMAND)
{
const uint32_t param = LOWORD(wParam);
switch (param)
{
case UI_EXTMENU_SHOWLOG:
{
ShowWindow(g_ConsoleHwnd, SW_SHOW);
SetForegroundWindow(g_ConsoleHwnd);
}
return 0;
case UI_EXTMENU_CLEARLOG:
{
PostMessageA(g_ConsoleHwnd, UI_CMD_CLEARLOGTEXT, 0, 0);
}
return 0;
case UI_EXTMENU_LOOKUPFORM:
{
FormSearch::Show();
}
return 0;
case UI_EXTMENU_VIEW_MODIFIED_FORMS:
{
ModifiedFormViewer::Show();
}
return 0;
case UI_EXTMENU_VIEW_NAVMESH_IGNORED_FORMS:
{
NavMeshPickPreventer::ShowList();
}
return 0;
case UI_EXTMENU_AUTO_ADD_TO_MULTIBOUNDS:
{
MultiBoundsAdder::TestObjects(false);
}
return 0;
case UI_EXTMENU_READD_TO_MULTIBOUNDS:
{
MultiBoundsAdder::TestObjects(true);
}
return 0;
case UI_EXTMENU_AUTOSCROLL:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
GetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_AUTOSCROLL, FALSE, &menuInfo);
if (menuInfo.fState == MFS_CHECKED)
{
// Disable scroll
menuInfo.fState = MFS_UNCHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_AUTOSCROLL, FALSE, &menuInfo);
PostMessageA(g_ConsoleHwnd, UI_CMD_AUTOSCROLL, (WPARAM)false, 0);
}
else
{
// Enable scroll
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_AUTOSCROLL, FALSE, &menuInfo);
PostMessageA(g_ConsoleHwnd, UI_CMD_AUTOSCROLL, (WPARAM)true, 0);
}
}
return 0;
case UI_EXTMENU_SPELLCHECK:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
GetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_SPELLCHECK, FALSE, &menuInfo);
if (menuInfo.fState == MFS_CHECKED)
{
// Disable Spell Check
menuInfo.fState = MFS_UNCHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_SPELLCHECK, FALSE, &menuInfo);
config.bEnableSpellChecker = 0;
char buffer[8];
WritePrivateProfileString("General", "bEnableSpellChecker", _itoa(config.bEnableSpellChecker, buffer, 2), IniPath);
}
else
{
// Enable Spell Check
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_SPELLCHECK, FALSE, &menuInfo);
config.bEnableSpellChecker = 1;
char buffer[8];
WritePrivateProfileString("General", "bEnableSpellChecker", _itoa(config.bEnableSpellChecker, buffer, 2), IniPath);
}
}
return 0;
case UI_EXTMENU_RENDER:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
GetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_RENDER, FALSE, &menuInfo);
if (menuInfo.fState == MFS_CHECKED)
{
// Disable Render Uncap
menuInfo.fState = MFS_UNCHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_RENDER, FALSE, &menuInfo);
config.bRenderWindowUncap = 0;
char buffer[8];
WritePrivateProfileString("General", "bRenderWindowUncap", _itoa(config.bRenderWindowUncap, buffer, 2), IniPath);
}
else
{
// Enable Render Uncap
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_RENDER, FALSE, &menuInfo);
config.bRenderWindowUncap = 1;
char buffer[8];
WritePrivateProfileString("General", "bRenderWindowUncap", _itoa(config.bRenderWindowUncap, buffer, 2), IniPath);
}
}
return 0;
case UI_EXTMENU_PREVIEW:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
GetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_PREVIEW, FALSE, &menuInfo);
if (menuInfo.fState == MFS_CHECKED)
{
// Disable Preview Uncap
menuInfo.fState = MFS_UNCHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_PREVIEW, FALSE, &menuInfo);
config.bPreviewWindowUncap = 0;
char buffer[8];
WritePrivateProfileString("General", "bPreviewWindowUncap", _itoa(config.bPreviewWindowUncap, buffer, 2), IniPath);
}
else
{
// Enable Preview Uncap
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_PREVIEW, FALSE, &menuInfo);
config.bPreviewWindowUncap = 1;
char buffer[8];
WritePrivateProfileString("General", "bPreviewWindowUncap", _itoa(config.bPreviewWindowUncap, buffer, 2), IniPath);
}
}
return 0;
case UI_EXTMENU_OBJECTWINDOW_TOGGLESHOWUNEDITED:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
GetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_OBJECTWINDOW_TOGGLESHOWUNEDITED, FALSE, &menuInfo);
if (menuInfo.fState == MFS_CHECKED)
{
// Disable showing unedited
menuInfo.fState = MFS_UNCHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_OBJECTWINDOW_TOGGLESHOWUNEDITED, FALSE, &menuInfo);
ToggleObjectWindowFilterUnedited(true);
}
else
{
// Show unedited only
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_OBJECTWINDOW_TOGGLESHOWUNEDITED, FALSE, &menuInfo);
ToggleObjectWindowFilterUnedited(false);
}
ObjectsView::Refresh();
}
return 0;
case UI_EXTMENU_LAUNCHGAME:
{
LaunchGame::Launch();
}
return 0;
case UI_EXTMENU_SAVEPOSITION:
{
GetCamera(&savedRenderPos, &savedRenderDirection);
}
return 0;
case UI_EXTMENU_LOADPOSITION:
{
SetCamera(&savedRenderPos, &savedRenderDirection);
}
return 0;
case UI_EXTMENU_TOGGLENAVEMESHBISECT:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
GetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_TOGGLENAVEMESHBISECT, FALSE, &menuInfo);
if (menuInfo.fState == MFS_CHECKED)
{
menuInfo.fState = MFS_UNCHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_TOGGLENAVEMESHBISECT, FALSE, &menuInfo);
ToggleNavmeshPlaceAboveOthers(false);
}
else
{
// Show unedited only
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_ExtensionMenu, UI_EXTMENU_TOGGLENAVEMESHBISECT, FALSE, &menuInfo);
ToggleNavmeshPlaceAboveOthers(true);
}
// save state to ini
char buffer[8];
WritePrivateProfileString("Render Window", "bNavmeshAllowPlaceAboveOthers", _itoa(config.bNavmeshAllowPlaceAboveOthers, buffer, 2), IniPath);
}
return 0;
case ID_TIMEOFDAYTEXT:
{
if (GetFocus() != (HWND)lParam) break;
if (HIWORD(wParam) == EN_MAXTEXT) break;
char text[16];
int len = SendMessageA((HWND)lParam, EM_GETLINE, 0, (LPARAM)text);
text[len] = '\0'; // null terminate the line since EM_GETLINE does not
float time = atof(text);
SetTimeOfDay(time);
SendMessageA(g_trackBarHwnd, TBM_SETPOS, TRUE, time * 4); // update scrollbar
}
return 0;
case ID_RENDERWINDOWCELLLOADS_CHECKBOX:
{
if (HIWORD(wParam) == BN_CLICKED && config.bShowAdditionalToolbarButtons)
{
bool newButtonState = !SendMessageA(g_allowCellWindowLoadsButtonHwnd, BM_GETCHECK, 0, 0);
SendMessageA(g_allowCellWindowLoadsButtonHwnd, BM_SETCHECK, newButtonState, 0);
ToggleRenderWindowAllowCellLoads(newButtonState);
}
}
return 0;
case ID_RENDERWINDOW_SHOWWATER_CHECKBOX:
{
if (HIWORD(wParam) == BN_CLICKED && config.bShowAdditionalToolbarButtons)
{
bool newButtonState = !SendMessageA(g_renderWindowShowWaterButtonHwnd, BM_GETCHECK, 0, 0);
SendMessageA(g_renderWindowShowWaterButtonHwnd, BM_SETCHECK, newButtonState, 0);
SetIsShowWater(newButtonState);
}
}
return 0;
case ID_RENDERWINDOW_SHOWPORTALS_CHECKBOX:
{
if (HIWORD(wParam) == BN_CLICKED && config.bShowAdditionalToolbarButtons)
{
bool newButtonState = !SendMessageA(g_renderWindowShowPortalsButtonHwnd, BM_GETCHECK, 0, 0);
SendMessageA(g_renderWindowShowPortalsButtonHwnd, BM_SETCHECK, newButtonState, 0);
SetIsShowPortalsAndRooms(newButtonState);
}
}
return 0;
case MENUOPTION_RENDER_WINDOW:
{
MENUITEMINFO menuInfo;
menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_STATE;
GetMenuItemInfo(g_MainMenu, MENUOPTION_RENDER_WINDOW, FALSE, &menuInfo);
if (menuInfo.fState == MFS_CHECKED)
{
// Hide window
menuInfo.fState = MFS_UNCHECKED;
SetMenuItemInfo(g_MainMenu, MENUOPTION_RENDER_WINDOW, FALSE, &menuInfo);
ShowWindow(RenderWindow::GetWindow(), false);
}
else
{
// Show window
menuInfo.fState = MFS_CHECKED;
SetMenuItemInfo(g_MainMenu, MENUOPTION_RENDER_WINDOW, FALSE, &menuInfo);
ShowWindow(RenderWindow::GetWindow(), true);
}
}
return 0;
case MAIN_WINDOW_CALLBACK:
{
auto callback = reinterpret_cast<void(*)()>(lParam);
callback();
}
return 0;
}
}
else if (Message == WM_SETTEXT && Hwnd == g_MainHwnd)
{
// Continue normal execution but with a custom string
char customTitle[256];
stbsp_snprintf(customTitle, sizeof(customTitle), "%s -= Extender Rev. 0.47 =-", (const char*)lParam);
return CallWindowProc(originalMainWindowCallback, Hwnd, Message, wParam, (LPARAM)customTitle);
}
else if (Message == WM_HSCROLL && config.bShowTimeOfDaySlider)
{
if ((HWND)lParam == g_trackBarHwnd)
{
char timeBuf[100];
if ((LOWORD(wParam) == SB_THUMBPOSITION || LOWORD(wParam) == SB_THUMBTRACK))
{
float time = HIWORD(wParam) * 0.25;
SetTimeOfDay(time);
stbsp_sprintf(timeBuf, "%.2f", time);
SetWindowTextA(g_timeOfDayTextHwnd, timeBuf);
}
else if (LOWORD(wParam) == SB_ENDSCROLL)
{
float time = SendMessageA(g_trackBarHwnd, TBM_GETPOS, 0, 0) * 0.25;
SetTimeOfDay(time);
stbsp_sprintf(timeBuf, "%.2f", time);
SetWindowTextA(g_timeOfDayTextHwnd, timeBuf);
}
return 0;
}
}
else if (Message == WM_MOVE)
{
static int prevX, prevY = 0;
// Extract the new position from lParam
int newX = LOWORD(lParam); // New x-coordinate
int newY = HIWORD(lParam); // New y-coordinate
if ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0)
{
// Calculate the offset based on the new and old positions
POINT offset = { newX - prevX, newY - prevY };
for (auto pWindow : { RenderWindow::GetWindow(), CellView::GetWindow(), ObjectsView::GetWindow() })
{
MoveChildWindow(pWindow, &offset);
}
}
// Update the previous position for the next move
prevX = newX;
prevY = newY;
}
return CallWindowProc(originalMainWindowCallback, Hwnd, Message, wParam, lParam);
}
void ExtensionsMenu_InitHooks()
{
originalMainWindowCallback = *(WNDPROC*)0x0044612D;
SafeWrite32(0x0044612D, (UInt32)MainWindowCallback);
}