-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
85 lines (64 loc) · 2.18 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
#include "common/IDebugLog.h" // IDebugLog
#include "f4se_common/f4se_version.h" // RUNTIME_VERSION
#include "f4se/PluginAPI.h" // SKSEInterface, PluginInfo
#include "f4sE_common/Relocation.h"
#include "F4SE_common/SafeWrite.h"
#include "F4SE_common/BranchTrampoline.h"
#include "f4se/GameData.h"
#include <ShlObj.h> // CSIDL_MYDOCUMENTS
#include "version.h"
static PluginHandle g_pluginHandle = kPluginHandle_Invalid;
static F4SEMessagingInterface* g_messaging = NULL;
//Listener for F4SE Messages
void OnF4SEMessage(F4SEMessagingInterface::Message* msg)
{
if (msg)
{
if (msg->type == F4SEMessagingInterface::kMessage_GameLoaded)
{
// PUT FUNCTIONS HERE THAT NEED TO RUN AFTER A NEW GAME OR SAVE GAME IS LOADED
}
}
}
extern "C" {
bool F4SEPlugin_Query(const F4SEInterface* a_f4se, PluginInfo* a_info)
{
Sleep(5000);
gLog.OpenRelative(CSIDL_MYDOCUMENTS, R"(\\My Games\\Fallout4VR\\F4SE\\F4SE_plugin_template.log)");
gLog.SetPrintLevel(IDebugLog::kLevel_DebugMessage);
gLog.SetLogLevel(IDebugLog::kLevel_DebugMessage);
_MESSAGE("F4SE Plugin Template v%s", F4SEVRTEMPLATE_VERSION_VERSTRING);
a_info->infoVersion = PluginInfo::kInfoVersion;
a_info->name = "F4SETemplate";
a_info->version = F4SEVRTEMPLATE_VERSION_MAJOR;
if (a_f4se->isEditor) {
_FATALERROR("[FATAL ERROR] Loaded in editor, marking as incompatible!\n");
return false;
}
a_f4se->runtimeVersion;
if (a_f4se->runtimeVersion < RUNTIME_VR_VERSION_1_2_72)
{
_FATALERROR("Unsupported runtime version %s!\n", a_f4se->runtimeVersion);
return false;
}
return true;
}
bool F4SEPlugin_Load(const F4SEInterface* a_f4se)
{
_MESSAGE("F4SE TEMPLATE Init");
g_pluginHandle = a_f4se->GetPluginHandle();
if (g_pluginHandle == kPluginHandle_Invalid) {
return false;
}
g_messaging = (F4SEMessagingInterface*)a_f4se->QueryInterface(kInterface_Messaging);
g_messaging->RegisterListener(g_pluginHandle, "F4SE", OnF4SEMessage);
if (!g_branchTrampoline.Create(1024 * 64))
{
_ERROR("couldn't create branch trampoline. this is fatal. skipping remainder of init process.");
return false;
}
// Usually put plugin functions here
_MESSAGE("F4SETemplate Loaded");
return true;
}
};