From 20ce9a9a9d4e8a95ba788b8fb3d331413b4a6698 Mon Sep 17 00:00:00 2001 From: Cj Date: Wed, 6 Mar 2024 08:49:49 +0000 Subject: [PATCH] Fix watermark bounds going off the screen (!88) Fixes the screen bounds for the water mark, it now no longer clips off the screen. It was really bothering me... Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Modules/pulls/88 Co-authored-by: Cj Co-committed-by: Cj --- project/Aki.Debugging/AkiDebuggingPlugin.cs | 1 + .../Aki.Debugging/Patches/DebugLogoPatch.cs | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/project/Aki.Debugging/AkiDebuggingPlugin.cs b/project/Aki.Debugging/AkiDebuggingPlugin.cs index dcb8bd0..2e98638 100644 --- a/project/Aki.Debugging/AkiDebuggingPlugin.cs +++ b/project/Aki.Debugging/AkiDebuggingPlugin.cs @@ -19,6 +19,7 @@ namespace Aki.Debugging // new StaticLootDumper().Enable(); new DebugLogoPatch().Enable(); new DebugLogoPatch2().Enable(); + new DebugLogoPatch3().Enable(); // BTR debug command patches, can be disabled later //new BTRDebugCommandPatch().Enable(); diff --git a/project/Aki.Debugging/Patches/DebugLogoPatch.cs b/project/Aki.Debugging/Patches/DebugLogoPatch.cs index f4a32e8..c638b2d 100644 --- a/project/Aki.Debugging/Patches/DebugLogoPatch.cs +++ b/project/Aki.Debugging/Patches/DebugLogoPatch.cs @@ -7,6 +7,7 @@ using EFT.UI; using HarmonyLib; using System.Reflection; using TMPro; +using UnityEngine; namespace Aki.Debugging.Patches { @@ -34,7 +35,7 @@ namespace Aki.Debugging.Patches } [PatchPostfix] - private static void patchPostfix(ref TextMeshProUGUI ____label, Profile ___profile_0) + private static void PatchPostfix(ref TextMeshProUGUI ____label, Profile ___profile_0) { if (sptVersion is null) { @@ -45,4 +46,27 @@ namespace Aki.Debugging.Patches ____label.text = $"{sptVersion} \n {___profile_0.Nickname} \n {GClass1296.Now.ToString("HH:mm:ss")}"; } } + + public class DebugLogoPatch3 : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(ClientWatermark), nameof(ClientWatermark.smethod_0)); + } + + // Prefix so the logic isnt being duplicated. + [PatchPrefix] + private static bool PatchPrefix(int screenHeight, int screenWidth, int rectHeight, int rectWidth, ref Vector2 __result) + { + System.Random random = new System.Random(); + + int maxX = (screenWidth / 4) - (rectWidth / 2); + int maxY = (screenHeight / 4) - (rectHeight / 2); + int newX = random.Next(-maxX, maxX); + int newY = random.Next(-maxY, maxY); + + __result = new Vector2(newX, newY); + return false; + } + } }