using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BackgroundBlurImproved")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.7.6.0")]
[assembly: AssemblyInformationalVersion("0.7.6+78bca3d224771ada0e69c2a068288289c8e250cf")]
[assembly: AssemblyProduct("BackgroundBlurImproved")]
[assembly: AssemblyTitle("BackgroundBlurImproved")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/alexkiri/BackgroundBlurImprovedPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.7.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
internal sealed class ConfigurationManagerAttributes
{
public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);
public bool? ShowRangeAsPercent;
public Action<ConfigEntryBase> CustomDrawer;
public CustomHotkeyDrawerFunc CustomHotkeyDrawer;
public bool? Browsable;
public string Category;
public object DefaultValue;
public bool? HideDefaultButton;
public bool? HideSettingName;
public string Description;
public string DispName;
public int? Order;
public bool? ReadOnly;
public bool? IsAdvanced;
public Func<object, string> ObjToStr;
public Func<string, object> StrToObj;
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BackgroundBlurImproved
{
[BepInPlugin("io.github.alexkiri.backgroundblurimproved", "BackgroundBlurImproved", "0.7.6")]
public class BackgroundBlurImprovedPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private readonly Harmony harmony = new Harmony("io.github.alexkiri.backgroundblurimproved");
public static ConfigEntry<BlurHeight> blurRenderTextureHeightConfigEntry;
public static ConfigEntry<int> blurPassGroupCountConfigEntry;
public static ConfigEntry<bool> blurEnableConfigEntry;
public static ConfigEntry<BlurPreset> presetConfigEntry;
public static LightBlurredBackground? lightBlurredBackground;
public const string Id = "io.github.alexkiri.backgroundblurimproved";
public static string Name => "BackgroundBlurImproved";
public static string Version => "0.7.6";
public static void applyCurrentSettings()
{
int value = (int)blurRenderTextureHeightConfigEntry.Value;
int value2 = blurPassGroupCountConfigEntry.Value;
bool value3 = blurEnableConfigEntry.Value;
if ((Object)(object)lightBlurredBackground != (Object)null)
{
Log.LogInfo((object)$"will apply settings for {lightBlurredBackground} RenderTextureHeight: {lightBlurredBackground.renderTextureHeight}->{value} PassGroupCount: {lightBlurredBackground.passGroupCount}->{value2}");
((Behaviour)lightBlurredBackground.lightBlur).enabled = true;
lightBlurredBackground.RenderTextureHeight = value;
lightBlurredBackground.PassGroupCount = value2;
((Behaviour)lightBlurredBackground).enabled = false;
((Behaviour)lightBlurredBackground).enabled = true;
((Behaviour)lightBlurredBackground.lightBlur).enabled = value3;
}
}
private void Awake()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll();
blurRenderTextureHeightConfigEntry = ((BaseUnityPlugin)this).Config.Bind<BlurHeight>("General", "RenderTextureHeight", BlurHeight.Medium_720, new ConfigDescription("The height of the BlurredBackground layer. Improves the quality, but lowers the blur effect intensity, with low impact on performance. Game default is 360.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 3
}
}));
blurRenderTextureHeightConfigEntry.SettingChanged += delegate
{
presetConfigEntry.Value = BlurPreset.Custom;
applyCurrentSettings();
};
blurPassGroupCountConfigEntry = ((BaseUnityPlugin)this).Config.Bind<int>("General", "PassGroupCount", 4, new ConfigDescription("The number of passes of the BlurredBackground layer. Increases the intensity of the blur effect, with medium / heavy impact on performance. Game default is 2.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 32), new object[1]
{
new ConfigurationManagerAttributes
{
Order = 2
}
}));
blurPassGroupCountConfigEntry.SettingChanged += delegate
{
presetConfigEntry.Value = BlurPreset.Custom;
applyCurrentSettings();
};
blurEnableConfigEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableEffect", true, new ConfigDescription("When disabled, the blur effect is completely removed, and the PassGroupCount setting will have no effect.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
IsAdvanced = true,
Order = 1
}
}));
blurEnableConfigEntry.SettingChanged += delegate
{
bool value = blurEnableConfigEntry.Value;
Log.LogInfo((object)$"blurEnableConfigEntry.SettingChanged -> {value}");
presetConfigEntry.Value = BlurPreset.Custom;
if ((Object)(object)lightBlurredBackground != (Object)null)
{
((Behaviour)lightBlurredBackground.lightBlur).enabled = value;
}
};
presetConfigEntry = ((BaseUnityPlugin)this).Config.Bind<BlurPreset>("General", "Apply Preset", BlurPreset.Medium, new ConfigDescription("Click to apply any preset.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
HideDefaultButton = true,
CustomDrawer = PresetsCustomDrawer,
Order = 0
}
}));
GameCameras instance = GameCameras.instance;
if ((Object)(object)instance != (Object)null)
{
Log.LogInfo((object)$"Existing GameCameras object found {instance}");
LightBlurredBackground component = ((Component)instance).GetComponent<LightBlurredBackground>();
if ((Object)(object)component != (Object)null)
{
Log.LogInfo((object)$"Existing LightBlurredBackground object found {component}");
lightBlurredBackground = component;
applyCurrentSettings();
}
}
UIManager instance2 = UIManager.instance;
if ((Object)(object)instance2 != (Object)null)
{
Log.LogInfo((object)$"Existing UIManager object found {instance2}");
CustomizeMenu(instance2);
}
Log.LogInfo((object)("Plugin " + Name + " (io.github.alexkiri.backgroundblurimproved) has loaded!"));
}
private void OnDestroy()
{
harmony.UnpatchSelf();
lightBlurredBackground = null;
Log.LogInfo((object)("Plugin " + Name + " (io.github.alexkiri.backgroundblurimproved) has unloaded!"));
}
private void PresetsCustomDrawer(ConfigEntryBase configEntry)
{
if (GUILayout.Button(BlurPreset.Vanilla.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
{
blurEnableConfigEntry.Value = true;
blurRenderTextureHeightConfigEntry.Value = BlurHeight.Vanilla_360;
blurPassGroupCountConfigEntry.Value = 2;
presetConfigEntry.Value = BlurPreset.Vanilla;
}
if (GUILayout.Button(BlurPreset.Medium.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
{
blurEnableConfigEntry.Value = true;
blurRenderTextureHeightConfigEntry.Value = BlurHeight.Medium_720;
blurPassGroupCountConfigEntry.Value = 4;
presetConfigEntry.Value = BlurPreset.Medium;
}
if (GUILayout.Button(BlurPreset.High.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
{
blurEnableConfigEntry.Value = true;
blurRenderTextureHeightConfigEntry.Value = BlurHeight.High_1080;
blurPassGroupCountConfigEntry.Value = 6;
presetConfigEntry.Value = BlurPreset.High;
}
if (GUILayout.Button(BlurPreset.VeryHigh.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
{
blurEnableConfigEntry.Value = true;
blurRenderTextureHeightConfigEntry.Value = BlurHeight.VeryHigh_1440;
blurPassGroupCountConfigEntry.Value = 8;
presetConfigEntry.Value = BlurPreset.VeryHigh;
}
}
public static void CustomizeMenu(UIManager um)
{
Transform val = ((Component)um.advancedVideoMenuScreen).transform.Find("Content/ShaderSetting");
if (!((Object)(object)val == (Object)null))
{
((Component)val).gameObject.SetActive(false);
}
}
}
public enum BlurHeight
{
VeryLow_240 = 240,
Low_270 = 270,
Vanilla_360 = 360,
Medium_720 = 720,
High_1080 = 1080,
VeryHigh_1440 = 1440,
UltraHigh_2160 = 2160
}
public enum BlurPreset
{
[Description("Vanilla")]
Vanilla,
[Description("Medium")]
Medium,
[Description("High")]
High,
[Description("VeryHigh")]
VeryHigh,
[Description("Custom")]
Custom
}
[HarmonyPatch]
public class Patcher
{
private static readonly ManualLogSource Log = BackgroundBlurImprovedPlugin.Log;
[HarmonyPatch(typeof(BlurManager), "Awake")]
[HarmonyPostfix]
private static void BlurManager_Awake(BlurManager __instance)
{
int value = (int)BackgroundBlurImprovedPlugin.blurRenderTextureHeightConfigEntry.Value;
Log.LogDebug((object)$"BlurManager.Awake() called on {__instance}[{((object)__instance).GetHashCode()}] baseHeight: {__instance.baseHeight} -> {value}");
__instance.baseHeight = value;
BackgroundBlurImprovedPlugin.lightBlurredBackground = __instance.lightBlurredBackground;
}
[HarmonyPatch(typeof(BlurManager), "Update")]
[HarmonyPrefix]
private static void BlurManager_Update(BlurManager __instance)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
GameManager instance = GameManager.instance;
if ((Object)(object)instance != (Object)null)
{
ShaderQualities shaderQuality = instance.gameSettings.shaderQuality;
__instance.appliedShaderQuality = shaderQuality;
}
}
[HarmonyPatch(typeof(LightBlurredBackground), "Awake")]
[HarmonyPostfix]
private static void LightBlurredBackground_Awake(LightBlurredBackground __instance)
{
int value = (int)BackgroundBlurImprovedPlugin.blurRenderTextureHeightConfigEntry.Value;
int value2 = BackgroundBlurImprovedPlugin.blurPassGroupCountConfigEntry.Value;
Log.LogDebug((object)$"LightBlurredBackground.Awake called on {__instance}[{((object)__instance).GetHashCode()}], renderTextureHeight: {__instance.renderTextureHeight} -> {value}, passGroupCount: {__instance.passGroupCount} -> {value2}");
__instance.passGroupCount = value2;
__instance.renderTextureHeight = value;
}
[HarmonyPatch(typeof(LightBlur), "Awake")]
[HarmonyPrefix]
private static void LightBlur_Awake(LightBlur __instance)
{
bool value = BackgroundBlurImprovedPlugin.blurEnableConfigEntry.Value;
Log.LogDebug((object)$"LightBlur.Awake called on {__instance}[{((object)__instance).GetHashCode()}], will enable {value}");
((Behaviour)__instance).enabled = value;
}
[HarmonyPatch(typeof(UIManager), "Awake")]
[HarmonyPostfix]
public static void UIManager_Awake(UIManager __instance)
{
Log.LogDebug((object)$"UIManager.Awake called on {__instance}[{((object)__instance).GetHashCode()}]");
BackgroundBlurImprovedPlugin.CustomizeMenu(__instance);
}
}
}