using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConfigurationManager.Patches.GameSetting;
using ConfigurationManager.Patches.UI;
using ConfigurationManager.UIFactory.CustomBehaviours;
using ConfigurationManager.Utilities;
using HarmonyLib;
using ModdingTales;
using SRF;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyProduct("BepInEx.ConfigurationManager")]
[assembly: AssemblyTitle("BepInEx.ConfigurationManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("https://github.com/BepInEx/BepInEx.ConfigurationManager")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.17.0.0")]
public sealed class ConfigurationManagerAttributes
{
public bool? Browsable;
public Action<object> CallbackAction;
public string Category;
public Func<ConfigEntryBase, GameObject> CustomDrawer;
public object DefaultValue;
public string Description;
public string DispName;
public bool? HideDefaultButton;
public bool? HideSettingName;
public bool? IsAdvanced;
public bool? IsJSON;
public Func<object, string> ObjToStr;
public int? Order;
public bool? ReadOnly;
public bool? ShowRangeAsPercent;
public Func<string, object> StrToObj;
}
namespace ConfigurationManager
{
[BepInPlugin("com.hf.hollofox.configurationmanager", "Config Manager", "0.17.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class ConfigurationManager : BaseUnityPlugin
{
public const string Guid = "com.hf.hollofox.configurationmanager";
public const string Version = "0.17.0.0";
internal static ManualLogSource _logger;
internal static ConfigurationManager _instance;
public ConfigurationManager()
{
_instance = this;
_logger = ((BaseUnityPlugin)this).Logger;
Setup();
}
private void Setup()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
try
{
new Harmony("com.hf.hollofox.configurationmanager").PatchAll();
ModdingUtils.AddPluginToMenuList((BaseUnityPlugin)(object)this, "HolloFoxes'");
SceneManager.sceneLoaded += OnSceneLoaded;
}
catch (Exception ex)
{
_logger.LogError((object)ex);
}
}
public static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
GameSettingsSetupPatch.AlreadyRan = false;
}
}
internal static class SettingSearcher
{
public static void CollectSettings(out IEnumerable<ConfigEntryBase> results, out List<string> modsWithoutSettings, out BaseUnityPlugin[] plugins)
{
modsWithoutSettings = new List<string>();
List<ConfigEntryBase> list = new List<ConfigEntryBase>();
try
{
list.AddRange(GetBepInExCoreConfig());
}
catch (Exception ex)
{
results = Enumerable.Empty<ConfigEntryBase>();
ConfigurationManager._logger.LogError((object)ex);
}
plugins = Utils.FindPlugins();
results = list.AsEnumerable();
}
private static IEnumerable<ConfigEntryBase> GetBepInExCoreConfig()
{
//IL_0031: 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_0064: Expected O, but got Unknown
//IL_0074: Expected O, but got Unknown
PropertyInfo? property = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.NonPublic);
if (property == null)
{
throw new ArgumentNullException("coreConfigProp");
}
ConfigFile val = (ConfigFile)property.GetValue(null, null);
BepInPlugin val2 = new BepInPlugin("BepInEx", "BepInEx", typeof(Chainloader).Assembly.GetName().Version.ToString());
ConfigurationManager._logger.LogInfo((object)val2);
return from c in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)val).ToArray()
select c.Value;
}
internal static IEnumerable<ConfigEntryBase> GetPluginConfig(BaseUnityPlugin plugin)
{
ConfigurationManager._logger.LogInfo((object)plugin);
return from c in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)plugin.Config).ToArray()
select c.Value;
}
}
}
namespace ConfigurationManager.Utilities
{
public static class Utils
{
public static BaseUnityPlugin[] FindPlugins()
{
return Chainloader.Plugins.Concat(Object.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast<BaseUnityPlugin>()).Distinct().ToArray();
}
public static bool IsNumber(this object value)
{
if (!(value is sbyte) && !(value is byte) && !(value is short) && !(value is ushort) && !(value is int) && !(value is uint) && !(value is long) && !(value is ulong) && !(value is float) && !(value is double))
{
return value is decimal;
}
return true;
}
}
}
namespace ConfigurationManager.UIFactory.CustomBehaviours
{
public sealed class ColorBehaviour : MonoBehaviour
{
public Action<object> CallbackAction;
}
public sealed class DropDownBehaviour : MonoBehaviour
{
internal ConfigurationManagerAttributes Attributes;
internal ConfigEntryBase Entry;
private void Awake()
{
try
{
Setup();
}
catch (Exception ex)
{
ConfigurationManager._logger.LogError((object)ex);
}
}
internal void Setup()
{
if (Entry == null)
{
return;
}
SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
((Component)this).gameObject.GetComponent<UI_LabelReference>().SetText(Entry.Definition.Key);
TMP_Dropdown tmp_dropdown = ((Component)this).gameObject.GetComponent<TMP_Dropdown>();
tmp_dropdown.ClearOptions();
Array values = Enum.GetValues(Entry.BoxedValue.GetType());
List<string> list = new List<string>();
foreach (object item in values)
{
list.Add(item.ToString());
}
tmp_dropdown.AddOptions(list);
int value = -1;
for (int j = 0; j < values.Length; j++)
{
if (list[j] == Entry.BoxedValue.ToString())
{
value = j;
}
}
((UnityEventBase)tmp_dropdown.onValueChanged).RemoveAllListeners();
((UnityEvent<int>)(object)tmp_dropdown.onValueChanged).AddListener((UnityAction<int>)delegate(int i)
{
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
Entry.BoxedValue = Enum.Parse(Entry.BoxedValue.GetType(), tmp_dropdown.options[i].text);
Attributes?.CallbackAction?.Invoke(i);
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
});
tmp_dropdown.value = value;
if (Entry.Description.Tags.Length == 0)
{
return;
}
object[] tags = Entry.Description.Tags;
for (int k = 0; k < tags.Length; k++)
{
if (tags[k] is ConfigurationManagerAttributes attributes)
{
Attributes = attributes;
}
}
}
private void RevertToDefault()
{
Entry.BoxedValue = Entry.DefaultValue;
((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.BoxedValue.ToString();
}
}
public sealed class KeybindBehaviour : MonoBehaviour
{
internal ConfigurationManagerAttributes Attributes;
internal ConfigEntryBase Entry;
private void Awake()
{
try
{
Setup();
}
catch (Exception ex)
{
ConfigurationManager._logger.LogError((object)ex);
}
}
internal void Setup()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
SRFGameObjectExtensions.RemoveComponentIfExists<UIKeybinding>(((Component)this).gameObject);
SRFGameObjectExtensions.RemoveComponentIfExists<UIListItemClickEvents>(((Component)((Component)this).gameObject.transform.GetChild(0)).gameObject);
if (Entry == null)
{
return;
}
if (Entry.Description.Tags.Length != 0)
{
object[] tags = Entry.Description.Tags;
for (int i = 0; i < tags.Length; i++)
{
if (tags[i] is ConfigurationManagerAttributes attributes)
{
Attributes = attributes;
}
}
}
((UnityEventBase)((Component)((Component)this).gameObject.transform.GetChild(1)).GetComponent<Button>().onClick).RemoveAllListeners();
((UnityEvent)((Component)((Component)this).gameObject.transform.GetChild(1)).GetComponent<Button>().onClick).AddListener(new UnityAction(RevertToDefault));
((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.BoxedValue.ToString();
((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(2)).GetComponent<TextMeshProUGUI>()).SetText(Entry.Definition.Key, true);
}
private void RevertToDefault()
{
Entry.BoxedValue = Entry.DefaultValue;
((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.BoxedValue.ToString();
}
private void Update()
{
if (((TMP_Text)((Component)((Component)this).gameObject.transform.GetChild(0).GetChild(2)).GetComponent<TextMeshProUGUI>()).text != Entry.Definition.Key)
{
Setup();
}
}
}
public sealed class NumberBehaviour : MonoBehaviour
{
internal ConfigurationManagerAttributes Attributes;
internal ConfigEntryBase Entry;
internal float posy;
private void Awake()
{
try
{
Setup();
}
catch (Exception ex)
{
ConfigurationManager._logger.LogError((object)ex);
}
}
private void Update()
{
//IL_0006: 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)
if (((Component)this).transform.localPosition.y != posy)
{
((Component)this).transform.localPosition = new Vector3(20f, posy);
}
}
internal void Setup()
{
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
SRFGameObjectExtensions.RemoveComponentIfExists<UIKeybinding>(((Component)this).gameObject);
SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
if (Entry == null)
{
return;
}
if (Entry.Description.Tags.Length != 0)
{
object[] tags = Entry.Description.Tags;
for (int i = 0; i < tags.Length; i++)
{
if (tags[i] is ConfigurationManagerAttributes attributes)
{
Attributes = attributes;
}
}
}
((TMP_Text)((Component)((Component)this).transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.Definition.Key;
TextMeshProUGUI value = ((Component)((Component)this).transform.GetChild(1).GetChild(0)).GetComponent<TextMeshProUGUI>();
((TMP_Text)value).text = Entry.BoxedValue.ToString();
Button component = ((Component)((Component)this).transform.GetChild(1).GetChild(1)).GetComponent<Button>();
((UnityEventBase)component.onClick).RemoveAllListeners();
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
SystemMessage.AskForTextInput("Update " + Entry.Definition.Key + " Config", "Enter the desired number", "OK", (Action<string>)delegate(string t)
{
Dictionary<Type, int> obj = new Dictionary<Type, int>
{
{
typeof(sbyte),
0
},
{
typeof(byte),
1
},
{
typeof(short),
2
},
{
typeof(ushort),
3
},
{
typeof(int),
4
},
{
typeof(uint),
5
},
{
typeof(long),
6
},
{
typeof(ulong),
7
},
{
typeof(float),
8
},
{
typeof(double),
9
},
{
typeof(decimal),
10
}
};
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
switch (obj[Entry.BoxedValue.GetType()])
{
case 0:
{
if (sbyte.TryParse(t, out var result6))
{
Entry.BoxedValue = result6;
}
break;
}
case 1:
{
if (byte.TryParse(t, out var result10))
{
Entry.BoxedValue = result10;
}
break;
}
case 2:
{
if (short.TryParse(t, out var result2))
{
Entry.BoxedValue = result2;
}
break;
}
case 3:
{
if (ushort.TryParse(t, out var result8))
{
Entry.BoxedValue = result8;
}
break;
}
case 4:
{
if (int.TryParse(t, out var result4))
{
Entry.BoxedValue = result4;
}
break;
}
case 5:
{
if (uint.TryParse(t, out var result11))
{
Entry.BoxedValue = result11;
}
break;
}
case 6:
{
if (long.TryParse(t, out var result9))
{
Entry.BoxedValue = result9;
}
break;
}
case 7:
{
if (ulong.TryParse(t, out var result7))
{
Entry.BoxedValue = result7;
}
break;
}
case 8:
{
if (float.TryParse(t, out var result5))
{
Entry.BoxedValue = result5;
}
break;
}
case 9:
{
if (double.TryParse(t, out var result3))
{
Entry.BoxedValue = result3;
}
break;
}
case 10:
{
if (decimal.TryParse(t, out var result))
{
Entry.BoxedValue = result;
}
break;
}
}
((TMP_Text)value).text = Entry.BoxedValue.ToString();
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
Attributes?.CallbackAction?.Invoke(Entry.BoxedValue);
}, (Action)null, "Cancel", (Action)null, Entry.BoxedValue.ToString());
});
}
}
public sealed class SliderBehaviour : MonoBehaviour
{
public Action<object> CallbackAction;
}
public sealed class TextBehaviour : MonoBehaviour
{
internal ConfigurationManagerAttributes Attributes;
internal ConfigEntryBase Entry;
internal float posy;
internal TextMeshProUGUI value;
private void Awake()
{
try
{
Setup();
}
catch (Exception ex)
{
ConfigurationManager._logger.LogError((object)ex);
}
}
private void Update()
{
//IL_0006: 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)
if (((Component)this).transform.localPosition.y != posy)
{
((Component)this).transform.localPosition = new Vector3(20f, posy);
}
}
private void OnGUI()
{
}
internal void Setup()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
SRFGameObjectExtensions.RemoveComponentIfExists<UIKeybinding>(((Component)this).gameObject);
SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
if (Entry == null)
{
return;
}
if (Entry.Description.Tags.Length != 0)
{
object[] tags = Entry.Description.Tags;
for (int i = 0; i < tags.Length; i++)
{
if (tags[i] is ConfigurationManagerAttributes attributes)
{
Attributes = attributes;
}
}
}
((TMP_Text)((Component)((Component)this).transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = Entry.Definition.Key;
value = ((Component)((Component)this).transform.GetChild(1).GetChild(0)).GetComponent<TextMeshProUGUI>();
((TMP_Text)value).text = Entry.BoxedValue.ToString();
Button component = ((Component)((Component)this).transform.GetChild(1).GetChild(1)).GetComponent<Button>();
((UnityEventBase)component.onClick).RemoveAllListeners();
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
SystemMessage.AskForTextInput("Update " + Entry.Definition.Key + " Config", "Enter the desired text", "OK", (Action<string>)delegate(string t)
{
Save(t);
Attributes?.CallbackAction?.Invoke(Entry.BoxedValue);
}, (Action)null, "Cancel", (Action)null, Entry.BoxedValue.ToString());
});
}
private void Save(string t)
{
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
Entry.BoxedValue = t;
((TMP_Text)value).text = t;
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
}
}
public sealed class ToggleBehaviour : MonoBehaviour
{
internal ConfigurationManagerAttributes Attributes;
internal ConfigEntryBase Entry;
private void Awake()
{
try
{
Setup();
}
catch (Exception ex)
{
ConfigurationManager._logger.LogError((object)ex);
}
}
internal void Setup()
{
if (Entry == null)
{
return;
}
SRFGameObjectExtensions.RemoveComponentIfExists<UI_GetSettings>(((Component)this).gameObject);
((Component)this).gameObject.GetComponent<UI_LabelReference>().SetText(Entry.Definition.Key);
Toggle component = ((Component)this).gameObject.GetComponent<Toggle>();
((UnityEventBase)component.onValueChanged).RemoveAllListeners();
((UnityEvent<bool>)(object)component.onValueChanged).AddListener((UnityAction<bool>)delegate(bool b)
{
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " started updating"));
Entry.BoxedValue = b;
Attributes?.CallbackAction?.Invoke(b);
ConfigurationManager._logger.LogInfo((object)(Entry.Definition.Key + " has been updated"));
});
component.isOn = (bool)Entry.BoxedValue;
((Component)this).gameObject.GetComponentInChildren<UI_ToggleSwitchGraphic>().Toggle((bool)Entry.BoxedValue);
if (Entry.Description.Tags.Length == 0)
{
return;
}
object[] tags = Entry.Description.Tags;
for (int i = 0; i < tags.Length; i++)
{
if (tags[i] is ConfigurationManagerAttributes attributes)
{
Attributes = attributes;
}
}
}
}
}
namespace ConfigurationManager.Patches.UI
{
internal static class UI_SwitchButtonGroupStartPatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__11_0;
public static Func<ConfigEntryBase, string> <>9__14_0;
internal void <AddButton>b__11_0()
{
Click();
}
internal string <AddContent>b__14_0(ConfigEntryBase e)
{
return e.Definition.Section;
}
}
internal static Button clone;
internal static GameObject content;
internal static GameObject original;
private static GameObject _modNameHeader;
private static GameObject _sectionHeader;
private static GameObject _keybindTemplate;
private static GameObject _dropDownTemplate;
private static GameObject _toggleTemplate;
private static GameObject _textFieldTemplate;
private static Vector3 pos;
public static Sprite LoadEmbeddedTexture(string texturePath)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(ConfigurationManager).Namespace + "." + texturePath.Replace("/", "."));
byte[] array;
using (MemoryStream memoryStream = new MemoryStream())
{
manifestResourceStream.CopyTo(memoryStream);
array = memoryStream.ToArray();
}
Texture2D val = new Texture2D(1, 1);
ImageConversion.LoadImage(val, array);
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
private static void AddButton(UI_SwitchButtonGroup __instance, int i, Button template, string key, ref List<Button> ____buttons, float distance)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_00bd: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
clone = Object.Instantiate<Button>(template);
((Component)clone).transform.SetParent(((Component)__instance).transform, false);
if (i >= ____buttons.Count)
{
____buttons.Add(clone);
}
else
{
____buttons[i] = clone;
}
((Object)((Component)clone).gameObject).name = key;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(((Component)clone).transform.position.x + distance * (float)i, ((Component)clone).transform.position.y, ((Component)clone).transform.position.z);
Quaternion rotation = ((Component)clone).transform.rotation;
((Component)clone).transform.SetPositionAndRotation(val, rotation);
((UnityEventBase)clone.onClick).RemoveAllListeners();
ButtonClickedEvent onClick = clone.onClick;
object obj = <>c.<>9__11_0;
if (obj == null)
{
UnityAction val2 = delegate
{
Click();
};
<>c.<>9__11_0 = val2;
obj = (object)val2;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
((Component)clone).gameObject.GetComponent<MouseTextOnHover>().mouseHoverText = "Plugin Configurations";
((Component)clone).GetComponentsInChildren<Image>()[2].sprite = LoadEmbeddedTexture("Assets/plug.png");
Transform child = ((Component)template).transform.parent.parent.GetChild(0).GetChild(0).GetChild(0)
.GetChild(2);
_sectionHeader = ((Component)child.GetChild(2).GetChild(0).GetChild(0)).gameObject;
_keybindTemplate = ((Component)child.GetChild(2).GetChild(0).GetChild(1)
.GetChild(0)).gameObject;
Transform child2 = ((Component)template).transform.parent.parent.GetChild(0).GetChild(0).GetChild(0)
.GetChild(0);
_toggleTemplate = ((Component)child2.GetChild(4).GetChild(1)).gameObject;
_dropDownTemplate = ((Component)child2.GetChild(5).GetChild(1)).gameObject;
_textFieldTemplate = ((Component)child2.GetChild(2).GetChild(2)).gameObject;
}
private static void Click()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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)
content.transform.SetPositionAndRotation(original.transform.position, original.transform.rotation);
((Component)content.transform).GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 0f - pos.y);
((Component)((Component)clone).transform.parent.parent.parent).gameObject.GetComponent<GameSettings>().SwitchTab(3);
}
internal static void Postfix(UI_SwitchButtonGroup __instance, ref List<Button> ____buttons, BaseUnityPlugin[] plugins)
{
//IL_0086: 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)
if (((Object)((Component)__instance).gameObject).name == "ToggleGroup" && ((Object)((Component)__instance).transform.parent).name == "Settings")
{
Button val = ____buttons[0];
Button obj = ____buttons[1];
Transform child = ((Component)val).transform.parent.parent.GetChild(0).GetChild(0).GetChild(0);
Transform child2 = child.GetChild(4);
child2.SetParent((Transform)null);
Object.Destroy((Object)(object)child2);
float distance = ((Component)obj).transform.localPosition.x - ((Component)val).transform.localPosition.x;
AddButton(__instance, 5, val, "Mod Config", ref ____buttons, distance);
AddContent(child, plugins);
((UnityEvent)obj.onClick).Invoke();
((UnityEvent)val.onClick).Invoke();
}
}
private static void AddContent(Transform scrollView, BaseUnityPlugin[] plugins)
{
//IL_0057: 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_0061: 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_0144: 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_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: 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_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: 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_01fa: 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_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_045d: Unknown result type (might be due to invalid IL or missing references)
//IL_0462: Unknown result type (might be due to invalid IL or missing references)
//IL_0467: Unknown result type (might be due to invalid IL or missing references)
//IL_046c: Unknown result type (might be due to invalid IL or missing references)
//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
//IL_04d1: 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_04db: 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_0548: Unknown result type (might be due to invalid IL or missing references)
//IL_0552: Unknown result type (might be due to invalid IL or missing references)
//IL_0557: Unknown result type (might be due to invalid IL or missing references)
//IL_055c: Unknown result type (might be due to invalid IL or missing references)
//IL_0561: Unknown result type (might be due to invalid IL or missing references)
original = ((Component)scrollView.GetChild(0)).gameObject;
content = Object.Instantiate<GameObject>(original);
content.transform.SetParent(scrollView);
((Object)content).name = "MOD OPTIONS";
Transform child = content.transform.GetChild(0);
Transform child2 = child.GetChild(0);
pos = child2.position;
Quaternion rotation = child2.rotation;
_modNameHeader = ((Component)child).gameObject;
content.transform.DetachChildren();
foreach (BaseUnityPlugin val in plugins)
{
IEnumerable<ConfigEntryBase> pluginConfig = SettingSearcher.GetPluginConfig(val);
IEnumerable<string> enumerable = pluginConfig.Select((ConfigEntryBase e) => e.Definition.Section).Distinct();
if (!pluginConfig.Any())
{
continue;
}
Transform transform = Object.Instantiate<GameObject>(_modNameHeader).transform;
((Object)((Component)transform).gameObject).name = val.Info.Metadata.Name;
Transform child3 = transform.GetChild(0);
((TMP_Text)((Component)child3).GetComponent<TextMeshProUGUI>()).text = val.Info.Metadata.Name;
transform.SetParent(content.transform);
((Component)transform).transform.DetachChildren();
child3.SetParent(transform);
child3.SetPositionAndRotation(pos, rotation);
pos += 53.1f * Vector3.down;
_ = ((Component)child3).GetComponent<RectTransform>().anchoredPosition;
foreach (string section in enumerable)
{
GameObject obj = Object.Instantiate<GameObject>(_sectionHeader);
obj.transform.SetParent(content.transform);
obj.transform.localPosition = new Vector3(0f, pos.y);
((TMP_Text)obj.GetComponent<TextMeshProUGUI>()).text = section;
pos += 22f * Vector3.down;
((Object)obj.gameObject).name = val.Info.Metadata.Name + "_" + section;
foreach (ConfigEntryBase item in pluginConfig.Where((ConfigEntryBase e) => e.Definition.Section == section))
{
ConfigurationManager._logger.LogInfo((object)$"{item.Definition.Section}:{item.Definition.Key}:{item.BoxedValue}");
if (item.BoxedValue is KeyboardShortcut || item.BoxedValue is KeyCode)
{
GameObject obj2 = Object.Instantiate<GameObject>(_keybindTemplate);
obj2.transform.SetParent(content.transform);
obj2.transform.localPosition = new Vector3(20f, pos.y);
KeybindBehaviour keybindBehaviour = obj2.AddComponent<KeybindBehaviour>();
keybindBehaviour.Entry = item;
keybindBehaviour.Setup();
pos += 28f * Vector3.down;
}
else if (item.BoxedValue.IsNumber())
{
GameObject obj3 = Object.Instantiate<GameObject>(_textFieldTemplate);
obj3.transform.SetParent(content.transform);
obj3.transform.localPosition = new Vector3(20f, pos.y - 14f);
NumberBehaviour numberBehaviour = obj3.AddComponent<NumberBehaviour>();
numberBehaviour.posy = pos.y - 14f;
numberBehaviour.Entry = item;
numberBehaviour.Setup();
pos += 28f * Vector3.down;
}
else if (item.BoxedValue is string)
{
GameObject obj4 = Object.Instantiate<GameObject>(_textFieldTemplate);
obj4.transform.SetParent(content.transform);
obj4.transform.localPosition = new Vector3(20f, pos.y - 14f);
TextBehaviour textBehaviour = obj4.AddComponent<TextBehaviour>();
textBehaviour.posy = pos.y - 14f;
textBehaviour.Entry = item;
textBehaviour.Setup();
pos += 28f * Vector3.down;
}
else if (item.BoxedValue is bool)
{
GameObject obj5 = Object.Instantiate<GameObject>(_toggleTemplate);
obj5.transform.SetParent(content.transform);
obj5.transform.localPosition = new Vector3(5f, pos.y);
pos += 28f * Vector3.down;
ToggleBehaviour toggleBehaviour = obj5.AddComponent<ToggleBehaviour>();
toggleBehaviour.Entry = item;
toggleBehaviour.Setup();
}
else if (item.BoxedValue.GetType().IsEnum)
{
GameObject obj6 = Object.Instantiate<GameObject>(_dropDownTemplate);
obj6.transform.SetParent(content.transform);
obj6.transform.localPosition = new Vector3(108f, pos.y);
pos += 28f * Vector3.down;
DropDownBehaviour dropDownBehaviour = obj6.AddComponent<DropDownBehaviour>();
dropDownBehaviour.Entry = item;
dropDownBehaviour.Setup();
}
else
{
_ = item.BoxedValue is Color;
}
}
pos += 11f * Vector3.down;
}
pos += 11f * Vector3.down;
}
}
}
}
namespace ConfigurationManager.Patches.GameSetting
{
[HarmonyPatch(typeof(GameSettings), "OnInstanceSetup")]
internal sealed class GameSettingsSetupPatch
{
internal static bool AlreadyRan;
private static BaseUnityPlugin[] _plugins;
public static void Postfix()
{
try
{
Setup();
}
catch (Exception ex)
{
ConfigurationManager._logger.LogError((object)ex);
}
}
private static void Setup()
{
ConfigurationManager._logger.LogInfo((object)$"GameSettings.OnInstanceSetup: {AlreadyRan}");
if (AlreadyRan)
{
return;
}
SettingSearcher.CollectSettings(out var results, out var _, out _plugins);
foreach (ConfigEntryBase item in results)
{
ConfigurationManager._logger.LogInfo((object)("Settings Found: " + item.Definition.Section + ", " + item.Definition.Key + " "));
}
BaseUnityPlugin[] plugins = _plugins;
foreach (BaseUnityPlugin val in plugins)
{
foreach (ConfigEntryBase item2 in SettingSearcher.GetPluginConfig(val))
{
ConfigurationManager._logger.LogInfo((object)("Settings Found in " + val.Info.Metadata.Name + " : " + item2.Definition.Section + ", " + item2.Definition.Key + " "));
}
}
UI_SwitchButtonGroup componentInChildren = ((Component)SingletonBehaviour<GameSettings>.Instance).gameObject.GetComponentInChildren<UI_SwitchButtonGroup>();
List<Button> ____buttons = ((Component)componentInChildren).gameObject.GetComponentsInChildren<Button>().ToList();
UI_SwitchButtonGroupStartPatch.Postfix(componentInChildren, ref ____buttons, _plugins);
ConfigurationManager._logger.LogInfo((object)"GameSettings SetUp Patch completed");
AlreadyRan = true;
}
}
}