forked from alexjiang200407/skyrim-lights-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.cpp
71 lines (61 loc) · 1.94 KB
/
plugin.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
#include "hooks.hpp"
#include "RE/Skyrim.h"
#include "SKSE/SKSE.h"
#include "Version.h"
#include "palette.hpp"
#include "serialization.hpp"
namespace SLM
{
void SetupLog()
{
assert(SKSE::log::log_directory().has_value());
auto path = SKSE::log::log_directory().value() / std::filesystem::path(Version::NAME.data() + ".log"s);
auto sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path.string(), true);
auto log = std::make_shared<spdlog::logger>("global log", std::move(sink));
log->set_level(spdlog::level::trace);
log->flush_on(spdlog::level::trace);
spdlog::set_default_logger(std::move(log));
spdlog::set_pattern("%g(%#): [%^%l%$] %v", spdlog::pattern_time_type::local);
}
}
#ifdef SKYRIM_AE
extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []()
{
SKSE::PluginVersionData v;
v.PluginVersion(REL::Version{ Version::MAJOR, Version::MINOR, Version::PATCH, 0 });
v.PluginName("SkyrimLightsMenu");
v.AuthorName("shdowraithe101");
v.UsesAddressLibrary();
v.CompatibleVersions({ SKSE::RUNTIME_LATEST });
v.UsesUpdatedStructs();
return v;
}();
#endif
extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface * skse)
{
SLM::SetupLog();
SLM::Palette::LoadPaletteFile();
SKSE::Init(skse);
SLM::Hooks::Install();
SLM::Serialization::RegisterSerialization();
// Once all plugins and mods are loaded, then the ~ console is ready and
// can be printed to
SKSE::GetMessagingInterface()->RegisterListener(
[](SKSE::MessagingInterface::Message* message)
{
if (message->type == SKSE::MessagingInterface::kDataLoaded)
{
RE::ConsoleLog::GetSingleton()->Print("SkyrimLightsMenu has been loaded");
}
else if (message->type == SKSE::MessagingInterface::kPreLoadGame)
{
logger::info("Pre load game");
}
else if (message->type == SKSE::MessagingInterface::kPostLoadGame)
{
logger::info("Post load game");
SLM::SkyrimLightsMenu::GetSingleton()->PostSaveLoad();
}
});
return true;
}