Decompiled source of More Saves v1.0.1

Isbjorn52.MoreSaves.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using TMPro;
using UnityEngine;
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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("MoreSaves")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreSaves")]
[assembly: AssemblyTitle("MoreSaves")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
		}
	}
}
namespace MoreSaves
{
	[BepInPlugin("Isbjorn52.MoreSaves", "More Saves", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const int NUMBER_OF_SAVES = 20;

		public void OnEnable()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			new Hook((MethodBase)typeof(SaveUICellTABS).GetMethod("Start", BindingFlags.Instance | BindingFlags.NonPublic), (Delegate)new Action<Action<SaveUICellTABS>, SaveUICellTABS>(SaveUICellTABS_Start));
			new ILHook((MethodBase)typeof(SaveSystem).GetMethod("LoadSavesFromDisk"), new Manipulator(IL_SaveSystem_LoadSavesFromDisk));
		}

		private void SaveUICellTABS_Start(Action<SaveUICellTABS> orig, SaveUICellTABS self)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			((Component)self).GetComponent<RectTransform>().sizeDelta = new Vector2(1600f, 320f);
			Object.Destroy((Object)(object)((Component)self).GetComponent<HorizontalLayoutGroup>());
			((Component)self).transform.localPosition = new Vector3(0f, 100f, 0f);
			for (int i = 3; i < 20; i++)
			{
				Object.Instantiate<GameObject>(((Component)((Component)self).transform.GetChild(0)).gameObject, ((Component)self).transform);
			}
			((MonoBehaviour)this).StartCoroutine(SaveUICellTABS_Start_Delay(self));
			orig(self);
		}

		private IEnumerator SaveUICellTABS_Start_Delay(SaveUICellTABS self)
		{
			yield return null;
			GridLayoutGroup gridLayoutGroup = ((Component)self).gameObject.AddComponent<GridLayoutGroup>();
			gridLayoutGroup.cellSize = new Vector2(310f, 150f);
			((LayoutGroup)gridLayoutGroup).childAlignment = (TextAnchor)4;
			gridLayoutGroup.spacing = new Vector2(10f, 10f);
			for (int i = 0; i < 20; i++)
			{
				SaveUICell saveCell = ((Component)((Component)((Component)self).transform.GetChild(i)).transform).GetComponent<SaveUICell>();
				((TMP_Text)((Component)((Component)saveCell).transform.Find("Text (TMP)")).GetComponent<TextMeshProUGUI>()).text = $"SAVE {i + 1}";
				saveCell.m_deleteButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(135f, 55f);
				((TMP_Text)saveCell.dateText).rectTransform.anchoredPosition = new Vector2(-9.5f, 30f);
				((TMP_Text)saveCell.dayText).rectTransform.anchoredPosition = new Vector2(-9.5f, -5f);
				((TMP_Text)saveCell.moneyText).rectTransform.anchoredPosition = new Vector2(-9.5f, -35f);
				((TMP_Text)saveCell.dayText).fontSize = 28f;
				((TMP_Text)saveCell.moneyText).fontSize = 28f;
				((TMP_Text)saveCell.m_emtpySave.GetComponent<TextMeshProUGUI>()).fontSize = 28f;
			}
		}

		private void IL_SaveSystem_LoadSavesFromDisk(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.Index = 4;
			val.EmitDelegate<Action>((Action)delegate
			{
				SaveSystem.SavesOnFile = (Save[])(object)new Save[20];
			});
		}
	}
}