diff options
-rw-r--r-- | NorthstarDedicatedTest/sourceconsole.cpp | 26 | ||||
-rw-r--r-- | NorthstarDedicatedTest/squirrel.cpp | 11 |
2 files changed, 24 insertions, 13 deletions
diff --git a/NorthstarDedicatedTest/sourceconsole.cpp b/NorthstarDedicatedTest/sourceconsole.cpp index ed986af8..8e1dcb83 100644 --- a/NorthstarDedicatedTest/sourceconsole.cpp +++ b/NorthstarDedicatedTest/sourceconsole.cpp @@ -16,6 +16,16 @@ void ConCommand_toggleconsole(const CCommand& arg) (*g_SourceGameConsole)->Activate(); } +void ConCommand_showconsole(const CCommand& arg) +{ + (*g_SourceGameConsole)->Activate(); +} + +void ConCommand_hideconsole(const CCommand& arg) +{ + (*g_SourceGameConsole)->Hide(); +} + typedef void (*OnCommandSubmittedType)(CConsoleDialog* consoleDialog, const char* pCommand); OnCommandSubmittedType onCommandSubmittedOriginal; void OnCommandSubmittedHook(CConsoleDialog* consoleDialog, const char* pCommand) @@ -48,12 +58,6 @@ void InitialiseConsoleOnInterfaceCreation() reinterpret_cast<LPVOID*>(&onCommandSubmittedOriginal)); } -ON_DLL_LOAD_CLIENT_RELIESON("client.dll", SourceConsole, ConCommand, (HMODULE baseAddress) -{ - g_SourceGameConsole = new SourceInterface<CGameConsole>("client.dll", "GameConsole004"); - RegisterConCommand("toggleconsole", ConCommand_toggleconsole, "toggles the console", FCVAR_DONTRECORD); -}) - // logging stuff SourceConsoleSink::SourceConsoleSink() @@ -78,4 +82,12 @@ void SourceConsoleSink::sink_it_(const spdlog::details::log_msg& msg) ->m_pConsole->m_pConsolePanel->ColorPrint(logColours[msg.level], fmt::to_string(formatted).c_str()); // todo needs colour support } -void SourceConsoleSink::flush_() {}
\ No newline at end of file +void SourceConsoleSink::flush_() {} + +ON_DLL_LOAD_CLIENT_RELIESON("client.dll", SourceConsole, ConCommand, (HMODULE baseAddress) +{ + g_SourceGameConsole = new SourceInterface<CGameConsole>("client.dll", "GameConsole004"); + RegisterConCommand("toggleconsole", ConCommand_toggleconsole, "toggles the console", FCVAR_DONTRECORD); + RegisterConCommand("showconsole", ConCommand_showconsole, "shows the console", FCVAR_DONTRECORD); + RegisterConCommand("hideconsole", ConCommand_hideconsole, "hides the console", FCVAR_DONTRECORD); +})
\ No newline at end of file diff --git a/NorthstarDedicatedTest/squirrel.cpp b/NorthstarDedicatedTest/squirrel.cpp index 34eb0fdc..754661a4 100644 --- a/NorthstarDedicatedTest/squirrel.cpp +++ b/NorthstarDedicatedTest/squirrel.cpp @@ -144,7 +144,7 @@ template <ScriptContext context> void ScriptCompileErrorHook(void* sqvm, const c cmd_source_t::kCommandSrcCode); if (realContext == ScriptContext::UI) - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "toggleconsole", cmd_source_t::kCommandSrcCode); // likely temp: show console so user can see any errors + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "showconsole", cmd_source_t::kCommandSrcCode); // likely temp: show console so user can see any errors } // dont call the original function since it kills game lol @@ -225,7 +225,7 @@ template <ScriptContext context> bool CallScriptInitCallbackHook(void* sqvm, con return ret; } -template <ScriptContext context> void ExecuteCodeCommand(const CCommand& args) +template <ScriptContext context> void ConCommand_script(const CCommand& args) { if (context == ScriptContext::CLIENT) g_pClientSquirrel->ExecuteCode(args.ArgS()); @@ -247,8 +247,7 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (HMODULE baseAddr (char*)baseAddress + 0x12B00, &SQPrintHook<ScriptContext::CLIENT>, reinterpret_cast<LPVOID*>(&ClientSQPrint)); // client print function - RegisterConCommand( - "script_client", ExecuteCodeCommand<ScriptContext::CLIENT>, "Executes script code on the client vm", FCVAR_CLIENTDLL); + RegisterConCommand("script_client", ConCommand_script<ScriptContext::CLIENT>, "Executes script code on the client vm", FCVAR_CLIENTDLL); // ui inits g_pUISquirrel = new SquirrelManager<ScriptContext::UI>; @@ -258,7 +257,7 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (HMODULE baseAddr (char*)baseAddress + 0x12BA0, &SQPrintHook<ScriptContext::UI>, reinterpret_cast<LPVOID*>(&UISQPrint)); // ui print function - RegisterConCommand("script_ui", ExecuteCodeCommand<ScriptContext::UI>, "Executes script code on the ui vm", FCVAR_CLIENTDLL); + RegisterConCommand("script_ui", ConCommand_script<ScriptContext::UI>, "Executes script code on the ui vm", FCVAR_CLIENTDLL); g_pClientSquirrel->RegisterSquirrelFunc = (RegisterSquirrelFuncType)((char*)baseAddress + 0x108E0); g_pUISquirrel->RegisterSquirrelFunc = (RegisterSquirrelFuncType)((char*)baseAddress + 0x108E0); @@ -379,7 +378,7 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (HMODULE baseAddr // for script_client and script_ui, we don't use cheats, so clients can execute them on themselves all they want RegisterConCommand( "script", - ExecuteCodeCommand<ScriptContext::SERVER>, + ConCommand_script<ScriptContext::SERVER>, "Executes script code on the server vm", FCVAR_GAMEDLL | FCVAR_CLIENTCMD_CAN_EXECUTE | FCVAR_CHEAT); })
\ No newline at end of file |