-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathObjectWindowOverrides.cpp
163 lines (133 loc) · 5.48 KB
/
ObjectWindowOverrides.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
#include "ObjectWindowOverrides.h"
#include "MiscWindowOverrides.h"
#include "DialogImposterManager.h"
#include "HallOfFame.h"
namespace cse
{
namespace uiManager
{
std::string ObjectWindowFormListGetColumnText(HWND FormList, TESForm* Form, UInt32 ColumnIndex)
{
char Buffer[0x500];
NMLVDISPINFO CallbackInfo;
CallbackInfo.hdr.hwndFrom = FormList;
CallbackInfo.hdr.idFrom = GetDlgCtrlID(FormList);
CallbackInfo.hdr.code = LVN_GETDISPINFO;
CallbackInfo.item.mask = LVIF_TEXT;
CallbackInfo.item.lParam = reinterpret_cast<LPARAM>(Form);
CallbackInfo.item.pszText = Buffer;
CallbackInfo.item.cchTextMax = sizeof(Buffer);
CallbackInfo.item.iSubItem = ColumnIndex;
TESObjectWindow::TreeEntryInfo Dummy;
Dummy.formType = Form->formType;
Dummy.ListViewGetDispInfoCallback(&CallbackInfo);
return Buffer;
}
LRESULT CALLBACK ObjectWindowSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
bgsee::WindowSubclassProcCollection::SubclassProcExtraParams* SubclassParams)
{
LRESULT DlgProcResult = FALSE;
if (ObjectWindowImposterManager::Instance.IsImposter(hWnd))
{
// the imposter needs to handle its own messages exclusively
return DlgProcResult;
}
HWND FilterEditBox = GetDlgItem(hWnd, IDC_CSEFILTERABLEFORMLIST_FILTEREDIT);
HWND FormList = GetDlgItem(hWnd, TESObjectWindow::kFormListCtrlID);
HWND TreeList = GetDlgItem(hWnd, TESObjectWindow::kTreeViewCtrlID);
switch (uMsg)
{
case TESObjectWindow::kWindowMessage_Reload:
SubclassParams->Out.MarkMessageAsHandled = true;
// the window subclasser's windows hook has an out-sized performance penalty for
// insertions in tree view controls (probably also has to do with the way it's used in this dialog)
// so we have to temporarily suspend the hook when this code is executing
BGSEEUI->GetInvalidationManager()->Push(TreeList);
SubclassParams->In.Subclasser->SuspendHooks();
{
DlgProcResult = SubclassParams->In.Subclasser->TunnelMessageToOrgWndProc(hWnd, uMsg, wParam, lParam, true);
}
SubclassParams->In.Subclasser->ResumeHooks();
BGSEEUI->GetInvalidationManager()->Pop(TreeList);
BGSEEUI->GetInvalidationManager()->Redraw(TreeList);
break;
case WM_NOTIFY:
{
bool Skip = true;
if (((NMHDR*)lParam)->code == NM_KEYDOWN && ((NMKEY*)lParam)->nVKey == VK_F5)
Skip = false;
else if (((NMHDR*)lParam)->code == LVN_KEYDOWN && ((NMLVKEYDOWN*)lParam)->wVKey == VK_F5)
Skip = false;
else if (((NMHDR*)lParam)->code == TVN_KEYDOWN && ((NMTVKEYDOWN*)lParam)->wVKey == VK_F5)
Skip = false;
if (Skip)
break;
SubclassParams->Out.MarkMessageAsHandled = true;
ObjectWindowImposterManager::Instance.RefreshImposters();
SendMessage(hWnd, TESDialog::kWindowMessage_Refresh, NULL, NULL);
}
case WM_ACTIVATE:
ObjectWindowImposterManager::Instance.HandleObjectWindowActivating(hWnd, uMsg, wParam, lParam);
SubclassParams->Out.MarkMessageAsHandled = true;
break;
case WM_CLOSE:
SendMessage(*TESCSMain::WindowHandle, WM_COMMAND, TESCSMain::kMainMenu_View_ObjectWindow, NULL);
SubclassParams->Out.MarkMessageAsHandled = true;
break;
case TESDialog::kWindowMessage_Destroy:
case WM_DESTROY:
{
FilterableFormListManager::Instance.Unregister(FilterEditBox);
ObjectWindowImposterManager::Instance.DestroyImposters();
TESObjectWindow::PrimaryObjectWindowHandle = nullptr;
}
break;
case WM_INITDIALOG:
{
SME_ASSERT(FilterEditBox);
uiManager::FilterableFormListManager::InitParams Params;
Params.ParentWindow = hWnd;
Params.FormListView = FormList;
Params.FilterEditBox = FilterEditBox;
Params.FilterLabel = GetDlgItem(hWnd, IDC_CSEFILTERABLEFORMLIST_FILTERLBL);
Params.ColumnTextCallback = ObjectWindowFormListGetColumnText;
uiManager::FilterableFormListManager::Instance.Register(Params);
std::string WndTitle = "Object Window";
if (settings::general::kShowHallOfFameMembersInTitleBar().i != hallOfFame::kDisplayESMember_None)
{
hallOfFame::GetRandomESMember(WndTitle);
WndTitle += " Object Window";
}
SetWindowText(hWnd, WndTitle.c_str());
TESObjectWindow::PrimaryObjectWindowHandle = hWnd;
}
break;
case WM_SIZE:
ObjectWindowImposterManager::Instance.HandleObjectWindowSizing(hWnd, uMsg, wParam, lParam);
SubclassParams->Out.MarkMessageAsHandled = true;
break;
}
if (SubclassParams->Out.MarkMessageAsHandled == false && FilterableFormListManager::Instance.HandleMessages(FilterEditBox, uMsg, wParam, lParam))
{
HTREEITEM Selection = TreeView_GetSelection(TreeList);
TreeView_SelectItem(TreeList, nullptr);
TreeView_SelectItem(TreeList, Selection);
}
return DlgProcResult;
}
void InitializeObjectWindowOverrides()
{
BGSEEUI->GetSubclasser()->RegisterSubclassForDialogResourceTemplate(TESDialog::kDialogTemplate_ObjectWindow,
uiManager::ObjectWindowSubclassProc);
BGSEEUI->GetSubclasser()->RegisterSubclassForDialogResourceTemplate(TESDialog::kDialogTemplate_ObjectWindow,
uiManager::CommonDialogExtraFittingsSubClassProc);
if (settings::dialogs::kShowMainWindowsInTaskbar.GetData().i)
{
bgsee::WindowStyler::StyleData RegularAppWindow = { 0 };
RegularAppWindow.Extended = WS_EX_APPWINDOW;
RegularAppWindow.ExtendedOp = bgsee::WindowStyler::StyleData::kOperation_OR;
BGSEEUI->GetWindowStyler()->RegisterStyle(TESDialog::kDialogTemplate_ObjectWindow, RegularAppWindow);
}
}
}
}