-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
86 lines (59 loc) · 2.39 KB
/
main.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
#include "skse64/PluginAPI.h" // super
#include "skse64_common/skse_version.h" // What version of SKSE is running?
#include <shlobj.h> // CSIDL_MYCODUMENTS
#include "DragonbornPresence.h"
const char * log_path = R"(\My Games\Skyrim Special Edition\SKSE\DragonbornPresence.log)";
const char * plugin_name = "DragonbornPresence";
const UInt32 kVersionMajor = 1;
const UInt32 kVersionMinor = 1;
const UInt32 kVersionPatch = 0;
static PluginHandle g_pluginHandle = kPluginHandle_Invalid;
SKSEScaleformInterface * g_scaleform = nullptr;
SKSESerializationInterface * g_serialization = nullptr;
SKSEMessagingInterface * g_messageInterface = nullptr;
SKSEPapyrusInterface * g_papyrus = nullptr;
extern "C" {
bool SKSEPlugin_Query(const SKSEInterface * skse, PluginInfo * info) {
// Called by SKSE to learn about this plugin and check that it's safe to load it
IDebugLog::OpenRelative(CSIDL_MYDOCUMENTS, log_path);
IDebugLog::SetPrintLevel(IDebugLog::kLevel_Error);
#ifdef _DEBUG
IDebugLog::SetLogLevel(IDebugLog::kLevel_DebugMessage);
#else
IDebugLog::SetLogLevel(IDebugLog::kLevel_Message);
#endif
_MESSAGE("%s %i.%i.%i", plugin_name, kVersionMajor, kVersionMinor,
kVersionPatch);
// populate info structure
info->infoVersion = PluginInfo::kInfoVersion;
info->name = plugin_name;
info->version = kVersionMajor;
// store plugin handle so we can identify ourselves later
g_pluginHandle = skse->GetPluginHandle();
if (skse->isEditor) {
_MESSAGE("loaded in editor, marking as incompatible");
return false;
}
if (skse->runtimeVersion != RUNTIME_VERSION_1_6_323) {
_MESSAGE("unsupported runtime version %08X", skse->runtimeVersion);
return false;
}
// ### do not do anything else in this callback
// ### only fill out PluginInfo and return true/false
// supported runtime version
return true;
}
bool SKSEPlugin_Load(const SKSEInterface * skse) {
// Called by SKSE to load this plugin
_MESSAGE("DragonbornPresence loaded");
dragonborn_presence_namespace::SetLocale();
g_papyrus = static_cast<SKSEPapyrusInterface *>(skse->QueryInterface(
kInterface_Papyrus));
//Check if the function registration was a success...
const auto reg_check = g_papyrus->Register(
dragonborn_presence_namespace::RegisterFuncs);
if (reg_check) { _MESSAGE("Papyrus Register Succeeded"); }
dragonborn_presence_namespace::RegisterGameEventHandlers();
return true;
}
};