using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json; using BoneLib; using BoneLib.BoneMenu; using BoneLib.BoneMenu.UI; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Bonelab; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using QuestGraphicsSettings; using Unity.XR.Oculus; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering.Universal; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Core), "QuestGraphicsSettings", "3.0.0", "Jorink", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] [assembly: AssemblyCompany("QuestGraphicsSettings")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5a626ac69b786cd219aabcf3540e5d6d37d8e63f")] [assembly: AssemblyProduct("QuestGraphicsSettings")] [assembly: AssemblyTitle("QuestGraphicsSettings")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace QuestGraphicsSettings; public class Core : MelonMod { private sealed class GraphicsPreset { public float RenderScale { get; set; } public float RenderDistance { get; set; } public bool DisableRenderDistanceTweaks { get; set; } public float LODBias { get; set; } public int FFRLevel { get; set; } } private MelonPreferences_Category category; private MelonPreferences_Entry RenderScaleEntry; private MelonPreferences_Entry RenderDistanceEntry; private MelonPreferences_Entry DisableRenderDistanceTweaksEntry; private MelonPreferences_Entry LODBiasEntry; private MelonPreferences_Entry FFRLevelEntry; private MelonPreferences_Entry CustomPresetsEntry; private int ffrLevel; private Camera playerCamera; private Camera defaultRenderDistanceCamera; private bool hasDefaultRenderDistance; private float defaultRenderDistance; private float TimerStart; private bool ApplyNeeded = true; private Page defaultPage; private Page presetsPage; private GameObject pauseMenuButton; private string customPresetNameInput = string.Empty; private readonly Dictionary customPresetElements = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly Dictionary builtInPresets = new Dictionary(StringComparer.OrdinalIgnoreCase) { ["low"] = new GraphicsPreset { RenderScale = 0.8f, RenderDistance = 60f, DisableRenderDistanceTweaks = true, LODBias = 1f, FFRLevel = 3 }, ["medium"] = new GraphicsPreset { RenderScale = 1f, RenderDistance = 120f, DisableRenderDistanceTweaks = true, LODBias = 1.25f, FFRLevel = 3 }, ["high"] = new GraphicsPreset { RenderScale = 1.5f, RenderDistance = 200f, DisableRenderDistanceTweaks = true, LODBias = 1.5f, FFRLevel = 3 } }; private readonly Dictionary customPresets = new Dictionary(StringComparer.OrdinalIgnoreCase); public override void OnInitializeMelon() { ((MelonBase)this).OnInitializeMelon(); SetupMelonPreferences(); SetupBoneMenu(); Hooking.OnLevelLoaded += OnLevelLoaded; Hooking.OnUIRigCreated += SetupPauseMenuButton; } public override void OnDeinitializeMelon() { ((MelonBase)this).OnDeinitializeMelon(); Hooking.OnLevelLoaded -= OnLevelLoaded; Hooking.OnUIRigCreated -= SetupPauseMenuButton; } private void OnLevelLoaded(LevelInfo levelInfo) { ApplySettings(); TimerStart = Time.time; ApplyNeeded = true; SetupPauseMenuButton(); } private void SetupBoneMenu() { //IL_000b: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) defaultPage = Page.Root.CreatePage("Jorink", Color.red, 0, true).CreatePage("QuestGraphicsSettings", Color.red, 0, true); defaultPage.CreateFloat("Render Scale", Color.yellow, RenderScaleEntry.Value, 0.05f, 0.5f, 2f, (Action)delegate(float a) { RenderScaleEntry.Value = a; SetRenderScale(); }); defaultPage.CreateFloat("LOD Bias", Color.yellow, LODBiasEntry.Value, 0.05f, 0.5f, 2f, (Action)delegate(float a) { LODBiasEntry.Value = a; SetLODBias(); }); defaultPage.CreateInt("FFR Level", Color.green, FFRLevelEntry.Value, 1, 0, 3, (Action)delegate(int a) { FFRLevelEntry.Value = a; SetFFR(); }); defaultPage.CreateFunction("Save Settings", Color.cyan, (Action)delegate { MelonPreferences.Save(); }); Page obj = defaultPage.CreatePage("Experimental", Color.yellow, 0, true); obj.CreateFloat("Render Distance", Color.green, RenderDistanceEntry.Value, 5f, 5f, 300f, (Action)delegate(float a) { RenderDistanceEntry.Value = a; SetRenderDistance(); }); obj.CreateBool("Disable Render Distance Tweaks", Color.cyan, DisableRenderDistanceTweaksEntry.Value, (Action)delegate(bool a) { DisableRenderDistanceTweaksEntry.Value = a; SetRenderDistance(); }); presetsPage = defaultPage.CreatePage("Presets", Color.magenta, 0, true); presetsPage.CreateString("Custom Preset Name", Color.white, customPresetNameInput, (Action)delegate(string value) { customPresetNameInput = NormalizePresetName(value); }); presetsPage.CreateFunction("Save Manual Settings As Preset", Color.cyan, (Action)SaveCurrentAsCustomPreset); presetsPage.CreateFunction("Delete Preset", Color.red, (Action)RemoveCustomPreset); CreatePresetMenuEntry("low", isBuiltIn: true); CreatePresetMenuEntry("medium", isBuiltIn: true); CreatePresetMenuEntry("high", isBuiltIn: true); foreach (string key in customPresets.Keys) { CreatePresetMenuEntry(key, isBuiltIn: false); } } private void SetupPauseMenuButton() { if ((Object)(object)pauseMenuButton != (Object)null) { return; } try { TrySetupPauseMenuButton(); } catch (Exception ex) { MelonLogger.Warning("Failed to set up pause menu button: " + ex.Message); } } private void TrySetupPauseMenuButton() { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown UIRig uIRig = Player.UIRig; if ((Object)(object)uIRig == (Object)null) { return; } PreferencesPanelView panelView = uIRig.popUpMenu.preferencesPanelView; if (!((Object)(object)panelView == (Object)null)) { Transform val = ((Il2CppArrayBase)(object)panelView.pages)[panelView.defaultPage].transform.Find("grid_Options"); GameObject val2 = Object.Instantiate(((Component)val.Find("button_Control")).gameObject, val, false); ((Object)val2).name = "button_QuestGraphicsSettings"; Transform val3 = val.Find("button_Quit"); if ((Object)(object)val3 != (Object)null) { val2.transform.SetSiblingIndex(val3.GetSiblingIndex()); } Transform obj = val2.transform.Find("text_Control"); TMP_Text val4 = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)val4 != (Object)null) { val4.text = "Graphics"; ((Object)((Component)val4).gameObject).name = "text_QuestGraphicsSettings"; } Button component = val2.GetComponent