-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTMStuffImGuiStyle.cpp
More file actions
248 lines (221 loc) · 11.6 KB
/
TMStuffImGuiStyle.cpp
File metadata and controls
248 lines (221 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#include "TMStuffImGuiStyle.h"
CMwClassInfo TMStuff::CTMStuffImGuiStyle::m_MwClassInfo_TMStuffImGuiStyle;
SMwActionInfo CTMStuffImGuiStyle_Capture;
SMwActionInfo CTMStuffImGuiStyle_Set;
SMwActionInfo CTMStuffImGuiStyle_Edit;
void TMStuff::CTMStuffImGuiStyle::Init()
{
printf("Creating TMStuffConfigImGui class...\n");
CMwClassInfo* MwClassInfo_CMwNod = GbxTools::GetClassInfoByMwClassId(0x01001000);
GbxTools::CreateMwClassInfo(&m_MwClassInfo_TMStuffImGuiStyle, 0x48002000, MwClassInfo_CMwNod, "CTMStuffImGuiStyle", (void*)MwNewCTMStuffImGuiStyle);
m_MwClassInfo_TMStuffImGuiStyle.m_MemberCount = 3;
m_MwClassInfo_TMStuffImGuiStyle.m_MemberInfos = (SMwMemberInfo**)malloc(sizeof(SMwMemberInfo*) * m_MwClassInfo_TMStuffImGuiStyle.m_MemberCount);
GbxTools::SetMwMemberInfo(&CTMStuffImGuiStyle_Capture, 0x48002000, "Capture", "m_Capture", "Capture", SMwMemberInfo::eFlags::SET, (void*)TMStuff::CTMStuffImGuiStyle::Capture);
m_MwClassInfo_TMStuffImGuiStyle.m_MemberInfos[0] = &CTMStuffImGuiStyle_Capture;
GbxTools::SetMwMemberInfo(&CTMStuffImGuiStyle_Set, 0x48002001, "Set", "m_Set", "Set", SMwMemberInfo::eFlags::SET, (void*)TMStuff::CTMStuffImGuiStyle::Set);
m_MwClassInfo_TMStuffImGuiStyle.m_MemberInfos[1] = &CTMStuffImGuiStyle_Set;
GbxTools::SetMwMemberInfo(&CTMStuffImGuiStyle_Edit, 0x48002002, "Edit", "m_Edit", "Edit", SMwMemberInfo::eFlags::SET, (void*)TMStuff::CTMStuffImGuiStyle::Edit);
m_MwClassInfo_TMStuffImGuiStyle.m_MemberInfos[2] = &CTMStuffImGuiStyle_Edit;
// add it to the engine
CMwEngineManager* engine_man = GbxTools::GetEngineManager();
CMwEngineManager::AddClass(engine_man, &m_MwClassInfo_TMStuffImGuiStyle);
}
void** vtable_TMStuffImGuiStyle = nullptr;
TMStuff::CTMStuffImGuiStyle* TMStuff::CTMStuffImGuiStyle::MwNewCTMStuffImGuiStyle()
{
if(!vtable_TMStuffImGuiStyle) {
// prep vtable for first use
vtable_TMStuffImGuiStyle = (void**)malloc(0x80);
if(memcpy_s(vtable_TMStuffImGuiStyle, 0x80, vtable_CMwNod, 0x80)) // copy vtable from CMwNod
{
printf("err: %s\n", strerror(errno));
}
vtable_TMStuffImGuiStyle[0] = (void*)TMStuff::CTMStuffImGuiStyle::vDelete;
vtable_TMStuffImGuiStyle[1] = (void*)TMStuff::CTMStuffImGuiStyle::vMwGetClassInfo;
vtable_TMStuffImGuiStyle[2] = (void*)TMStuff::CTMStuffImGuiStyle::vGetMwClassId;
vtable_TMStuffImGuiStyle[3] = (void*)TMStuff::CTMStuffImGuiStyle::vMwIsKindOf;
vtable_TMStuffImGuiStyle[4] = (void*)TMStuff::CTMStuffImGuiStyle::vMwGetId;
vtable_TMStuffImGuiStyle[13] = (void*)TMStuff::CTMStuffImGuiStyle::vGetUidParamFromIndex;
vtable_TMStuffImGuiStyle[14] = (void*)TMStuff::CTMStuffImGuiStyle::vGetParamCount;
vtable_TMStuffImGuiStyle[16] = (void*)TMStuff::CTMStuffImGuiStyle::vChunk;
vtable_TMStuffImGuiStyle[17] = (void*)TMStuff::CTMStuffImGuiStyle::vGetChunkInfo;
vtable_TMStuffImGuiStyle[18] = (void*)TMStuff::CTMStuffImGuiStyle::vGetUidChunkFromIndex;
vtable_TMStuffImGuiStyle[19] = (void*)TMStuff::CTMStuffImGuiStyle::vGetChunkCount;
}
// create nod
TMStuff::CTMStuffImGuiStyle* nod = (TMStuff::CTMStuffImGuiStyle*)malloc(sizeof(TMStuff::CTMStuffImGuiStyle));
if(nod != nullptr) {
memset(nod, 0, sizeof(TMStuff::CTMStuffImGuiStyle));
void (__thiscall* callable)(CMwNod* in_nod) = (void (__thiscall* )(CMwNod* in_nod))0x004d6140; // CMwNod constructor
callable(nod); // CMwNod(nod);
void** new_class_vtable = (void**)nod;
new_class_vtable[0] = vtable_TMStuffImGuiStyle;
// prep members
nod->m_Style = ImGuiStyle();
nod->m_ShowEditor = false;
return nod;
}
return nullptr;
}
TMStuff::CTMStuffImGuiStyle* __thiscall TMStuff::CTMStuffImGuiStyle::vDelete(CTMStuffImGuiStyle* nod, byte purge)
{
void (__thiscall* vDelCMwNod)(CMwNod* nod) = (void (__thiscall*)(CMwNod* nod))0x004d61a0;
void** new_class_vtable = (void**)nod;
new_class_vtable[0] = vtable_TMStuffImGuiStyle;
vDelCMwNod(nod);
if((purge & 1) != 0) {
free(nod);
}
return nod;
}
void __thiscall TMStuff::CTMStuffImGuiStyle::vChunk(TMStuff::CTMStuffImGuiStyle* nod, CClassicArchive* pA, int chunkId)
{
void (__thiscall* CMwId_Archive)(CMwId* id, CClassicArchive* pA) = (void (__thiscall* )(CMwId* id, CClassicArchive* pA))0x004dd680;
void (__thiscall* DoBool)(CClassicArchive* pArchive, Bool* value, int amount) = (void (__thiscall* )(CClassicArchive* pArchive, Bool* value, int amount))0x0041eb80;
void (__thiscall* DoReal)(CClassicArchive* pArchive, Real* value, int amount) = (void (__thiscall* )(CClassicArchive* pArchive, Real* value, int amount))0x0041eb20;
void (__thiscall* DoInteger)(CClassicArchive* pArchive, Integer* value, int amount, Bool isHex) = (void (__thiscall* )(CClassicArchive* pArchive, Integer* value, int amount, Bool isHex))0x0041ea40;
void (__thiscall* DoNatural)(CClassicArchive* pArchive, Natural* value, int amount, Bool isHex) = (void (__thiscall* )(CClassicArchive* pArchive, Natural* value, int amount, Bool isHex))0x0041e9e0;
void (__thiscall* CMwNod_Chunk)(CMwNod* nod, CClassicArchive* pA, int chunkId) = (void (__thiscall* )(CMwNod* nod, CClassicArchive* pA, int chunkId))vtable_CMwNod[16];
switch(chunkId) {
case 0x48002000: {
CMwId_Archive(&nod->m_IdName, pA);
break;
}
case 0x48002001: {
DoReal(pA, &nod->m_Style.Alpha, 1);
DoReal(pA, &nod->m_Style.DisabledAlpha, 1);
DoReal(pA, &nod->m_Style.WindowPadding.x, 1);
DoReal(pA, &nod->m_Style.WindowPadding.y, 1);
DoReal(pA, &nod->m_Style.WindowRounding, 1);
DoReal(pA, &nod->m_Style.WindowBorderSize, 1);
DoReal(pA, &nod->m_Style.WindowMinSize.x, 1);
DoReal(pA, &nod->m_Style.WindowMinSize.y, 1);
DoReal(pA, &nod->m_Style.WindowTitleAlign.x, 1);
DoReal(pA, &nod->m_Style.WindowTitleAlign.y, 1);
DoInteger(pA, (Integer*)&nod->m_Style.WindowMenuButtonPosition, 1, 0);
DoReal(pA, &nod->m_Style.ChildRounding, 1);
DoReal(pA, &nod->m_Style.ChildBorderSize, 1);
DoReal(pA, &nod->m_Style.PopupRounding, 1);
DoReal(pA, &nod->m_Style.PopupBorderSize, 1);
DoReal(pA, &nod->m_Style.FramePadding.x, 1);
DoReal(pA, &nod->m_Style.FramePadding.y, 1);
DoReal(pA, &nod->m_Style.FrameRounding, 1);
DoReal(pA, &nod->m_Style.FrameBorderSize, 1);
DoReal(pA, &nod->m_Style.ItemSpacing.x, 1);
DoReal(pA, &nod->m_Style.ItemSpacing.y, 1);
DoReal(pA, &nod->m_Style.ItemInnerSpacing.x, 1);
DoReal(pA, &nod->m_Style.ItemInnerSpacing.y, 1);
DoReal(pA, &nod->m_Style.CellPadding.x, 1);
DoReal(pA, &nod->m_Style.CellPadding.y, 1);
DoReal(pA, &nod->m_Style.TouchExtraPadding.x, 1);
DoReal(pA, &nod->m_Style.TouchExtraPadding.y, 1);
DoReal(pA, &nod->m_Style.IndentSpacing, 1);
DoReal(pA, &nod->m_Style.ColumnsMinSpacing, 1);
DoReal(pA, &nod->m_Style.ScrollbarSize, 1);
DoReal(pA, &nod->m_Style.ScrollbarRounding, 1);
DoReal(pA, &nod->m_Style.GrabMinSize, 1);
DoReal(pA, &nod->m_Style.GrabRounding, 1);
DoReal(pA, &nod->m_Style.LogSliderDeadzone, 1);
DoReal(pA, &nod->m_Style.TabRounding, 1);
DoReal(pA, &nod->m_Style.TabBorderSize, 1);
//DoReal(pA, &nod->m_Style.TabMinWidthForCloseButton, 1); // deprecated since 1.92.1
float dummy = 0.0;
DoReal(pA, &dummy, 1);
// *
DoReal(pA, &nod->m_Style.TabBarBorderSize, 1);
DoReal(pA, &nod->m_Style.TabBarOverlineSize, 1);
DoReal(pA, &nod->m_Style.TableAngledHeadersAngle, 1);
DoReal(pA, &nod->m_Style.TableAngledHeadersTextAlign.x, 1);
DoReal(pA, &nod->m_Style.TableAngledHeadersTextAlign.y, 1);
DoInteger(pA, (Integer*)&nod->m_Style.ColorButtonPosition, 1, 0);
DoReal(pA, &nod->m_Style.ButtonTextAlign.x, 1);
DoReal(pA, &nod->m_Style.ButtonTextAlign.y, 1);
DoReal(pA, &nod->m_Style.SelectableTextAlign.x, 1);
DoReal(pA, &nod->m_Style.SelectableTextAlign.y, 1);
DoReal(pA, &nod->m_Style.SeparatorTextBorderSize, 1);
DoReal(pA, &nod->m_Style.SeparatorTextAlign.x, 1);
DoReal(pA, &nod->m_Style.SeparatorTextAlign.y, 1);
DoReal(pA, &nod->m_Style.SeparatorTextPadding.x, 1);
DoReal(pA, &nod->m_Style.SeparatorTextPadding.y, 1);
DoReal(pA, &nod->m_Style.DisplayWindowPadding.x, 1);
DoReal(pA, &nod->m_Style.DisplayWindowPadding.y, 1);
DoReal(pA, &nod->m_Style.DisplaySafeAreaPadding.x, 1);
DoReal(pA, &nod->m_Style.DisplaySafeAreaPadding.y, 1);
DoReal(pA, &nod->m_Style.MouseCursorScale, 1);
DoBool(pA, (Bool*)&nod->m_Style.AntiAliasedLines, 1);
DoBool(pA, (Bool*)&nod->m_Style.AntiAliasedLinesUseTex, 1);
DoBool(pA, (Bool*)&nod->m_Style.AntiAliasedFill, 1);
DoReal(pA, &nod->m_Style.CurveTessellationTol, 1);
DoReal(pA, &nod->m_Style.CircleTessellationMaxError, 1);
return;
}
case 0x48002002: {
int cnt = ImGuiCol_COUNT;
int cnt_overflow = 0;
DoInteger(pA, &cnt, 1, 0);
if(cnt > ImGuiCol_COUNT) { // backwards compatibility
cnt_overflow = cnt - ImGuiCol_COUNT;
cnt = ImGuiCol_COUNT;
}
for(int i=0;i<cnt;i++) {
DoReal(pA, &nod->m_Style.Colors[i].x, 1);
DoReal(pA, &nod->m_Style.Colors[i].y, 1);
DoReal(pA, &nod->m_Style.Colors[i].z, 1);
DoReal(pA, &nod->m_Style.Colors[i].w, 1);
}
for(int i=0;i<cnt_overflow;i++) {
float dummy = 0;
DoReal(pA, &dummy, 1);
DoReal(pA, &dummy, 1);
DoReal(pA, &dummy, 1);
DoReal(pA, &dummy, 1);
}
return;
}
case 0x48002003: {
DoReal(pA, &nod->m_Style.HoverStationaryDelay, 1);
DoReal(pA, &nod->m_Style.HoverDelayShort, 1);
DoReal(pA, &nod->m_Style.HoverDelayNormal, 1);
DoNatural(pA, (Natural*)&nod->m_Style.HoverFlagsForTooltipMouse, 1, 0);
DoNatural(pA, (Natural*)&nod->m_Style.HoverFlagsForTooltipNav, 1, 0);
return;
}
case 0x48002004: {
DoReal(pA, &nod->m_Style.FontSizeBase, 1);
DoReal(pA, &nod->m_Style.FontScaleMain, 1);
DoReal(pA, &nod->m_Style.FontScaleDpi, 1);
return;
}
}
CMwNod_Chunk(nod, pA, chunkId);
return;
}
int __stdcall TMStuff::CTMStuffImGuiStyle::vGetChunkInfo(int chunkId) {
int (__stdcall* CMwNod_GetChunkInfo)(int chunkId) = (int (__stdcall* )(int chunkId))vtable_CMwNod[17];
switch(chunkId) {
case 0x48002000:
case 0x48002001:
case 0x48002002:
case 0x48002003:
case 0x48002004:
return 3;
}
int res = CMwNod_GetChunkInfo(chunkId);
return res;
};
void __fastcall TMStuff::CTMStuffImGuiStyle::Capture(CTMStuffImGuiStyle* nod)
{
printf("Capturing ImGuiStyle...\n");
ImGuiStyle& style = ImGui::GetStyle();
nod->m_Style = style;
}
void __fastcall TMStuff::CTMStuffImGuiStyle::Set(CTMStuffImGuiStyle* nod)
{
printf("Setting ImGuiStyle...\n");
ImGuiStyle& style = ImGui::GetStyle();
style = nod->m_Style;
}
void __fastcall TMStuff::CTMStuffImGuiStyle::Edit(CTMStuffImGuiStyle* nod)
{
nod->m_ShowEditor = !nod->m_ShowEditor;
}