1
artifact-tracker/Source/ArtifactTrackerDLL/src/Main.cpp

54 lines
1.4 KiB
C++
Raw Normal View History

2022-06-19 20:35:56 +00:00
#include "Papyrus.h"
2022-06-21 21:51:57 +00:00
#include "BookCheck.h"
2022-06-22 00:52:12 +00:00
#include "MiscCheck.h"
2022-06-19 20:35:56 +00:00
using namespace RE::BSScript;
using namespace SKSE;
using namespace SKSE::log;
using namespace SKSE::stl;
namespace {
2022-06-21 21:51:57 +00:00
2022-06-19 20:35:56 +00:00
void InitializeLogging() {
auto path = logger::log_directory();
if (!path) {
stl::report_and_fail("Failed to find standard logging directory"sv);
}
*path /= "ArtifactTrackerFunctions.log"sv;
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("[%l] %v"s);
}
2022-06-21 21:51:57 +00:00
void InitializeMessaging() {
2022-06-21 23:30:45 +00:00
GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) {
if (message->type == MessagingInterface::kDataLoaded) {
2022-06-21 21:51:57 +00:00
BookCheck::PreloadBookList();
2022-06-22 00:52:12 +00:00
MiscCheck::PreloadMiscList();
2022-06-21 23:30:45 +00:00
}
});
2022-06-21 21:51:57 +00:00
}
2022-06-19 20:35:56 +00:00
}
SKSEPluginLoad(const LoadInterface* skse) {
InitializeLogging();
auto* plugin = PluginDeclaration::GetSingleton();
auto version = plugin->GetVersion();
log::info("{} {} is loading...", plugin->GetName(), version);
Init(skse);
2022-06-21 21:51:57 +00:00
InitializeMessaging();
2022-06-19 20:35:56 +00:00
SKSE::GetPapyrusInterface()->Register(Papyrus::Bind);
log::info("{} has finished loading.", plugin->GetName());
return true;
}