forked from shadeMe/Fuz-Ro-D-oh-64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
92 lines (80 loc) · 2.37 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
87
88
89
90
91
92
#include "FuzRoDohInternals.h"
#include "Hooks.h"
#include "VersionInfo.h"
#include <ShlObj.h>
#ifdef VR_BUILD
#define RUNTIME_VERSION RUNTIME_VR_VERSION_1_4_15
#else
#define RUNTIME_VERSION RUNTIME_VERSION_1_5_97
#endif
extern "C"
{
void MessageHandler(SKSEMessagingInterface::Message * msg)
{
switch (msg->type)
{
case SKSEMessagingInterface::kMessage_InputLoaded:
{
// schedule a cleanup thread for the subtitle hasher
std::thread CleanupThread([]() {
while (true)
{
std::this_thread::sleep_for(std::chrono::seconds(2));
SubtitleHasher::Instance.Tick();
}
});
CleanupThread.detach();
_MESSAGE("Scheduled cleanup thread");
_MESSAGE("%s Initialized!", MakeSillyName().c_str());
}
break;
}
}
bool SKSEPlugin_Query(const SKSEInterface * skse, PluginInfo * info)
{
#ifdef VR_BUILD
gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Skyrim VR\\SKSE\\Fuz Ro D-oh.log");
#else
gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Skyrim Special Edition\\SKSE\\Fuz Ro D-oh.log");
#endif
_MESSAGE("%s Initializing...", MakeSillyName().c_str());
// populate info structure
info->infoVersion = PluginInfo::kInfoVersion;
info->name = "Fuz Ro D'oh";
info->version = PACKED_SME_VERSION;
interfaces::kPluginHandle = skse->GetPluginHandle();
interfaces::kMsgInterface = (SKSEMessagingInterface*)skse->QueryInterface(kInterface_Messaging);
if (skse->isEditor)
return false;
else if (skse->runtimeVersion != RUNTIME_VERSION)
{
_MESSAGE("Unsupported runtime version %08X", skse->runtimeVersion);
return false;
}
else if (!interfaces::kMsgInterface)
{
_MESSAGE("Couldn't initialize messaging interface");
return false;
}
else if (interfaces::kMsgInterface->interfaceVersion < 2)
{
_MESSAGE("Messaging interface too old (%d expected %d)", interfaces::kMsgInterface->interfaceVersion, 2);
return false;
}
// supported runtime version
return true;
}
bool SKSEPlugin_Load(const SKSEInterface * skse)
{
_MESSAGE("Initializing INI Manager");
FuzRoDohINIManager::Instance.Initialize("Data\\SKSE\\Plugins\\Fuz Ro D'oh.ini", nullptr);
if (interfaces::kMsgInterface->RegisterListener(interfaces::kPluginHandle, "SKSE", MessageHandler) == false)
{
_MESSAGE("Couldn't register message listener");
return false;
}
else if (InstallHooks() == false)
return false;
return true;
}
};