From e070b8b610de10401d62fdeee1037c4d451d40dc Mon Sep 17 00:00:00 2001
From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Date: Sat, 9 Apr 2022 02:15:26 +0100
Subject: add rui_drawEnable (#134)
* add rui_drawEnable
* oops forgot to push vcxproj changes to branch
* format clientruihooks.cpp
---
.../NorthstarDedicatedTest.vcxproj | 2 ++
.../NorthstarDedicatedTest.vcxproj.filters | 6 ++++++
NorthstarDedicatedTest/clientruihooks.cpp | 24 ++++++++++++++++++++++
NorthstarDedicatedTest/clientruihooks.h | 2 ++
NorthstarDedicatedTest/dllmain.cpp | 2 ++
5 files changed, 36 insertions(+)
create mode 100644 NorthstarDedicatedTest/clientruihooks.cpp
create mode 100644 NorthstarDedicatedTest/clientruihooks.h
(limited to 'NorthstarDedicatedTest')
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index e9a27ad9..be70b70b 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -114,6 +114,7 @@
+
@@ -572,6 +573,7 @@
+
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index 3cc20b58..4089f1ca 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -1503,6 +1503,9 @@
Header Files
+
+ Header Files\Client
+
@@ -1664,6 +1667,9 @@
Source Files
+
+ Source Files\Client
+
diff --git a/NorthstarDedicatedTest/clientruihooks.cpp b/NorthstarDedicatedTest/clientruihooks.cpp
new file mode 100644
index 00000000..bc6c7aa7
--- /dev/null
+++ b/NorthstarDedicatedTest/clientruihooks.cpp
@@ -0,0 +1,24 @@
+#include "pch.h"
+#include "clientruihooks.h"
+#include "convar.h"
+
+ConVar* Cvar_rui_drawEnable;
+
+typedef char (*DrawRUIFuncType)(void* a1, float* a2);
+DrawRUIFuncType DrawRUIFunc;
+
+char DrawRUIFuncHook(void* a1, float* a2)
+{
+ if (!Cvar_rui_drawEnable->GetBool())
+ return 0;
+
+ return DrawRUIFunc(a1, a2);
+}
+
+void InitialiseEngineClientRUIHooks(HMODULE baseAddress)
+{
+ Cvar_rui_drawEnable = new ConVar("rui_drawEnable", "1", FCVAR_CLIENTDLL, "Controls whether RUI should be drawn");
+
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0xFC500, &DrawRUIFuncHook, reinterpret_cast(&DrawRUIFunc));
+}
\ No newline at end of file
diff --git a/NorthstarDedicatedTest/clientruihooks.h b/NorthstarDedicatedTest/clientruihooks.h
new file mode 100644
index 00000000..967ccefe
--- /dev/null
+++ b/NorthstarDedicatedTest/clientruihooks.h
@@ -0,0 +1,2 @@
+#pragma once
+void InitialiseEngineClientRUIHooks(HMODULE baseAddress);
\ No newline at end of file
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index 22b9a673..b5e06e3a 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -40,6 +40,7 @@
#include "plugin_abi.h"
#include "plugins.h"
#include "clientvideooverrides.h"
+#include "clientruihooks.h"
#include
#include "version.h"
#include "pch.h"
@@ -246,6 +247,7 @@ bool InitialiseNorthstar()
AddDllLoadCallbackForClient("client.dll", InitialiseLocalChatWriter);
AddDllLoadCallbackForClient("client.dll", InitialiseScriptServerToClientStringCommands);
AddDllLoadCallbackForClient("client.dll", InitialiseClientVideoOverrides);
+ AddDllLoadCallbackForClient("engine.dll", InitialiseEngineClientRUIHooks);
// audio hooks
AddDllLoadCallbackForClient("client.dll", InitialiseMilesAudioHooks);
--
cgit v1.2.3