-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGameFace.h
707 lines (598 loc) · 18 KB
/
GameFace.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
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
/*
* MacroQuest: The extension platform for EverQuest
* Copyright (C) 2002-present MacroQuest Authors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "Common.h"
#include "GraphicsEngine.h"
#include "CXWnd.h"
#include "UITemplates.h"
#include "eqstd/string.h"
#include "eqstd/unordered_map.h"
namespace eqlib {
class CGFScreenWnd;
template <typename T>
class BaseComponent
{
public:
using XWndType = T;
virtual eqstd::string GetTypeName() const { return ""; }
virtual void SyncFromJS() {}
virtual void SyncToJS() {}
T* GetTarget() const { return target; }
bool IsValid() const { return !name.empty() && target != nullptr; }
/*0x00*/ // vftable
/*0x08*/ eqstd::string name;
/*0x28*/ eqstd::string fullName;
/*0x48*/ eqstd::string modelPrefix;
/*0x68*/ CGFScreenWnd* parent;
/*0x70*/ T* target;
/*0x78*/ eqstd::string str_78;
/*0x98*/ uint64_t u64_98;
/*0xa0*/
};
class [[offsetcomments]] UIComponent : public BaseComponent<CXWnd>
{
public:
void Setup(CGFScreenWnd* parentScreenWnd, const eqstd::string& name, bool required, CXWnd* wnd);
};
class UIStaticAnimationTemplate : public BaseComponent<CStaticAnimationTemplate>
{
public:
};
class [[offsetcomments]] UIScreenComponent : public UIComponent
{
public:
/*0xa0*/ uint8_t u8_a0; // = 255
/*0xa4*/
};
class [[offsetcomments]] UIButtonComponent : public BaseComponent<CButtonWnd>
{
public:
virtual eqstd::string GetTypeName() const override { return "UIButton"; }
};
class [[offsetcomments]] UIListComponent : public BaseComponent<CListWnd>
{
public:
virtual eqstd::string GetTypeName() const override { return "UIList"; }
};
class [[offsetcomments]] UIStmlComponent : public BaseComponent<CStmlWnd>
{
public:
virtual eqstd::string GetTypeName() const override { return "UIStml"; }
/*0xa0*/
};
class [[offsetcomments]] UIInvSlotComponent
{
public:
/*0x00*/ eqstd::string name;
/*0x20*/ eqstd::string fullName;
/*0x40*/ eqstd::string modelPrefix;
/*0x60*/ CInvSlotWnd* target;
/*0x68*/ int i32_68; // -2
/*0x6c*/ float float_6c; // -1.0
/*0x70*/ float float_70; // -1.0
/*0x74*/ int i32_74;
/*0x78*/ int i32_78;
/*0x7c*/ int i32_7c;
/*0x80*/ int i32_80;
/*0x88*/ eqstd::string str_88;
/*0xa8*/
};
class [[offsetcomments]] CGFScreenWnd : public CSidlScreenWnd
{
public:
EQLIB_OBJECT CGFScreenWnd(CXWnd* parent = nullptr, bool useClassicUI = true, const CXStr& screenName = CXStr());
EQLIB_OBJECT CGFScreenWnd(CXWnd* parent, bool useClassicUI, const CXStr& screenName, int IniFlags, int IniVersion, const char* BlockName);
EQLIB_OBJECT virtual ~CGFScreenWnd();
void SetupComponent(UIComponent& component, const eqstd::string& ScreenID, bool required);
virtual void HandleJsEvent(void* a, void* b);
virtual void Unknown0x388();
virtual void Unknown0x390(const CXRect& rect);
/*0x2c8*/ UIScreenComponent WindowComponent;
/*0x370*/ eqstd::unordered_map<eqstd::string, UIComponent*> ChildComponents;
/*0x3b0*/
struct [[offsetcomments]] VirtualFunctionTable : public CSidlScreenWnd::VirtualFunctionTable
{
/*0x380*/ void* HandleJsEvent; // Probably something like HandleJSEvent
/*0x388*/ void* Unknown0x388;
/*0x390*/ void* Unknown0x390; // Probably Center()
/*0x398*/ };
// Returns the current instance of this class's vftable. Might represent some other
// inherited class (and not CSidlScreenWnd's)
VirtualFunctionTable* GetVFTable()
{
if (this == nullptr) return nullptr;
return *reinterpret_cast<VirtualFunctionTable**>(this);
}
void ReplaceVFTable(VirtualFunctionTable* table)
{
if (this == nullptr) return;
*reinterpret_cast<VirtualFunctionTable**>(this) = table;
}
// points to the eq instance of the virtual function table for this class
static VirtualFunctionTable* sm_vftable;
};
//----------------------------------------------------------------------------
EQLIB_VAR bool gbUseNewUIEngine;
template <typename Component, typename T = typename Component::XWndType>
T* GetNewUIEngineWindow(T* old, const Component& component)
{
if (gbUseNewUIEngine)
{
return component.name.empty() ? nullptr : static_cast<T*>(component.target);
}
return old;
}
namespace cohtml {
//============================================================================
// IAllocator
//============================================================================
enum class MemTags
{
Unknown = 0,
Untagged,
System,
Logging,
Loader,
DOM,
DOMStatic,
Layout,
CSS,
CSSStatic,
TaskSystemMemory,
Display,
Profiling,
HTMLParser,
TempAllocator,
PoolAllocator,
Dump,
Script,
XML,
Server,
Inspector,
SVG,
UnityPlugin,
UriParser,
Media,
JSON,
Count
};
class IAllocator
{
public:
IAllocator();
virtual void* Allocate(unsigned size, cohtml::MemTags memtag) = 0;
virtual void* Reallocate(void* ptr, unsigned size, cohtml::MemTags memtag) = 0;
virtual void Deallocate(void* ptr, cohtml::MemTags memtag) = 0;
virtual void* AlignedAllocate(unsigned size, unsigned alignment, cohtml::MemTags memtag) = 0;
virtual void AlignedDeallocate(void* ptr, cohtml::MemTags memtag) = 0;
virtual void* VirtualAllocate(void* hint, unsigned size, int protection, int flags, cohtml::MemTags memtag) = 0;
virtual bool VirtualFree(void* ptr, unsigned size, int flags, cohtml::MemTags memtag) = 0;
virtual ~IAllocator();
};
//============================================================================
// IAsyncResourceHandler
//============================================================================
class IAsyncResourceRequest;
class IAsyncResourceResponse;
class IAsyncResourceStreamResponse;
//============================================================================
class IAsyncResourceHandler
{
public:
IAsyncResourceHandler();
virtual ~IAsyncResourceHandler();
virtual void OnResourceRequest(const cohtml::IAsyncResourceRequest* request,
cohtml::IAsyncResourceResponse* response) = 0;
virtual void OnResourceStreamRequest(const cohtml::IAsyncResourceRequest* request,
cohtml::IAsyncResourceStreamResponse* response) = 0;
virtual void OnAbortResourceRequest(unsigned id) = 0;
};
//============================================================================
// IViewListener
//============================================================================
struct ScreenInfo
{
uint32_t Width;
uint32_t Height;
uint32_t AvailableWidth;
uint32_t AvailableHeight;
uint32_t ColorDepth;
uint32_t PixelDepth;
};
struct EventModifiersState
{
bool shift;
bool ctrl;
bool alt;
bool meta;
bool numLock;
bool capsLock;
};
struct EventMouseModifiersState
{
bool left;
bool middle;
bool right;
bool back;
bool forward;
};
enum InterceptRequestStatus
{
Allow,
Restrict,
};
enum class EventAction
{
ContinueHandling,
InterruptHandling,
};
enum class InputEventPhase
{
None,
Capturing,
AtTarget,
Bubbling,
};
enum class TextInputControlType
{
TextInput,
Other,
};
enum class CursorTypes
{
Alias,
AllScroll,
Auto,
Cell,
ContextMenu,
ColResize,
Copy,
Crosshair,
Default,
EResize,
EWResize,
Grab,
Grabbing,
Help,
Move,
NResize,
NEResize,
NESWResize,
NSResize,
NWResize,
NWSEResize,
NoDrop,
None,
NotAllowed,
Pointer,
Progress,
RowResize,
SResize,
SEResize,
SWResize,
Text,
URL,
VerticalText,
WResize,
Wait,
ZoomIn,
ZoomOut,
};
class INodeProxy;
// Data for a cohtml mouse event
struct MouseEventData
{
enum EventType
{
MouseMove,
MouseDown,
MouseUp,
MouseWheel,
MouseLeave,
};
enum MouseButton
{
MouseLeft,
MouseMiddle,
MouseRight,
ButtonBack,
ButtonForward,
};
EventType type;
MouseButton button;
int x;
int y;
float wheelX;
float wheelY;
int deltaX;
int deltaY;
EventModifiersState modifiers;
EventMouseModifiersState mouseModifiers;
};
// Data for a cohtml keyboard event
struct KeyEventData
{
enum EventType
{
Unknown,
KeyDown,
KeyUp,
Char,
};
enum EventLocation
{
Standard,
Left,
Right,
Numpad,
};
int keyCode;
EventType type;
EventModifiersState modifiers;
EventLocation location;
bool isAutoRepeat;
bool isNumPad;
bool isSystemKey;
};
struct IClipboardData
{
virtual void Set(const char* text, unsigned int lengthBytes) = 0;
virtual ~IClipboardData() {}
};
class IClientSideSocket;
class ISocketListener;
class IViewListener
{
public:
virtual ~IViewListener();
virtual bool OnNavigateTo(const char* url);
virtual cohtml::InterceptRequestStatus OnResourceRequestIntercepted(const char* url);
virtual void OnScriptContextCreated();
virtual void OnDOMBuilt();
virtual void OnLoadFailed(const char* url, const char* error);
virtual void OnFinishLoad(const char* url);
virtual void OnReadyForBindings(); // overridden
virtual void OnBindingsReleased(); // overridden
virtual cohtml::ScreenInfo OnScreenInfoRequested();
virtual cohtml::EventAction OnNodeMouseEvent(const cohtml::INodeProxy* node,
const cohtml::MouseEventData* event, void* userData, cohtml::InputEventPhase phase);
virtual cohtml::EventAction OnNodeKeyEvent(const cohtml::INodeProxy* node,
const cohtml::KeyEventData* event, void* userData, cohtml::InputEventPhase phase);
virtual void OnAudioStreamCreated(int id, int bitDepth, int channels, float samplingRate);
virtual void OnAudioStreamClosed(int id);
virtual void OnAudioStreamPlay(int id);
virtual void OnAudioStreamPause(int id);
virtual void OnAudioDataReceived(int id, int samples, float** pcm, int channels);
virtual void OnAudoStreamEnded(int id);
virtual void OnAudioStreamVolumneChanged(int id, float volume);
virtual void OnTextInputTypeChanged(cohtml::TextInputControlType type);
virtual void OnCaretRectChanged(int x, int y, unsigned int width, unsigned int height);
virtual void OnIMEShouldCancelComposition();
virtual void OnCursorChanged(cohtml::CursorTypes cursor, const char* url, const float* xHotSpot, const float* yHotSpot); // overridden
virtual void OnClipboardTextSet(const char* text, unsigned int lengthBytes);
virtual void OnClipboardTextGet(cohtml::IClipboardData*);
virtual cohtml::IClientSideSocket* OnCreateWebSocket(cohtml::ISocketListener* listener, const char* url, const char** protocol, unsigned int protocolsCount);
};
//============================================================================
// ILogHandler
//============================================================================
namespace Logging {
enum Severity
{
Trace,
Debug,
Info,
Warning,
Error,
AssertFailure,
Critical,
SeveritiesCount,
};
class ILogHandler
{
public:
ILogHandler();
virtual ~ILogHandler();
virtual void WriteLog(cohtml::Logging::Severity, const char* message, size_t length) = 0;
};
} // namespace Logging;
//============================================================================
class System;
class SystemRenderer;
class View;
class ViewRenderer;
class Library {
public:
};
class System {
public:
};
//----------------------------------------------------------------------------
struct ViewRendererSettings {};
class SystemRenderer {
public:
/*0x00*/ virtual ~SystemRenderer();
/*0x08*/ virtual ViewRenderer* CreateViewRenderer(View* owner, const ViewRendererSettings& settings) = 0;
/*0x10*/ virtual void Destroy() = 0;
/*0x18*/ virtual void RegisterRenderThread(void* /* renoir::RendererBackend* */ backend) = 0;
/*0x20*/ virtual void FreeRenderingResources() = 0;
};
class View {
public:
};
class ViewRenderer {
public:
};
class ArgumentsBinder;
class IEventHandler {
public:
virtual ~IEventHandler() {}
virtual void Invoke(ArgumentsBinder* binder) = 0;
virtual const void* GetTarget() = 0;
virtual void SetTarget(void* target) = 0;
};
//============================================================================
} // namespace cohtml
namespace GF {
//============================================================================
class LogHandler : public cohtml::Logging::ILogHandler
{
public:
virtual void WriteLog(cohtml::Logging::Severity, const char* message, size_t length) override;
};
class Allocator : public cohtml::IAllocator
{
public:
Allocator();
virtual ~Allocator();
virtual void* Allocate(unsigned size, cohtml::MemTags memtag) { return nullptr; }
virtual void* Reallocate(void* ptr, unsigned size, cohtml::MemTags memtag) { return nullptr; }
virtual void Deallocate(void* ptr, cohtml::MemTags memtag) {}
virtual void* AlignedAllocate(unsigned size, unsigned alignment, cohtml::MemTags memtag) { return nullptr; }
virtual void AlignedDeallocate(void* ptr, cohtml::MemTags memtag) {}
virtual void* VirtualAllocate(void* hint, unsigned size, int protection, int flags, cohtml::MemTags memtag) { return nullptr; }
virtual bool VirtualFree(void* ptr, unsigned size, int flags, cohtml::MemTags memtag) { return false; }
};
class ViewListener_Object3;
class AsyncResourceHandler : public cohtml::IAsyncResourceHandler
{
public:
virtual ~AsyncResourceHandler() {}
virtual void OnResourceRequest(const cohtml::IAsyncResourceRequest* request, cohtml::IAsyncResourceResponse* response) {}
virtual void OnResourceStreamRequest(const cohtml::IAsyncResourceRequest* request, cohtml::IAsyncResourceStreamResponse* response) {}
virtual void OnAbortResourceRequest(unsigned id) {}
// Size of node = 0x10 + sizeof(key) + sizeof(value0
struct UnknownObject {
uint8_t data[0x40];
}; // probably a resource of some kind.
struct UnknownObject2 {
uint8_t data[0x28];
};
/*0x000*/ // vftable
/*0x008*/ eqstd::unordered_map<eqstd::string, UnknownObject> mappings; // node size: 0x70
/*0x048*/ void* a;
/*0x050*/ void* b;
/*0x058*/ void* c;
/*0x060*/ void* d; // looks like a pointer to a pointer to a string
/*0x068*/ void* e;
/*0x070*/ void* f;
/*0x078*/ eqstd::unordered_map<eqstd::string, UnknownObject2> mappings2; // node size: 0x58
/*0x0b8*/ uint32_t u32_b8;
/*0x0c0*/ CGameFaceRenderInterface* pGameFaceRenderInterface;
/*0x0c8*/ ViewListener_Object3* pObject3;
// probably a subobject
/*0x0d0*/ eqstd::unordered_map<int, void*> mappings3;
/*0x110*/ /* +40 */ bool mappings3Unknown;
/*0x118*/
};
// size: 0x58
class [[offsetcomments]] ViewListener_Object1
{
public:
/*0x00*/ eqstd::unordered_map<eqstd::string, void*> unordered_map_00;
/*0x40*/ void* pointer_40;
/*0x48*/ void* pointer_48;
/*0x50*/ void* pointer_50;
/*0x58*/
};
// This interface is probably exposed by the graphics engine. The implementation
// is passed back to it.
class ViewListener_Object2_Interface
{
public:
/*0x00*/ virtual ~ViewListener_Object2_Interface() {}
/*0x08*/ virtual void UnknownVirtualFunction1() = 0;
/*0x10*/ virtual void UnknownVirtualFunction2() = 0;
/*0x18*/ virtual void UnknownVirtualFunction3() = 0;
/*0x20*/ virtual void UnknownVirtualFunction4() = 0;
/*0x28*/ virtual void UnknownVirtualFunction5() = 0;
};
class ViewListener;
// size: 0x30
class [[offsetcomments]] ViewListener_Object2 : public ViewListener_Object2_Interface
{
public:
virtual ~ViewListener_Object2() {}
virtual void UnknownVirtualFunction1() {}
virtual void UnknownVirtualFunction2() {}
virtual void UnknownVirtualFunction3() {}
virtual void UnknownVirtualFunction4() {}
virtual void UnknownVirtualFunction5() {}
/*0x00*/ // vftable
/*0x08*/ ViewListener* pViewListener; // 1b8
/*0x10*/ CGameFaceRenderInterface* pGameFaceRender; // 1c0
/*0x18*/ CResourceManagerInterface* pResourceManager; // 1c8
/*0x20*/ uint64_t u64_1d0;
/*0x28*/ uint64_t u64_1d8;
/*0x30*/ // 1e0
};
// size: 0xa0
class [[offsetcomments]] ViewListener_Object3
{
public:
struct UnknownObject1 { // size: 0x40
/*0x00*/ eqstd::string fileName;
/*0x20*/ uint32_t width;
/*0x24*/ uint32_t height;
/*0x28*/ eqstd::string* string_ptr_28; // probably a pointer to an object that starts with a string
/*0x20*/ uint64_t data[2];
/*0x40*/
};
struct UnknownObject2 {
/*0x00*/ eqstd::string pieceName;
/*0x20*/ uint64_t data[5];
/*0x48*/
};
/*0x00*/ eqstd::string string_00;
/*0x20*/ eqstd::unordered_map<eqstd::string, UnknownObject1> map_20; // node size: 0x70
/*0x60*/ eqstd::unordered_map<eqstd::string, UnknownObject2> map_60; // node size: 0x78
/*0xa0*/
};
// size: 0x498
class [[offsetcomments]] ViewListener : public cohtml::IViewListener
{
public:
virtual void OnReadyForBindings() override;
virtual void OnBindingsReleased() override;
virtual void OnTextInputTypeChanged(cohtml::TextInputControlType type) override;
virtual void OnCursorChanged(cohtml::CursorTypes cursor, const char* url, const float* xHotSpot, const float* yHotSpot) override;
/*0x000*/ // vftable
/*0x008*/ cohtml::Library* pLibrary;
/*0x010*/ cohtml::System* pSystem;
/*0x018*/ cohtml::SystemRenderer* pSystemRenderer;
/*0x020*/ cohtml::ViewRenderer* pViewRenderer;
/*0x028*/ cohtml::View* pView;
/*0x030*/ LogHandler logHandler;
/*0x038*/ Allocator allocator;
/*0x040*/ AsyncResourceHandler resourceHandler;
/*0x158*/ ViewListener_Object1 object1;
/*0x1b0*/ ViewListener_Object2 object2;
/*0x1e0*/ eqstd::unordered_map<void*, void*> map_1e0; // node size: 0x20
/*0x220*/ uint64_t u64_220[2]; // [0] = frame counter?
/*0x230*/ cohtml::IEventHandler* pEventHandler; // maybe?
/*0x238*/ uint32_t u32_238[2];
/*0x240*/ ViewListener_Object3 object3;
/*0x2e0*/ ViewListener_Object3 object4;
/*0x380*/ ViewListener_Object3 object5;
/*0x420*/ eqstd::string string_420;
/*0x440*/ bool bool_440;
/*0x448*/ eqstd::string string_448;
/*0x468*/ bool bool_468;
/*0x46c*/ uint32_t u32_46c;
/*0x470*/ uint64_t u64_470[5]; // cursor, click focus?
/*0x498*/
};
} // namespace GF
extern GF::ViewListener* g_pViewListener;
} // namespace eqlib