Decompiled source of AtlyssCharacterMenuPlus v1.0.5

AtlyssCharacterMenuPlus.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("portalsam")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+0373b84bff2ad4b6535d334aa3c471e2b0db7943")]
[assembly: AssemblyProduct("AtlyssCharacterMenuPlus")]
[assembly: AssemblyTitle("AtlyssCharacterMenuPlus")]
[assembly: AssemblyVersion("1.0.5.0")]
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;
		}
	}
}
namespace AtlyssCharacterMenuPlus
{
	[HarmonyPatch(typeof(CharacterCreationManager), "Awake")]
	public class CharacterCreationManagerPatch
	{
		private static GameObject? referenceText;

		private static GameObject? referenceLeftButton;

		private static GameObject? referenceRightButton;

		private static Slider? headWidthSlider;

		private static Slider? modifySlider;

		private static Slider? voicePitchSlider;

		private static Slider? heightSlider;

		private static Slider? widthSlider;

		private static Slider? chestSlider;

		private static Slider? armsSlider;

		private static Slider? bellySlider;

		private static Slider? bottomSlider;

		private static void Postfix()
		{
			referenceText = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_head/_dolly_headCustomizer/_characterSlider_headWidth/_tag");
			referenceLeftButton = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_head/_dolly_headCustomizer/_characterButtons_hairStyle/_button_leftSelect");
			referenceRightButton = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_head/_dolly_headCustomizer/_characterButtons_hairStyle/_button_rightSelect");
			headWidthSlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_head/_dolly_headCustomizer/_characterSlider_headWidth/Slider_headWidth").GetComponent<Slider>();
			modifySlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_head/_dolly_headCustomizer/_characterSlider_headMod/Slider_muzzle").GetComponent<Slider>();
			voicePitchSlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_head/_dolly_headCustomizer/_characterSlider_voicePitch/Slider_voicePitch").GetComponent<Slider>();
			heightSlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_body/_dolly_bodyCustomizer/_characterSlider_height/Slider_height").GetComponent<Slider>();
			widthSlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_body/_dolly_bodyCustomizer/_characterSlider_width/Slider_width").GetComponent<Slider>();
			chestSlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_body/_dolly_bodyCustomizer/_characterSlider_chest/Slider_chest").GetComponent<Slider>();
			armsSlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_body/_dolly_bodyCustomizer/_characterSlider_arms/Slider_arms").GetComponent<Slider>();
			bellySlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_body/_dolly_bodyCustomizer/_characterSlider_belly/Slider_belly").GetComponent<Slider>();
			bottomSlider = GameObject.Find("_GameUI_MainMenu/_characterSelectMenu/Canvas_characterCreation/_dolly_customizer/_customizer_body/_dolly_bodyCustomizer/_characterSlider_bottom/Slider_bottom").GetComponent<Slider>();
			SetupSliderTextAndButtons(headWidthSlider);
			SetupSliderTextAndButtons(modifySlider);
			SetupSliderTextAndButtons(voicePitchSlider);
			SetupSliderTextAndButtons(heightSlider);
			SetupSliderTextAndButtons(widthSlider);
			SetupSliderTextAndButtons(chestSlider);
			SetupSliderTextAndButtons(armsSlider);
			SetupSliderTextAndButtons(bellySlider);
			SetupSliderTextAndButtons(bottomSlider);
			CharacterMenuPlus.Logger.LogInfo((object)"Character Creation Menu has been patched.");
		}

		private static void SetupSliderTextAndButtons(Slider slider)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			Slider slider2 = slider;
			GameObject val = Object.Instantiate<GameObject>(referenceText, ((Component)slider2).transform.parent, true);
			val.transform.localScale = Vector3.one;
			val.transform.localPosition = new Vector3(20f, -10f, 0f);
			Text sliderText = val.GetComponent<Text>();
			sliderText.fontSize = 14;
			sliderText.text = (Configuration.UsePercentages.Value ? (Math.Round((slider2.value - slider2.minValue) / (slider2.maxValue - slider2.minValue) * 100f) + "%") : (Math.Truncate(slider2.value * 100f) / 100.0).ToString(CultureInfo.InvariantCulture));
			((UnityEvent<float>)(object)slider2.onValueChanged).AddListener((UnityAction<float>)sliderAction);
			GameObject obj = Object.Instantiate<GameObject>(referenceLeftButton, ((Component)slider2).transform.parent, true);
			obj.transform.localScale = new Vector3(0.375f, 0.375f, 0.375f);
			obj.transform.localPosition = new Vector3(85f, -20f, 0f);
			Button component = obj.GetComponent<Button>();
			component.onClick = new ButtonClickedEvent();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				Slider obj4 = slider2;
				obj4.value += (slider2.wholeNumbers ? 1f : ((slider2.maxValue - slider2.minValue) * 0.0025f));
			});
			GameObject obj2 = Object.Instantiate<GameObject>(referenceRightButton, ((Component)slider2).transform.parent, true);
			obj2.transform.localScale = new Vector3(0.375f, 0.375f, 0.375f);
			obj2.transform.localPosition = new Vector3(70f, -20f, 0f);
			Button component2 = obj2.GetComponent<Button>();
			component2.onClick = new ButtonClickedEvent();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				Slider obj3 = slider2;
				obj3.value -= (slider2.wholeNumbers ? 1f : ((slider2.maxValue - slider2.minValue) * 0.0025f));
			});
			void sliderAction(float value)
			{
				sliderText.text = (Configuration.UsePercentages.Value ? (Math.Round((slider2.value - slider2.minValue) / (slider2.maxValue - slider2.minValue) * 100f) + "%") : (Math.Truncate(slider2.value * 100f) / 100.0).ToString(CultureInfo.InvariantCulture));
			}
		}
	}
	[BepInPlugin("net.portalsam.AtlyssCharacterMenuPlus", "CharacterMenuPlus", "1.0.5.0")]
	[BepInProcess("ATLYSS.exe")]
	public class CharacterMenuPlus : BaseUnityPlugin
	{
		internal static CharacterMenuPlus Instance;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			Configuration.BindConfiguration();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Logger.LogInfo((object)"CharacterMenuPlus has been initialized!");
		}

		internal static ConfigFile GetConfig()
		{
			return ((BaseUnityPlugin)Instance).Config;
		}
	}
	internal static class Configuration
	{
		public static ConfigEntry<bool> UsePercentages;

		internal static void BindConfiguration()
		{
			UsePercentages = CharacterMenuPlus.GetConfig().Bind<bool>("General", "UsePercentages", false, "Display percentages instead of whole numbers for the slider labels.");
		}
	}
	[HarmonyPatch(typeof(VanityMirrorManager), "Awake")]
	public class VanityMirrorManagerPatch
	{
		private static GameObject? referenceText;

		private static GameObject? referenceLeftButton;

		private static GameObject? referenceRightButton;

		private static Slider? headWidthSlider;

		private static Slider? modifySlider;

		private static Slider? voicePitchSlider;

		private static Slider? heightSlider;

		private static Slider? widthSlider;

		private static Slider? chestSlider;

		private static Slider? armsSlider;

		private static Slider? bellySlider;

		private static Slider? bottomSlider;

		private static void Postfix()
		{
			referenceText = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_head/_dolly_headCustomizer/_characterSlider_headWidth/_tag");
			referenceLeftButton = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_head/_dolly_headCustomizer/_characterButtons_hairStyle/_button_leftSelect");
			referenceRightButton = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_head/_dolly_headCustomizer/_characterButtons_hairStyle/_button_rightSelect");
			headWidthSlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_head/_dolly_headCustomizer/_characterSlider_headWidth/Slider").GetComponent<Slider>();
			modifySlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_head/_dolly_headCustomizer/_characterSlider_headMod/Slider").GetComponent<Slider>();
			voicePitchSlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_head/_dolly_headCustomizer/_characterSlider_voicePitch/Slider").GetComponent<Slider>();
			heightSlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_body/_dolly_bodyCustomizer/_characterSlider_height/Slider_height").GetComponent<Slider>();
			widthSlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_body/_dolly_bodyCustomizer/_characterSlider_width/Slider_width").GetComponent<Slider>();
			chestSlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_body/_dolly_bodyCustomizer/_characterSlider_chest/Slider_chest").GetComponent<Slider>();
			armsSlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_body/_dolly_bodyCustomizer/_characterSlider_arms/Slider_arms").GetComponent<Slider>();
			bellySlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_body/_dolly_bodyCustomizer/_characterSlider_belly/Slider_belly").GetComponent<Slider>();
			bottomSlider = GameObject.Find("_GameUI_InGame/Canvas_DialogSystem/_dolly_vanityMirrorBox/_customizer_body/_dolly_bodyCustomizer/_characterSlider_bottom/Slider_bottom").GetComponent<Slider>();
			SetupSliderTextAndButtons(headWidthSlider);
			SetupSliderTextAndButtons(modifySlider);
			SetupSliderTextAndButtons(voicePitchSlider);
			SetupSliderTextAndButtons(heightSlider);
			SetupSliderTextAndButtons(widthSlider);
			SetupSliderTextAndButtons(chestSlider);
			SetupSliderTextAndButtons(armsSlider);
			SetupSliderTextAndButtons(bellySlider);
			SetupSliderTextAndButtons(bottomSlider);
			CharacterMenuPlus.Logger.LogInfo((object)"Vanity Mirror Menu has been patched.");
		}

		private static void SetupSliderTextAndButtons(Slider slider)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			Slider slider2 = slider;
			GameObject val = Object.Instantiate<GameObject>(referenceText, ((Component)slider2).transform.parent, true);
			val.transform.localScale = Vector3.one;
			val.transform.localPosition = new Vector3(20f, -10f, 0f);
			Text sliderText = val.GetComponent<Text>();
			sliderText.fontSize = 14;
			sliderText.text = (Configuration.UsePercentages.Value ? (Math.Round((slider2.value - slider2.minValue) / (slider2.maxValue - slider2.minValue) * 100f) + "%") : (Math.Truncate(slider2.value * 100f) / 100.0).ToString(CultureInfo.InvariantCulture));
			((UnityEvent<float>)(object)slider2.onValueChanged).AddListener((UnityAction<float>)sliderAction);
			GameObject obj = Object.Instantiate<GameObject>(referenceLeftButton, ((Component)slider2).transform.parent, true);
			obj.transform.localScale = new Vector3(0.375f, 0.375f, 0.375f);
			obj.transform.localPosition = new Vector3(85f, -20f, 0f);
			Button component = obj.GetComponent<Button>();
			component.onClick = new ButtonClickedEvent();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				Slider obj4 = slider2;
				obj4.value += (slider2.wholeNumbers ? 1f : ((slider2.maxValue - slider2.minValue) * 0.0025f));
			});
			GameObject obj2 = Object.Instantiate<GameObject>(referenceRightButton, ((Component)slider2).transform.parent, true);
			obj2.transform.localScale = new Vector3(0.375f, 0.375f, 0.375f);
			obj2.transform.localPosition = new Vector3(70f, -20f, 0f);
			Button component2 = obj2.GetComponent<Button>();
			component2.onClick = new ButtonClickedEvent();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				Slider obj3 = slider2;
				obj3.value -= (slider2.wholeNumbers ? 1f : ((slider2.maxValue - slider2.minValue) * 0.0025f));
			});
			void sliderAction(float value)
			{
				sliderText.text = (Configuration.UsePercentages.Value ? (Math.Round((slider2.value - slider2.minValue) / (slider2.maxValue - slider2.minValue) * 100f) + "%") : (Math.Truncate(slider2.value * 100f) / 100.0).ToString(CultureInfo.InvariantCulture));
			}
		}
	}
}