aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/logging/sourceconsole.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-27 00:32:01 +0000
committerGitHub <noreply@github.com>2023-12-27 01:32:01 +0100
commitf5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (patch)
tree90f2c6a4885dbd181799e2325cf33588697674e1 /NorthstarDLL/logging/sourceconsole.cpp
parentbb8ed59f6891b1196c5f5bbe7346cd171c8215fa (diff)
downloadNorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.tar.gz
NorthstarLauncher-f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287.zip
Folder restructuring from primedev (#624)v1.21.2-rc3v1.21.2
Copies of over the primedev folder structure for easier cherry-picking of further changes Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'NorthstarDLL/logging/sourceconsole.cpp')
-rw-r--r--NorthstarDLL/logging/sourceconsole.cpp91
1 files changed, 0 insertions, 91 deletions
diff --git a/NorthstarDLL/logging/sourceconsole.cpp b/NorthstarDLL/logging/sourceconsole.cpp
deleted file mode 100644
index e436d1d4..00000000
--- a/NorthstarDLL/logging/sourceconsole.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "core/convar/convar.h"
-#include "sourceconsole.h"
-#include "core/sourceinterface.h"
-#include "core/convar/concommand.h"
-#include "util/printcommands.h"
-
-SourceInterface<CGameConsole>* g_pSourceGameConsole;
-
-void ConCommand_toggleconsole(const CCommand& arg)
-{
- if ((*g_pSourceGameConsole)->IsConsoleVisible())
- (*g_pSourceGameConsole)->Hide();
- else
- (*g_pSourceGameConsole)->Activate();
-}
-
-void ConCommand_showconsole(const CCommand& arg)
-{
- (*g_pSourceGameConsole)->Activate();
-}
-
-void ConCommand_hideconsole(const CCommand& arg)
-{
- (*g_pSourceGameConsole)->Hide();
-}
-
-void SourceConsoleSink::custom_sink_it_(const custom_log_msg& msg)
-{
- if (!(*g_pSourceGameConsole)->m_bInitialized)
- return;
-
- spdlog::memory_buf_t formatted;
- spdlog::sinks::base_sink<std::mutex>::formatter_->format(msg, formatted);
-
- // get message string
- std::string str = fmt::to_string(formatted);
-
- SourceColor levelColor = m_LogColours[msg.level];
- std::string name {msg.logger_name.begin(), msg.logger_name.end()};
-
- (*g_pSourceGameConsole)->m_pConsole->m_pConsolePanel->ColorPrint(msg.origin->SRCColor, ("[" + name + "]").c_str());
- (*g_pSourceGameConsole)->m_pConsole->m_pConsolePanel->Print(" ");
- (*g_pSourceGameConsole)->m_pConsole->m_pConsolePanel->ColorPrint(levelColor, ("[" + std::string(level_names[msg.level]) + "]").c_str());
- (*g_pSourceGameConsole)->m_pConsole->m_pConsolePanel->Print(" ");
- (*g_pSourceGameConsole)->m_pConsole->m_pConsolePanel->Print(fmt::to_string(formatted).c_str());
-}
-
-void SourceConsoleSink::sink_it_(const spdlog::details::log_msg& msg)
-{
- throw std::runtime_error("sink_it_ called on SourceConsoleSink with pure log_msg. This is an error!");
-}
-
-void SourceConsoleSink::flush_() {}
-
-// clang-format off
-HOOK(OnCommandSubmittedHook, OnCommandSubmitted,
-void, __fastcall, (CConsoleDialog* consoleDialog, const char* pCommand))
-// clang-format on
-{
- consoleDialog->m_pConsolePanel->Print("] ");
- consoleDialog->m_pConsolePanel->Print(pCommand);
- consoleDialog->m_pConsolePanel->Print("\n");
-
- TryPrintCvarHelpForCommand(pCommand);
-
- OnCommandSubmitted(consoleDialog, pCommand);
-}
-
-// called from sourceinterface.cpp in client createinterface hooks, on GameClientExports001
-void InitialiseConsoleOnInterfaceCreation()
-{
- (*g_pSourceGameConsole)->Initialize();
- // hook OnCommandSubmitted so we print inputted commands
- OnCommandSubmittedHook.Dispatch((LPVOID)(*g_pSourceGameConsole)->m_pConsole->m_vtable->OnCommandSubmitted);
-
- auto consoleSink = std::make_shared<SourceConsoleSink>();
- if (g_bSpdLog_UseAnsiColor)
- consoleSink->set_pattern("%v"); // no need to include the level in the game console, the text colour signifies it anyway
- else
- consoleSink->set_pattern("[%n] [%l] %v"); // no colour, so we should show the level for colourblind people
- RegisterCustomSink(consoleSink);
-}
-
-ON_DLL_LOAD_CLIENT_RELIESON("client.dll", SourceConsole, ConCommand, (CModule module))
-{
- g_pSourceGameConsole = new SourceInterface<CGameConsole>("client.dll", "GameConsole004");
-
- RegisterConCommand("toggleconsole", ConCommand_toggleconsole, "Show/hide the console.", FCVAR_DONTRECORD);
- RegisterConCommand("showconsole", ConCommand_showconsole, "Show the console.", FCVAR_DONTRECORD);
- RegisterConCommand("hideconsole", ConCommand_hideconsole, "Hide the console.", FCVAR_DONTRECORD);
-}