-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2596cdd
commit 404e688
Showing
4 changed files
with
95 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#include "Hooks.h" | ||
|
||
namespace Hooks | ||
{ | ||
void Install() noexcept | ||
{ | ||
} | ||
} // namespace Hooks | ||
#include "Hooks.h" | ||
|
||
namespace Hooks | ||
{ | ||
void Install() noexcept | ||
{ | ||
} | ||
} // namespace Hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
#include "Logging.h" | ||
|
||
void InitializeLogging() noexcept | ||
{ | ||
auto path{ SFSE::log::log_directory() }; | ||
if (!path) | ||
stl::report_and_fail("Unable to lookup SFSE logs directory."); | ||
*path /= Plugin::Name; | ||
*path += L".log"; | ||
|
||
std::shared_ptr<spdlog::logger> log; | ||
if (IsDebuggerPresent()) | ||
log = std::make_shared<spdlog::logger>("Global", std::make_shared<spdlog::sinks::msvc_sink_mt>()); | ||
else | ||
log = std::make_shared<spdlog::logger>("Global", std::make_shared<spdlog::sinks::basic_file_sink_mt>(path->string(), true)); | ||
|
||
log->set_level(spdlog::level::level_enum::info); | ||
log->flush_on(spdlog::level::level_enum::trace); | ||
|
||
set_default_logger(std::move(log)); | ||
|
||
spdlog::set_pattern("[%T.%e UTC%z] [%L] [%=5t] %v"); | ||
} | ||
#include "Logging.h" | ||
|
||
void InitializeLogging() noexcept | ||
{ | ||
auto path{ SFSE::log::log_directory() }; | ||
if (!path) | ||
stl::report_and_fail("Unable to lookup SFSE logs directory."); | ||
*path /= Plugin::Name; | ||
*path += L".log"; | ||
|
||
std::shared_ptr<spdlog::logger> log; | ||
if (IsDebuggerPresent()) | ||
log = std::make_shared<spdlog::logger>("Global", std::make_shared<spdlog::sinks::msvc_sink_mt>()); | ||
else | ||
log = std::make_shared<spdlog::logger>("Global", std::make_shared<spdlog::sinks::basic_file_sink_mt>(path->string(), true)); | ||
|
||
log->set_level(spdlog::level::level_enum::info); | ||
log->flush_on(spdlog::level::level_enum::trace); | ||
|
||
set_default_logger(std::move(log)); | ||
|
||
spdlog::set_pattern("[%T.%e UTC%z] [%L] [%=5t] %v"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
#include "Hooks.h" | ||
#include "Logging.h" | ||
#include "Settings.h" | ||
|
||
void Listener(SFSE::MessagingInterface::Message* message) noexcept | ||
{ | ||
if (message->type <=> SFSE::MessagingInterface::kPostPostLoad == 0) | ||
{ | ||
Settings::LoadSettings(); | ||
Hooks::Install(); | ||
} | ||
} | ||
|
||
SFSEPluginLoad(const SFSE::LoadInterface* sfse) | ||
{ | ||
InitializeLogging(); | ||
|
||
logger::info("{} {} is loading...", Plugin::Name, Plugin::Version); | ||
|
||
Init(sfse); | ||
|
||
if (const auto messaging{ SFSE::GetMessagingInterface() }; !messaging->RegisterListener(Listener)) | ||
return false; | ||
|
||
logger::info("{} has finished loading.", Plugin::Name); | ||
|
||
return true; | ||
} | ||
|
||
SFSEPluginVersion = []() noexcept { | ||
SFSE::PluginVersionData data{}; | ||
|
||
data.PluginVersion(Plugin::Version); | ||
data.PluginName(Plugin::Name); | ||
data.AuthorName(Plugin::Author); | ||
data.UsesSigScanning(false); | ||
data.HasNoStructUse(true); | ||
data.CompatibleVersions({ SFSE::RUNTIME_LATEST }); | ||
|
||
return data; | ||
}(); | ||
#include "Hooks.h" | ||
#include "Logging.h" | ||
#include "Settings.h" | ||
|
||
void Listener(SFSE::MessagingInterface::Message* message) noexcept | ||
{ | ||
if (message->type <=> SFSE::MessagingInterface::kPostPostLoad == 0) | ||
{ | ||
Settings::LoadSettings(); | ||
Hooks::Install(); | ||
} | ||
} | ||
|
||
SFSEPluginLoad(const SFSE::LoadInterface* sfse) | ||
{ | ||
InitializeLogging(); | ||
|
||
logger::info("{} {} is loading...", Plugin::Name, Plugin::Version); | ||
|
||
Init(sfse); | ||
|
||
if (const auto messaging{ SFSE::GetMessagingInterface() }; !messaging->RegisterListener(Listener)) | ||
return false; | ||
|
||
logger::info("{} has finished loading.", Plugin::Name); | ||
|
||
return true; | ||
} | ||
|
||
SFSEPluginVersion = []() noexcept { | ||
SFSE::PluginVersionData data{}; | ||
|
||
data.PluginVersion(Plugin::Version); | ||
data.PluginName(Plugin::Name); | ||
data.AuthorName(Plugin::Author); | ||
data.UsesSigScanning(false); | ||
data.HasNoStructUse(true); | ||
data.CompatibleVersions({ SFSE::RUNTIME_LATEST }); | ||
|
||
return data; | ||
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
#include "Settings.h" | ||
|
||
void Settings::LoadSettings() noexcept | ||
{ | ||
logger::info("Loading settings"); | ||
|
||
CSimpleIniA ini; | ||
|
||
ini.SetUnicode(); | ||
ini.LoadFile(R"(.\Data\SFSE\Plugins\PluginName.ini)"); | ||
|
||
debug_logging = ini.GetBoolValue("Log", "Debug"); | ||
|
||
if (debug_logging) | ||
{ | ||
spdlog::get("Global")->set_level(spdlog::level::level_enum::debug); | ||
logger::debug("Debug logging enabled"); | ||
} | ||
|
||
// Load settings | ||
|
||
logger::info("Loaded settings"); | ||
} | ||
#include "Settings.h" | ||
|
||
void Settings::LoadSettings() noexcept | ||
{ | ||
logger::info("Loading settings"); | ||
|
||
CSimpleIniA ini; | ||
|
||
ini.SetUnicode(); | ||
ini.LoadFile(R"(.\Data\SFSE\Plugins\PluginName.ini)"); | ||
|
||
debug_logging = ini.GetBoolValue("Log", "Debug"); | ||
|
||
if (debug_logging) | ||
{ | ||
spdlog::get("Global")->set_level(spdlog::level::level_enum::debug); | ||
logger::debug("Debug logging enabled"); | ||
} | ||
|
||
// Load settings | ||
|
||
logger::info("Loaded settings"); | ||
} |