using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ModSettingsMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0.8+92aba11ef7820248d19a212c9e7b451d42228e22")]
[assembly: AssemblyProduct("ModSettingsMenu")]
[assembly: AssemblyTitle("ModSettingsMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class ModConfigGUI : MonoBehaviour
{
private static GameObject _modWindow;
private static GameObject _scrollView;
private static GameObject _content;
private static VerticalLayoutGroup _layoutGroup;
private static bool _visible = false;
public static InputField KeyBindInput;
private static Dictionary<string, Dictionary<string, string[]>> _cachedOptions = new Dictionary<string, Dictionary<string, string[]>>();
public static void Toggle()
{
if ((Object)(object)_modWindow == (Object)null)
{
try
{
CreateGUI();
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error creating GUI: " + ex.Message));
return;
}
}
_visible = !_visible;
_modWindow.SetActive(_visible);
if (_visible)
{
RefreshMods();
}
EventSystem.current.SetSelectedGameObject((GameObject)null);
}
private static void CreateGUI()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Expected O, but got Unknown
//IL_015b: 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_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Expected O, but got Unknown
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: 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_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_0390: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: 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_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_0439: Expected O, but got Unknown
//IL_0439: Unknown result type (might be due to invalid IL or missing references)
//IL_0450: Expected O, but got Unknown
GameObject val = new GameObject("ModConfigCanvas", new Type[3]
{
typeof(Canvas),
typeof(CanvasScaler),
typeof(GraphicRaycaster)
});
val.transform.SetParent((Transform)null, false);
Canvas component = val.GetComponent<Canvas>();
if (!((Object)(object)component == (Object)null))
{
component.renderMode = (RenderMode)0;
component.sortingOrder = 100;
}
GameObject val2 = new GameObject("ModConfigPanel", new Type[1] { typeof(Image) });
val2.transform.SetParent(val.transform, false);
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0.5f, 0.5f);
component2.anchorMax = new Vector2(0.5f, 0.5f);
component2.pivot = new Vector2(0.5f, 0.5f);
component2.sizeDelta = new Vector2(800f, 600f);
((Graphic)val2.GetComponent<Image>()).color = new Color(0.15f, 0.15f, 0.2f, 0.95f);
GameObject val3 = new GameObject("Title", new Type[1] { typeof(Image) });
val3.transform.SetParent(val2.transform, false);
((Graphic)val3.GetComponent<Image>()).color = new Color(0.4f, 0.4f, 0.5f, 1f);
RectTransform component3 = val3.GetComponent<RectTransform>();
component3.anchorMin = new Vector2(0f, 1f);
component3.anchorMax = new Vector2(1f, 1f);
component3.offsetMin = new Vector2(10f, -50f);
component3.offsetMax = new Vector2(-10f, -10f);
GameObject val4 = new GameObject("TitleText", new Type[1] { typeof(Text) });
val4.transform.SetParent(val3.transform, false);
RectTransform component4 = val4.GetComponent<RectTransform>();
component4.anchorMin = Vector2.zero;
component4.anchorMax = Vector2.one;
component4.offsetMin = Vector2.zero;
component4.offsetMax = Vector2.zero;
Text component5 = val4.GetComponent<Text>();
component5.text = "Mod Configurations";
component5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
component5.fontSize = 26;
((Graphic)component5).color = new Color(1f, 1f, 1f, 1f);
component5.alignment = (TextAnchor)4;
GameObject val5 = new GameObject("ScrollView", new Type[3]
{
typeof(ScrollRect),
typeof(Image),
typeof(Mask)
});
val5.transform.SetParent(val2.transform, false);
val5.GetComponent<Mask>().showMaskGraphic = false;
RectTransform component6 = val5.GetComponent<RectTransform>();
component6.anchorMin = new Vector2(0f, 0f);
component6.anchorMax = new Vector2(1f, 1f);
component6.offsetMin = new Vector2(20f, 20f);
component6.offsetMax = new Vector2(-20f, -60f);
((Graphic)val5.GetComponent<Image>()).color = new Color(0.1f, 0.1f, 0.15f, 0.8f);
ScrollRect component7 = val5.GetComponent<ScrollRect>();
GameObject val6 = new GameObject("Content", new Type[1] { typeof(VerticalLayoutGroup) });
val6.transform.SetParent(val5.transform, false);
RectTransform component8 = val6.GetComponent<RectTransform>();
component8.anchorMin = new Vector2(0f, 1f);
component8.anchorMax = new Vector2(1f, 1f);
component8.pivot = new Vector2(0f, 1f);
component8.sizeDelta = new Vector2(0f, 0f);
component7.content = component8;
component7.vertical = true;
component7.horizontal = false;
component7.scrollSensitivity = 0.1f;
VerticalLayoutGroup component9 = val6.GetComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)component9).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)component9).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)component9).spacing = 15f;
((LayoutGroup)component9).padding = new RectOffset(20, 20, 15, 20);
val6.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
_modWindow = val2;
_content = val6;
_layoutGroup = component9;
}
public static void RefreshMods()
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_0106: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
foreach (Transform item in _content.transform)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
foreach (Transform item2 in _modWindow.transform.parent)
{
Transform val = item2;
if (((Object)val).name == "List")
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
try
{
IReadOnlyList<ModInfo> mods = ModManager.Mods;
if (mods == null)
{
return;
}
foreach (ModInfo item3 in mods)
{
ModInfo current = item3;
try
{
CreateModConfig(current, _content.transform);
GameObject val2 = new GameObject("Separator", new Type[1] { typeof(Image) });
val2.transform.SetParent(_content.transform, false);
((Graphic)val2.GetComponent<Image>()).color = new Color(0.5f, 0.5f, 0.6f, 0.5f);
LayoutElement obj = val2.AddComponent<LayoutElement>();
obj.preferredWidth = 760f;
obj.preferredHeight = 3f;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error creating config for mod " + ((ModInfo)(ref current)).Name + ": " + ex.Message));
}
}
}
catch (Exception ex2)
{
SparrohPlugin.Logger.LogError((object)("Error refreshing mods list: " + ex2.Message));
}
}
private static Dictionary<string, List<(string entry, string[] options)>> ParseModConfig(string configPath)
{
try
{
Dictionary<string, List<(string, string[])>> dictionary = new Dictionary<string, List<(string, string[])>>();
string key = "";
List<string> list = new List<string>();
foreach (string item2 in File.ReadLines(configPath))
{
if (string.IsNullOrWhiteSpace(item2))
{
continue;
}
if (item2.StartsWith("#"))
{
list.Add(item2.TrimStart(new char[1] { '#' }).Trim());
}
else if (item2.StartsWith("[") && item2.EndsWith("]"))
{
key = item2.Trim();
if (!dictionary.ContainsKey(key))
{
dictionary[key] = new List<(string, string[])>();
}
list.Clear();
}
else
{
if (!item2.Contains("="))
{
continue;
}
if (!dictionary.ContainsKey(key))
{
dictionary[key] = new List<(string, string[])>();
}
string[] item = null;
foreach (string item3 in list)
{
if (item3.StartsWith("Acceptable values:"))
{
item = (from s in item3.Substring("Acceptable values:".Length).Split(new char[1] { ',' })
select s.Trim()).ToArray();
break;
}
}
dictionary[key].Add((item2.Trim(), item));
list.Clear();
}
}
return dictionary;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error parsing config file '" + configPath + "': " + ex.Message));
return new Dictionary<string, List<(string, string[])>>();
}
}
private static void CreateModConfig(ModInfo mod, Transform parent)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Expected O, but got Unknown
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Expected O, but got Unknown
//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_041f: Unknown result type (might be due to invalid IL or missing references)
//IL_0426: Unknown result type (might be due to invalid IL or missing references)
//IL_0431: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_0446: Unknown result type (might be due to invalid IL or missing references)
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Unknown result type (might be due to invalid IL or missing references)
//IL_0639: Expected O, but got Unknown
//IL_0662: Unknown result type (might be due to invalid IL or missing references)
//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0704: Unknown result type (might be due to invalid IL or missing references)
//IL_0718: Unknown result type (might be due to invalid IL or missing references)
//IL_073c: Unknown result type (might be due to invalid IL or missing references)
//IL_0746: Expected O, but got Unknown
//IL_0776: Unknown result type (might be due to invalid IL or missing references)
//IL_078b: Unknown result type (might be due to invalid IL or missing references)
//IL_079f: Unknown result type (might be due to invalid IL or missing references)
//IL_07ef: Unknown result type (might be due to invalid IL or missing references)
//IL_083c: Unknown result type (might be due to invalid IL or missing references)
//IL_0843: Expected O, but got Unknown
//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
//IL_09f2: Unknown result type (might be due to invalid IL or missing references)
//IL_09f9: Expected O, but got Unknown
//IL_0a1f: Unknown result type (might be due to invalid IL or missing references)
//IL_0a2a: Unknown result type (might be due to invalid IL or missing references)
//IL_0a35: Unknown result type (might be due to invalid IL or missing references)
//IL_0a3f: Unknown result type (might be due to invalid IL or missing references)
//IL_0a82: Unknown result type (might be due to invalid IL or missing references)
//IL_0ac1: Unknown result type (might be due to invalid IL or missing references)
//IL_0acb: Expected O, but got Unknown
//IL_0b10: Unknown result type (might be due to invalid IL or missing references)
//IL_0b2b: Unknown result type (might be due to invalid IL or missing references)
//IL_0b46: Unknown result type (might be due to invalid IL or missing references)
//IL_0b6e: Unknown result type (might be due to invalid IL or missing references)
//IL_0b89: Unknown result type (might be due to invalid IL or missing references)
//IL_0bb3: Unknown result type (might be due to invalid IL or missing references)
//IL_0f2b: Unknown result type (might be due to invalid IL or missing references)
//IL_0f4d: Unknown result type (might be due to invalid IL or missing references)
//IL_0f54: Expected O, but got Unknown
//IL_0f7f: Unknown result type (might be due to invalid IL or missing references)
//IL_0f94: Unknown result type (might be due to invalid IL or missing references)
//IL_0f9f: Unknown result type (might be due to invalid IL or missing references)
//IL_0fb4: Unknown result type (might be due to invalid IL or missing references)
//IL_0fc8: Unknown result type (might be due to invalid IL or missing references)
//IL_101f: Unknown result type (might be due to invalid IL or missing references)
//IL_0eb5: Unknown result type (might be due to invalid IL or missing references)
//IL_0ebc: Expected O, but got Unknown
//IL_0ebf: Unknown result type (might be due to invalid IL or missing references)
//IL_0c4c: Unknown result type (might be due to invalid IL or missing references)
//IL_0c53: Expected O, but got Unknown
//IL_0c83: Unknown result type (might be due to invalid IL or missing references)
//IL_0c98: Unknown result type (might be due to invalid IL or missing references)
//IL_0cad: Unknown result type (might be due to invalid IL or missing references)
//IL_0cc2: Unknown result type (might be due to invalid IL or missing references)
//IL_0cd8: Unknown result type (might be due to invalid IL or missing references)
//IL_0d01: Unknown result type (might be due to invalid IL or missing references)
//IL_0d35: Unknown result type (might be due to invalid IL or missing references)
//IL_0d3a: Unknown result type (might be due to invalid IL or missing references)
//IL_0d4d: Unknown result type (might be due to invalid IL or missing references)
//IL_0d5e: Unknown result type (might be due to invalid IL or missing references)
//IL_0d73: Unknown result type (might be due to invalid IL or missing references)
//IL_0d88: Unknown result type (might be due to invalid IL or missing references)
//IL_0d9c: Unknown result type (might be due to invalid IL or missing references)
//IL_0dc4: Unknown result type (might be due to invalid IL or missing references)
//IL_0df4: Unknown result type (might be due to invalid IL or missing references)
//IL_0dfe: Expected O, but got Unknown
//IL_0e28: Unknown result type (might be due to invalid IL or missing references)
//IL_0e32: Expected O, but got Unknown
//IL_08cb: Unknown result type (might be due to invalid IL or missing references)
//IL_08c4: Unknown result type (might be due to invalid IL or missing references)
//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
//IL_08f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0900: Unknown result type (might be due to invalid IL or missing references)
//IL_090a: Unknown result type (might be due to invalid IL or missing references)
//IL_0956: Unknown result type (might be due to invalid IL or missing references)
try
{
ModInfo val2 = mod;
GameObject val3 = new GameObject(((ModInfo)(ref val2)).Name + " Title", new Type[1] { typeof(Image) });
val3.transform.SetParent(parent, false);
((Graphic)val3.GetComponent<Image>()).color = new Color(0.6f, 0.6f, 0.7f, 1f);
LayoutElement obj = val3.AddComponent<LayoutElement>();
obj.preferredWidth = 760f;
obj.minHeight = 40f;
GameObject val4 = new GameObject("Text", new Type[1] { typeof(Text) });
val4.transform.SetParent(val3.transform, false);
RectTransform component = val4.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
Text component2 = val4.GetComponent<Text>();
component2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
component2.text = "<b>" + ((ModInfo)(ref val2)).Name + "</b>";
if (((ModInfo)(ref val2)).IsSandbox)
{
component2.text += " <size=50%>[<i><color=#FF0000>Sandbox</color></i>]</size>";
}
component2.fontSize = 22;
((Graphic)component2).color = new Color(0.1f, 0.1f, 0.1f, 1f);
component2.alignment = (TextAnchor)4;
string[] files = Directory.GetFiles(Paths.ConfigPath, "*.cfg");
string text = null;
string[] array = files;
int i;
for (i = 0; i < array.Length; i++)
{
string text2 = array[i];
if (Path.GetFileNameWithoutExtension(text2).ToLower().Contains(((ModInfo)(ref val2)).Name.ToLower()))
{
text = text2;
break;
}
}
if (text == null || !File.Exists(text))
{
GameObject val5 = new GameObject("NoConfig", new Type[1] { typeof(Text) });
val5.transform.SetParent(parent, false);
Text component3 = val5.GetComponent<Text>();
component3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
component3.text = "(No config found)";
component3.fontSize = 18;
((Graphic)component3).color = Color.gray;
component3.alignment = (TextAnchor)4;
LayoutElement obj2 = val5.AddComponent<LayoutElement>();
obj2.preferredWidth = 760f;
obj2.preferredHeight = 28f;
return;
}
ConfigFile val6 = new ConfigFile(text, true);
if (!_cachedOptions.ContainsKey(text))
{
Dictionary<string, List<(string entry, string[] options)>> dictionary = ParseModConfig(text);
_cachedOptions[text] = new Dictionary<string, string[]>();
foreach (KeyValuePair<string, List<(string, string[])>> item4 in dictionary)
{
string text3 = item4.Key.Trim('[', ']');
foreach (var item5 in item4.Value)
{
string item = item5.Item1;
string[] item2 = item5.Item2;
string text4 = item.Substring(0, item.IndexOf('=')).Trim();
_cachedOptions[text][text3 + "." + text4] = item2;
}
}
}
foreach (KeyValuePair<string, List<(string, string[])>> section in ParseModConfig(text))
{
GameObject val7 = new GameObject("Section: " + section.Key, new Type[1] { typeof(Image) });
val7.transform.SetParent(parent, false);
((Graphic)val7.GetComponent<Image>()).color = new Color(0.3f, 0.4f, 0.5f, 1f);
val7.GetComponent<RectTransform>().sizeDelta = new Vector2(760f, -1f);
LayoutElement obj3 = val7.AddComponent<LayoutElement>();
obj3.preferredWidth = 760f;
obj3.minHeight = 35f;
GameObject val8 = new GameObject("Text", new Type[1] { typeof(Text) });
val8.transform.SetParent(val7.transform, false);
RectTransform component4 = val8.GetComponent<RectTransform>();
component4.anchorMin = Vector2.zero;
component4.anchorMax = Vector2.one;
component4.offsetMin = Vector2.zero;
component4.offsetMax = Vector2.zero;
Text component5 = val8.GetComponent<Text>();
component5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
component5.text = section.Key;
component5.fontSize = 20;
((Graphic)component5).color = Color.white;
component5.alignment = (TextAnchor)4;
foreach (var item6 in section.Value)
{
string item3 = item6.Item1;
string key = item3.Substring(0, item3.IndexOf('=')).Trim();
string text5 = item3.Substring(item3.IndexOf('=') + 1).Trim();
ConfigEntry<string> configEntry = val6.Bind<string>(section.Key.Trim('[', ']'), key, text5, (ConfigDescription)null);
string[] options = null;
string key2 = section.Key.Trim('[', ']') + "." + key;
if (_cachedOptions.ContainsKey(text) && _cachedOptions[text].ContainsKey(key2))
{
options = _cachedOptions[text][key2];
}
string text6 = configEntry.Value ?? "";
Type typeFromHandle = typeof(string);
float result2;
if (bool.TryParse(text6, out var _))
{
typeFromHandle = typeof(bool);
}
else if (int.TryParse(text6, out i))
{
typeFromHandle = typeof(int);
}
else if (float.TryParse(text6, out result2))
{
typeFromHandle = typeof(float);
}
GameObject val9 = new GameObject("Entry " + key);
val9.transform.SetParent(parent, false);
((Graphic)val9.AddComponent<Image>()).color = new Color(0.2f, 0.2f, 0.25f, 0.8f);
LayoutElement obj4 = val9.AddComponent<LayoutElement>();
obj4.preferredWidth = 760f;
obj4.minHeight = 55f;
GameObject val10 = new GameObject("Label", new Type[1] { typeof(Text) });
val10.transform.SetParent(val9.transform, false);
Text component6 = val10.GetComponent<Text>();
component6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
component6.text = key;
component6.fontSize = 16;
((Graphic)component6).color = Color.white;
component6.alignment = (TextAnchor)4;
RectTransform component7 = val10.GetComponent<RectTransform>();
component7.anchorMin = new Vector2(0f, 0.5f);
component7.anchorMax = new Vector2(0.4f, 0.5f);
GameObject valueObj = new GameObject("Value", new Type[1] { typeof(RectTransform) });
valueObj.transform.SetParent(val9.transform, false);
RectTransform component8 = valueObj.GetComponent<RectTransform>();
component8.anchorMin = new Vector2(0.45f, 0f);
component8.anchorMax = new Vector2(1f, 1f);
component8.sizeDelta = new Vector2(-10f, 0f);
if (typeFromHandle == typeof(bool))
{
valueObj.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
Toggle val11 = valueObj.AddComponent<Toggle>();
val11.isOn = text6.ToLower() == "true";
GameObject val12 = new GameObject("Status", new Type[1] { typeof(Text) });
val12.transform.SetParent(valueObj.transform, false);
Text statusComp = val12.GetComponent<Text>();
statusComp.text = (val11.isOn ? "ON" : "OFF");
statusComp.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
statusComp.fontSize = 16;
((Graphic)statusComp).color = (val11.isOn ? Color.green : Color.red);
statusComp.alignment = (TextAnchor)4;
RectTransform component9 = val12.GetComponent<RectTransform>();
component9.anchorMin = Vector2.zero;
component9.anchorMax = Vector2.one;
component9.offsetMin = Vector2.zero;
component9.offsetMax = Vector2.zero;
((UnityEvent<bool>)(object)val11.onValueChanged).AddListener((UnityAction<bool>)delegate(bool val)
{
//IL_005e: 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)
configEntry.Value = (val ? "True" : "False");
((ConfigEntryBase)configEntry).ConfigFile.Save();
statusComp.text = (val ? "ON" : "OFF");
((Graphic)statusComp).color = (val ? Color.green : Color.red);
});
Image val13 = valueObj.AddComponent<Image>();
((Graphic)val13).color = new Color(0.7f, 0.7f, 0.8f, 0.9f);
((Selectable)val11).targetGraphic = (Graphic)(object)val13;
continue;
}
if (options != null)
{
Button val14 = valueObj.AddComponent<Button>();
((Selectable)val14).targetGraphic = (Graphic)(object)valueObj.AddComponent<Image>();
((Selectable)val14).targetGraphic.color = new Color(0.8f, 0.8f, 0.9f, 0.9f);
GameObject val15 = new GameObject("MainText", new Type[1] { typeof(Text) });
val15.transform.SetParent(valueObj.transform, false);
RectTransform component10 = val15.GetComponent<RectTransform>();
component10.anchorMin = Vector2.zero;
component10.anchorMax = Vector2.one;
component10.offsetMin = Vector2.zero;
component10.offsetMax = Vector2.zero;
Text mainText = val15.GetComponent<Text>();
mainText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
mainText.fontSize = 16;
((Graphic)mainText).color = Color.black;
mainText.alignment = (TextAnchor)4;
mainText.text = text5;
GameObject listObj = new GameObject("List", new Type[1] { typeof(Image) });
listObj.transform.SetParent(_modWindow.transform.parent, false);
RectTransform listRect = listObj.GetComponent<RectTransform>();
listRect.anchorMin = new Vector2(0.5f, 0.5f);
listRect.anchorMax = new Vector2(0.5f, 0.5f);
listRect.pivot = new Vector2(0.5f, 1f);
listRect.sizeDelta = new Vector2(200f, (float)(30 * options.Length));
listRect.anchoredPosition = new Vector2(0f, 0f);
((Graphic)listObj.GetComponent<Image>()).color = new Color(0.9f, 0.9f, 0.95f, 1f);
listObj.AddComponent<Canvas>().sortingOrder = 200;
listObj.AddComponent<GraphicRaycaster>();
listObj.SetActive(false);
for (int j = 0; j < options.Length; j++)
{
string text7 = options[j];
GameObject val16 = new GameObject("Option " + j, new Type[2]
{
typeof(Button),
typeof(Image)
});
val16.transform.SetParent(listObj.transform, false);
RectTransform component11 = val16.GetComponent<RectTransform>();
component11.anchorMin = new Vector2(0f, 1f);
component11.anchorMax = new Vector2(1f, 1f);
component11.pivot = new Vector2(0.5f, 1f);
component11.sizeDelta = new Vector2(0f, 30f);
component11.anchoredPosition = new Vector2(0f, (float)(-j * 30));
Image component12 = val16.GetComponent<Image>();
((Graphic)component12).color = new Color(0.8f, 0.8f, 0.9f, 1f);
Button component13 = val16.GetComponent<Button>();
((Selectable)component13).targetGraphic = (Graphic)(object)component12;
GameObject val17 = new GameObject("Text", new Type[1] { typeof(Text) });
val17.transform.SetParent(val16.transform, false);
RectTransform component14 = val17.GetComponent<RectTransform>();
component14.anchorMin = new Vector2(0f, 0f);
component14.anchorMax = new Vector2(1f, 1f);
component14.offsetMin = new Vector2(20f, 0f);
component14.offsetMax = new Vector2(-4f, 0f);
Text component15 = val17.GetComponent<Text>();
component15.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
component15.fontSize = 14;
((Graphic)component15).color = Color.black;
component15.alignment = (TextAnchor)3;
component15.text = text7;
int index = j;
((UnityEvent)component13.onClick).AddListener((UnityAction)delegate
{
configEntry.Value = options[index];
((ConfigEntryBase)configEntry).ConfigFile.Save();
mainText.text = options[index];
listObj.SetActive(false);
});
}
((UnityEvent)val14.onClick).AddListener((UnityAction)delegate
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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)
if (!listObj.activeSelf)
{
Vector3[] array2 = (Vector3[])(object)new Vector3[4];
valueObj.GetComponent<RectTransform>().GetWorldCorners(array2);
Vector3 val21 = (array2[0] + array2[2]) / 2f;
Vector2 val22 = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(((Component)_modWindow.transform.parent).GetComponent<RectTransform>(), Vector2.op_Implicit(val21), (Camera)null, ref val22);
RectTransform obj6 = listRect;
Vector2 val23 = val22;
Rect rect = valueObj.GetComponent<RectTransform>().rect;
obj6.anchoredPosition = val23 + new Vector2(0f, (0f - ((Rect)(ref rect)).height) / 2f - 5f);
}
listObj.SetActive(!listObj.activeSelf);
});
continue;
}
InputField input = valueObj.AddComponent<InputField>();
input.text = text5;
if (section.Key.Trim('[', ']') == "Keybinds" && key == "ToggleModConfigGUI")
{
EventTrigger obj5 = ((Component)input).gameObject.AddComponent<EventTrigger>();
Entry val18 = new Entry();
val18.eventID = (EventTriggerType)4;
((UnityEvent<BaseEventData>)(object)val18.callback).AddListener((UnityAction<BaseEventData>)delegate
{
if (!SparrohPlugin.IsRebinding)
{
input.text = "Press new key...";
((Selectable)input).interactable = false;
SparrohPlugin.IsRebinding = true;
KeyBindInput = input;
}
});
obj5.triggers.Add(val18);
}
((UnityEvent<string>)(object)input.onValueChanged).AddListener((UnityAction<string>)delegate(string newVal)
{
if (!SparrohPlugin.IsRebinding || section.Key.Trim('[', ']') != "Keybinds" || key != "ToggleModConfigGUI")
{
configEntry.Value = newVal;
((ConfigEntryBase)configEntry).ConfigFile.Save();
}
});
Image val19 = valueObj.AddComponent<Image>();
((Graphic)val19).color = new Color(0.8f, 0.8f, 0.9f, 0.9f);
GameObject val20 = new GameObject("Text", new Type[1] { typeof(Text) });
val20.transform.SetParent(valueObj.transform, false);
RectTransform component16 = val20.GetComponent<RectTransform>();
component16.anchorMin = new Vector2(0.5f, 0.5f);
component16.anchorMax = new Vector2(0.5f, 0.5f);
component16.anchoredPosition = Vector2.zero;
component16.pivot = new Vector2(0.5f, 0.5f);
component16.sizeDelta = new Vector2(300f, 30f);
input.textComponent = val20.GetComponent<Text>();
input.textComponent.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
input.textComponent.fontSize = 16;
((Graphic)input.textComponent).color = Color.black;
input.textComponent.alignment = (TextAnchor)4;
((Selectable)input).targetGraphic = (Graphic)(object)val19;
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error creating mod config for " + ((ModInfo)(ref mod)).Name + ": " + ex.Message));
}
}
}
[MycoMod(/*Could not decode attribute arguments.*/)]
[BepInPlugin("sparroh.modsettingsmenu", "ModSettingsMenu", "1.1.0")]
public class SparrohPlugin : BaseUnityPlugin
{
public const string PLUGINGUID = "sparroh.modsettingsmenu";
public const string PLUGINNAME = "ModSettingsMenu";
public const string PLUGINVERSION = "1.1.0";
public static ManualLogSource Logger;
private ConfigEntry<int> _intEntry;
private ConfigEntry<bool> _boolEntry;
private ConfigEntry<string> _stringEntry;
public static ConfigEntry<string> ToggleKey { get; private set; }
public static bool IsRebinding { get; set; }
private void Awake()
{
//IL_0034: 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)
Logger = ((BaseUnityPlugin)this).Logger;
ToggleKey = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "ToggleModConfigGUI", "F10", "Key to toggle mod config GUI");
Harmony val = new Harmony("sparroh.modsettingsmenu");
val.PatchAll(typeof(SparrohPlugin));
val.PatchAll(typeof(MenuPatches));
((BaseUnityPlugin)this).Config.Save();
Logger.LogInfo((object)"sparroh.modsettingsmenu loaded!");
}
private void Update()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_0036: Unknown result type (might be due to invalid IL or missing references)
if (!IsRebinding)
{
try
{
Key val = (Key)Enum.Parse(typeof(Key), ToggleKey.Value, ignoreCase: true);
if (Keyboard.current != null && (int)val != 0 && ((ButtonControl)Keyboard.current[val]).wasPressedThisFrame)
{
ModConfigGUI.Toggle();
}
}
catch (Exception ex)
{
Logger.LogError((object)("Error parsing toggle key '" + ToggleKey.Value + "': " + ex.Message));
}
}
if (!IsRebinding || Keyboard.current == null)
{
return;
}
Enumerator<KeyControl> enumerator = Keyboard.current.allKeys.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyControl current = enumerator.Current;
if (((ButtonControl)current).wasPressedThisFrame)
{
ToggleKey.Value = ((InputControl)current).name;
((BaseUnityPlugin)this).Config.Save();
IsRebinding = false;
if ((Object)(object)ModConfigGUI.KeyBindInput != (Object)null)
{
ModConfigGUI.KeyBindInput.text = ToggleKey.Value;
((Selectable)ModConfigGUI.KeyBindInput).interactable = true;
}
EventSystem.current.SetSelectedGameObject((GameObject)null);
break;
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
}
private void OnGUI()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
try
{
if (MenuPatches.IsMenuOpen && GUI.Button(new Rect((float)(Screen.width - 280), 10f, 160f, 30f), "Mod Config"))
{
ModConfigGUI.Toggle();
}
}
catch (Exception ex)
{
Logger.LogError((object)("Error in OnGUI: " + ex.Message));
}
}
}
public static class MenuPatches
{
public static bool IsMenuOpen;
[HarmonyPatch(typeof(Menu), "Open")]
public static void Prefix(Menu __instance)
{
IsMenuOpen = true;
}
[HarmonyPatch(typeof(Menu), "Close")]
public static void Prefix()
{
IsMenuOpen = false;
}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
public const string AssemblySemFileVer = "0.0.1.0";
public const string AssemblySemVer = "0.0.1.0";
public const string BranchName = "master";
public const string BuildMetaData = "";
public const string CommitDate = "2025-12-26";
public const string CommitsSinceVersionSource = "9";
public const string EscapedBranchName = "master";
public const string FullBuildMetaData = "Branch.master.Sha.92aba11ef7820248d19a212c9e7b451d42228e22";
public const string FullSemVer = "0.0.1-9";
public const string InformationalVersion = "0.0.1-9+Branch.master.Sha.92aba11ef7820248d19a212c9e7b451d42228e22";
public const string Major = "0";
public const string MajorMinorPatch = "0.0.1";
public const string Minor = "0";
public const string Patch = "1";
public const string PreReleaseLabel = "";
public const string PreReleaseLabelWithDash = "";
public const string PreReleaseNumber = "9";
public const string PreReleaseTag = "9";
public const string PreReleaseTagWithDash = "-9";
public const string SemVer = "0.0.1-9";
public const string Sha = "92aba11ef7820248d19a212c9e7b451d42228e22";
public const string ShortSha = "92aba11";
public const string UncommittedChanges = "13";
public const string VersionSourceSha = "";
public const string WeightedPreReleaseNumber = "55009";
}
namespace ModSettingsMenu
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ModSettingsMenu";
public const string PLUGIN_NAME = "ModSettingsMenu";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}