diff options
author | uniboi <64006268+uniboi@users.noreply.github.com> | 2024-10-14 13:20:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-14 15:20:54 +0200 |
commit | 27e17113161323b5a6269d395dbcc04162f50319 (patch) | |
tree | fbe294e2be70f1838504482d4d87727a689bd7e6 /primedev/plugins/plugins.cpp | |
parent | 42d97028e1a474e7fecc1de7e76c5d92ecf2c28f (diff) | |
download | NorthstarLauncher-27e17113161323b5a6269d395dbcc04162f50319.tar.gz NorthstarLauncher-27e17113161323b5a6269d395dbcc04162f50319.zip |
plugins: Allow plugins to customize their log colors (#823)
Allows plugins to specify a custom colour for their indicator in the logs
Diffstat (limited to 'primedev/plugins/plugins.cpp')
-rw-r--r-- | primedev/plugins/plugins.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/primedev/plugins/plugins.cpp b/primedev/plugins/plugins.cpp index 21169c06..3e623167 100644 --- a/primedev/plugins/plugins.cpp +++ b/primedev/plugins/plugins.cpp @@ -23,6 +23,7 @@ bool isValidSquirrelIdentifier(std::string s) Plugin::Plugin(std::string path) : m_location(path) + , m_logColor(NS::Colors::PLUGIN) { HMODULE pluginModule = GetModuleHandleA(path.c_str()); @@ -69,6 +70,13 @@ Plugin::Plugin(std::string path) m_runOnServer = context & PluginContext::DEDICATED; m_runOnClient = context & PluginContext::CLIENT; + int64_t logColor = m_pluginId->GetField(PluginField::COLOR); + // Apply custom colour if plugin has specified one + if ((logColor & 0xFFFFFF) != 0) + { + m_logColor = Color((int)(logColor & 0xFF), (int)((logColor >> 8) & 0xFF), (int)((logColor >> 16) & 0xFF)); + } + if (!name) { NS::log::PLUGINSYS->error("Could not load name of plugin at '{}'", path); @@ -105,7 +113,7 @@ Plugin::Plugin(std::string path) return; } - m_logger = std::make_shared<ColoredLogger>(m_logName, NS::Colors::PLUGIN); + m_logger = std::make_shared<ColoredLogger>(m_logName, m_logColor); RegisterLogger(m_logger); if (IsDedicatedServer() && !m_runOnServer) |