using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalSettings.Properties;
using LethalSettings.UI;
using LethalSettings.UI.Components;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("willis81808")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A centralized place for configuring mods from in-game")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1+12660311029c0a53d9e5e5bc6b2a962d751e79a0")]
[assembly: AssemblyProduct("LethalSettings")]
[assembly: AssemblyTitle("LethalSettings")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/willis81808/LethalSettings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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;
}
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace LethalSettings
{
internal static class Assets
{
internal static ModMenu ModSettingsView { get; private set; }
internal static GameObject VerticalWrapper { get; private set; }
internal static GameObject HorizontalWrapper { get; private set; }
internal static LabelComponentObject LabelPrefab { get; private set; }
internal static ButtonComponentObject ButtonPrefab { get; private set; }
internal static SliderComponentObject SliderPrefab { get; private set; }
internal static ToggleComponentObject TogglePrefab { get; private set; }
internal static DropdownComponentObject DropdownPrefab { get; private set; }
internal static InputComponentObject InputPrefab { get; private set; }
internal static void LoadAssets()
{
AssetBundle val = AssetBundle.LoadFromMemory(Resources.settings_assets);
ModSettingsView = val.LoadAsset<GameObject>("Mod Settings Container").GetComponent<ModMenu>();
VerticalWrapper = val.LoadAsset<GameObject>("Vertical Wrapper");
HorizontalWrapper = val.LoadAsset<GameObject>("Horizontal Wrapper");
LabelPrefab = val.LoadAsset<GameObject>("Label").GetComponent<LabelComponentObject>();
ButtonPrefab = val.LoadAsset<GameObject>("Button").GetComponent<ButtonComponentObject>();
SliderPrefab = val.LoadAsset<GameObject>("Slider").GetComponent<SliderComponentObject>();
TogglePrefab = val.LoadAsset<GameObject>("Toggle").GetComponent<ToggleComponentObject>();
DropdownPrefab = val.LoadAsset<GameObject>("Dropdown").GetComponent<DropdownComponentObject>();
InputPrefab = val.LoadAsset<GameObject>("Input").GetComponent<InputComponentObject>();
}
}
[BepInPlugin("com.willis.lc.lethalsettings", "LethalSettings", "1.4.1")]
public class LethalSettingsPlugin : BaseUnityPlugin
{
public static LethalSettingsPlugin Instance { get; private set; }
internal static ManualLogSource Log { get; private set; }
public void Awake()
{
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Assets.LoadAssets();
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.willis.lc.lethalsettings");
ModMenu.RegisterMod(new ModMenu.ModSettingsConfig
{
Name = "LethalSettings",
Id = "com.willis.lc.lethalsettings",
Version = "1.4.1",
Description = "A centralized place for configuring mods from in-game"
}, allowedInMainMenu: true, allowedInGame: true);
}
}
internal static class GeneratedPluginInfo
{
public const string Identifier = "com.willis.lc.lethalsettings";
public const string Name = "LethalSettings";
public const string Version = "1.4.1";
}
}
namespace LethalSettings.UI
{
public class ModMenu : MonoBehaviour
{
public class ModSettingsConfig
{
public Action<GameObject, ReadOnlyCollection<MenuComponent>> OnMenuOpen;
public Action<GameObject, ReadOnlyCollection<MenuComponent>> OnMenuClose;
public string Name { get; set; }
public string Id { get; set; }
public string Description { get; set; }
public string Version { get; set; }
public MenuComponent[] MenuComponents { get; set; } = Array.Empty<MenuComponent>();
internal ButtonComponent ShowSettingsButton { get; set; }
internal GameObject Viewport { get; set; }
}
private static List<ModSettingsConfig> registeredMainMenuMods = new List<ModSettingsConfig>();
private static List<ModSettingsConfig> registeredQuickMenuMods = new List<ModSettingsConfig>();
[SerializeField]
internal Transform modListScrollView;
[SerializeField]
internal Transform modSettingsScrollView;
internal bool InGame { get; set; }
private List<ModSettingsConfig> AvailableMods => InGame ? registeredQuickMenuMods : registeredMainMenuMods;
private IEnumerator Start()
{
BuildMod(AvailableMods.First());
foreach (ModSettingsConfig mod in from m in AvailableMods.Skip(1)
orderby m.Name
select m)
{
BuildMod(mod);
}
ShowModSettings(AvailableMods.First(), AvailableMods);
yield return (object)new WaitUntil((Func<bool>)(() => ((Component)modSettingsScrollView).gameObject.activeInHierarchy));
yield return LayoutFix();
}
private IEnumerator LayoutFix()
{
((Component)modSettingsScrollView).gameObject.SetActive(false);
yield return null;
((Component)modSettingsScrollView).gameObject.SetActive(true);
yield return null;
((Component)modListScrollView).gameObject.SetActive(false);
yield return null;
((Component)modListScrollView).gameObject.SetActive(true);
}
private void BuildMod(ModSettingsConfig mod)
{
ModSettingsConfig mod2 = mod;
mod2.ShowSettingsButton = new ButtonComponent
{
Text = mod2.Name,
OnClick = delegate
{
ShowModSettings(mod2, AvailableMods);
}
};
mod2.ShowSettingsButton.Construct(((Component)modListScrollView).gameObject);
ModSettingsConfig modSettingsConfig = mod2;
VerticalComponent verticalComponent = new VerticalComponent
{
ChildAlignment = (TextAnchor)0
};
List<MenuComponent> list = new List<MenuComponent>();
list.Add(new LabelComponent
{
Text = "Description",
FontSize = 16f
});
list.Add(new LabelComponent
{
Text = mod2.Description,
FontSize = 10f
});
list.Add(new HorizontalComponent
{
ChildAlignment = (TextAnchor)5,
Children = new MenuComponent[2]
{
new VerticalComponent
{
Children = new MenuComponent[2]
{
new LabelComponent
{
Text = "Version",
FontSize = 16f
},
new LabelComponent
{
Text = mod2.Version,
FontSize = 10f
}
}
},
new VerticalComponent
{
Children = new MenuComponent[2]
{
new LabelComponent
{
Text = "Mod ID",
FontSize = 16f
},
new LabelComponent
{
Text = mod2.Id,
FontSize = 10f
}
}
}
}
});
list.AddRange(mod2.MenuComponents);
verticalComponent.Children = list.ToArray();
modSettingsConfig.Viewport = verticalComponent.Construct(((Component)modSettingsScrollView).gameObject);
}
private static void ShowModSettings(ModSettingsConfig activeMod, List<ModSettingsConfig> availableMods)
{
foreach (ModSettingsConfig availableMod in availableMods)
{
bool flag = availableMod.Viewport.activeSelf && availableMod != activeMod;
bool flag2 = !availableMod.Viewport.activeSelf && availableMod == activeMod;
if (flag)
{
availableMod.OnMenuClose?.Invoke(availableMod.Viewport, new ReadOnlyCollection<MenuComponent>(availableMod.MenuComponents));
}
availableMod.Viewport.SetActive(availableMod == activeMod);
availableMod.ShowSettingsButton.ShowCaret = availableMod == activeMod;
if (flag2)
{
availableMod.OnMenuOpen?.Invoke(availableMod.Viewport, new ReadOnlyCollection<MenuComponent>(availableMod.MenuComponents));
}
}
}
public static void RegisterMod(ModSettingsConfig config)
{
RegisterMod(config, allowedInMainMenu: true, allowedInGame: false);
}
public static void RegisterMod(ModSettingsConfig config, bool allowedInMainMenu, bool allowedInGame)
{
if (allowedInMainMenu)
{
registeredMainMenuMods.Add(config);
}
if (allowedInGame)
{
registeredQuickMenuMods.Add(config);
}
}
}
}
namespace LethalSettings.UI.Components
{
public class ButtonComponent : MenuComponent
{
public string Text { internal get; set; } = "Button";
public bool ShowCaret { internal get; set; } = true;
public bool Enabled { get; set; } = true;
public Action<ButtonComponent> OnClick { internal get; set; } = delegate
{
};
public Action<ButtonComponent> OnInitialize { get; set; } = delegate
{
};
public override GameObject Construct(GameObject root)
{
return Object.Instantiate<ButtonComponentObject>(Assets.ButtonPrefab, root.transform).Initialize(this);
}
}
internal class ButtonComponentObject : MonoBehaviour
{
[SerializeField]
private Button button;
[SerializeField]
private TextMeshProUGUI label;
private ButtonComponent component;
internal GameObject Initialize(ButtonComponent component)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
ButtonComponent component2 = component;
this.component = component2;
((UnityEvent)button.onClick).AddListener((UnityAction)delegate
{
component2.OnClick?.Invoke(component2);
});
component2.OnInitialize?.Invoke(component2);
return ((Component)this).gameObject;
}
private void FixedUpdate()
{
((Selectable)button).interactable = component.Enabled;
((TMP_Text)label).text = (component.ShowCaret ? "> " : "") + component.Text;
}
}
public class DropdownComponent : MenuComponent
{
internal OptionData _currentValue;
private DropdownComponentObject componentObject;
public string Text { get; set; }
public bool Enabled { get; set; } = true;
public List<OptionData> Options { get; set; } = new List<OptionData>();
public Action<DropdownComponent, OptionData> OnValueChanged { get; set; } = delegate
{
};
public Action<DropdownComponent> OnInitialize { get; set; } = delegate
{
};
public OptionData Value
{
get
{
return _currentValue;
}
set
{
if ((Object)(object)componentObject != (Object)null)
{
int num = Options.IndexOf(value);
if (num < 0)
{
throw new Exception("Could not find the provided value in the Options list! Did you pass in a reference to a TMP_Dropdown.OptionData that is not in the list?");
}
componentObject.SetSelected(num);
}
else
{
_currentValue = value;
}
}
}
public override GameObject Construct(GameObject root)
{
componentObject = Object.Instantiate<DropdownComponentObject>(Assets.DropdownPrefab, root.transform);
return componentObject.Initialize(this);
}
}
internal class DropdownComponentObject : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI title;
[SerializeField]
private TMP_Dropdown dropdown;
private DropdownComponent component;
public GameObject Initialize(DropdownComponent component)
{
this.component = component;
dropdown.options = component.Options;
((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)SetSelected);
if (component.Value == null)
{
component.Value = component.Options.First();
}
else
{
int num = component.Options.IndexOf(component.Value);
if (num >= 0)
{
SetSelected(num);
}
}
component.OnInitialize?.Invoke(component);
return ((Component)this).gameObject;
}
internal void SetSelected(int index)
{
dropdown.value = index;
component._currentValue = dropdown.options[index];
component.OnValueChanged?.Invoke(component, dropdown.options[index]);
}
private void FixedUpdate()
{
((Selectable)dropdown).interactable = component.Enabled;
((TMP_Text)title).text = component.Text;
if (component.Options != dropdown.options)
{
dropdown.options = component.Options;
}
}
}
public class HorizontalComponent : MenuComponent
{
public MenuComponent[] Children { internal get; set; } = Array.Empty<MenuComponent>();
public int Spacing { internal get; set; } = 10;
public TextAnchor ChildAlignment { internal get; set; } = (TextAnchor)3;
public override GameObject Construct(GameObject root)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
HorizontalLayoutGroup component = Object.Instantiate<GameObject>(Assets.HorizontalWrapper, root.transform).GetComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)component).spacing = Spacing;
((LayoutGroup)component).childAlignment = ChildAlignment;
MenuComponent[] children = Children;
foreach (MenuComponent menuComponent in children)
{
menuComponent.Construct(((Component)component).gameObject);
}
return ((Component)component).gameObject;
}
}
public class InputComponent : MenuComponent
{
internal string _currentValue = "";
private InputComponentObject componentObject;
public string Placeholder { get; set; } = "Enter text...";
public Action<InputComponent, string> OnValueChanged { get; set; } = delegate
{
};
public Action<InputComponent> OnInitialize { get; set; } = delegate
{
};
public string Value
{
get
{
return _currentValue;
}
set
{
if ((Object)(object)componentObject != (Object)null)
{
componentObject.SetValue(value);
}
else
{
_currentValue = value;
}
}
}
public override GameObject Construct(GameObject root)
{
componentObject = Object.Instantiate<InputComponentObject>(Assets.InputPrefab, root.transform);
return componentObject.Initialize(this);
}
public TMP_InputField GetBackingObject()
{
if ((Object)(object)componentObject == (Object)null)
{
return null;
}
return componentObject.input;
}
}
internal class InputComponentObject : MonoBehaviour
{
[SerializeField]
internal TMP_InputField input;
[SerializeField]
private TextMeshProUGUI placeholder;
private InputComponent component;
public GameObject Initialize(InputComponent component)
{
this.component = component;
((UnityEvent<string>)(object)input.onValueChanged).AddListener((UnityAction<string>)SetValue);
component.OnInitialize?.Invoke(component);
return ((Component)this).gameObject;
}
private void FixedUpdate()
{
((TMP_Text)placeholder).text = component.Placeholder;
input.text = component.Value;
}
internal void SetValue(string value)
{
input.text = value;
component._currentValue = value;
component.OnValueChanged?.Invoke(component, value);
}
}
public class LabelComponent : MenuComponent
{
public string Text { internal get; set; } = "Label Text";
public float FontSize { internal get; set; } = 16f;
public TextAlignmentOptions Alignment { internal get; set; } = (TextAlignmentOptions)4097;
public Action<LabelComponent> OnInitialize { get; set; } = delegate
{
};
public override GameObject Construct(GameObject root)
{
return Object.Instantiate<LabelComponentObject>(Assets.LabelPrefab, root.transform).Initialize(this);
}
}
internal class LabelComponentObject : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI label;
private LabelComponent component;
internal GameObject Initialize(LabelComponent component)
{
this.component = component;
component.OnInitialize?.Invoke(component);
return ((Component)this).gameObject;
}
private void FixedUpdate()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
((TMP_Text)label).text = component.Text;
((TMP_Text)label).fontSize = component.FontSize;
((TMP_Text)label).alignment = component.Alignment;
}
}
public abstract class MenuComponent
{
public abstract GameObject Construct(GameObject root);
}
public class SliderComponent : MenuComponent
{
internal float _currentValue = 50f;
private SliderComponentObject componentObject;
public string Text { get; set; } = "Slider";
public bool ShowValue { get; set; } = true;
public bool WholeNumbers { get; set; } = true;
public bool Enabled { get; set; } = true;
public float MinValue { get; set; } = 0f;
public float MaxValue { get; set; } = 100f;
public float Value
{
get
{
return _currentValue;
}
set
{
if ((Object)(object)componentObject != (Object)null)
{
componentObject.SetValue(value);
}
else
{
_currentValue = value;
}
}
}
public Action<SliderComponent, float> OnValueChanged { internal get; set; } = delegate
{
};
public Action<SliderComponent> OnInitialize { get; set; } = delegate
{
};
public override GameObject Construct(GameObject root)
{
componentObject = Object.Instantiate<SliderComponentObject>(Assets.SliderPrefab, root.transform);
return componentObject.Initialize(this);
}
}
internal class SliderComponentObject : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI label;
[SerializeField]
private Slider slider;
private SliderComponent component;
internal GameObject Initialize(SliderComponent component)
{
this.component = component;
slider.wholeNumbers = component.WholeNumbers;
((Selectable)slider).interactable = component.Enabled;
float currentValue = component._currentValue;
slider.minValue = component.MinValue;
slider.maxValue = component.MaxValue;
slider.value = component._currentValue;
((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)SetValue);
component.OnInitialize?.Invoke(component);
return ((Component)this).gameObject;
}
private void FixedUpdate()
{
slider.wholeNumbers = component.WholeNumbers;
((Selectable)slider).interactable = component.Enabled;
slider.minValue = component.MinValue;
slider.maxValue = component.MaxValue;
slider.value = component._currentValue;
((TMP_Text)label).text = string.Format("{0} {1}", component.Text, component.ShowValue ? ((object)slider.value) : "");
}
internal void SetValue(float value)
{
slider.value = value;
component._currentValue = value;
component.OnValueChanged?.Invoke(component, value);
}
}
public class ToggleComponent : MenuComponent
{
internal bool _toggled;
private ToggleComponentObject componentObject;
public string Text { get; set; } = "Toggle";
public int FontSize { get; set; } = 15;
public bool Enabled { get; set; } = true;
public bool Value
{
get
{
return _toggled;
}
set
{
if ((Object)(object)componentObject != (Object)null)
{
componentObject.SetToggled(value);
}
else
{
_toggled = value;
}
}
}
public Action<ToggleComponent, bool> OnValueChanged { internal get; set; } = delegate
{
};
public Action<ToggleComponent> OnInitialize { get; set; } = delegate
{
};
public override GameObject Construct(GameObject root)
{
componentObject = Object.Instantiate<ToggleComponentObject>(Assets.TogglePrefab, root.transform);
return componentObject.Initialize(this);
}
}
internal class ToggleComponentObject : MonoBehaviour
{
[SerializeField]
private Button button;
[SerializeField]
private TextMeshProUGUI label;
[SerializeField]
private GameObject toggleImage;
private ToggleComponent component;
internal GameObject Initialize(ToggleComponent component)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
ToggleComponent component2 = component;
this.component = component2;
((UnityEvent)button.onClick).AddListener((UnityAction)delegate
{
SetToggled(!component2.Value);
});
component2.OnInitialize?.Invoke(component2);
return ((Component)this).gameObject;
}
private void FixedUpdate()
{
((Selectable)button).interactable = component.Enabled;
((TMP_Text)label).text = component.Text;
((TMP_Text)label).fontSize = component.FontSize;
toggleImage.SetActive(component.Value);
}
internal void SetToggled(bool toggled)
{
component._toggled = toggled;
component.OnValueChanged?.Invoke(component, toggled);
}
}
public class VerticalComponent : MenuComponent
{
public MenuComponent[] Children { internal get; set; } = Array.Empty<MenuComponent>();
public int Spacing { internal get; set; } = 10;
public TextAnchor ChildAlignment { internal get; set; } = (TextAnchor)3;
public override GameObject Construct(GameObject root)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
VerticalLayoutGroup component = Object.Instantiate<GameObject>(Assets.VerticalWrapper, root.transform).GetComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)component).spacing = Spacing;
((LayoutGroup)component).childAlignment = ChildAlignment;
MenuComponent[] children = Children;
foreach (MenuComponent menuComponent in children)
{
menuComponent.Construct(((Component)component).gameObject);
}
return ((Component)component).gameObject;
}
}
}
namespace LethalSettings.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("LethalSettings.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] settings_assets
{
get
{
object @object = ResourceManager.GetObject("settings_assets", resourceCulture);
return (byte[])@object;
}
}
internal Resources()
{
}
}
}
namespace LethalSettings.Patches
{
[HarmonyPatch(typeof(MenuManager))]
internal class MenuManager_Patches
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(MenuManager __instance)
{
Transform val = ((Component)__instance).transform.parent.Find("MenuContainer/SettingsPanel");
ModMenu modMenu = Object.Instantiate<ModMenu>(Assets.ModSettingsView, val);
((Component)modMenu).transform.SetSiblingIndex(((Component)modMenu).transform.GetSiblingIndex() - 2);
((Component)((Component)modMenu).gameObject.transform.Find("Mod Settings Panel")).gameObject.SetActive(false);
}
}
[HarmonyPatch(typeof(QuickMenuManager))]
internal class QuickMenuManager_Patches
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(QuickMenuManager __instance)
{
Transform val = __instance.menuContainer.transform.Find("SettingsPanel");
ModMenu modMenu = Object.Instantiate<ModMenu>(Assets.ModSettingsView, val);
modMenu.InGame = true;
((Component)modMenu).transform.SetSiblingIndex(((Component)modMenu).transform.GetSiblingIndex() - 2);
((Component)((Component)modMenu).gameObject.transform.Find("Mod Settings Panel")).gameObject.SetActive(false);
}
}
}