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

Add: New RaidSettingsWindowPatch to make Raidsettingswindow to not default inraid values to BSG defaults on game settings click. (!7)

Co-authored-by: Kaeno <>
Reviewed-on: SPT-AKI/Modules#7
Reviewed-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
Co-authored-by: Kaeno <kaeno@noreply.dev.sp-tarkov.com>
Co-committed-by: Kaeno <kaeno@noreply.dev.sp-tarkov.com>
This commit is contained in:
Kaeno 2023-04-01 10:39:12 +00:00 committed by Terkoiz
parent ff98c690a6
commit f9e7681fec
2 changed files with 44 additions and 0 deletions

View File

@ -24,6 +24,7 @@ namespace Aki.Custom
new BotDifficultyPatch().Enable();
new CoreDifficultyPatch().Enable();
new OfflineRaidMenuPatch().Enable();
new RaidSettingsWindowPatch().Enable();
new OfflineRaidSettingsMenuPatch().Enable();
new SessionIdPatch().Enable();
new VersionLabelPatch().Enable();

View File

@ -0,0 +1,43 @@
using Aki.Common.Http;
using Aki.Common.Utils;
using Aki.Reflection.Patching;
using Aki.Custom.Models;
using EFT.UI;
using EFT.UI.Matchmaker;
using System.Reflection;
namespace Aki.Custom.Patches
{
/// <summary>
/// The purpose of this patch is to make RaidSettingsWindow not reset the values to BSG default
/// Keeping our own from InRaid.json therefore not defaulting to bosses being disabled.
/// </summary>
public class RaidSettingsWindowPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
var desiredType = typeof(RaidSettingsWindow);
var desiredMethod = desiredType.GetMethod("method_9", BindingFlags.NonPublic | BindingFlags.Instance);
Logger.LogDebug($"{this.GetType().Name} Type: {desiredType?.Name}");
Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name}");
return desiredMethod;
}
[PatchPrefix]
private static bool PatchPreFix(UpdatableToggle ____enableBosses, UpdatableToggle ____scavWars, UpdatableToggle ____taggedAndCursed, DropDownBox ____aiDifficultyDropdown, DropDownBox ____aiAmountDropdown)
{
var json = RequestHandler.GetJson("/singleplayer/settings/raid/menu");
var settings = Json.Deserialize<DefaultRaidSettings>(json);
____enableBosses.UpdateValue(settings.BossEnabled);
____scavWars.UpdateValue(false);
____taggedAndCursed.UpdateValue(settings.TaggedAndCursed);
____aiDifficultyDropdown.UpdateValue((int)settings.AiDifficulty);
____aiAmountDropdown.UpdateValue((int)(settings.AiAmount));
return false;
}
}
}