using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.BoneMenu.UI;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppTMPro;
using MelonLoader;
using Unity.XR.Oculus;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering.Universal;
using UnityEngine.UI;
using jlib;
using questgraphicssettings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(QuestGraphicsSettings), "QuestGraphicsSettings", "4.0.0", "Jorink", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonColor(255, 255, 255, 0)]
[assembly: MelonAuthorColor(255, 255, 0, 0)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace questgraphicssettings;
public class QuestGraphicsSettings : MelonMod
{
public const string Version = "4.0.0";
private MelonPreferences_Entry<float> renderScale;
private MelonPreferences_Entry<float> lodBias;
private MelonPreferences_Entry<int> ffrLevel;
private MelonPreferences_Entry<bool> dynamicFFR;
private MelonPreferences_Entry<bool> enableFarClipPlane;
private MelonPreferences_Entry<float> farClipPlane;
private Camera playerCamera;
private GameObject menuButton;
private bool needsApply;
private ModPage menu;
public override void OnInitializeMelon()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
menu = JLib.Register("QuestGraphicsSettings", Color.yellow);
renderScale = menu.Float("Render Scale", 1f, 0.05f, 0.5f, 2f, Color.yellow, (Action<float>)delegate
{
Apply();
});
lodBias = menu.Float("LOD Bias", 1.25f, 0.05f, 0.5f, 2f, Color.yellow, (Action<float>)delegate
{
Apply();
});
ffrLevel = menu.Int("FFR Level", 3, 1, 0, 3, Color.green, (Action<int>)delegate
{
Apply();
});
dynamicFFR = menu.Bool("Dynamic FFR", false, Color.green, (Action<bool>)delegate
{
Apply();
});
ModPage val = menu.SubPage("Experimental", Color.yellow);
enableFarClipPlane = val.Bool("Enable farClipPlane", false, Color.cyan, (Action<bool>)delegate
{
Apply();
});
farClipPlane = val.Float("farClipPlane (Render Distance)", 100f, 5f, 5f, 200f, Color.green, (Action<float>)delegate
{
Apply();
});
Hooking.OnLevelLoaded += OnLevelLoaded;
}
private void OnLevelLoaded(LevelInfo levelInfo)
{
playerCamera = Object.FindObjectOfType<Camera>();
needsApply = true;
}
public override void OnUpdate()
{
if (needsApply && !HelperMethods.IsLoading())
{
Apply();
}
if ((Object)(object)menuButton == (Object)null)
{
CreateMenuButton();
}
}
private void Apply()
{
UniversalRenderPipelineAsset asset = UniversalRenderPipeline.asset;
if (!((Object)(object)playerCamera == (Object)null) && !((Object)(object)asset == (Object)null))
{
needsApply = false;
asset.renderScale = renderScale.Value;
QualitySettings.lodBias = lodBias.Value;
Utils.foveatedRenderingLevel = ffrLevel.Value;
Utils.useDynamicFoveatedRendering = dynamicFFR.Value;
playerCamera.farClipPlane = (enableFarClipPlane.Value ? farClipPlane.Value : 1000f);
}
}
private void CreateMenuButton()
{
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
UIRig instance = UIRig.Instance;
if (!((Object)(object)instance == (Object)null))
{
PreferencesPanelView panelView = instance.popUpMenu.preferencesPanelView;
Transform val = ((Component)panelView).transform.Find("page_OPTIONS/grid_Options");
GameObject gameObject = ((Component)val.Find("button_Control")).gameObject;
menuButton = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent, false);
((Object)menuButton).name = "button_Graphics";
menuButton.transform.SetSiblingIndex(val.Find("button_Quit").GetSiblingIndex() - 1);
TMP_Text component = ((Component)menuButton.transform.Find("text_Control")).GetComponent<TMP_Text>();
component.text = "Graphics";
((Object)((Component)component).gameObject).name = "text_Graphics";
Button component2 = menuButton.GetComponent<Button>();
component2.onClick = new ButtonClickedEvent();
((UnityEvent)component2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
OpenFromMenu(panelView);
}));
}
}
private void OpenFromMenu(PreferencesPanelView panelView)
{
GUIMenu instance = GUIMenu.Instance;
GameObject val = ((instance != null) ? ((Component)instance).gameObject : null);
int num = 0;
while ((Object)(object)val != (Object)null && num < ((Il2CppArrayBase<GameObject>)(object)panelView.pages).Length)
{
if (!((Object)(object)((Il2CppArrayBase<GameObject>)(object)panelView.pages)[num] != (Object)(object)val))
{
panelView.PAGESELECT(num);
break;
}
num++;
}
Menu.OpenPage(menu.page);
}
}