using System;
using System.Collections.Generic;
using System.Diagnostics;
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.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.6.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreSaveSlots")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreSaveSlots")]
[assembly: AssemblyTitle("MoreSaveSlots")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 MoreSaveSlots
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MoreSaveSlots_AriyTwo6";
public const string PLUGIN_NAME = "MoreSaveSlots";
public const string PLUGIN_VERSION = "1.1.0";
}
[HarmonyPatch(typeof(SaveSlotManager), "PopulateSlots")]
public class Patch_MoreSlots
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("MoreSaveSlots");
private static bool Prefix(SaveSlotManager __instance)
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: 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_0176: Unknown result type (might be due to invalid IL or missing references)
Log.LogInfo((object)"Prefix called");
FieldInfo fieldInfo = AccessTools.Field(typeof(SaveSlotManager), "saveSlots");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(SaveSlotManager), "maxSlots");
FieldInfo fieldInfo3 = AccessTools.Field(typeof(SaveSlotManager), "saveSlotPanel");
int value = Plugin.MaxSlots.Value;
SaveSlotUI[] array = (SaveSlotUI[])fieldInfo.GetValue(__instance);
Log.LogInfo((object)$"existing={array?.Length} desired={value}");
if (array == null || array.Length >= value)
{
return true;
}
GameObject gameObject = ((Component)((Component)array[0]).transform.parent).gameObject;
GameObject val = (GameObject)fieldInfo3.GetValue(__instance);
GameObject val2 = new GameObject("SlotViewport");
val2.transform.SetParent(val.transform, false);
val2.transform.SetAsFirstSibling();
RectTransform val3 = val2.AddComponent<RectTransform>();
val3.anchorMin = Vector2.zero;
val3.anchorMax = Vector2.one;
val3.offsetMin = Vector2.zero;
val3.offsetMax = Vector2.zero;
val2.AddComponent<RectMask2D>();
Image val4 = val2.AddComponent<Image>();
((Graphic)val4).color = new Color(0f, 0f, 0f, 0f);
((Graphic)val4).raycastTarget = true;
gameObject.transform.SetParent(val2.transform, false);
HorizontalLayoutGroup component = gameObject.GetComponent<HorizontalLayoutGroup>();
if ((Object)(object)component != (Object)null)
{
((LayoutGroup)component).padding.left = 60;
((LayoutGroup)component).padding.right = 60;
}
ContentSizeFitter val5 = gameObject.AddComponent<ContentSizeFitter>();
val5.horizontalFit = (FitMode)2;
val5.verticalFit = (FitMode)0;
ScrollRect val6 = val2.AddComponent<ScrollRect>();
val6.content = gameObject.GetComponent<RectTransform>();
val6.horizontal = true;
val6.vertical = false;
val6.movementType = (MovementType)1;
val6.elasticity = 0.1f;
val6.scrollSensitivity = Plugin.ScrollSpeed.Value;
val6.inertia = true;
val6.decelerationRate = 0.135f;
GameObject gameObject2 = ((Component)array[0]).gameObject;
int num = value - array.Length;
List<SaveSlotUI> list = new List<SaveSlotUI>(array);
for (int i = 0; i < num; i++)
{
GameObject val7 = Object.Instantiate<GameObject>(gameObject2, gameObject.transform);
list.Add(val7.GetComponent<SaveSlotUI>());
}
fieldInfo.SetValue(__instance, list.ToArray());
fieldInfo2.SetValue(__instance, value);
Log.LogInfo((object)$"Done: slots={list.Count} maxSlots={value}");
return true;
}
}
[BepInPlugin("MoreSaveSlots_AriyTwo6", "MoreSaveSlots", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
internal static ConfigEntry<int> MaxSlots;
internal static ConfigEntry<float> ScrollSpeed;
private void Awake()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MoreSaveSlots is loading!");
MaxSlots = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxSlots", 6, "How many Save Slots to Show.");
ScrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ScrollSpeed", 20f, "How fast you scroll.");
try
{
Harmony val = new Harmony("MoreSaveSlots_AriyTwo6");
val.PatchAll(Assembly.GetExecutingAssembly());
((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied successfully");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to apply Harmony patches: " + ex.Message));
}
}
}
}