Decompiled source of Alias v1.0.0

Alias.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AskaAlias.Core;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using SSSGame.Localization;
using SSSGame.UI;
using SandSailorStudio.Localization;
using SandSailorStudio.Storage;
using SandSailorStudio.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Alias")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ff069da894ec5c4d75ed5d4c7fe9d210e8c423e1")]
[assembly: AssemblyProduct("Alias")]
[assembly: AssemblyTitle("Alias")]
[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 AskaAlias
{
	[HarmonyPatch]
	internal static class ChangeNameButton
	{
		private const string CloneName = "Alias_ChangeNameButton";

		private static UnityAction _click;

		private static HostTabPage _page;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HostTabPage), "Show")]
		private static void AfterShow(HostTabPage __instance, bool value)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			if (!value)
			{
				return;
			}
			try
			{
				_page = __instance;
				if ((Object)(object)FindButton(__instance) == (Object)null)
				{
					Create(__instance);
				}
				Refresh(__instance);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(35, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Adding the Set Alias button threw: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HostTabPage), "_RefreshPlayButtonState")]
		private static void AfterRefreshPlayButtonState(HostTabPage __instance)
		{
			SafeRefresh(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HostTabPage), "_OnSaveSlotClicked")]
		private static void AfterSaveSlotClicked(HostTabPage __instance)
		{
			SafeRefresh(__instance);
		}

		private static void SafeRefresh(HostTabPage page)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			try
			{
				_page = page;
				Refresh(page);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Updating the Set Alias button threw: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private static void Refresh(HostTabPage page)
		{
			GameObject val = FindButton(page);
			if (!((Object)(object)val == (Object)null))
			{
				bool flag = page.SelectedSessionData != null;
				if (val.activeSelf != flag)
				{
					val.SetActive(flag);
				}
				TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.text = GameLanguage.Text("set_alias");
				}
			}
		}

		private static GameObject FindButton(HostTabPage page)
		{
			Transform val = ((Component)page.playButton).transform.parent.Find("Alias_ChangeNameButton");
			if (!((Object)(object)val == (Object)null))
			{
				return ((Component)val).gameObject;
			}
			return null;
		}

		private static void Create(HostTabPage page)
		{
			Button playButton = page.playButton;
			GameObject val = Object.Instantiate<GameObject>(((Component)playButton).gameObject, ((Component)playButton).transform.parent);
			((Object)val).name = "Alias_ChangeNameButton";
			foreach (LocalizedText componentsInChild in val.GetComponentsInChildren<LocalizedText>(true))
			{
				Object.DestroyImmediate((Object)(object)componentsInChild);
			}
			TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				throw new InvalidOperationException("The cloned Load button has no TMP_Text label.");
			}
			componentInChildren.text = GameLanguage.Text("set_alias");
			Button component = val.GetComponent<Button>();
			UnityEventBase onClick = (UnityEventBase)(object)component.onClick;
			for (int i = 0; i < onClick.GetPersistentEventCount(); i++)
			{
				onClick.SetPersistentListenerState(i, (UnityEventCallState)0);
			}
			((UnityEventBase)component.onClick).RemoveAllListeners();
			if (_click == null)
			{
				_click = DelegateSupport.ConvertDelegate<UnityAction>((Delegate)new Action(OnClick));
			}
			((UnityEvent)component.onClick).AddListener(_click);
			val.transform.SetSiblingIndex(((Component)playButton).transform.GetSiblingIndex() + 1);
			Plugin.Log.LogInfo((object)"Added the Set Alias button to the load screen.");
		}

		private static void OnClick()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			try
			{
				if ((Object)(object)_page == (Object)null)
				{
					Plugin.Log.LogWarning((object)"Set Alias was clicked with no load screen open.");
				}
				else
				{
					ChangeNameDialog.Open(_page);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Opening the Set Alias dialog threw: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}
	}
	internal static class ChangeNameDialog
	{
		private sealed class Pending
		{
			internal HostTabPage Page;

			internal SessionData Session;

			internal string SessionId;

			internal string RealName;

			internal string Folder;

			internal InputFieldHelper Helper;

			internal int OriginalMinCharacters;
		}

		private const string ConfirmCaptionKey = "common.confirm";

		private const string CancelCaptionKey = "common.cancel";

		private const float OpenGraceSeconds = 5f;

		private static Action<ConfirmActionMenu> _confirmHandler;

		private static Action<ConfirmActionMenu> _cancelHandler;

		private static Pending _pending;

		private static Menu _menu;

		private static float _openedAt;

		internal static void Open(HostTabPage page)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Expected O, but got Unknown
			if (IsBusy())
			{
				Plugin.Log.LogInfo((object)"A Set Alias dialog is already open.");
				return;
			}
			SessionData selectedSessionData = page.SelectedSessionData;
			if (selectedSessionData == null)
			{
				Plugin.Log.LogWarning((object)"Set Alias was clicked with no save selected.");
				return;
			}
			SessionMetaData metadata = selectedSessionData.metadata;
			string sessionId = metadata.sessionId;
			string sessionName = metadata.sessionName;
			bool flag = default(bool);
			if (!SaveFolders.TryGet(page.StorageManager, sessionId, out var folder))
			{
				ManualLogSource log = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(64, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No save folder resolves for session ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sessionId);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", so its name cannot change.");
				}
				log.LogWarning(val);
				return;
			}
			MenuManager instance = MenuManager.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Plugin.Log.LogWarning((object)"There is no MenuManager, so the Set Alias dialog cannot open.");
				return;
			}
			InputFieldConfirmActionMenu prefab = instance.GetPrefab<InputFieldConfirmActionMenu>();
			if ((Object)(object)prefab == (Object)null)
			{
				Plugin.Log.LogWarning((object)"MenuManager has no InputFieldConfirmActionMenu prefab, so the Set Alias dialog cannot open.");
				return;
			}
			string text = AliasFile.Read(folder);
			if (_confirmHandler == null)
			{
				_confirmHandler = HandleConfirm;
			}
			if (_cancelHandler == null)
			{
				_cancelHandler = HandleCancel;
			}
			InputFieldConfirmActionMenuParameters val2 = new InputFieldConfirmActionMenuParameters
			{
				Title = GameLanguage.Text("set_alias"),
				Message = GameLanguage.Text("dialog_message"),
				ConfirmMessage = "common.confirm",
				CancelMessage = "common.cancel",
				CloseOnConfirm = true,
				defaultText = AliasRules.InitialText(text, sessionName),
				placeholderText = (sessionName ?? string.Empty),
				characterLimit = 32,
				checkForProfanities = false,
				OnConfirm = DelegateSupport.ConvertDelegate<Action<ConfirmActionMenu>>((Delegate)_confirmHandler),
				OnCancel = DelegateSupport.ConvertDelegate<Action<ConfirmActionMenu>>((Delegate)_cancelHandler)
			};
			Menu val3 = instance.OpenMenuPrefab((Menu)(object)prefab, (MenuParameters)(object)val2);
			if ((Object)(object)val3 == (Object)null)
			{
				Plugin.Log.LogWarning((object)"OpenMenuPrefab returned nothing, so the Set Alias dialog did not open.");
				return;
			}
			InputFieldHelper inputFieldHelper = ((Il2CppObjectBase)val3).TryCast<InputFieldConfirmActionMenu>().InputFieldHelper;
			_pending = new Pending
			{
				Page = page,
				Session = selectedSessionData,
				SessionId = sessionId,
				RealName = sessionName,
				Folder = folder,
				Helper = inputFieldHelper,
				OriginalMinCharacters = inputFieldHelper.MinCharactersCount
			};
			inputFieldHelper.MinCharactersCount = 0;
			_menu = val3;
			_openedAt = Time.unscaledTime;
			ManualLogSource log2 = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(50, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Set Alias opened for session ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(sessionId);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (name '");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(sessionName);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("', alias '");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("').");
			}
			log2.LogInfo(val4);
		}

		private static bool IsBusy()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if ((Object)(object)_menu == (Object)null)
			{
				return false;
			}
			bool flag;
			try
			{
				flag = _menu.IsActive;
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag2 = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(67, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Reading the Set Alias dialog's state threw ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; treating it as closed.");
				}
				log.LogWarning(val);
				flag = false;
			}
			if (flag || Time.unscaledTime - _openedAt < 5f)
			{
				return true;
			}
			Plugin.Log.LogWarning((object)"The Set Alias dialog closed without a confirm or cancel.");
			Forget();
			return false;
		}

		private static void HandleConfirm(ConfirmActionMenu menu)
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			Pending pending = Forget();
			if (pending == null)
			{
				return;
			}
			bool flag = default(bool);
			try
			{
				AliasChange val = AliasRules.Decide(((Il2CppObjectBase)menu).TryCast<InputFieldConfirmActionMenu>().InputFieldHelper.inputField.text, pending.RealName);
				if (((AliasChange)(ref val)).Clears)
				{
					AliasFile.Delete(pending.Folder);
					ManualLogSource log = Plugin.Log;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Session ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(pending.SessionId);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": alias cleared.");
					}
					log.LogInfo(val2);
				}
				else
				{
					AliasFile.Write(pending.Folder, ((AliasChange)(ref val)).Alias);
					ManualLogSource log2 = Plugin.Log;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(26, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Session ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(pending.SessionId);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": alias set to '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((AliasChange)(ref val)).Alias);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
					}
					log2.LogInfo(val2);
				}
				RefreshSlot(pending);
			}
			catch (Exception ex)
			{
				ManualLogSource log3 = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(42, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Applying the new name for session ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(pending.SessionId);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" threw: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				log3.LogError(val3);
			}
		}

		private static void HandleCancel(ConfirmActionMenu menu)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			Pending pending = Forget();
			if (pending != null)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Set Alias cancelled for session ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(pending.SessionId);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				}
				log.LogInfo(val);
			}
		}

		private static Pending Forget()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Pending pending = _pending;
			_pending = null;
			_menu = null;
			if (pending == null)
			{
				return null;
			}
			try
			{
				pending.Helper.MinCharactersCount = pending.OriginalMinCharacters;
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(51, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Restoring the dialog's minimum name length threw ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
			return pending;
		}

		private static void RefreshSlot(Pending pending)
		{
			foreach (SaveSlotPanel componentsInChild in ((Component)pending.Page).GetComponentsInChildren<SaveSlotPanel>())
			{
				if (componentsInChild.sessionID == pending.SessionId)
				{
					componentsInChild.Set(pending.Session.metadata);
				}
			}
		}
	}
	internal static class GameLanguage
	{
		private static bool _logged;

		internal static string Text(string key)
		{
			return Strings.Get(key, Current());
		}

		private static string Current()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				LocalizationManager instance = LocalizationManager.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return null;
				}
				string text = ((object)instance.SystemLanguage/*cast due to .constrained prefix*/).ToString();
				if (!_logged)
				{
					_logged = true;
					ManualLogSource log = Plugin.Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Showing Alias text in the game's language: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
					}
					log.LogInfo(val);
				}
				return text;
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(50, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Reading the game's language threw ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("; using english.");
				}
				log2.LogWarning(val2);
				return null;
			}
		}
	}
	[BepInPlugin("mugsy33.alias", "Alias", "1.0.0")]
	public class Plugin : BasePlugin
	{
		public const string PluginGuid = "mugsy33.alias";

		public const string PluginName = "Alias";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		internal static readonly bool DebugLogging;

		public override void Load()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			Harmony val = new Harmony("mugsy33.alias");
			val.PatchAll(typeof(SlotLabelPatch));
			val.PatchAll(typeof(ChangeNameButton));
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Alias");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.0");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded.");
			}
			log.LogInfo(val2);
		}
	}
	internal static class SaveFolders
	{
		internal static bool TryGet(StorageManager manager, string sessionId, out string folder)
		{
			folder = null;
			if ((Object)(object)manager == (Object)null || string.IsNullOrEmpty(sessionId))
			{
				return false;
			}
			if (manager.TryGetSessionStoragePath(sessionId, ref folder))
			{
				return !string.IsNullOrEmpty(folder);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(SaveSlotPanel), "Set")]
	internal static class SlotLabelPatch
	{
		private static void Postfix(SaveSlotPanel __instance, SessionMetaData metadata)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			try
			{
				ShowAlias(__instance, metadata);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Showing a save's alias threw: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private static void ShowAlias(SaveSlotPanel panel, SessionMetaData metadata)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			string sessionId = metadata.sessionId;
			bool flag = default(bool);
			if (!SaveFolders.TryGet(panel.StorageManager, sessionId, out var folder))
			{
				ManualLogSource log = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(73, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No save folder resolves for session ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sessionId);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; its label stays as the game set it.");
				}
				log.LogWarning(val);
				return;
			}
			string text = AliasFile.Read(folder);
			if (text == null)
			{
				return;
			}
			string sessionName = metadata.sessionName;
			string text2 = ((TMP_Text)panel.NameLabel).text;
			string text3 = SlotLabel.Apply(text2, sessionName, text);
			if (text3 == text2 && text != sessionName)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(89, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Session ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sessionId);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": the label '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' does not start with the save's name '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sessionName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', so the alias is not shown.");
				}
				log2.LogWarning(val);
				return;
			}
			((TMP_Text)panel.NameLabel).text = text3;
			if (Plugin.DebugLogging)
			{
				ManualLogSource log3 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(31, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Session ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(sessionId);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": label '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' shown as '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text3);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
				}
				log3.LogInfo(val2);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Alias";

		public const string PLUGIN_NAME = "Alias";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

Alias.Core.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.Json;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Alias.Core")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ff069da894ec5c4d75ed5d4c7fe9d210e8c423e1")]
[assembly: AssemblyProduct("Alias.Core")]
[assembly: AssemblyTitle("Alias.Core")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 AskaAlias.Core
{
	public readonly record struct AliasChange(string? Alias)
	{
		public bool Clears => Alias == null;
	}
	public static class AliasFile
	{
		public const string FileName = "alias";

		private static readonly char[] LineBreaks = new char[2] { '\r', '\n' };

		private static readonly UTF8Encoding Utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);

		public static string? Read(string saveFolder)
		{
			string path = Path.Combine(saveFolder, "alias");
			if (!File.Exists(path))
			{
				return null;
			}
			string text = File.ReadAllText(path).Trim();
			int num = text.IndexOfAny(LineBreaks);
			if (num >= 0)
			{
				text = text.Substring(0, num).TrimEnd();
			}
			if (text.Length != 0)
			{
				return AliasRules.Cut(text);
			}
			return null;
		}

		public static void Write(string saveFolder, string alias)
		{
			File.WriteAllText(Path.Combine(saveFolder, "alias"), alias, Utf8NoBom);
		}

		public static void Delete(string saveFolder)
		{
			File.Delete(Path.Combine(saveFolder, "alias"));
		}
	}
	public static class AliasRules
	{
		public const int MaxLength = 32;

		public static AliasChange Decide(string? input, string? realName)
		{
			string text = (input ?? string.Empty).Trim();
			return new AliasChange((text.Length == 0 || string.Equals(text, realName, StringComparison.Ordinal)) ? null : Cut(text));
		}

		public static string InitialText(string? alias, string? realName)
		{
			return alias ?? realName ?? string.Empty;
		}

		internal static string Cut(string text)
		{
			if (text.Length <= 32)
			{
				return text;
			}
			return text[..(char.IsHighSurrogate(text[31]) ? 31 : 32)];
		}
	}
	public static class SlotLabel
	{
		public static string Apply(string labelText, string? realName, string? alias)
		{
			string text = realName ?? string.Empty;
			if (string.IsNullOrEmpty(alias) || !labelText.StartsWith(text, StringComparison.Ordinal))
			{
				return labelText;
			}
			return alias + labelText.Substring(text.Length);
		}
	}
	public static class Strings
	{
		public const string SetAlias = "set_alias";

		public const string DialogMessage = "dialog_message";

		public static readonly IReadOnlyList<string> Keys = new string[2] { "set_alias", "dialog_message" };

		public static string Get(string key, string? language)
		{
			return StringTable.Embedded.Get(key, language);
		}
	}
	public sealed class StringTable
	{
		public const string FallbackLanguage = "english";

		public static readonly IReadOnlyList<string> GameLanguages = new string[13]
		{
			"english", "romanian", "german", "spanish", "french", "italian", "japanese", "schinese", "tchinese", "polish",
			"brazilian", "russian", "ukrainian"
		};

		private const string ResourceName = "Alias.Core.Strings.json";

		private static StringTable? _embedded;

		private readonly Dictionary<string, Dictionary<string, string>> _table;

		public static StringTable Embedded => _embedded ?? (_embedded = LoadEmbedded());

		private StringTable(Dictionary<string, Dictionary<string, string>> table)
		{
			_table = table;
		}

		public static StringTable Parse(string json)
		{
			return new StringTable(JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(json) ?? new Dictionary<string, Dictionary<string, string>>());
		}

		public string Get(string key, string? language)
		{
			if (!_table.TryGetValue(key, out Dictionary<string, string> value))
			{
				return key;
			}
			if (language == "englishUS")
			{
				language = "english";
			}
			if (language != null && value.TryGetValue(language, out var value2) && !string.IsNullOrEmpty(value2))
			{
				return value2;
			}
			if (!value.TryGetValue("english", out var value3) || string.IsNullOrEmpty(value3))
			{
				return key;
			}
			return value3;
		}

		public bool Has(string key, string language)
		{
			if (_table.TryGetValue(key, out Dictionary<string, string> value) && value.TryGetValue(language, out var value2))
			{
				return !string.IsNullOrEmpty(value2);
			}
			return false;
		}

		private static StringTable LoadEmbedded()
		{
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Alias.Core.Strings.json");
				if (stream == null)
				{
					return new StringTable(new Dictionary<string, Dictionary<string, string>>());
				}
				using StreamReader streamReader = new StreamReader(stream);
				return Parse(streamReader.ReadToEnd());
			}
			catch (Exception)
			{
				return new StringTable(new Dictionary<string, Dictionary<string, string>>());
			}
		}
	}
}