using System;
using System.Collections.Generic;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using LC_FramerateSlider.Config;
using LC_FramerateSlider.ModDeps;
using LC_FramerateSlider.Patches;
using LethalConfig;
using LethalConfig.ConfigItems;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using On;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("com.Confusified.FramerateSlider")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("FramerateSlider")]
[assembly: AssemblyTitle("com.Confusified.FramerateSlider")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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;
}
}
}
namespace LC_FramerateSlider
{
[BepInPlugin("com.Confusified.FramerateSlider", "FramerateSlider", "1.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class LC_FramerateSlider : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__MainMenuStart;
public static hook_Start <1>__QuickMenuStart;
public static hook_OpenQuickMenu <2>__OpenedQuickMenu;
public static hook_CloseQuickMenu <3>__ClosedQuickMenu;
public static hook_UpdateGameToMatchSettings <4>__SaveChangedSettings;
public static hook_SetFramerateCap <5>__SaveSliderValueToConfig;
public static hook_DiscardChangedSettings <6>__DiscardChangedFramerate;
public static hook_ResetSettingsToDefault <7>__ResetToDefault;
}
internal static readonly string configLocation;
internal static ConfigFile modConfig;
public static LC_FramerateSlider Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
global::LC_FramerateSlider.Config.Config.BindSettings();
if (!global::LC_FramerateSlider.Config.Config.Enabled.Value)
{
Logger.LogInfo((object)"Stopped loading com.Confusified.FramerateSlider 1.1.1, as it is disabled in the config file");
return;
}
RunDependencies();
PatchAll();
Logger.LogInfo((object)"FramerateSlider 1.1.1 has loaded!");
}
internal static void PatchAll()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Expected O, but got Unknown
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
Logger.LogDebug((object)"Hooking...");
object obj = <>O.<0>__MainMenuStart;
if (obj == null)
{
hook_Start val = MenuInjector.MainMenuStart;
<>O.<0>__MainMenuStart = val;
obj = (object)val;
}
MenuManager.Start += (hook_Start)obj;
object obj2 = <>O.<1>__QuickMenuStart;
if (obj2 == null)
{
hook_Start val2 = MenuInjector.QuickMenuStart;
<>O.<1>__QuickMenuStart = val2;
obj2 = (object)val2;
}
QuickMenuManager.Start += (hook_Start)obj2;
object obj3 = <>O.<2>__OpenedQuickMenu;
if (obj3 == null)
{
hook_OpenQuickMenu val3 = SliderBehaviour.OpenedQuickMenu;
<>O.<2>__OpenedQuickMenu = val3;
obj3 = (object)val3;
}
QuickMenuManager.OpenQuickMenu += (hook_OpenQuickMenu)obj3;
object obj4 = <>O.<3>__ClosedQuickMenu;
if (obj4 == null)
{
hook_CloseQuickMenu val4 = SliderBehaviour.ClosedQuickMenu;
<>O.<3>__ClosedQuickMenu = val4;
obj4 = (object)val4;
}
QuickMenuManager.CloseQuickMenu += (hook_CloseQuickMenu)obj4;
object obj5 = <>O.<4>__SaveChangedSettings;
if (obj5 == null)
{
hook_UpdateGameToMatchSettings val5 = SliderBehaviour.SaveChangedSettings;
<>O.<4>__SaveChangedSettings = val5;
obj5 = (object)val5;
}
IngamePlayerSettings.UpdateGameToMatchSettings += (hook_UpdateGameToMatchSettings)obj5;
object obj6 = <>O.<5>__SaveSliderValueToConfig;
if (obj6 == null)
{
hook_SetFramerateCap val6 = SliderBehaviour.SaveSliderValueToConfig;
<>O.<5>__SaveSliderValueToConfig = val6;
obj6 = (object)val6;
}
IngamePlayerSettings.SetFramerateCap += (hook_SetFramerateCap)obj6;
object obj7 = <>O.<6>__DiscardChangedFramerate;
if (obj7 == null)
{
hook_DiscardChangedSettings val7 = SliderBehaviour.DiscardChangedFramerate;
<>O.<6>__DiscardChangedFramerate = val7;
obj7 = (object)val7;
}
IngamePlayerSettings.DiscardChangedSettings += (hook_DiscardChangedSettings)obj7;
object obj8 = <>O.<7>__ResetToDefault;
if (obj8 == null)
{
hook_ResetSettingsToDefault val8 = SliderBehaviour.ResetToDefault;
<>O.<7>__ResetToDefault = val8;
obj8 = (object)val8;
}
IngamePlayerSettings.ResetSettingsToDefault += (hook_ResetSettingsToDefault)obj8;
}
internal static void RunDependencies()
{
Dictionary<string, Action> dictionary = new Dictionary<string, Action>
{
{
"BMX.LobbyCompatibility",
delegate
{
LobbyCompatibility.Instance.DependencyMethod();
}
},
{
"ainavt.lc.lethalconfig",
delegate
{
LethalConfig.Instance.DependencyMethod();
}
}
};
foreach (KeyValuePair<string, Action> item in dictionary)
{
string key = item.Key;
if (Chainloader.PluginInfos.ContainsKey(key))
{
Logger.LogDebug((object)("Found " + key));
dictionary[key]();
break;
}
}
}
static LC_FramerateSlider()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
string[] array = new string[1];
string configPath = Paths.ConfigPath;
string text = "com.Confusified.FramerateSlider";
array[0] = configPath + "\\" + text.Substring(4, text.Length - 4).Replace(".", "\\");
configLocation = Utility.CombinePaths(array);
modConfig = new ConfigFile(configLocation + ".cfg", false);
Instance = null;
Logger = null;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.Confusified.FramerateSlider";
public const string PLUGIN_NAME = "FramerateSlider";
public const string PLUGIN_VERSION = "1.1.1";
}
}
namespace LC_FramerateSlider.Patches
{
internal class MenuInjector
{
internal static int unsavedFramerateValue = global::LC_FramerateSlider.Config.Config.Framerate.Value;
internal const string framerateSliderText = "Frame rate cap: ";
private static Vector3 FramerateSliderPositionOffset = Vector3.left * 9f;
private const float scaleMultiplier = 1.1f;
public static GameObject GameVolumeSlider { get; private set; }
public static Slider GameVolumeSliderComponent { get; private set; }
public static GameObject GameFramerateDropdown { get; private set; }
public static GameObject ModFramerateSlider { get; private set; }
public static Slider ModSliderComponent { get; private set; }
public static TextMeshProUGUI ModTextComponent { get; private set; }
internal static IngamePlayerSettings ingamePlayerSettings { get; private set; }
internal static GameNetworkManager gameNetworkManager { get; private set; }
internal static MenuManager menuManager { get; private set; }
internal static QuickMenuManager quickMenuManager { get; private set; }
internal static void MainMenuStart(orig_Start orig, MenuManager self)
{
orig.Invoke(self);
if (self.isInitScene)
{
ingamePlayerSettings = IngamePlayerSettings.Instance;
gameNetworkManager = GameNetworkManager.Instance;
}
menuManager = self;
if (!self.isInitScene)
{
InjectFramerateSlider();
SliderBehaviour.UpdateFramerate();
}
}
internal static void QuickMenuStart(orig_Start orig, QuickMenuManager self)
{
orig.Invoke(self);
quickMenuManager = self;
InjectFramerateSlider();
SliderBehaviour.UpdateFramerate();
}
internal static void InjectFramerateSlider()
{
FetchGameElements();
if (!Object.op_Implicit((Object)(object)GameFramerateDropdown))
{
LC_FramerateSlider.Logger.LogError((object)"Could not find vanilla's framerate dropdown");
return;
}
GameFramerateDropdown.SetActive(false);
CreateSlider();
((UnityEvent<float>)(object)ModSliderComponent.onValueChanged).AddListener((UnityAction<float>)delegate
{
SliderValueChanged();
});
}
private static void FetchGameElements()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Invalid comparison between Unknown and I4
SettingsOption[] array = Object.FindObjectsOfType<SettingsOption>(true);
bool flag = false;
bool flag2 = false;
SettingsOption[] array2 = array;
foreach (SettingsOption val in array2)
{
if (!(flag && flag2))
{
if ((int)val.optionType == 9)
{
LC_FramerateSlider.Logger.LogDebug((object)"Found framerate dropdown");
GameFramerateDropdown = ((Component)val).gameObject;
flag = true;
}
else if ((int)val.optionType == 8)
{
LC_FramerateSlider.Logger.LogDebug((object)"Found volume slider");
GameVolumeSlider = ((Component)((Component)val).transform.parent).gameObject;
GameVolumeSliderComponent = GameVolumeSlider.GetComponentInChildren<Slider>();
flag2 = true;
}
continue;
}
break;
}
}
private static void CreateSlider()
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
ModFramerateSlider = Object.Instantiate<GameObject>(GameVolumeSlider);
((Object)ModFramerateSlider).name = "FramerateSlider";
ModFramerateSlider.transform.SetSiblingIndex(GameFramerateDropdown.transform.GetSiblingIndex() + 1);
SettingsOption componentInChildren = ModFramerateSlider.GetComponentInChildren<SettingsOption>();
Object.Destroy((Object)(object)componentInChildren);
Transform transform = ModFramerateSlider.transform;
transform.SetParent(GameFramerateDropdown.transform.parent, false);
transform.localScale *= 1.1f;
transform.localPosition = GameFramerateDropdown.transform.localPosition + FramerateSliderPositionOffset;
ModSliderComponent = ModFramerateSlider.GetComponentInChildren<Slider>();
ModSliderComponent.minValue = 0f;
ModSliderComponent.maxValue = global::LC_FramerateSlider.Config.Config.MaxFramerate.Value + 1;
ModSliderComponent.Set((float)global::LC_FramerateSlider.Config.Config.Framerate.Value, false);
ModTextComponent = ModFramerateSlider.GetComponentInChildren<TextMeshProUGUI>();
((TMP_Text)ModTextComponent).SetText("Frame rate cap: " + CurrentSliderValueToText(), true);
}
internal static string CurrentSliderValueToText()
{
float value = ModSliderComponent.value;
if (value <= ModSliderComponent.minValue)
{
return "VSync";
}
if (value >= ModSliderComponent.maxValue)
{
return "Uncapped";
}
return value.ToString();
}
private static void SliderValueChanged()
{
((TMP_Text)ModTextComponent).SetText("Frame rate cap: " + CurrentSliderValueToText(), true);
unsavedFramerateValue = (int)ModSliderComponent.value;
ingamePlayerSettings.SettingsAudio.PlayOneShot(gameNetworkManager.buttonTuneSFX);
ingamePlayerSettings.SetChangesNotAppliedTextVisible(true);
}
internal static void UpdateVanillaFramerateIndex()
{
float value = ModSliderComponent.value;
byte framerateCapIndex = (byte)((!(value <= ModSliderComponent.minValue)) ? ((value >= ModSliderComponent.maxValue) ? 1 : ((value > 144f) ? 2 : ((value > 120f) ? 3 : ((!(value > 60f)) ? 5 : 4)))) : 0);
ingamePlayerSettings.unsavedSettings.framerateCapIndex = framerateCapIndex;
}
}
internal class SliderBehaviour
{
internal static void ResetToDefault(orig_ResetSettingsToDefault orig, IngamePlayerSettings self)
{
global::LC_FramerateSlider.Config.Config.Framerate.Value = (int)((ConfigEntryBase)global::LC_FramerateSlider.Config.Config.Framerate).DefaultValue;
MenuInjector.ModSliderComponent.Set((float)global::LC_FramerateSlider.Config.Config.Framerate.Value, false);
global::LC_FramerateSlider.Config.Config.MaxFramerate.Value = (int)((ConfigEntryBase)global::LC_FramerateSlider.Config.Config.MaxFramerate).DefaultValue;
global::LC_FramerateSlider.Config.Config.MenuFramerateSetting.Value = (global::LC_FramerateSlider.Config.Config.MenuFramerateSettings)((ConfigEntryBase)global::LC_FramerateSlider.Config.Config.MenuFramerateSetting).DefaultValue;
global::LC_FramerateSlider.Config.Config.MaxMenuFramerate.Value = (int)((ConfigEntryBase)global::LC_FramerateSlider.Config.Config.MaxMenuFramerate).DefaultValue;
orig.Invoke(self);
}
internal static void DiscardChangedFramerate(orig_DiscardChangedSettings orig, IngamePlayerSettings self)
{
MenuInjector.ModSliderComponent.Set((float)global::LC_FramerateSlider.Config.Config.Framerate.Value, false);
((TMP_Text)MenuInjector.ModTextComponent).SetText("Frame rate cap: " + MenuInjector.CurrentSliderValueToText(), true);
orig.Invoke(self);
}
internal static void SaveSliderValueToConfig(orig_SetFramerateCap orig = null, IngamePlayerSettings self = null, int value = 4)
{
if ((Object.op_Implicit((Object)(object)MenuInjector.menuManager) && !MenuInjector.menuManager.isInitScene) || Object.op_Implicit((Object)(object)MenuInjector.quickMenuManager))
{
MenuInjector.UpdateVanillaFramerateIndex();
}
}
internal static void SaveChangedSettings(orig_UpdateGameToMatchSettings orig = null, IngamePlayerSettings self = null)
{
if (orig != null && (Object)(object)self != (Object)null)
{
orig.Invoke(self);
}
if ((Object.op_Implicit((Object)(object)MenuInjector.menuManager) && !MenuInjector.menuManager.isInitScene) || Object.op_Implicit((Object)(object)MenuInjector.quickMenuManager))
{
UpdateFramerate();
}
}
internal static void UpdateFramerate()
{
global::LC_FramerateSlider.Config.Config.Framerate.Value = (int)MenuInjector.ModSliderComponent.value;
int value = global::LC_FramerateSlider.Config.Config.Framerate.Value;
global::LC_FramerateSlider.Config.Config.MenuFramerateSettings value2 = global::LC_FramerateSlider.Config.Config.MenuFramerateSetting.Value;
bool flag = global::LC_FramerateSlider.Config.Config.MenuFramerateSetting.Value == global::LC_FramerateSlider.Config.Config.MenuFramerateSettings.MainMenuOnly;
bool flag2 = global::LC_FramerateSlider.Config.Config.MenuFramerateSetting.Value == global::LC_FramerateSlider.Config.Config.MenuFramerateSettings.QuickMenuOnly;
bool flag3 = global::LC_FramerateSlider.Config.Config.MenuFramerateSetting.Value == global::LC_FramerateSlider.Config.Config.MenuFramerateSettings.Both;
if ((Object.op_Implicit((Object)(object)MenuInjector.menuManager) && flag) || (Object.op_Implicit((Object)(object)MenuInjector.quickMenuManager) && flag2 && MenuInjector.quickMenuManager.isMenuOpen) || (flag3 && Object.op_Implicit((Object)(object)MenuInjector.quickMenuManager) && MenuInjector.quickMenuManager.isMenuOpen) || Object.op_Implicit((Object)(object)MenuInjector.menuManager))
{
int num = global::LC_FramerateSlider.Config.Config.MaxMenuFramerate.Value;
if (num > value)
{
num = value;
}
Application.targetFrameRate = num;
QualitySettings.vSyncCount = 0;
return;
}
bool flag4 = value <= 0;
if (flag4 || value >= global::LC_FramerateSlider.Config.Config.MaxFramerate.Value)
{
if (flag4)
{
QualitySettings.vSyncCount = 1;
}
Application.targetFrameRate = -1;
}
else
{
Application.targetFrameRate = value;
QualitySettings.vSyncCount = 0;
}
}
internal static void ClosedQuickMenu(orig_CloseQuickMenu orig, QuickMenuManager self)
{
orig.Invoke(self);
UpdateFramerate();
}
internal static void OpenedQuickMenu(orig_OpenQuickMenu orig, QuickMenuManager self)
{
orig.Invoke(self);
UpdateFramerate();
}
}
}
namespace LC_FramerateSlider.ModDeps
{
public abstract class DependencyBase
{
public string modGUID { get; internal set; }
public bool modInstalled { get; internal set; }
internal abstract void DependencyMethod();
}
public class LethalConfig : DependencyBase
{
public new const string modGUID = "ainavt.lc.lethalconfig";
public static LethalConfig Instance { get; private set; } = new LethalConfig();
internal override void DependencyMethod()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
LethalConfigManager.SkipAutoGen();
IntInputFieldConfigItem val = new IntInputFieldConfigItem(global::LC_FramerateSlider.Config.Config.MaxFramerate, false);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
val = new IntInputFieldConfigItem(global::LC_FramerateSlider.Config.Config.MaxMenuFramerate, false);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
EnumDropDownConfigItem<global::LC_FramerateSlider.Config.Config.MenuFramerateSettings> val2 = new EnumDropDownConfigItem<global::LC_FramerateSlider.Config.Config.MenuFramerateSettings>(global::LC_FramerateSlider.Config.Config.MenuFramerateSetting, false);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
global::LC_FramerateSlider.Config.Config.MaxFramerate.SettingChanged += MaxFramerate_SettingChanged;
global::LC_FramerateSlider.Config.Config.MaxMenuFramerate.SettingChanged += MenuSetting_SettingChanged;
global::LC_FramerateSlider.Config.Config.MenuFramerateSetting.SettingChanged += MenuSetting_SettingChanged;
}
private void MenuSetting_SettingChanged(object sender, EventArgs e)
{
SliderBehaviour.SaveChangedSettings();
}
private void MaxFramerate_SettingChanged(object sender, EventArgs e)
{
Slider modSliderComponent = MenuInjector.ModSliderComponent;
if ((Object)(object)modSliderComponent != (Object)null)
{
modSliderComponent.maxValue = global::LC_FramerateSlider.Config.Config.MaxFramerate.Value + 1;
}
}
}
public class LobbyCompatibility : DependencyBase
{
public new const string modGUID = "BMX.LobbyCompatibility";
public static LobbyCompatibility Instance { get; private set; } = new LobbyCompatibility();
internal override void DependencyMethod()
{
PluginHelper.RegisterPlugin("com.Confusified.FramerateSlider", Version.Parse("1.1.1"), (CompatibilityLevel)0, (VersionStrictness)0);
Instance.modInstalled = true;
}
}
}
namespace LC_FramerateSlider.Config
{
public class Config
{
public enum MenuFramerateSettings
{
None,
MainMenuOnly,
QuickMenuOnly,
Both
}
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<int> Framerate;
public static ConfigEntry<int> MaxFramerate;
public static ConfigEntry<MenuFramerateSettings> MenuFramerateSetting;
public static ConfigEntry<int> MaxMenuFramerate;
private static readonly AcceptableValueRange<int> int_RangeValue = new AcceptableValueRange<int>(1, 2147483646);
internal static ConfigEntry<byte> ConfigVersion;
internal const byte currentVersion = 3;
public static void BindSettings()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
Enabled = LC_FramerateSlider.modConfig.Bind<bool>("Mod Settings", "Mod Enabled", true, "Replace the framerate dropdown with a framerate slider?");
Framerate = LC_FramerateSlider.modConfig.Bind<int>("Mod Settings", "Current Framerate", 60, new ConfigDescription("The current framerate your game will run at", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2147483646), Array.Empty<object>()));
MaxFramerate = LC_FramerateSlider.modConfig.Bind<int>("Mod Settings", "Max Framerate", 500, new ConfigDescription("The maximum framerate you can select through the slider", (AcceptableValueBase)(object)int_RangeValue, Array.Empty<object>()));
MaxMenuFramerate = LC_FramerateSlider.modConfig.Bind<int>("Mod Settings", "Max Menu Framerate", 60, new ConfigDescription("The maximum framerate the game will render at while you are in a menu", (AcceptableValueBase)(object)int_RangeValue, Array.Empty<object>()));
MenuFramerateSetting = LC_FramerateSlider.modConfig.Bind<MenuFramerateSettings>("Mod Settings", "Limit Menu Framerate", MenuFramerateSettings.MainMenuOnly, "Limit the maximum framerate while the menu is open?");
ConfigVersion = LC_FramerateSlider.modConfig.Bind<byte>("z Do Not Touch z", "Config Version", (byte)0, "The current config file version");
UpdateFromOldConfig();
}
internal static void UpdateFromOldConfig()
{
string text = LC_FramerateSlider.configLocation + ".private";
bool flag = ES3.FileExists(text);
byte b = ((!flag) ? ConfigVersion.Value : ((byte)ES3.Load<int>("ConfigVersion", text, (int)ConfigVersion.Value)));
if (b == 3)
{
return;
}
if (b < 3)
{
ConfigEntry<int> val = LC_FramerateSlider.modConfig.Bind<int>("Mod Settings", "Framerate Limit", 60, (ConfigDescription)null);
Framerate.Value = val.Value;
LC_FramerateSlider.modConfig.Remove(((ConfigEntryBase)val).Definition);
ConfigEntry<bool> val2 = LC_FramerateSlider.modConfig.Bind<bool>("Mod Settings", "Enabled", true, (ConfigDescription)null);
Enabled.Value = val2.Value;
LC_FramerateSlider.modConfig.Remove(((ConfigEntryBase)val2).Definition);
if (flag)
{
ES3.DeleteFile(text);
}
}
PropertyInfo property = ((object)LC_FramerateSlider.modConfig).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(LC_FramerateSlider.modConfig, null);
dictionary.Clear();
ConfigVersion.Value = 3;
LC_FramerateSlider.Logger.LogDebug((object)$"Updated config file version: {b} => {(byte)3}");
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}