enderal-se-easy-crafting/src/src/Main.cpp

55 lines
1.6 KiB
C++
Raw Normal View History

2022-08-17 21:43:01 +00:00
#include "EventListener.h"
#include "Util.h"
using namespace SKSE;
namespace {
void InitializeLogging() {
auto path = logger::log_directory();
if (!path) {
SKSE::stl::report_and_fail("Failed to find standard logging directory"sv);
}
*path /= "EnderalSEEasyCrafting.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);
}
void InitializeMessaging()
{
GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) {
if (message->type == MessagingInterface::kPostPostLoad) {
2022-09-09 21:11:16 +00:00
if (!std::filesystem::exists("Data\\Enderal - Forgotten Stories.esm") || !std::filesystem::exists("Data\\SKSE\\Plugins\\EnderalSE.ini")) {
MessageBoxW(NULL, L"Easy Crafting requires Enderal SE 2.0.12 or newer.", L"Enderal SE Easy Crafting", MB_OK | MB_ICONERROR);
2022-08-17 21:43:01 +00:00
exit(EXIT_FAILURE);
}
GetSettings(true);
EventListener::Install();
}
});
}
}
SKSEPluginLoad(const LoadInterface* skse) {
InitializeLogging();
auto* plugin = PluginDeclaration::GetSingleton();
auto version = plugin->GetVersion();
logger::info("{} {} is loading...", plugin->GetName(), version);
Init(skse);
InitializeMessaging();
logger::info("{} has finished loading.", plugin->GetName());
return true;
}