-
Notifications
You must be signed in to change notification settings - Fork 7
/
ScaleformUtil.h
371 lines (328 loc) · 9.75 KB
/
ScaleformUtil.h
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
#pragma once
#include "skse64/ScaleformValue.h"
namespace Tralala
{
class GFxValue;
void ScaleformUtilGetAddresses();
class ScaleformHeap
{
public:
virtual void Fn_00(void);
virtual void Fn_01(void);
virtual void Fn_02(void);
virtual void Fn_03(void);
virtual void Fn_04(void);
virtual void Fn_05(void);
virtual void Fn_06(void);
virtual void Fn_07(void);
virtual void Fn_08(void);
virtual void Fn_09(void);
virtual void * Allocate(size_t size, UInt32 unk = 0); // unk is probably align, maybe flags (haven't traced)
virtual void Fn_0B(void);
virtual void Free(void * ptr);
static ScaleformHeap * GetSingleton();
};
void * ScaleformHeap_Allocate(UInt32 size);
void ScaleformHeap_Free(void * ptr);
class GRefCountImplCore
{
public:
GRefCountImplCore() :refCount(1) { }
virtual ~GRefCountImplCore() { }
// void ** _vtbl; // 00
volatile SInt32 refCount; // 08
// redirect new/delete to the scaleform heap
static void * operator new(std::size_t size)
{
return ScaleformHeap_Allocate(size);
}
static void * operator new(std::size_t size, const std::nothrow_t &)
{
return ScaleformHeap_Allocate(size);
}
// placement new
static void * operator new(std::size_t size, void * ptr)
{
return ptr;
}
static void operator delete(void * ptr)
{
ScaleformHeap_Free(ptr);
}
// placement delete
static void operator delete(void *, void *)
{
//
}
void AddRef(void)
{
InterlockedIncrement(&refCount);
}
void Release(void)
{
if (InterlockedDecrement(&refCount) == 0)
{
delete this;
}
}
};
class GRefCountImpl : public GRefCountImplCore
{
public:
GRefCountImpl() { }
virtual ~GRefCountImpl() { }
};
class GRefCountBaseStatImpl : public GRefCountImpl
{
public:
GRefCountBaseStatImpl() { }
virtual ~GRefCountBaseStatImpl() { }
};
class GRefCountBase : public GRefCountBaseStatImpl
{
public:
GRefCountBase() { }
virtual ~GRefCountBase() { }
};
// 08
class FxDelegateHandler : public GRefCountBase
{
public:
FxDelegateHandler() {}
virtual ~FxDelegateHandler() {}
virtual void Accept(void * processor) = 0;
};
class GFxMovieView : public GRefCountBase
{
public:
GFxMovieView();
virtual ~GFxMovieView();
virtual void * GetMovieDef();
virtual UInt32 Unk_02(void);
virtual UInt32 Unk_03(void);
virtual void GotoFrame(UInt32 idx);
virtual bool GotoLabeledFrame(const char * label, UInt32 unk);
virtual void SetPause(UInt32 pause);
virtual UInt32 GetPause(void);
virtual void SetVisible(bool visible);
virtual bool GetVisible();
virtual bool IsPathAvailable(const char * path);
virtual void CreateString(GFxValue * value, const char * str);
virtual void CreateWideString(GFxValue * value, const wchar_t * str);
virtual void CreateObject(GFxValue * value, const char * className = NULL, GFxValue * args = NULL, UInt32 numArgs = 0);
virtual void CreateArray(GFxValue * value);
virtual void CreateFunction(GFxValue * value, void * callback, void * refcon = NULL);
virtual void SetVariable(const char * name, GFxValue * value, UInt32 flags);
virtual bool GetVariable(GFxValue * value, const char * name);
virtual bool SetArray(UInt32 type, const char * name, UInt32 offset, void * buf, UInt32 len, UInt32 flags);
virtual bool ResizeArray(const char * name, UInt32 len, UInt32 flags);
virtual UInt32 GetArrayLen(const char * name); // 050
virtual bool GetArray(UInt32 type, const char * name, UInt32 offset, void * buf, UInt32 len);
virtual bool Invoke(const char * name, GFxValue * result, GFxValue * args, UInt32 numArgs);
virtual bool Invoke(const char * name, GFxValue * result, const char * fmt, ...);
virtual bool Invoke_v(const char * name, GFxValue * result, const char * fmt, va_list args); // 060
virtual void SetViewport(const GViewport & viewDesc);
virtual void GetViewport(GViewport *pviewDesc) const;
virtual void Unk_1B(UInt32 unk); // SE: 0D8 (Skyrim32: 06C)
virtual void Unk_1C(void); // 070
virtual void Unk_1D(void);
virtual void Unk_1E(void);
virtual GRectF GetVisibleFrameRect(void);
virtual void Unk_20(void); // 080
virtual void Unk_21(void);
virtual void Unk_22(void);
virtual void Unk_23(void);
virtual void Unk_24(void); // 090
virtual void Unk_25(void);
virtual void Render(void);
virtual void Unk_27(void);
virtual void Unk_28(void); // 0A0
virtual void Unk_29(void);
virtual void Unk_2A(void);
virtual void Unk_2B(void);
virtual void Unk_2C(void); // 0B0
virtual UInt32 HandleEvent(void* data);
virtual void Unk_2E(void);
virtual void Unk_2F(void);
virtual void Unk_30(void);
virtual void Unk_31(void);
virtual void Unk_32(void);
virtual void Unk_33(void);
virtual void Unk_34(void);
virtual void Unk_35(void);
virtual void Unk_36(void);
virtual void Unk_37(void);
virtual void Unk_38(void);
virtual void Unk_39(void);
virtual void Unk_3A(void);
virtual void Unk_3B(void);
virtual void Unk_3C(void);
virtual void Unk_3D(void);
virtual void Unk_3E(void);
virtual void Unk_3F(void);
virtual void Unk_40(void);
virtual void Unk_41(void);
virtual void Unk_42(void);
virtual void Unk_43(void);
virtual void Unk_44(void);
virtual void ForceCollectGarbage(void);
// more
};
// 10
class GFxValue
{
public:
GFxValue()
:objectInterface(NULL), type(kType_Undefined) { }
GFxValue(const GFxValue& src)
:objectInterface(NULL), type(src.type)
{
data = src.data;
if (src.IsManaged()) AddManaged(src);
}
~GFxValue();
const GFxValue& operator = (const GFxValue& src)
{
if (this != &src)
{
if (IsManaged()) CleanManaged();
type = src.type;
data = src.data;
if (src.IsManaged()) AddManaged(src);
}
return *this;
}
enum
{
kType_Undefined = 0,
kType_Null,
kType_Bool,
kType_Number,
kType_String,
kType_WideString,
kType_Object,
kType_Array,
kType_DisplayObject,
kTypeFlag_Managed = 1 << 6,
kMask_Type = 0x8F, // not sure why it checks the top bit
};
union Data
{
double number;
bool boolean;
const char * string;
const char ** managedString;
const wchar_t * wideString;
const wchar_t ** managedWideString;
void * obj;
};
//#pragma pack (push, 8)
class DisplayInfo
{
public:
DisplayInfo() : _varsSet(0) {}
enum
{
kChange_x = (1 << 0),
kChange_y = (1 << 1),
kChange_rotation = (1 << 2),
kChange_xscale = (1 << 3),
kChange_yscale = (1 << 4),
kChange_alpha = (1 << 5),
kChange_visible = (1 << 6),
kChange_z = (1 << 7),
kChange_xrotation = (1 << 8),
kChange_yrotation = (1 << 9),
kChange_zscale = (1 << 10),
kChange_FOV = (1 << 11),
kChange_projMatrix3D = (1 << 12),
kChange_viewMatrix3D = (1 << 13)
};
double _x;
double _y;
double _rotation;
double _xScale;
double _yScale;
double _alpha;
bool _visible;
double _z;
double _xRotation;
double _yRotation;
double _zScale;
double _perspFOV;
GMatrix3D _viewMatrix3D;
GMatrix3D _perspectiveMatrix3D;
UInt16 _varsSet;
void SetX(double x) { SetFlags(kChange_x); _x = x; }
void SetY(double y) { SetFlags(kChange_y); _y = y; }
void SetRotation(double degrees) { SetFlags(kChange_rotation); _rotation = degrees; }
void SetXScale(double xscale) { SetFlags(kChange_xscale); _xScale = xscale; }
void SetYScale(double yscale) { SetFlags(kChange_yscale); _yScale = yscale; }
void SetAlpha(double alpha) { SetFlags(kChange_alpha); _alpha = alpha; }
void SetVisible(bool visible) { SetFlags(kChange_visible); _visible = visible; }
void SetZ(double z) { SetFlags(kChange_z); _z = z; }
void SetXRotation(double degrees) { SetFlags(kChange_xrotation); _xRotation = degrees; }
void SetYRotation(double degrees) { SetFlags(kChange_yrotation); _yRotation = degrees; }
void SetZScale(double zscale) { SetFlags(kChange_zscale); _zScale = zscale; }
void SetFOV(double fov) { SetFlags(kChange_FOV); _perspFOV = fov; }
void SetProjectionMatrix3D(const GMatrix3D *pmat)
{
if (pmat) {
SetFlags(kChange_projMatrix3D);
_perspectiveMatrix3D = *pmat;
}
else
ClearFlags(kChange_projMatrix3D);
}
void SetViewMatrix3D(const GMatrix3D *pmat)
{
if (pmat) {
SetFlags(kChange_viewMatrix3D);
_viewMatrix3D = *pmat;
}
else
ClearFlags(kChange_viewMatrix3D);
}
// Convenience functions
void SetPosition(double x, double y) { SetFlags(kChange_x | kChange_y); _x = x; _y = y; }
void SetScale(double xscale, double yscale) { SetFlags(kChange_xscale | kChange_yscale); _xScale = xscale; _yScale = yscale; }
void SetFlags(UInt32 flags) { _varsSet |= flags; }
void ClearFlags(UInt32 flags) { _varsSet &= ~flags; }
};
//#pragma pack (pop)
// 4
class ObjectInterface
{
public:
GFxMovieRoot * root;
};
ObjectInterface * objectInterface; // 00
UInt32 type; // 08
Data data; // 10
UInt32 GetType(void) const { return type & kMask_Type; }
bool IsManaged(void) const { return (type & kTypeFlag_Managed) != 0; }
void CleanManaged(void);
void AddManaged(void);
void AddManaged(const GFxValue& src);
bool IsObject(void) const { return GetType() == kType_Object; }
bool IsDisplayObject(void) const { return GetType() == kType_DisplayObject; }
void SetUndefined(void);
void SetNull(void);
void SetBool(bool value);
void SetNumber(double value);
void SetString(const char * value);
void SetWideString(const wchar_t * value);
bool Invoke(const char * name, GFxValue * result, GFxValue * args, UInt32 numArgs);
};
class GFxLoader
{
public:
UInt32 unk00; // 00
void * stateBag; // 04
UInt32 unk08; // 08
UInt32 unk0C; // 0C
void * imageLoader; // 10
static GFxLoader * GetSingleton();
bool LoadMovie(void* menu, GFxMovieView ** viewOut, const char* name, int arg4, float arg5);
};
}