-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathUIHelpers.h
140 lines (110 loc) · 3.61 KB
/
UIHelpers.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
/*
* 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 "CXStr.h"
#include <cstdint>
namespace eqlib {
//----------------------------------------------------------------------------
// helpers
// "Controller" helper class
class ControllerBase
{
public:
EQLIB_OBJECT virtual ~ControllerBase() {}
EQLIB_OBJECT virtual ControllerBase* CreateController(CXStr& controllerName, int windowType) { return nullptr; }
EQLIB_OBJECT virtual void OnProcessFrame() {}
EQLIB_OBJECT virtual bool AboutToShow() { return true; }
EQLIB_OBJECT virtual bool AboutToHide() { return true; }
EQLIB_OBJECT virtual void WndNotification(CXWnd* sender, uint32_t message, void* data) {}
EQLIB_OBJECT virtual void SetWindow(CXWnd* pWindow) = 0;
EQLIB_OBJECT virtual void Init(const CXStr&) {}
};
class [[offsetcomments]] ControllerFactory
{
public:
virtual ~ControllerFactory();
// creates controllers
virtual ControllerBase* CreateController(const CXStr& controller, int type);
// this is probably wrong but might be the right size.
/*0x08*/ HashTable<void*, int, ResizePolicyNoShrink> Factories;
/*0x20*/
};
class [[offsetcomments]] ControllerManager
{
public:
virtual ~ControllerManager();
/*0x08*/ ControllerFactory* DefaultControllerFactory;
/*0x10*/ HashTable<ControllerFactory*> ControllerFactories;
/*0x28*/
};
//----------------------------------------------------------------------------
// A special type of controller that we create that allow us to hook an existing window
class CXWndControllerHook : public ControllerBase
{
public:
EQLIB_OBJECT CXWndControllerHook()
{
}
EQLIB_OBJECT virtual ~CXWndControllerHook()
{
Unhook();
}
EQLIB_OBJECT virtual ControllerBase* CreateController(CXStr& controllerName, int windowType) override
{
if (m_pOriginalController)
return m_pOriginalController->CreateController(controllerName, windowType);
return ControllerBase::CreateController(controllerName, windowType);
}
EQLIB_OBJECT virtual void OnProcessFrame() override
{
if (m_pOriginalController)
m_pOriginalController->OnProcessFrame();
}
EQLIB_OBJECT virtual bool AboutToShow() override
{
if (m_pOriginalController)
return m_pOriginalController->AboutToShow();
return ControllerBase::AboutToShow();
}
EQLIB_OBJECT virtual bool AboutToHide() override
{
if (m_pOriginalController)
return m_pOriginalController->AboutToShow();
return ControllerBase::AboutToHide();
}
EQLIB_OBJECT virtual void WndNotification(CXWnd* sender, uint32_t message, void* data) override
{
if (m_pOriginalController)
m_pOriginalController->WndNotification(sender, message, data);
}
EQLIB_OBJECT virtual void SetWindow(CXWnd* pWindow) override
{
if (m_pOriginalController)
m_pOriginalController->SetWindow(pWindow);
}
EQLIB_OBJECT virtual void Init(const CXStr& data) override
{
if (m_pOriginalController)
m_pOriginalController->Init(data);
}
EQLIB_OBJECT virtual void OnHooked() {}
EQLIB_OBJECT virtual void OnAboutToUnhook() {}
EQLIB_OBJECT void Hook(CXWnd* pWnd);
EQLIB_OBJECT bool Unhook();
protected:
CXWnd* m_pWnd = nullptr;
private:
ControllerBase* m_pOriginalController = nullptr;
};
} // namespace eqlib