0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 05:30:43 -05:00

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: SPT-AKI/Modules#88
Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com>
Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
This commit is contained in:
Cj 2024-03-06 08:49:49 +00:00 committed by chomp
parent f614378ff6
commit 20ce9a9a9d
2 changed files with 26 additions and 1 deletions

View File

@ -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();

View File

@ -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;
}
}
}