-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathEventSources.cpp
300 lines (250 loc) · 8.39 KB
/
EventSources.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
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
#include "EventSources.h"
using namespace SME::MiscGunk;
namespace cse
{
namespace events
{
TypedEventSource::TypedEventSource(UInt32 TypeID) :
IEventSource(),
TypeID(TypeID)
{
SME_ASSERT(TypeID > kType__BEGIN && TypeID < kType__END);
Register(this);
}
const UInt32 TypedEventSource::GetTypeID() const
{
return TypeID;
}
TypedEventSource::~TypedEventSource()
{
DEBUG_ASSERT(Sinks.size() == 0);
Unregister(this);
}
TypedEventSource::EventSourceArrayT& TypedEventSource::GetRegistry()
{
static EventSourceArrayT kRegistry;
return kRegistry;
}
void TypedEventSource::Register(TypedEventSource* Source)
{
EventSourceArrayT& Registry = GetRegistry();
EventSourceArrayT::iterator Match = std::find(Registry.begin(), Registry.end(), Source);
DEBUG_ASSERT(Match == Registry.end());
GetRegistry().push_back(Source);
}
void TypedEventSource::Unregister(TypedEventSource * Source)
{
EventSourceArrayT& Registry = GetRegistry();
EventSourceArrayT::iterator Match = std::find(Registry.begin(), Registry.end(), Source);
DEBUG_ASSERT(Match != Registry.end());
Registry.erase(Match);
}
void TypedEventSource::Deinitialize()
{
EventSourceArrayT& Registry = GetRegistry();
bool HasActiveSinks = false;
for (auto Itr : Registry)
{
if (Itr->Sinks.size())
{
HasActiveSinks = true;
BGSEECONSOLE_MESSAGE("TypedEventSource %d has %d active sinks at shutdown", (UInt32)Itr->TypeID, Itr->Sinks.size());
}
}
SME_ASSERT(HasActiveSinks == false);
}
BasicEventSource::BasicEventSource(UInt32 Type) :
TypedEventSource(Type)
{
;//
}
void BasicEventSource::RaiseEvent() const
{
IEventData Data(this);
Dispatch(&Data);
}
BasicTESFileEventSource::BasicTESFileEventSource(UInt32 Type) :
TypedEventSource(Type)
{
;//
}
void BasicTESFileEventSource::RaiseEvent(TESFile* File) const
{
TESFileEventData Data(this, File);
Dispatch(&Data);
}
TESFileEventData::TESFileEventData(const BasicTESFileEventSource* Source, TESFile* File) :
IEventData(Source),
File(File)
{
;//
}
TESFormEventData::TESFormEventData(const BasicTESFormEventSource* Source, TESForm* Form, UInt8 Type) :
IEventData(Source),
Form(Form),
EventType(Type)
{
NewEditorID = nullptr;
NewFormID = 0;
ActiveState = false;
DeletedState = false;
}
BasicTESFormEventSource::BasicTESFormEventSource(UInt32 Type) :
TypedEventSource(Type)
{
}
void BasicTESFormEventSource::HandleInstantiation(TESForm* Form) const
{
TESFormEventData Data(this, Form, TESFormEventData::kType_Instantiation);
Dispatch(&Data);
}
void BasicTESFormEventSource::HandleSetActive(TESForm* Form, bool State) const
{
TESFormEventData Data(this, Form, TESFormEventData::kType_SetActive);
Data.ActiveState = State;
Dispatch(&Data);
}
void BasicTESFormEventSource::HandleSetDeleted(TESForm* Form, bool State) const
{
TESFormEventData Data(this, Form, TESFormEventData::kType_SetDeleted);
Data.DeletedState = State;
Dispatch(&Data);
}
void BasicTESFormEventSource::HandleSetFormID(TESForm* Form, UInt32 FormID) const
{
TESFormEventData Data(this, Form, TESFormEventData::kType_SetFormID);
Data.NewFormID = FormID;
Dispatch(&Data);
}
void BasicTESFormEventSource::HandleSetEditorID(TESForm* Form, const char* EditorID) const
{
TESFormEventData Data(this, Form, TESFormEventData::kType_SetEditorID);
Data.NewEditorID = EditorID;
Dispatch(&Data);
}
namespace general
{
BasicEventSource kShutdown(TypedEventSource::kType_Shutdown);
}
namespace plugin
{
BasicEventSource kPreLoad(TypedEventSource::kType_Plugin_PreLoad);
BasicEventSource kPostLoad(TypedEventSource::kType_Plugin_PostLoad);
BasicTESFileEventSource kPreSave(TypedEventSource::kType_Plugin_PreSave);
BasicEventSource kPostSave(TypedEventSource::kType_Plugin_PostSave);
BasicEventSource kClearData(TypedEventSource::kType_Plugin_ClearData);
BasicEventSource kConstructSpecialForms(TypedEventSource::kType_Plugin_ConstructSpecialForms);
}
namespace renderer
{
PreSceneGraphRenderData::PreSceneGraphRenderData(const PreSceneGraphRenderEventSource* Source, NiCamera* Camera, NiNode* SceneGraph, NiCullingProcess* CullingProc, BSRenderedTexture* RenderTarget) :
IEventData(Source),
Camera(Camera),
SceneGraph(SceneGraph),
CullingProc(CullingProc),
RenderTarget(RenderTarget)
{
;//
}
PreSceneGraphRenderEventSource::PreSceneGraphRenderEventSource() :
TypedEventSource(kType_Renderer_PreMainSceneGraphRender)
{
}
void PreSceneGraphRenderEventSource::RaiseEvent(NiCamera* Camera, NiNode* SceneGraph, NiCullingProcess* CullingProc, BSRenderedTexture* RenderTarget) const
{
PreSceneGraphRenderData Data(this, Camera, SceneGraph, CullingProc, RenderTarget);
Dispatch(&Data);
}
BSFadeNodeDrawData::BSFadeNodeDrawData(const BSFadeNodeDrawEventSource* Source, BSFadeNode* Node, UInt32 EventType) :
IEventData(Source),
Node(Node),
EventType(EventType)
{
auto RefProp = NI_CAST(TESRender::GetExtraData(Node, "REF"), TESObjectExtraData);
if (RefProp)
ParentRef = RefProp->refr;
else
ParentRef = nullptr;
}
BSFadeNodeDrawEventSource::BSFadeNodeDrawEventSource(UInt32 EventType) :
TypedEventSource(EventType)
{
;//
}
void BSFadeNodeDrawEventSource::RaiseEvent(BSFadeNode* Node) const
{
BSFadeNodeDrawData Data(this, Node, GetTypeID() == TypedEventSource::kType_Renderer_PreBSFadeNodeDraw ? BSFadeNodeDrawData::kType_PreDraw : BSFadeNodeDrawData::kType_PostDraw);
Dispatch(&Data);
}
BasicEventSource kRelease(TypedEventSource::kType_Renderer_Release);
BasicEventSource kRenew(TypedEventSource::kType_Renderer_Renew);
PreSceneGraphRenderEventSource kPreSceneGraphRender;
BasicEventSource kPostSceneGraphRender(TypedEventSource::kType_Renderer_PostMainSceneGraphRender);
BasicEventSource kPostRenderWindowUpdate(TypedEventSource::kType_Renderer_PostRenderWindowUpdate);
BSFadeNodeDrawEventSource kPreBSFadeNodeDraw(TypedEventSource::kType_Renderer_PreBSFadeNodeDraw);
BSFadeNodeDrawEventSource kPostBSFadeNodeDraw(TypedEventSource::kType_Renderer_PostBSFadeNodeDraw);
}
namespace dialog
{
namespace cellView
{
CellViewDialogEventSource::CellViewDialogEventSource(UInt32 Type) :
TypedEventSource(Type)
{
SME_ASSERT(Type > kType__BEGIN_CELLVIEW && Type < kType__END_CELLVIEW);
}
void CellViewDialogEventSource::HandleSelectCell(TESObjectCELL* Cell) const
{
CellViewDialogEventData Data(this, Cell, CellViewDialogEventData::kType_SelectCell);
Dispatch(&Data);
}
CellViewDialogEventData::CellViewDialogEventData(const CellViewDialogEventSource* Source, TESObjectCELL* Cell, UInt32 Type) :
IEventData(Source),
Cell(Cell),
EventType(Type)
{
SME_ASSERT(Cell);
}
CellViewDialogEventSource kSelectCell(TypedEventSource::kType_CellView_SelectCell);
}
namespace renderWindow
{
RenderWindowDialogEventSource::RenderWindowDialogEventSource(UInt32 Type) :
TypedEventSource(Type)
{
SME_ASSERT(Type > kType__BEGIN_RENDERWINDOW && Type < kType__END_RENDERWINDOW);
}
void RenderWindowDialogEventSource::HandlePlaceRef(TESObjectREFR* NewRef) const
{
RenderWindowDialogEventData Data(this, RenderWindowDialogEventData::kType_PlaceRef);
Data.PlacedRef = NewRef;
Dispatch(&Data);
}
RenderWindowDialogEventData::RenderWindowDialogEventData(const RenderWindowDialogEventSource* Source, UInt32 Type) :
IEventData(Source),
EventType(Type)
{
PlacedRef = nullptr;
}
RenderWindowDialogEventSource kPlaceRef(TypedEventSource::kType_RenderWindow_PlaceRef);
}
BasicEventSource kCloseAll(TypedEventSource::kType_Dialog_CloseAll);
}
namespace form
{
BasicTESFormEventSource kInstantiation(TypedEventSource::kType_Form_Instantiation);
BasicTESFormEventSource kSetActive(TypedEventSource::kType_Form_SetActive);
BasicTESFormEventSource kSetDeleted(TypedEventSource::kType_Form_SetDeleted);
BasicTESFormEventSource kSetFormID(TypedEventSource::kType_Form_SetFormID);
BasicTESFormEventSource kSetEditorID(TypedEventSource::kType_Form_SetEditorID);
}
void InitializeSources()
{
;//
}
void DeinitializeSources()
{
TypedEventSource::Deinitialize();
}
}
}