CommonLibSSE (Parapets fork)
Loading...
Searching...
No Matches
Interfaces.h
Go to the documentation of this file.
1#pragma once
2
3#include "RE/G/GFxMovieView.h"
4#include "RE/G/GFxValue.h"
8
9#include "SKSE/Impl/Stubs.h"
10#include "SKSE/Version.h"
11
12namespace SKSE
13{
14 struct PluginInfo;
15
17 {
18 public:
19 [[nodiscard]] std::uint32_t EditorVersion() const;
20 [[nodiscard]] bool IsEditor() const;
21 [[nodiscard]] REL::Version RuntimeVersion() const;
22 [[nodiscard]] std::uint32_t SKSEVersion() const;
23
24 protected:
25 [[nodiscard]] const detail::SKSEInterface* GetProxy() const;
26 };
27
29 {
30 public:
31 enum : std::uint32_t
32 {
41 kTotal
42 };
43
44 [[nodiscard]] PluginHandle GetPluginHandle() const;
45 const PluginInfo* GetPluginInfo(const char* a_name) const;
46 [[nodiscard]] std::uint32_t GetReleaseIndex() const;
47 [[nodiscard]] void* QueryInterface(std::uint32_t a_id) const;
48 };
49
51 {
52 public:
53 using RegCallback = bool(RE::GFxMovieView* a_view, RE::GFxValue* a_root);
54 using RegInvCallback = void(RE::GFxMovieView* a_view, RE::GFxValue* a_object, RE::InventoryEntryData* a_item);
55
56 enum
57 {
58 kVersion = 2
59 };
60
61 [[nodiscard]] std::uint32_t Version() const;
62
63 bool Register(RegCallback* a_callback, const char* a_name) const;
64 void Register(RegInvCallback* a_callback) const;
65
66 protected:
67 [[nodiscard]] const detail::SKSEScaleformInterface* GetProxy() const;
68 };
69
71 {
72 public:
73 using EventCallback = void(SerializationInterface* a_intfc);
74 using FormDeleteCallback = void(RE::VMHandle a_handle);
75
76 enum
77 {
78 kVersion = 4
79 };
80
81 [[nodiscard]] std::uint32_t Version() const;
82
83 void SetUniqueID(std::uint32_t a_uid) const;
84
86 void SetLoadCallback(EventCallback* a_callback) const;
87 void SetRevertCallback(EventCallback* a_callback) const;
88 void SetSaveCallback(EventCallback* a_callback) const;
89
90 bool WriteRecord(std::uint32_t a_type, std::uint32_t a_version, const void* a_buf, std::uint32_t a_length) const;
91
92 template <
93 class T,
94 std::enable_if_t<
95 std::negation_v<
96 std::is_pointer<T>>,
97 int> = 0>
98 inline std::uint32_t WriteRecord(std::uint32_t a_type, std::uint32_t a_version, const T& a_buf) const
99 {
100 return WriteRecord(a_type, a_version, std::addressof(a_buf), sizeof(T));
101 }
102
103 template <
104 class T,
105 std::size_t N,
106 std::enable_if_t<
107 std::is_array_v<T>,
108 int> = 0>
109 inline std::uint32_t WriteRecord(std::uint32_t a_type, std::uint32_t a_version, const T (&a_buf)[N]) const
110 {
111 return WriteRecord(a_type, a_version, std::addressof(a_buf), sizeof(T) * N);
112 }
113
114 [[nodiscard]] bool OpenRecord(std::uint32_t a_type, std::uint32_t a_version) const;
115
116 bool WriteRecordData(const void* a_buf, std::uint32_t a_length) const;
117
118 template <
119 class T,
120 std::enable_if_t<
121 std::negation_v<
122 std::is_pointer<T>>,
123 int> = 0>
124 inline std::uint32_t WriteRecordData(const T& a_buf) const
125 {
126 return WriteRecordData(std::addressof(a_buf), sizeof(T));
127 }
128
129 template <
130 class T,
131 std::size_t N,
132 std::enable_if_t<
133 std::is_array_v<T>,
134 int> = 0>
135 inline std::uint32_t WriteRecordData(const T (&a_buf)[N]) const
136 {
137 return WriteRecordData(std::addressof(a_buf), sizeof(T) * N);
138 }
139
140 bool GetNextRecordInfo(std::uint32_t& a_type, std::uint32_t& a_version, std::uint32_t& a_length) const;
141
142 std::uint32_t ReadRecordData(void* a_buf, std::uint32_t a_length) const;
143
144 template <
145 class T,
146 std::enable_if_t<
147 std::negation_v<
148 std::is_pointer<T>>,
149 int> = 0>
150 inline std::uint32_t ReadRecordData(T& a_buf) const
151 {
152 return ReadRecordData(std::addressof(a_buf), sizeof(T));
153 }
154
155 template <
156 class T,
157 std::size_t N,
158 std::enable_if_t<
159 std::is_array_v<T>,
160 int> = 0>
161 inline std::uint32_t ReadRecordData(T (&a_buf)[N]) const
162 {
163 return ReadRecordData(std::addressof(a_buf), sizeof(T) * N);
164 }
165
166 bool ResolveFormID(RE::FormID a_oldFormID, RE::FormID& a_newFormID) const;
167 bool ResolveHandle(RE::VMHandle a_oldHandle, RE::VMHandle& a_newHandle) const;
168
169 protected:
170 [[nodiscard]] const detail::SKSESerializationInterface* GetProxy() const;
171 };
172
174 {
175 public:
176 using TaskFn = std::function<void()>;
177
178 enum
179 {
180 kVersion = 2
181 };
182
183 [[nodiscard]] std::uint32_t Version() const;
184
185 void AddTask(TaskFn a_task) const;
186 void AddTask(TaskDelegate* a_task) const;
187 void AddUITask(TaskFn a_task) const;
188 void AddUITask(UIDelegate_v1* a_task) const;
189
190 protected:
192 {
193 public:
194 Task(TaskFn&& a_fn);
195
196 void Run() override;
197 void Dispose() override;
198
199 private:
200 TaskFn _fn;
201 };
202
204 {
205 public:
206 UITask(TaskFn&& a_fn);
207
208 void Run() override;
209 void Dispose() override;
210
211 private:
212 TaskFn _fn;
213 };
214
215 [[nodiscard]] const detail::SKSETaskInterface* GetProxy() const;
216 };
217
219 {
220 public:
223
224 enum
225 {
226 kVersion = 1
227 };
228
229 [[nodiscard]] std::uint32_t Version() const;
230
231 template <class Last>
232 bool Register(Last a_last) const
233 {
234 return Register_Impl(a_last);
235 }
236
237 template <class First, class... Rest>
238 bool Register(First a_first, Rest... a_rest) const
239 {
240 return Register_Impl(a_first) && Register(a_rest...);
241 }
242
243 protected:
244 [[nodiscard]] const detail::SKSEPapyrusInterface* GetProxy() const;
245
246 private:
247 bool Register_Impl(RegFunction1* a_fn) const;
248 bool Register_Impl(RegFunction2* a_fn) const;
249 };
250
252 {
253 public:
254 struct Message
255 {
256 const char* sender;
257 std::uint32_t type;
258 std::uint32_t dataLen;
259 void* data;
260 };
261
262 using EventCallback = void(Message* a_msg);
263
264 enum
265 {
266 kVersion = 2
267 };
268
269 enum : std::uint32_t
270 {
280
281 kTotal
282 };
283
284 enum class Dispatcher : std::uint32_t
285 {
286 kModEvent = 0,
291
292 kTotal
293 };
294
295 [[nodiscard]] std::uint32_t Version() const;
296
297 bool Dispatch(std::uint32_t a_messageType, void* a_data, std::uint32_t a_dataLen, const char* a_receiver) const;
298 [[nodiscard]] void* GetEventDispatcher(Dispatcher a_dispatcherID) const;
299 bool RegisterListener(EventCallback* a_callback) const;
300 bool RegisterListener(const char* a_sender, EventCallback* a_callback) const;
301
302 protected:
303 [[nodiscard]] const detail::SKSEMessagingInterface* GetProxy() const;
304 };
305
307 {
308 public:
309 enum
310 {
311 kVersion = 1
312 };
313
314 [[nodiscard]] std::uint32_t Version() const;
315
316 [[nodiscard]] SKSEDelayFunctorManager& GetDelayFunctorManager() const;
317 [[nodiscard]] SKSEObjectRegistry& GetObjectRegistry() const;
318 [[nodiscard]] SKSEPersistentObjectStorage& GetPersistentObjectStorage() const;
319
320 private:
321 [[nodiscard]] const detail::SKSEObjectInterface* GetProxy() const;
322 };
323
325 {
326 public:
327 enum
328 {
329 kVersion = 1
330 };
331
332 [[nodiscard]] std::uint32_t Version() const;
333
334 [[nodiscard]] void* AllocateFromBranchPool(std::size_t a_size) const;
335 [[nodiscard]] void* AllocateFromLocalPool(std::size_t a_size) const;
336
337 private:
338 [[nodiscard]] const detail::SKSETrampolineInterface* GetProxy() const;
339 };
340
342 {
343 enum
344 {
345 kVersion = 1
346 };
347
348 std::uint32_t infoVersion;
349 const char* name;
350 std::uint32_t version;
351 };
352
354 {
355 public:
356 enum
357 {
359 };
360
361 constexpr void AuthorEmail(std::string_view a_email) noexcept { SetCharBuffer(a_email, std::span{ supportEmail }); }
362 constexpr void AuthorName(std::string_view a_name) noexcept { SetCharBuffer(a_name, std::span{ author }); }
363
364 constexpr void CompatibleVersions(std::initializer_list<REL::Version> a_versions) noexcept
365 {
366 assert(a_versions.size() < std::size(compatibleVersions) - 1);
367 std::transform(
368 a_versions.begin(),
369 a_versions.end(),
370 std::begin(compatibleVersions),
371 [](const REL::Version& a_version) noexcept { return a_version.pack(); });
372 }
373
374 constexpr void MinimumRequiredXSEVersion(REL::Version a_version) noexcept { xseMinimum = a_version.pack(); }
375 constexpr void PluginName(std::string_view a_plugin) noexcept { SetCharBuffer(a_plugin, std::span{ pluginName }); }
376 constexpr void PluginVersion(REL::Version a_version) noexcept { pluginVersion = a_version.pack(); }
377#ifndef SKYRIMSE_PRE_1_6_629
378 constexpr void HasNoStructUse(bool a_value) noexcept
379 {
380 noStructUse = a_value;
381 }
382#endif
383 constexpr void UsesAddressLibrary(bool a_value) noexcept
384 {
385 addressLibrary = a_value;
386 }
387 constexpr void UsesSigScanning(bool a_value) noexcept { sigScanning = a_value; }
388#ifndef SKYRIMSE_PRE_1_6_629
389 constexpr void UsesStructsPost629(bool a_value) noexcept
390 {
391 structsPost629 = a_value;
392 }
393#endif
394
395 const std::uint32_t dataVersion{ kVersion };
396 std::uint32_t pluginVersion = 0;
397 char pluginName[256] = {};
398 char author[256] = {};
399#ifndef SKYRIMSE_PRE_1_6_629
400 char supportEmail[252] = {};
401 bool noStructUse: 1 = false;
402 std::uint8_t padding1: 7 = 0;
403 std::uint8_t padding2 = 0;
404 std::uint16_t padding3 = 0;
405 bool addressLibrary: 1 = false;
406 bool sigScanning: 1 = false;
407 bool structsPost629: 1 = true;
408 std::uint8_t padding4: 5 = 0;
409 std::uint8_t padding5 = 0;
410 std::uint16_t padding6 = 0;
411#else
412 char supportEmail[256] = {};
413 bool addressLibrary: 1 = false;
414 bool sigScanning: 1 = false;
415 std::uint8_t padding1: 6 = 0;
416 std::uint8_t padding2 = 0;
417 std::uint16_t padding3 = 0;
418#endif
419 std::uint32_t compatibleVersions[16] = {};
420 std::uint32_t xseMinimum = 0;
421
422 private:
423 static constexpr void SetCharBuffer(
424 std::string_view a_src,
425 std::span<char> a_dst) noexcept
426 {
427 assert(a_src.size() < a_dst.size());
428 std::fill(a_dst.begin(), a_dst.end(), '\0');
429 std::copy(a_src.begin(), a_src.end(), a_dst.begin());
430 }
431 };
432 static_assert(offsetof(PluginVersionData, dataVersion) == 0x000);
433 static_assert(offsetof(PluginVersionData, pluginVersion) == 0x004);
434 static_assert(offsetof(PluginVersionData, pluginName) == 0x008);
435 static_assert(offsetof(PluginVersionData, author) == 0x108);
436 static_assert(offsetof(PluginVersionData, supportEmail) == 0x208);
437#ifndef SKYRIMSE_PRE_1_6_629
438 static_assert(offsetof(PluginVersionData, padding2) == 0x305);
439 static_assert(offsetof(PluginVersionData, padding3) == 0x306);
440 static_assert(offsetof(PluginVersionData, padding5) == 0x309);
441 static_assert(offsetof(PluginVersionData, padding6) == 0x30A);
442#else
443 static_assert(offsetof(PluginVersionData, padding2) == 0x309);
444 static_assert(offsetof(PluginVersionData, padding3) == 0x30A);
445#endif
446 static_assert(offsetof(PluginVersionData, compatibleVersions) == 0x30C);
447 static_assert(offsetof(PluginVersionData, xseMinimum) == 0x34C);
448 static_assert(sizeof(PluginVersionData) == 0x350);
449}
Definition: IVirtualMachine.h:39
Definition: VirtualMachine.h:46
Definition: GFxMovieView.h:24
Definition: GFxValue.h:90
Definition: InventoryEntryData.h:14
Definition: Relocation.h:275
Definition: Interfaces.h:29
@ kTrampoline
Definition: Interfaces.h:40
@ kMessaging
Definition: Interfaces.h:38
@ kPapyrus
Definition: Interfaces.h:35
@ kSerialization
Definition: Interfaces.h:36
@ kObject
Definition: Interfaces.h:39
@ kTask
Definition: Interfaces.h:37
@ kInvalid
Definition: Interfaces.h:33
@ kScaleform
Definition: Interfaces.h:34
@ kTotal
Definition: Interfaces.h:41
void * QueryInterface(std::uint32_t a_id) const
PluginHandle GetPluginHandle() const
std::uint32_t GetReleaseIndex() const
const PluginInfo * GetPluginInfo(const char *a_name) const
Definition: Interfaces.h:252
Dispatcher
Definition: Interfaces.h:285
void * GetEventDispatcher(Dispatcher a_dispatcherID) const
@ kVersion
Definition: Interfaces.h:266
std::uint32_t Version() const
const detail::SKSEMessagingInterface * GetProxy() const
bool Dispatch(std::uint32_t a_messageType, void *a_data, std::uint32_t a_dataLen, const char *a_receiver) const
bool RegisterListener(const char *a_sender, EventCallback *a_callback) const
@ kTotal
Definition: Interfaces.h:281
@ kPostPostLoad
Definition: Interfaces.h:272
@ kPostLoad
Definition: Interfaces.h:271
@ kPreLoadGame
Definition: Interfaces.h:273
@ kSaveGame
Definition: Interfaces.h:275
@ kNewGame
Definition: Interfaces.h:278
@ kDataLoaded
Definition: Interfaces.h:279
@ kInputLoaded
Definition: Interfaces.h:277
@ kDeleteGame
Definition: Interfaces.h:276
@ kPostLoadGame
Definition: Interfaces.h:274
bool RegisterListener(EventCallback *a_callback) const
void(Message *a_msg) EventCallback
Definition: Interfaces.h:262
Definition: Interfaces.h:307
SKSEObjectRegistry & GetObjectRegistry() const
SKSEPersistentObjectStorage & GetPersistentObjectStorage() const
std::uint32_t Version() const
@ kVersion
Definition: Interfaces.h:311
SKSEDelayFunctorManager & GetDelayFunctorManager() const
Definition: Interfaces.h:219
bool Register(First a_first, Rest... a_rest) const
Definition: Interfaces.h:238
const detail::SKSEPapyrusInterface * GetProxy() const
std::uint32_t Version() const
@ kVersion
Definition: Interfaces.h:226
bool(RE::BSScript::Internal::VirtualMachine *a_vm) RegFunction1
Definition: Interfaces.h:221
bool(RE::BSScript::IVirtualMachine *a_vm) RegFunction2
Definition: Interfaces.h:222
bool Register(Last a_last) const
Definition: Interfaces.h:232
Definition: Interfaces.h:17
const detail::SKSEInterface * GetProxy() const
std::uint32_t EditorVersion() const
REL::Version RuntimeVersion() const
std::uint32_t SKSEVersion() const
bool IsEditor() const
Definition: Interfaces.h:51
const detail::SKSEScaleformInterface * GetProxy() const
void(RE::GFxMovieView *a_view, RE::GFxValue *a_object, RE::InventoryEntryData *a_item) RegInvCallback
Definition: Interfaces.h:54
@ kVersion
Definition: Interfaces.h:58
void Register(RegInvCallback *a_callback) const
bool Register(RegCallback *a_callback, const char *a_name) const
std::uint32_t Version() const
bool(RE::GFxMovieView *a_view, RE::GFxValue *a_root) RegCallback
Definition: Interfaces.h:53
Definition: Interfaces.h:71
std::uint32_t WriteRecord(std::uint32_t a_type, std::uint32_t a_version, const T(&a_buf)[N]) const
Definition: Interfaces.h:109
bool ResolveHandle(RE::VMHandle a_oldHandle, RE::VMHandle &a_newHandle) const
std::uint32_t WriteRecordData(const T(&a_buf)[N]) const
Definition: Interfaces.h:135
void SetLoadCallback(EventCallback *a_callback) const
std::uint32_t WriteRecord(std::uint32_t a_type, std::uint32_t a_version, const T &a_buf) const
Definition: Interfaces.h:98
void SetFormDeleteCallback(FormDeleteCallback *a_callback) const
std::uint32_t ReadRecordData(T &a_buf) const
Definition: Interfaces.h:150
void(SerializationInterface *a_intfc) EventCallback
Definition: Interfaces.h:73
void(RE::VMHandle a_handle) FormDeleteCallback
Definition: Interfaces.h:74
@ kVersion
Definition: Interfaces.h:78
std::uint32_t ReadRecordData(void *a_buf, std::uint32_t a_length) const
void SetRevertCallback(EventCallback *a_callback) const
const detail::SKSESerializationInterface * GetProxy() const
std::uint32_t WriteRecordData(const T &a_buf) const
Definition: Interfaces.h:124
void SetUniqueID(std::uint32_t a_uid) const
bool WriteRecordData(const void *a_buf, std::uint32_t a_length) const
bool GetNextRecordInfo(std::uint32_t &a_type, std::uint32_t &a_version, std::uint32_t &a_length) const
void SetSaveCallback(EventCallback *a_callback) const
std::uint32_t ReadRecordData(T(&a_buf)[N]) const
Definition: Interfaces.h:161
bool ResolveFormID(RE::FormID a_oldFormID, RE::FormID &a_newFormID) const
std::uint32_t Version() const
bool WriteRecord(std::uint32_t a_type, std::uint32_t a_version, const void *a_buf, std::uint32_t a_length) const
bool OpenRecord(std::uint32_t a_type, std::uint32_t a_version) const
Definition: Interfaces.h:192
void Dispose() override
Definition: Interfaces.h:204
Definition: Interfaces.h:174
void AddUITask(UIDelegate_v1 *a_task) const
std::function< void()> TaskFn
Definition: Interfaces.h:176
const detail::SKSETaskInterface * GetProxy() const
void AddTask(TaskFn a_task) const
void AddUITask(TaskFn a_task) const
@ kVersion
Definition: Interfaces.h:180
void AddTask(TaskDelegate *a_task) const
std::uint32_t Version() const
Definition: Interfaces.h:325
void * AllocateFromBranchPool(std::size_t a_size) const
std::uint32_t Version() const
@ kVersion
Definition: Interfaces.h:329
void * AllocateFromLocalPool(std::size_t a_size) const
Definition: Stubs.h:99
Definition: Stubs.h:106
std::uint32_t FormID
Definition: BSCoreTypes.h:5
std::uint64_t VMHandle
Definition: BSCoreTypes.h:7
Definition: API.h:14
std::uint32_t PluginHandle
Definition: Stubs.h:11
Definition: Interfaces.h:255
std::uint32_t dataLen
Definition: Interfaces.h:258
const char * sender
Definition: Interfaces.h:256
std::uint32_t type
Definition: Interfaces.h:257
void * data
Definition: Interfaces.h:259
Definition: Interfaces.h:342
std::uint32_t version
Definition: Interfaces.h:350
const char * name
Definition: Interfaces.h:349
std::uint32_t infoVersion
Definition: Interfaces.h:348
@ kVersion
Definition: Interfaces.h:345
Definition: Interfaces.h:354
std::uint8_t padding5
Definition: Interfaces.h:409
std::uint16_t padding6
Definition: Interfaces.h:410
constexpr void UsesSigScanning(bool a_value) noexcept
Definition: Interfaces.h:387
std::uint8_t padding4
Definition: Interfaces.h:408
bool structsPost629
Definition: Interfaces.h:407
constexpr void MinimumRequiredXSEVersion(REL::Version a_version) noexcept
Definition: Interfaces.h:374
constexpr void PluginName(std::string_view a_plugin) noexcept
Definition: Interfaces.h:375
std::uint16_t padding3
Definition: Interfaces.h:404
std::uint32_t pluginVersion
Definition: Interfaces.h:396
std::uint32_t xseMinimum
Definition: Interfaces.h:420
constexpr void HasNoStructUse(bool a_value) noexcept
Definition: Interfaces.h:378
constexpr void CompatibleVersions(std::initializer_list< REL::Version > a_versions) noexcept
Definition: Interfaces.h:364
char pluginName[256]
Definition: Interfaces.h:397
constexpr void AuthorEmail(std::string_view a_email) noexcept
Definition: Interfaces.h:361
bool addressLibrary
Definition: Interfaces.h:405
std::uint8_t padding1
Definition: Interfaces.h:402
constexpr void PluginVersion(REL::Version a_version) noexcept
Definition: Interfaces.h:376
char author[256]
Definition: Interfaces.h:398
@ kVersion
Definition: Interfaces.h:358
std::uint8_t padding2
Definition: Interfaces.h:403
bool sigScanning
Definition: Interfaces.h:406
constexpr void UsesStructsPost629(bool a_value) noexcept
Definition: Interfaces.h:389
constexpr void AuthorName(std::string_view a_name) noexcept
Definition: Interfaces.h:362
bool noStructUse
Definition: Interfaces.h:401
std::uint32_t compatibleVersions[16]
Definition: Interfaces.h:419
const std::uint32_t dataVersion
Definition: Interfaces.h:395
char supportEmail[252]
Definition: Interfaces.h:400
constexpr void UsesAddressLibrary(bool a_value) noexcept
Definition: Interfaces.h:383
Definition: Stubs.h:27
Definition: Stubs.h:47
Definition: Stubs.h:85