using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using MimesisPatches;
using TMPro;
using Unity.Cinemachine;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: MelonInfo(typeof(MelonEntry), "Fov", "1.5.3", "medovanx", "https://github.com/medovanx/mimesis-patches")]
[assembly: MelonGame("ReLUGames", "MIMESIS")]
[assembly: HarmonyDontPatchAll]
[assembly: AssemblyCompany("Mohamed Darwesh")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Mohamed Darwesh (github.com/medovanx)")]
[assembly: AssemblyFileVersion("1.5.3.0")]
[assembly: AssemblyInformationalVersion("1.5.3+c0c5849b6d1e86d27fb44104da693c963cf161f6")]
[assembly: AssemblyProduct("FovRuntime")]
[assembly: AssemblyTitle("FovRuntime")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (code, refactoring and documentation).")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude)")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 MimesisPatches
{
internal sealed class PatchMenu : MonoBehaviour
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Comparison<Dictionary<string, object>> <>9__8_1;
public static UnityAction <>9__25_0;
internal int <Register>b__8_1(Dictionary<string, object> a, Dictionary<string, object> b)
{
return string.CompareOrdinal((string)a["name"], (string)b["name"]);
}
internal void <BuildWindow>b__25_0()
{
Application.OpenURL("https://github.com/medovanx/mimesis-patches");
}
}
public const string Repo = "medovanx/mimesis-patches";
public const string RepoUrl = "https://github.com/medovanx/mimesis-patches";
private const string SizeKey = "medovanx.patches.window";
private static readonly Vector2 MinSize = new Vector2(900f, 560f);
private const string RegistryKey = "medovanx.patches.registry";
private const string OwnerKey = "medovanx.patches.owner";
private static readonly Color ChipColor = new Color(0f, 0f, 0f, 0.55f);
private static readonly Color UpdateColor = new Color(0.85f, 0.45f, 0.05f, 0.85f);
private RectTransform _row;
private TMP_Text _chipText;
private Image _chipBg;
private TMP_FontAsset _font;
private GameObject _window;
private RectTransform _sidebar;
private RectTransform _content;
private string _selected;
private static int _hovered;
private static IntPtr _hand;
private const int IDC_HAND = 32649;
private static List<Dictionary<string, object>> Entries => (AppDomain.CurrentDomain.GetData("medovanx.patches.registry") as List<Dictionary<string, object>>) ?? new List<Dictionary<string, object>>();
public static void Register(string name, Version version, Func<string> status = null, Action<RectTransform, TMP_FontAsset> build = null)
{
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
List<Dictionary<string, object>> list = AppDomain.CurrentDomain.GetData("medovanx.patches.registry") as List<Dictionary<string, object>>;
if (list == null)
{
AppDomain.CurrentDomain.SetData("medovanx.patches.registry", list = new List<Dictionary<string, object>>());
}
list.RemoveAll((Dictionary<string, object> e) => (string)e["name"] == name);
list.Add(new Dictionary<string, object>
{
["name"] = name,
["version"] = new Version(version.Major, version.Minor, Math.Max(version.Build, 0)),
["status"] = status,
["build"] = ((build == null) ? null : ((Action<RectTransform, TMP_FontAsset>)delegate(RectTransform rt, TMP_FontAsset font)
{
PatchUi.Refreshers.Clear();
build(rt, font);
PatchUi.RefreshAll();
}))
});
list.Sort((Dictionary<string, object> a, Dictionary<string, object> b) => string.CompareOrdinal((string)a["name"], (string)b["name"]));
if (AppDomain.CurrentDomain.GetData("medovanx.patches.owner") == null)
{
AppDomain.CurrentDomain.SetData("medovanx.patches.owner", name);
GameObject val = new GameObject("MedovanxPatchMenu");
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<PatchMenu>();
}
}
private static Version Latest(Dictionary<string, object> e)
{
if (!e.TryGetValue("latest", out var value))
{
return null;
}
return value as Version;
}
private static bool HasUpdate(Dictionary<string, object> e)
{
if (Latest(e) != null)
{
return Latest(e) > (Version)e["version"];
}
return false;
}
private IEnumerator Start()
{
WaitForSeconds wait = new WaitForSeconds(0.5f);
while (true)
{
GameObject val = GameObject.Find("UIPrefab_MainMenu(Clone)") ?? GameObject.Find("UIPrefab_MainMenu");
object obj;
if (!((Object)(object)val != (Object)null))
{
obj = null;
}
else
{
Transform obj2 = val.transform.Find("VersionTextRect/versionText");
obj = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null);
}
TMP_Text val2 = (TMP_Text)obj;
if ((Object)(object)val2 == (Object)null)
{
if ((Object)(object)_row != (Object)null)
{
((Component)_row).gameObject.SetActive(false);
}
_hovered = 0;
}
else if ((Object)(object)((Graphic)val2).canvas != (Object)null)
{
_font = val2.font;
if ((Object)(object)_row == (Object)null)
{
BuildChip(((Component)((Graphic)val2).canvas.rootCanvas).transform, val2);
}
List<Dictionary<string, object>> entries = Entries;
int num = entries.Count(HasUpdate);
_chipText.text = $"Patches ({entries.Count})" + ((num > 0) ? $", {num} update{((num > 1) ? "s" : "")}" : "");
((Graphic)_chipBg).color = ((num > 0) ? UpdateColor : ChipColor);
bool flag = val.activeInHierarchy && ((Object)(object)Hub.s == (Object)null || Hub.s.pdata == null || (Object)(object)Hub.s.pdata.main == (Object)null);
((Component)_row).gameObject.SetActive(flag);
if (!flag)
{
_hovered = 0;
Close();
}
}
yield return wait;
}
}
private void BuildChip(Transform canvas, TMP_Text version)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Expected O, but got Unknown
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
_row = new GameObject("PatchChips", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)_row).SetParent(canvas, false);
((Transform)_row).SetAsLastSibling();
RectTransform row = _row;
RectTransform row2 = _row;
Vector2 val = (_row.pivot = Vector2.zero);
Vector2 anchorMin = (row2.anchorMax = val);
row.anchorMin = anchorMin;
_row.anchoredPosition = new Vector2(24f, 20f);
_row.sizeDelta = new Vector2(600f, 30f);
HorizontalLayoutGroup obj = ((Component)_row).gameObject.AddComponent<HorizontalLayoutGroup>();
((LayoutGroup)obj).childAlignment = (TextAnchor)6;
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = childControlWidth;
childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false);
((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = childControlWidth;
GameObject val3 = new GameObject("Chip_Patches", new Type[3]
{
typeof(RectTransform),
typeof(Image),
typeof(Button)
});
val3.transform.SetParent((Transform)(object)_row, false);
_chipBg = val3.GetComponent<Image>();
Button component = val3.GetComponent<Button>();
((Selectable)component).targetGraphic = (Graphic)(object)_chipBg;
ColorBlock colors = ((Selectable)component).colors;
((ColorBlock)(ref colors)).highlightedColor = new Color(1.6f, 1.6f, 1.6f, 1f);
((Selectable)component).colors = colors;
((UnityEvent)component.onClick).AddListener(new UnityAction(Open));
Hover(val3);
HorizontalLayoutGroup obj2 = val3.AddComponent<HorizontalLayoutGroup>();
((LayoutGroup)obj2).padding = new RectOffset(12, 12, 4, 4);
childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = childControlWidth;
childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false);
((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = childControlWidth;
_chipText = (TMP_Text)(object)new GameObject("Text", new Type[1] { typeof(RectTransform) }).AddComponent<TextMeshProUGUI>();
_chipText.transform.SetParent(val3.transform, false);
_chipText.font = version.font;
_chipText.fontSize = version.fontSize * 0.85f;
((Graphic)_chipText).color = PatchUi.Text;
((Graphic)_chipText).raycastTarget = false;
Debug.Log((object)"[Patches] Main menu chip added");
}
private void Open()
{
if ((Object)(object)_window == (Object)null)
{
BuildWindow();
}
_window.SetActive(true);
List<Dictionary<string, object>> entries = Entries;
if (_selected == null || entries.All((Dictionary<string, object> e) => (string)e["name"] != _selected))
{
_selected = entries.FirstOrDefault()?["name"] as string;
}
BuildSidebar();
Select(_selected);
}
private void Close()
{
if ((Object)(object)_window != (Object)null)
{
_window.SetActive(false);
}
}
private void BuildWindow()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Expected O, but got Unknown
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0371: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: Unknown result type (might be due to invalid IL or missing references)
//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
//IL_0440: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
//IL_050a: Unknown result type (might be due to invalid IL or missing references)
//IL_0524: Unknown result type (might be due to invalid IL or missing references)
//IL_053e: Unknown result type (might be due to invalid IL or missing references)
//IL_055d: Unknown result type (might be due to invalid IL or missing references)
//IL_0567: Expected O, but got Unknown
//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0609: Unknown result type (might be due to invalid IL or missing references)
//IL_0482: Unknown result type (might be due to invalid IL or missing references)
//IL_0487: Unknown result type (might be due to invalid IL or missing references)
//IL_048d: Expected O, but got Unknown
Canvas component = new GameObject("PatchesWindow", new Type[3]
{
typeof(Canvas),
typeof(CanvasScaler),
typeof(GraphicRaycaster)
}).GetComponent<Canvas>();
((Component)component).transform.SetParent(((Component)this).transform, false);
component.renderMode = (RenderMode)0;
component.sortingOrder = 200;
CanvasScaler component2 = ((Component)component).GetComponent<CanvasScaler>();
component2.uiScaleMode = (ScaleMode)1;
component2.referenceResolution = new Vector2(1920f, 1080f);
component2.matchWidthOrHeight = 1f;
_window = ((Component)component).gameObject;
RectTransform obj = PatchUi.Box(((Component)component).transform, "Dim", new Color(0f, 0f, 0f, 0.55f));
PatchUi.Stretch(obj);
Button obj2 = ((Component)obj).gameObject.AddComponent<Button>();
((Selectable)obj2).transition = (Transition)0;
((UnityEvent)obj2.onClick).AddListener(new UnityAction(Close));
RectTransform val = PatchUi.Box(((Component)component).transform, "Panel", new Color(0.06f, 0.06f, 0.06f, 0.96f));
val.sizeDelta = new Vector2(Mathf.Clamp(PlayerPrefs.GetFloat("medovanx.patches.window.w", 1100f), MinSize.x, 1900f), Mathf.Clamp(PlayerPrefs.GetFloat("medovanx.patches.window.h", 760f), MinSize.y, 1060f));
val.anchoredPosition = new Vector2(PlayerPrefs.GetFloat("medovanx.patches.window.x", 0f), PlayerPrefs.GetFloat("medovanx.patches.window.y", 0f));
WindowFrame.AddMove(val);
TMP_Text obj3 = PatchUi.Label((Transform)(object)val, _font, "Patches", 30f);
Object.Destroy((Object)(object)((Component)obj3).GetComponent<LayoutElement>());
obj3.rectTransform.anchorMin = new Vector2(0f, 1f);
obj3.rectTransform.anchorMax = new Vector2(1f, 1f);
obj3.rectTransform.pivot = new Vector2(0f, 1f);
obj3.rectTransform.offsetMin = new Vector2(28f, -64f);
obj3.rectTransform.offsetMax = new Vector2(-80f, -16f);
RectTransform val2 = PatchUi.Box((Transform)(object)val, "Close", PatchUi.Off);
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(1f, 1f);
val2.pivot = val3;
Vector2 anchorMin = (val2.anchorMax = val3);
val2.anchorMin = anchorMin;
val2.anchoredPosition = new Vector2(-16f, -16f);
val2.sizeDelta = new Vector2(44f, 44f);
((Graphic)((Component)val2).GetComponent<Image>()).color = PatchUi.Off;
Button obj4 = ((Component)val2).gameObject.AddComponent<Button>();
((Selectable)obj4).targetGraphic = (Graphic)(object)((Component)val2).GetComponent<Image>();
((UnityEvent)obj4.onClick).AddListener(new UnityAction(Close));
Hover(((Component)val2).gameObject);
float[] array = new float[2] { 45f, -45f };
foreach (float num in array)
{
RectTransform obj5 = PatchUi.Box((Transform)(object)val2, "Bar", PatchUi.Text);
obj5.sizeDelta = new Vector2(22f, 3f);
((Vector2)(ref val3))..ctor(0.5f, 0.5f);
obj5.pivot = val3;
anchorMin = (obj5.anchorMax = val3);
obj5.anchorMin = anchorMin;
obj5.anchoredPosition = Vector2.zero;
((Transform)obj5).localRotation = Quaternion.Euler(0f, 0f, num);
((Graphic)((Component)obj5).GetComponent<Image>()).raycastTarget = false;
}
TMP_Text obj6 = PatchUi.Label((Transform)(object)val, _font, "Made by <b>Mohamed Darwesh</b> (@medovanx) | <u>github.com/medovanx/mimesis-patches</u>", 18f, PatchUi.Dim);
Object.Destroy((Object)(object)((Component)obj6).GetComponent<LayoutElement>());
obj6.alignment = (TextAlignmentOptions)514;
((Graphic)obj6).raycastTarget = true;
RectTransform rectTransform = obj6.rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0f);
rectTransform.anchorMax = new Vector2(1f, 0f);
rectTransform.pivot = new Vector2(0.5f, 0f);
rectTransform.offsetMin = new Vector2(16f, 12f);
rectTransform.offsetMax = new Vector2(-16f, 44f);
ButtonClickedEvent onClick = ((Component)obj6).gameObject.AddComponent<Button>().onClick;
object obj7 = <>c.<>9__25_0;
if (obj7 == null)
{
UnityAction val6 = delegate
{
Application.OpenURL("https://github.com/medovanx/mimesis-patches");
};
<>c.<>9__25_0 = val6;
obj7 = (object)val6;
}
((UnityEvent)onClick).AddListener((UnityAction)obj7);
Hover(((Component)obj6).gameObject);
_sidebar = PatchUi.Box((Transform)(object)val, "Sidebar", new Color(1f, 1f, 1f, 0.04f));
_sidebar.anchorMin = new Vector2(0f, 0f);
_sidebar.anchorMax = new Vector2(0f, 1f);
_sidebar.pivot = new Vector2(0f, 0.5f);
_sidebar.offsetMin = new Vector2(16f, 56f);
_sidebar.offsetMax = new Vector2(296f, -80f);
VerticalLayoutGroup obj8 = ((Component)_sidebar).gameObject.AddComponent<VerticalLayoutGroup>();
((LayoutGroup)obj8).padding = new RectOffset(8, 8, 8, 8);
((HorizontalOrVerticalLayoutGroup)obj8).spacing = 6f;
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj8).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj8).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)obj8).childForceExpandHeight = false;
_content = new GameObject("Content", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)_content).SetParent((Transform)(object)val, false);
_content.anchorMin = Vector2.zero;
_content.anchorMax = Vector2.one;
_content.offsetMin = new Vector2(320f, 56f);
_content.offsetMax = new Vector2(-24f, -80f);
VerticalLayoutGroup obj9 = ((Component)_content).gameObject.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)obj9).spacing = 14f;
childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj9).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj9).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)obj9).childForceExpandHeight = false;
WindowFrame.AddResize(val);
}
private void BuildSidebar()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
foreach (Transform item in (Transform)_sidebar)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
foreach (Dictionary<string, object> entry in Entries)
{
string name = (string)entry["name"];
string label = name + " <size=70%><color=#A6AAA0>v" + ((Version)entry["version"]).ToString(3) + "</color></size>" + (HasUpdate(entry) ? " <color=#E08A1E>●</color>" : "");
Button obj = PatchUi.Button((Transform)(object)_sidebar, _font, label, delegate
{
_selected = name;
Select(name);
}, 260f, 48f);
TMP_Text componentInChildren = ((Component)obj).GetComponentInChildren<TMP_Text>();
componentInChildren.alignment = (TextAlignmentOptions)4097;
componentInChildren.margin = new Vector4(14f, 0f, 8f, 0f);
((Graphic)((Component)obj).GetComponent<Image>()).color = ((name == _selected) ? PatchUi.On : PatchUi.Off);
}
}
private void Select(string name)
{
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Expected O, but got Unknown
BuildSidebar();
foreach (Transform item in (Transform)_content)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
Dictionary<string, object> dictionary = Entries.FirstOrDefault((Dictionary<string, object> x) => (string)x["name"] == name);
if (dictionary == null)
{
return;
}
PatchUi.Label((Transform)(object)_content, _font, name + " <size=70%><color=#A6AAA0>v" + ((Version)dictionary["version"]).ToString(3) + "</color></size>", 30f, null, 40f);
if (dictionary["status"] is Func<string> func)
{
string text = null;
try
{
text = func();
}
catch
{
}
if (!string.IsNullOrEmpty(text))
{
PatchUi.Label((Transform)(object)_content, _font, text, 18f, PatchUi.Dim, 26f);
}
}
if (!(dictionary["build"] is Action<RectTransform, TMP_FontAsset> action))
{
return;
}
RectTransform val = ScrollArea((Transform)(object)_content);
VerticalLayoutGroup obj2 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)obj2).spacing = 14f;
((LayoutGroup)obj2).padding = new RectOffset(0, 24, 8, 16);
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
((Component)val).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
try
{
action(val, _font);
}
catch (Exception value)
{
Debug.LogError((object)$"[{name}] Options page failed: {value}");
}
}
private RectTransform ScrollArea(Transform parent)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = new GameObject("Scroll", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
((Component)component).gameObject.AddComponent<LayoutElement>().flexibleHeight = 1f;
RectTransform component2 = new GameObject("Viewport", new Type[2]
{
typeof(RectTransform),
typeof(RectMask2D)
}).GetComponent<RectTransform>();
((Transform)component2).SetParent((Transform)(object)component, false);
PatchUi.Stretch(component2);
((Graphic)((Component)component2).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
RectTransform component3 = new GameObject("Options", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component3).SetParent((Transform)(object)component2, false);
component3.anchorMin = new Vector2(0f, 1f);
component3.anchorMax = new Vector2(1f, 1f);
component3.pivot = new Vector2(0.5f, 1f);
Vector2 offsetMin = (component3.offsetMax = Vector2.zero);
component3.offsetMin = offsetMin;
RectTransform val = PatchUi.Box((Transform)(object)component, "Scrollbar", new Color(1f, 1f, 1f, 0.05f));
val.anchorMin = new Vector2(1f, 0f);
val.anchorMax = Vector2.one;
val.pivot = new Vector2(1f, 0.5f);
val.sizeDelta = new Vector2(8f, 0f);
RectTransform component4 = new GameObject("Handle Area", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component4).SetParent((Transform)(object)val, false);
PatchUi.Stretch(component4);
RectTransform val2 = PatchUi.Box((Transform)(object)component4, "Handle", new Color(1f, 1f, 1f, 0.3f));
offsetMin = (val2.offsetMax = Vector2.zero);
val2.offsetMin = offsetMin;
Scrollbar val3 = ((Component)val).gameObject.AddComponent<Scrollbar>();
val3.handleRect = val2;
((Selectable)val3).targetGraphic = (Graphic)(object)((Component)val2).GetComponent<Image>();
val3.direction = (Direction)2;
ScrollRect obj = ((Component)component).gameObject.AddComponent<ScrollRect>();
obj.viewport = component2;
obj.content = component3;
obj.horizontal = false;
obj.movementType = (MovementType)2;
obj.scrollSensitivity = 30f;
obj.verticalScrollbar = val3;
obj.verticalScrollbarVisibility = (ScrollbarVisibility)1;
return component3;
}
[DllImport("user32.dll")]
private static extern IntPtr LoadCursor(IntPtr instance, int name);
[DllImport("user32.dll")]
private static extern IntPtr SetCursor(IntPtr cursor);
private static void Hover(GameObject target)
{
EventTrigger hover = target.AddComponent<EventTrigger>();
On((EventTriggerType)0, 1);
On((EventTriggerType)1, -1);
void On(EventTriggerType type, int delta)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
Entry val = new Entry
{
eventID = type
};
((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)delegate
{
_hovered = Mathf.Max(0, _hovered + delta);
});
hover.triggers.Add(val);
}
}
private void LateUpdate()
{
if (_hovered > 0)
{
if (_hand == IntPtr.Zero)
{
_hand = LoadCursor(IntPtr.Zero, 32649);
}
SetCursor(_hand);
}
}
}
internal sealed class WindowFrame : MonoBehaviour, IDragHandler, IEventSystemHandler, IEndDragHandler, IBeginDragHandler, IPointerEnterHandler, IPointerExitHandler
{
private const float MinW = 900f;
private const float MinH = 560f;
private const float Edge = 8f;
private const float Corner = 22f;
private const float TitleBar = 72f;
private const int IDC_SIZENWSE = 32642;
private const int IDC_SIZENESW = 32643;
private const int IDC_SIZEWE = 32644;
private const int IDC_SIZENS = 32645;
private const int IDC_SIZEALL = 32646;
private RectTransform _panel;
private Vector2Int _dir;
private int _cursor;
private bool _hover;
private bool _dragging;
private IntPtr _handle;
[DllImport("user32.dll")]
private static extern IntPtr LoadCursor(IntPtr instance, int name);
[DllImport("user32.dll")]
private static extern IntPtr SetCursor(IntPtr cursor);
private static WindowFrame Make(RectTransform panel, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax, Vector2Int dir, int cursor)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = PatchUi.Box((Transform)(object)panel, name, new Color(1f, 1f, 1f, 0.001f));
obj.anchorMin = anchorMin;
obj.anchorMax = anchorMax;
obj.offsetMin = offsetMin;
obj.offsetMax = offsetMax;
WindowFrame windowFrame = ((Component)obj).gameObject.AddComponent<WindowFrame>();
windowFrame._panel = panel;
windowFrame._dir = dir;
windowFrame._cursor = cursor;
return windowFrame;
}
public static void AddMove(RectTransform panel)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_0033: 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)
Make(panel, "TitleBar", new Vector2(0f, 1f), Vector2.one, new Vector2(8f, -72f), new Vector2(-8f, -8f), Vector2Int.zero, 32646);
}
public static void AddResize(RectTransform panel)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
Make(panel, "Left", Vector2.zero, new Vector2(0f, 1f), new Vector2(0f, 22f), new Vector2(8f, -22f), new Vector2Int(-1, 0), 32644);
Make(panel, "Right", new Vector2(1f, 0f), Vector2.one, new Vector2(-8f, 22f), new Vector2(0f, -22f), new Vector2Int(1, 0), 32644);
Make(panel, "Top", new Vector2(0f, 1f), Vector2.one, new Vector2(22f, -8f), new Vector2(-22f, 0f), new Vector2Int(0, -1), 32645);
Make(panel, "Bottom", Vector2.zero, new Vector2(1f, 0f), new Vector2(22f, 0f), new Vector2(-22f, 8f), new Vector2Int(0, 1), 32645);
Make(panel, "TopLeft", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, -22f), new Vector2(22f, 0f), new Vector2Int(-1, -1), 32642);
Make(panel, "TopRight", Vector2.one, Vector2.one, new Vector2(-22f, -22f), Vector2.zero, new Vector2Int(1, -1), 32643);
Make(panel, "BottomLeft", Vector2.zero, Vector2.zero, Vector2.zero, new Vector2(22f, 22f), new Vector2Int(-1, 1), 32643);
WindowFrame windowFrame = Make(panel, "BottomRight", new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-22f, 0f), new Vector2(0f, 22f), new Vector2Int(1, 1), 32642);
Vector2 val = default(Vector2);
for (int i = 0; i < 3; i++)
{
RectTransform obj = PatchUi.Box(((Component)windowFrame).transform, "Line", new Color(1f, 1f, 1f, 0.35f));
float num = 5f + 5f * (float)i;
((Vector2)(ref val))..ctor(1f, 0f);
obj.anchorMax = val;
obj.anchorMin = val;
obj.sizeDelta = new Vector2(num * 1.414f, 2f);
obj.anchoredPosition = new Vector2(-4f - num / 2f, 4f + num / 2f);
((Transform)obj).localRotation = Quaternion.Euler(0f, 0f, 45f);
((Graphic)((Component)obj).GetComponent<Image>()).raycastTarget = false;
}
}
public void OnPointerEnter(PointerEventData e)
{
_hover = true;
}
public void OnPointerExit(PointerEventData e)
{
_hover = false;
}
public void OnBeginDrag(PointerEventData e)
{
_dragging = true;
}
private void LateUpdate()
{
if (_hover || _dragging)
{
if (_handle == IntPtr.Zero)
{
_handle = LoadCursor(IntPtr.Zero, _cursor);
}
SetCursor(_handle);
}
}
public void OnDrag(PointerEventData e)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
Canvas componentInParent = ((Component)_panel).GetComponentInParent<Canvas>();
Vector2 val = e.delta / (((Object)(object)componentInParent != (Object)null) ? componentInParent.scaleFactor : 1f);
if (_dir == Vector2Int.zero)
{
RectTransform panel = _panel;
panel.anchoredPosition += val;
}
else
{
Vector2 sizeDelta = _panel.sizeDelta;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor((((Vector2Int)(ref _dir)).x == 0) ? sizeDelta.x : Mathf.Clamp(sizeDelta.x + (float)((Vector2Int)(ref _dir)).x * val.x, 900f, 1900f), (((Vector2Int)(ref _dir)).y == 0) ? sizeDelta.y : Mathf.Clamp(sizeDelta.y - (float)((Vector2Int)(ref _dir)).y * val.y, 560f, 1060f));
Vector2 val3 = val2 - sizeDelta;
_panel.sizeDelta = val2;
RectTransform panel2 = _panel;
panel2.anchoredPosition += new Vector2((float)((Vector2Int)(ref _dir)).x * val3.x / 2f, (float)(-((Vector2Int)(ref _dir)).y) * val3.y / 2f);
}
Rect rect = ((RectTransform)((Component)componentInParent).transform).rect;
Vector2 val4 = ((Rect)(ref rect)).size / 2f;
Vector2 anchoredPosition = _panel.anchoredPosition;
_panel.anchoredPosition = new Vector2(Mathf.Clamp(anchoredPosition.x, 0f - val4.x, val4.x), Mathf.Clamp(anchoredPosition.y, 0f - val4.y - _panel.sizeDelta.y / 2f + 80f, val4.y - _panel.sizeDelta.y / 2f));
}
public void OnEndDrag(PointerEventData e)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
_dragging = false;
PlayerPrefs.SetFloat("medovanx.patches.window.w", _panel.sizeDelta.x);
PlayerPrefs.SetFloat("medovanx.patches.window.h", _panel.sizeDelta.y);
PlayerPrefs.SetFloat("medovanx.patches.window.x", _panel.anchoredPosition.x);
PlayerPrefs.SetFloat("medovanx.patches.window.y", _panel.anchoredPosition.y);
PlayerPrefs.Save();
}
}
internal static class PatchUi
{
public static readonly Color Text = new Color(0.9f, 0.92f, 0.88f, 1f);
public static readonly Color Dim = new Color(0.65f, 0.67f, 0.63f, 1f);
public static readonly Color Off = new Color(1f, 1f, 1f, 0.08f);
public static readonly Color On = new Color(0.85f, 0.55f, 0.1f, 0.95f);
public static readonly Color Accent = new Color(0.85f, 0.45f, 0.05f, 1f);
public static readonly List<Action> Refreshers = new List<Action>();
public static void RefreshAll()
{
foreach (Action refresher in Refreshers)
{
refresher();
}
}
public static TMP_Text Label(Transform parent, TMP_FontAsset font, string text, float size = 22f, Color? color = null, float height = 0f)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI val = new GameObject("Label", new Type[1] { typeof(RectTransform) }).AddComponent<TextMeshProUGUI>();
((TMP_Text)val).transform.SetParent(parent, false);
if ((Object)(object)font != (Object)null)
{
((TMP_Text)val).font = font;
}
((TMP_Text)val).fontSize = size;
((Graphic)val).color = (Color)(((??)color) ?? Text);
((TMP_Text)val).text = text;
((Graphic)val).raycastTarget = false;
((TMP_Text)val).enableWordWrapping = true;
LayoutElement val2 = ((Component)val).gameObject.AddComponent<LayoutElement>();
if (height > 0f)
{
val2.preferredHeight = height;
}
return (TMP_Text)(object)val;
}
public static RectTransform Box(Transform parent, string name, Color color)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = new GameObject(name, new Type[2]
{
typeof(RectTransform),
typeof(Image)
}).GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
((Graphic)((Component)component).GetComponent<Image>()).color = color;
return component;
}
public static void Stretch(RectTransform rt)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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)
//IL_001e: 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)
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.one;
Vector2 offsetMin = (rt.offsetMax = Vector2.zero);
rt.offsetMin = offsetMin;
}
public static Button Button(Transform parent, TMP_FontAsset font, string label, Action onClick, float width = 160f, float height = 44f)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
RectTransform val = Box(parent, label, Off);
LayoutElement obj = ((Component)val).gameObject.AddComponent<LayoutElement>();
obj.preferredWidth = width;
obj.preferredHeight = height;
Button obj2 = ((Component)val).gameObject.AddComponent<Button>();
((Selectable)obj2).targetGraphic = (Graphic)(object)((Component)val).GetComponent<Image>();
((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
{
onClick();
RefreshAll();
});
TMP_Text obj3 = Label((Transform)(object)val, font, label, 20f);
obj3.alignment = (TextAlignmentOptions)514;
Stretch(obj3.rectTransform);
Object.Destroy((Object)(object)((Component)obj3).GetComponent<LayoutElement>());
return obj2;
}
public static RectTransform Row(Transform parent, float height = 48f)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = new GameObject("Row", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
HorizontalLayoutGroup obj = ((Component)component).gameObject.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
((LayoutGroup)obj).childAlignment = (TextAnchor)3;
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = childControlWidth;
childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false);
((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = childControlWidth;
((Component)component).gameObject.AddComponent<LayoutElement>().preferredHeight = height;
return component;
}
public static void Options(Transform parent, TMP_FontAsset font, string title, params (string label, Func<bool> selected, Action select)[] options)
{
Options(parent, font, title, 160f, options);
}
public static void Options(Transform parent, TMP_FontAsset font, string title, float width, params (string label, Func<bool> selected, Action select)[] options)
{
RectTransform parent2 = Row(parent);
((Component)Label((Transform)(object)parent2, font, title)).GetComponent<LayoutElement>().preferredWidth = 190f;
for (int i = 0; i < options.Length; i++)
{
(string, Func<bool>, Action) tuple = options[i];
string item = tuple.Item1;
Func<bool> selected = tuple.Item2;
Action item2 = tuple.Item3;
Image img = ((Component)Button((Transform)(object)parent2, font, item, item2, width)).GetComponent<Image>();
Refreshers.Add(delegate
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
((Graphic)img).color = (selected() ? On : Off);
});
}
}
public static void OnOff(Transform parent, TMP_FontAsset font, string title, Func<bool> get, Action<bool> set)
{
Options(parent, font, title, ("On", get, delegate
{
set(obj: true);
}), ("Off", () => !get(), delegate
{
set(obj: false);
}));
}
public static void Number(Transform parent, TMP_FontAsset font, string title, Func<int> get, Action<int> set, int fallback)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
RectTransform parent2 = Row(parent);
((Component)Label((Transform)(object)parent2, font, title)).GetComponent<LayoutElement>().preferredWidth = 190f;
RectTransform val = Box((Transform)(object)parent2, "Field", new Color(1f, 1f, 1f, 0.08f));
LayoutElement obj = ((Component)val).gameObject.AddComponent<LayoutElement>();
obj.preferredWidth = 200f;
obj.preferredHeight = 44f;
RectTransform component = new GameObject("Text Area", new Type[2]
{
typeof(RectTransform),
typeof(RectMask2D)
}).GetComponent<RectTransform>();
((Transform)component).SetParent((Transform)(object)val, false);
Stretch(component);
component.offsetMin = new Vector2(12f, 4f);
component.offsetMax = new Vector2(-12f, -4f);
TextMeshProUGUI val2 = new GameObject("Text", new Type[1] { typeof(RectTransform) }).AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).transform.SetParent((Transform)(object)component, false);
Stretch(((TMP_Text)val2).rectTransform);
if ((Object)(object)font != (Object)null)
{
((TMP_Text)val2).font = font;
}
((TMP_Text)val2).fontSize = 22f;
((Graphic)val2).color = Text;
((TMP_Text)val2).alignment = (TextAlignmentOptions)4097;
TMP_InputField input = ((Component)val).gameObject.AddComponent<TMP_InputField>();
input.textViewport = component;
input.textComponent = (TMP_Text)(object)val2;
input.contentType = (ContentType)2;
input.characterLimit = 7;
input.SetTextWithoutNotify(get().ToString());
((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string s)
{
set((int.TryParse(s, out var result) && result >= 0) ? result : fallback);
RefreshAll();
});
Refreshers.Add(delegate
{
if (!input.isFocused)
{
input.SetTextWithoutNotify(get().ToString());
}
});
}
public static void Section(Transform parent, TMP_FontAsset font, string title)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = new GameObject("Section", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
VerticalLayoutGroup obj = ((Component)component).gameObject.AddComponent<VerticalLayoutGroup>();
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)obj).spacing = 4f;
((LayoutGroup)obj).padding = new RectOffset(0, 0, 10, 2);
Label((Transform)(object)component, font, title.ToUpperInvariant(), 17f, Accent, 24f).characterSpacing = 6f;
((Component)Box((Transform)(object)component, "Line", new Color(1f, 1f, 1f, 0.12f))).gameObject.AddComponent<LayoutElement>().preferredHeight = 1f;
}
public static Slider Slider(Transform parent, TMP_FontAsset font, string title, int min, int max, Func<int> get, Action<int> set, string suffix = "", string description = null)
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = Row(parent, (description == null) ? 48f : 58f);
if (description == null)
{
((Component)Label((Transform)(object)val, font, title)).GetComponent<LayoutElement>().preferredWidth = 190f;
}
else
{
RectTransform component = new GameObject("Title", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component).SetParent((Transform)(object)val, false);
VerticalLayoutGroup obj = ((Component)component).gameObject.AddComponent<VerticalLayoutGroup>();
bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true);
((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = childControlWidth;
((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
((LayoutGroup)obj).childAlignment = (TextAnchor)3;
((HorizontalOrVerticalLayoutGroup)obj).spacing = 0f;
((Component)component).gameObject.AddComponent<LayoutElement>().preferredWidth = 190f;
Label((Transform)(object)component, font, title, 22f, null, 28f);
Label((Transform)(object)component, font, description, 15f, Dim, 20f);
}
RectTransform component2 = new GameObject("Slider", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component2).SetParent((Transform)(object)val, false);
LayoutElement obj2 = ((Component)component2).gameObject.AddComponent<LayoutElement>();
obj2.preferredWidth = 360f;
obj2.preferredHeight = 28f;
RectTransform obj3 = Box((Transform)(object)component2, "Track", Off);
obj3.anchorMin = new Vector2(0f, 0.5f);
obj3.anchorMax = new Vector2(1f, 0.5f);
obj3.sizeDelta = new Vector2(0f, 8f);
RectTransform component3 = new GameObject("Fill Area", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component3).SetParent((Transform)(object)component2, false);
component3.anchorMin = new Vector2(0f, 0.5f);
component3.anchorMax = new Vector2(1f, 0.5f);
component3.sizeDelta = new Vector2(0f, 8f);
RectTransform val2 = Box((Transform)(object)component3, "Fill", On);
val2.sizeDelta = Vector2.zero;
RectTransform component4 = new GameObject("Handle Area", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
((Transform)component4).SetParent((Transform)(object)component2, false);
Stretch(component4);
component4.offsetMin = new Vector2(8f, 0f);
component4.offsetMax = new Vector2(-8f, 0f);
RectTransform val3 = Box((Transform)(object)component4, "Handle", Text);
val3.sizeDelta = new Vector2(16f, 0f);
Slider slider = ((Component)component2).gameObject.AddComponent<Slider>();
slider.fillRect = val2;
slider.handleRect = val3;
((Selectable)slider).targetGraphic = (Graphic)(object)((Component)val3).GetComponent<Image>();
slider.direction = (Direction)0;
slider.minValue = min;
slider.maxValue = max;
slider.wholeNumbers = true;
slider.SetValueWithoutNotify((float)get());
TMP_Text value = Label((Transform)(object)val, font, get() + suffix);
((Component)value).GetComponent<LayoutElement>().preferredWidth = 80f;
((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)delegate(float v)
{
set((int)v);
RefreshAll();
});
Refreshers.Add(delegate
{
slider.SetValueWithoutNotify((float)get());
value.text = get() + suffix;
});
return slider;
}
}
public sealed class MelonEntry : MelonMod
{
private static Action _init;
public override void OnInitializeMelon()
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
MethodInfo methodInfo = typeof(MelonEntry).Assembly.GetType(((MelonBase)this).Info.Name + ".Plugin")?.GetMethod("Init", Type.EmptyTypes);
if (methodInfo == null)
{
((MelonBase)this).LoggerInstance.Error(((MelonBase)this).Info.Name + ".Plugin.Init not found");
return;
}
_init = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo);
((MelonBase)this).HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(Hub), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MelonEntry), "HubAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((MelonBase)this).LoggerInstance.Msg(((MelonBase)this).Info.Name + " " + ((MelonBase)this).Info.Version + " loaded; starts with the game");
}
private static void HubAwake()
{
_init?.Invoke();
}
}
}
namespace Fov
{
public static class Plugin
{
private static bool _initialized;
public static int Value
{
get
{
return PlayerPrefs.GetInt("medovanx.Fov.Value", 0);
}
set
{
PlayerPrefs.SetInt("medovanx.Fov.Value", value);
PlayerPrefs.Save();
}
}
public static void Init()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
if (_initialized)
{
return;
}
_initialized = true;
Version version = typeof(Plugin).Assembly.GetName().Version;
try
{
GameObject val = new GameObject("MedovanxFov");
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<FovApplier>();
PatchMenu.Register("Fov", version, () => (Value > 0) ? $"Field of view {Value}°" : $"Game default ({FovApplier.DefaultFov:0}°)", delegate(RectTransform page, TMP_FontAsset font)
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
PatchUi.Slider((Transform)(object)page, font, "Field of view", 50, 120, () => (Value <= 0) ? Mathf.RoundToInt(FovApplier.DefaultFov) : Value, delegate(int v)
{
Value = v;
}, "°");
PatchUi.Options((Transform)(object)page, font, "", ("Reset to default", () => Value == 0, delegate
{
Value = 0;
}));
PatchUi.Label((Transform)(object)page, font, "Applies right away. In game, tap [ / ] for 5° steps or hold them to change it quickly. Only you need this patch.", 20f, PatchUi.Dim);
});
Debug.Log((object)$"[Fov] v{version.ToString(3)}: loaded (fov {((Value > 0) ? Value.ToString() : "default")})");
}
catch (Exception ex)
{
Debug.LogError((object)("[Fov] Failed to start: " + ex));
}
}
}
internal sealed class FovApplier : MonoBehaviour
{
public static float DefaultFov = 60f;
private static bool _haveDefault;
public const int Step = 5;
public const int Min = 50;
public const int Max = 120;
private TMP_Text _toast;
private float _toastUntil;
private const float RepeatDelay = 0.35f;
private const float RepeatSpeed = 40f;
private float _held;
private float _exact;
private void Update()
{
Keyboard current = Keyboard.current;
CameraManager val = (((Object)(object)Hub.s != (Object)null) ? Hub.s.cameraman : null);
if (current == null || (Object)(object)val == (Object)null || (Object)(object)val.playerCamera == (Object)null || ((Object)(object)Hub.s.uiman != (Object)null && Hub.s.uiman.isGameMenuOpen))
{
return;
}
int num = (((ButtonControl)current.rightBracketKey).isPressed ? 1 : (((ButtonControl)current.leftBracketKey).isPressed ? (-1) : 0));
if (num == 0)
{
_held = 0f;
return;
}
int num2 = ((Plugin.Value > 0) ? Plugin.Value : Mathf.RoundToInt(DefaultFov));
if (((ButtonControl)current.rightBracketKey).wasPressedThisFrame || ((ButtonControl)current.leftBracketKey).wasPressedThisFrame)
{
_held = 0f;
_exact = Mathf.Clamp(num2 + num * 5, 50, 120);
}
else
{
_held += Time.unscaledDeltaTime;
if (_held < 0.35f)
{
return;
}
_exact = Mathf.Clamp(_exact + (float)num * 40f * Time.unscaledDeltaTime, 50f, 120f);
}
int num3 = Mathf.RoundToInt(_exact);
if (num3 != num2)
{
Plugin.Value = num3;
Toast($"FOV {num3}°");
}
}
private void Toast(string text)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_toast == (Object)null)
{
Canvas component = new GameObject("FovToast", new Type[2]
{
typeof(Canvas),
typeof(CanvasScaler)
}).GetComponent<Canvas>();
((Component)component).transform.SetParent(((Component)this).transform, false);
component.renderMode = (RenderMode)0;
component.sortingOrder = 120;
CanvasScaler component2 = ((Component)component).GetComponent<CanvasScaler>();
component2.uiScaleMode = (ScaleMode)1;
component2.referenceResolution = new Vector2(1920f, 1080f);
_toast = (TMP_Text)(object)new GameObject("Text", new Type[1] { typeof(RectTransform) }).AddComponent<TextMeshProUGUI>();
_toast.transform.SetParent(((Component)component).transform, false);
RectTransform rectTransform = _toast.rectTransform;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0.5f, 0.75f);
rectTransform.anchorMax = val;
rectTransform.anchorMin = val;
rectTransform.sizeDelta = new Vector2(400f, 60f);
TMP_Text obj = Object.FindAnyObjectByType<TMP_Text>();
TMP_FontAsset val2 = ((obj != null) ? obj.font : null);
if ((Object)(object)val2 != (Object)null)
{
_toast.font = val2;
}
_toast.fontSize = 34f;
_toast.alignment = (TextAlignmentOptions)514;
((Graphic)_toast).color = new Color(0.95f, 0.95f, 0.9f, 1f);
((Graphic)_toast).raycastTarget = false;
}
_toast.text = text;
((Component)_toast).gameObject.SetActive(true);
_toastUntil = Time.unscaledTime + 1.5f;
}
private void LateUpdate()
{
if ((Object)(object)_toast != (Object)null && ((Component)_toast).gameObject.activeSelf && Time.unscaledTime > _toastUntil)
{
((Component)_toast).gameObject.SetActive(false);
}
CameraManager val = (((Object)(object)Hub.s != (Object)null) ? Hub.s.cameraman : null);
CinemachineCamera val2 = (((Object)(object)val != (Object)null) ? val.playerCamera : null);
if (!((Object)(object)val2 == (Object)null) && !val.IsZoomToTargetActive)
{
if (!_haveDefault)
{
DefaultFov = val2.Lens.FieldOfView;
_haveDefault = true;
}
float num = ((Plugin.Value > 0) ? ((float)Plugin.Value) : DefaultFov);
if (!Mathf.Approximately(val2.Lens.FieldOfView, num))
{
val2.Lens.FieldOfView = num;
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}