-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
98 lines (79 loc) · 2.38 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
93
94
95
96
97
98
#include "papyrus.h"
#include <stddef.h>
//#include "Settings.h"
void MessageHandler(SKSE::MessagingInterface::Message* a_message)
{
switch (a_message->type) {
case SKSE::MessagingInterface::kDataLoaded:
{
}
break;
default:
break;
}
}
#ifdef SKYRIM_AE
extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() {
SKSE::PluginVersionData v;
v.PluginVersion(Version::MAJOR);
v.PluginName("NoLevelUpMenu");
v.AuthorName("Zzyxzz");
v.UsesAddressLibrary();
v.UsesUpdatedStructs();
v.CompatibleVersions({ SKSE::RUNTIME_LATEST });
return v;
}();
#else
extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Query(const SKSE::QueryInterface* a_skse, SKSE::PluginInfo* a_info)
{
a_info->infoVersion = SKSE::PluginInfo::kVersion;
a_info->name = "NoLevelUpMenu";
a_info->version = Version::MAJOR;
if (a_skse->IsEditor()) {
logger::critical("Loaded in editor, marking as incompatible"sv);
return false;
}
const auto ver = a_skse->RuntimeVersion();
if (ver
# ifndef SKYRIMVR
< SKSE::RUNTIME_1_5_39
# else
> SKSE::RUNTIME_VR_1_4_15_1
# endif
) {
logger::critical(FMT_STRING("Unsupported runtime version {}"), ver.string());
return false;
}
return true;
}
#endif
void InitializeLog()
{
auto path = logger::log_directory();
if (!path) {
stl::report_and_fail("Failed to find standard logging directory"sv);
}
*path /= fmt::format(FMT_STRING("{}.log"), Version::PROJECT);
auto sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path->string(), true);
auto log = std::make_shared<spdlog::logger>("global log"s, std::move(sink));
log->set_level(spdlog::level::info);
log->flush_on(spdlog::level::info);
spdlog::set_default_logger(std::move(log));
spdlog::set_pattern("[%H:%M:%S:%e] %v"s);
logger::info(FMT_STRING("{} v{}"), Version::PROJECT, Version::NAME);
}
extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* a_skse)
{
InitializeLog();
logger::info("Game version : {}", a_skse->RuntimeVersion().string());
SKSE::Init(a_skse);
SKSE::AllocTrampoline(1 << 10);
const auto messaging = SKSE::GetMessagingInterface();
messaging->RegisterListener(MessageHandler);
const auto papyrus = SKSE::GetPapyrusInterface();
if (!papyrus->Register(Papyrus::Register)) {
logger::critical("Failed to register papyrus callback"sv);
return false;
}
return true;
}