Decompiled source of Timestamp Texts v1.1.0

Release/AltMono-TimestampTexts.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using ScheduleOne.Audio;
using ScheduleOne.DevUtilities;
using ScheduleOne.GameTime;
using ScheduleOne.Messaging;
using ScheduleOne.NPCs;
using ScheduleOne.PlayerScripts;
using ScheduleOne.UI.Phone.Messages;
using Timestamp;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(TimestampTexts), "Timestamp Texts", "1.0.0", "GuysWeForgotDre", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("Timestamp")]
[assembly: AssemblyDescription("Adds timestamp and day label to text messages in Schedule One")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Timestamp")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cc60df14-d512-4596-a069-db9075541120")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Timestamp;

[HarmonyPatch(typeof(Player), "SleepStart")]
public class SleepStartPatch
{
	private static void Prefix()
	{
		TimestampTexts.DaySent.Clear();
	}
}
[HarmonyPatch(typeof(Player), "SleepEnd")]
public class SleepEndPatch
{
	private static void Postfix()
	{
		foreach (MSGConversation activeConversation in MessagesApp.ActiveConversations)
		{
			if (activeConversation != null && activeConversation.messageHistory.Count > 0)
			{
				Message val = TimestampTexts.CreateDayName(activeConversation.contactName);
				if (val != null)
				{
					activeConversation.SendMessage(val, false, false);
				}
			}
		}
	}
}
[HarmonyPatch(typeof(MSGConversation), "SendMessage")]
public class SendMessagePatch
{
	private static void Prefix(Message message, bool notify = true, bool network = true)
	{
		if (message != null)
		{
			message.text = TimestampTexts.SetTimestamp(message);
		}
	}
}
[HarmonyPatch(typeof(MSGConversation), "SendMessageChain")]
public class SendMessageChainPatch
{
	private static void Prefix(MessageChain messages, float initialDelay = 0f, bool notify = true, bool network = true)
	{
		for (int i = 0; i < messages.Messages.Count; i++)
		{
			messages.Messages[i] = TimestampTexts.SetTimestamp(messages.Messages[i], (ESenderType)1);
		}
	}
}
[HarmonyPatch(typeof(MSGConversation), "MoveToTop")]
public class MoveToTopPatch
{
	private static bool Prefix(MSGConversation __instance)
	{
		object obj;
		if (__instance == null)
		{
			obj = null;
		}
		else
		{
			NPC sender = __instance.sender;
			obj = ((sender != null) ? sender.fullName : null);
		}
		if (obj == null)
		{
			obj = null;
		}
		string text = (string)obj;
		if (string.IsNullOrEmpty(text) || !TimestampTexts.BlockMove.TryGetValue(text, out var _))
		{
			return true;
		}
		TimestampTexts.BlockMove.Remove(text);
		return false;
	}
}
[HarmonyPatch(typeof(MSGConversation), "RefreshPreviewText")]
public class MSGConversationRefreshPreviewTextPatch
{
	private static void Postfix(MSGConversation __instance)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (__instance == null || __instance.bubbles == null || __instance.bubbles.Count == 0)
		{
			return;
		}
		EDay currentDay = NetworkSingleton<TimeManager>.Instance.CurrentDay;
		string value = ((object)(EDay)(ref currentDay)).ToString();
		int count = __instance.bubbles.Count;
		FieldInfo fieldInfo = AccessTools.Field(typeof(MSGConversation), "entryPreviewText");
		if (fieldInfo != null && count > 1)
		{
			object? value2 = fieldInfo.GetValue(__instance);
			Text val = (Text)((value2 is Text) ? value2 : null);
			if (val != null && val.text.StartsWith(value))
			{
				val.text = __instance.bubbles[count - 2].text;
			}
		}
	}
}
public class TimestampTexts : MelonMod
{
	[CompilerGenerated]
	private sealed class <RestoreSoundLater>d__107 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AudioSourceController sound;

		public float volume;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RestoreSoundLater>d__107(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSecondsRealtime(0.1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				sound.VolumeMultiplier = volume;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static HashSet<string> DaySent = new HashSet<string>();

	public static HashSet<string> BlockMove = new HashSet<string>();

	private const string Filepath = "UserData/TimestampMono.cfg";

	public const string Grey = "666666";

	public const string Default = "666666";

	public static MelonPreferences_Category DisplayPrefs { get; private set; }

	public static MelonPreferences_Category SentTextPrefs { get; private set; }

	public static MelonPreferences_Category RcvdTextPrefs { get; private set; }

	public static MelonPreferences_Entry<bool> ShowSentPref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowRcvdPref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowDayNamePref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowDayNumPref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowAmPmPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentItalicsPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentIsSizedPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentIsColorPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentBracketPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentPrefixPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentNewlinePref { get; private set; }

	public static MelonPreferences_Entry<int> SentSizePref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdItalicsPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdIsSizedPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdIsColorPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdBracketPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdPrefixPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdNewlinePref { get; private set; }

	public static MelonPreferences_Entry<int> RcvdSizePref { get; private set; }

	public static MelonPreferences_Entry<string> SentColorPref { get; private set; }

	public static MelonPreferences_Entry<string> RcvdColorPref { get; private set; }

	public override void OnInitializeMelon()
	{
		InitializeSettings();
	}

	public static void InitializeSettings()
	{
		DisplayPrefs = MelonPreferences.CreateCategory("TimestampTexts_Pref", "Display Options");
		SentTextPrefs = MelonPreferences.CreateCategory("TimestampTexts_Sent", "Sent Texts");
		RcvdTextPrefs = MelonPreferences.CreateCategory("TimestampTexts_Rcvd", "Received Texts");
		DisplayPrefs.SetFilePath("UserData/TimestampMono.cfg");
		SentTextPrefs.SetFilePath("UserData/TimestampMono.cfg");
		RcvdTextPrefs.SetFilePath("UserData/TimestampMono.cfg");
		ShowSentPref = DisplayPrefs.CreateEntry<bool>("Pref1ShowSent", true, "Timestamp Sent Messages?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowRcvdPref = DisplayPrefs.CreateEntry<bool>("Pref2ShowRcvd", true, "Timestamp Received Messages?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowAmPmPref = DisplayPrefs.CreateEntry<bool>("Pref3ShowAmPm", true, "Include AM / PM Label?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowDayNamePref = DisplayPrefs.CreateEntry<bool>("Pref4ShowDay", true, "Show Day Name?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowDayNumPref = DisplayPrefs.CreateEntry<bool>("Pref5ShowDate", true, "Include Day Number?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentIsSizedPref = SentTextPrefs.CreateEntry<bool>("Sent1IsSized", true, "Change Text Size?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentSizePref = SentTextPrefs.CreateEntry<int>("Sent2Size", 28, "Timestamp Text Size:", (string)null, false, false, (ValueValidator)null, (string)null);
		SentIsColorPref = SentTextPrefs.CreateEntry<bool>("Sent3IsColor", true, "Use Color?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentColorPref = SentTextPrefs.CreateEntry<string>("Sent4Color", "666666", "Timestamp Text Color:", (string)null, false, false, (ValueValidator)null, (string)null);
		SentItalicsPref = SentTextPrefs.CreateEntry<bool>("Sent5Italics", true, "Use Italics?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentBracketPref = SentTextPrefs.CreateEntry<bool>("Sent6Bracket", false, "Put in Brackets?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentPrefixPref = SentTextPrefs.CreateEntry<bool>("Sent7Prefix", false, "Time before Message? (False for after)", (string)null, false, false, (ValueValidator)null, (string)null);
		SentNewlinePref = SentTextPrefs.CreateEntry<bool>("Sent8Newline", true, "Timestamp on Separate Line?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdIsSizedPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd1IsSized", true, "Change Text Size?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdSizePref = RcvdTextPrefs.CreateEntry<int>("Rcvd2Size", 28, "Timestamp Text Size:", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdIsColorPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd3IsColor", true, "Use Color?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdColorPref = RcvdTextPrefs.CreateEntry<string>("Rcvd4Color", "666666", "Timestamp Text Color:", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdItalicsPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd5Italics", true, "Use Italics?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdBracketPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd6Bracket", false, "Put in Brackets?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdPrefixPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd7Prefix", false, "Time before Message? (False for after)", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdNewlinePref = RcvdTextPrefs.CreateEntry<bool>("Rcvd8Newline", true, "Timestamp on Separate Line?", (string)null, false, false, (ValueValidator)null, (string)null);
		((MelonPreferences_Entry)ShowSentPref).Comment = "Show Timestamp on sent messages when True (default true)";
		((MelonPreferences_Entry)ShowRcvdPref).Comment = "Show Timestamp on received messages when True (default true)";
		((MelonPreferences_Entry)ShowAmPmPref).Comment = "Show AM or PM after Timestamp when True (default true)";
		((MelonPreferences_Entry)ShowDayNamePref).Comment = "Show name of each day e.g. \"Tuesday\" as the first text of each conversation (default true)";
		((MelonPreferences_Entry)ShowDayNumPref).Comment = "Include day number (running count of days in current save) (default true)";
		((MelonPreferences_Entry)SentIsSizedPref).Comment = "Change size of sent Timestamp (set False to use default text message size) (default true)";
		((MelonPreferences_Entry)SentSizePref).Comment = "Custom font size for sent Timestamp, adjust to preference (default 28)";
		((MelonPreferences_Entry)SentIsColorPref).Comment = "Change color of sent Timestamp (set False to use default text message color) (default true)";
		((MelonPreferences_Entry)SentColorPref).Comment = "Custom color for sent Tiemstamp, adjust to preference (default 666666)";
		((MelonPreferences_Entry)SentItalicsPref).Comment = "Show sent Timestamp in Italics (default true)";
		((MelonPreferences_Entry)SentBracketPref).Comment = "Show sent Timestamp in [brackets] (default false)";
		((MelonPreferences_Entry)SentPrefixPref).Comment = "Show Timestamp before sent message if True, after message if False (default false)";
		((MelonPreferences_Entry)SentNewlinePref).Comment = "Show Timestamp on separate line from sent message if True, inline if False (default true)";
		((MelonPreferences_Entry)RcvdIsSizedPref).Comment = "Change size of received Timestamp (set False to use default text message size) (default true)";
		((MelonPreferences_Entry)RcvdSizePref).Comment = "Custom font size for received Timestamp, adjust to preference (default 28)";
		((MelonPreferences_Entry)RcvdIsColorPref).Comment = "Change color of received Timestamp (set False to use default text message color) (default true)";
		((MelonPreferences_Entry)RcvdColorPref).Comment = "Custom color for received Tiemstamp, adjust to preference (default 666666)";
		((MelonPreferences_Entry)RcvdItalicsPref).Comment = "Show received Timestamp in Italics (default true)";
		((MelonPreferences_Entry)RcvdBracketPref).Comment = "Show received Timestamp in [brackets] (default false)";
		((MelonPreferences_Entry)RcvdPrefixPref).Comment = "Show Timestamp before received message if True, after message if False (default false)";
		((MelonPreferences_Entry)RcvdNewlinePref).Comment = "Show Timestamp on separate line from received message if True, inline if False (default true)";
	}

	public static string SetTimestamp(Message message)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return SetTimestamp(message.text, message.sender);
	}

	public static string SetTimestamp(string message, ESenderType sender)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		bool flag = (int)sender == 0;
		bool num = (flag ? ShowSentPref.Value : ShowRcvdPref.Value);
		string text = TimeManager.Get12HourTime((float)NetworkSingleton<TimeManager>.Instance.CurrentTime, ShowAmPmPref.Value);
		EDay currentDay = NetworkSingleton<TimeManager>.Instance.CurrentDay;
		string value = ((object)(EDay)(ref currentDay)).ToString();
		if (!num || message.Contains(value) || message.Contains(text))
		{
			return message;
		}
		bool flag2 = (flag ? SentPrefixPref.Value : RcvdPrefixPref.Value);
		bool flag3 = (flag ? SentNewlinePref.Value : RcvdNewlinePref.Value);
		bool num2 = (flag ? SentItalicsPref.Value : RcvdItalicsPref.Value);
		bool flag4 = (flag ? SentIsSizedPref.Value : RcvdIsSizedPref.Value);
		bool flag5 = (flag ? SentIsColorPref.Value : RcvdIsColorPref.Value);
		bool num3 = (flag ? SentBracketPref.Value : RcvdBracketPref.Value);
		int num4 = (flag ? SentSizePref.Value : RcvdSizePref.Value);
		string text2 = "#" + (flag ? SentColorPref.Value : RcvdColorPref.Value);
		if (num3)
		{
			text = "[" + text + "]";
		}
		if (num2)
		{
			text = "<i>" + text + "</i>";
		}
		if (flag4)
		{
			text = $"<size={num4}>{text}</size>";
		}
		if (flag5)
		{
			text = "<color=" + text2 + ">" + text + "</color>";
		}
		string text3 = (flag3 ? "\n" : " ");
		message = (flag2 ? (text + text3 + message) : (message + text3 + text));
		return message;
	}

	public static Message CreateDayName(string contact)
	{
		//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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		bool value = ShowDayNamePref.Value;
		string actualValue;
		bool flag = DaySent.TryGetValue(contact, out actualValue);
		if (!value || flag)
		{
			return null;
		}
		EDay currentDay = NetworkSingleton<TimeManager>.Instance.CurrentDay;
		string text = ((object)(EDay)(ref currentDay)).ToString();
		if (ShowDayNumPref.Value)
		{
			text = text + ", Day " + NetworkSingleton<TimeManager>.Instance.ElapsedDays;
		}
		DaySent.Add(contact);
		BlockMove.Add(contact);
		SilenceMessage();
		return new Message(text, (ESenderType)1, false, -1);
	}

	public static void SilenceMessage()
	{
		AudioSourceController val = PlayerSingleton<MessagesApp>.Instance?.MessageReceivedSound ?? null;
		if (val != null)
		{
			float volumeMultiplier = val.VolumeMultiplier;
			val.VolumeMultiplier = 0f;
			MelonCoroutines.Start(RestoreSoundLater(val, volumeMultiplier));
		}
	}

	[IteratorStateMachine(typeof(<RestoreSoundLater>d__107))]
	private static IEnumerator RestoreSoundLater(AudioSourceController sound, float volume)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RestoreSoundLater>d__107(0)
		{
			sound = sound,
			volume = volume
		};
	}
}

Release/MainIl2Cpp-TimestampTexts.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppScheduleOne.Audio;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.GameTime;
using Il2CppScheduleOne.Messaging;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.UI.Phone.Messages;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using Timestamp;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(TimestampTexts), "Timestamp Texts", "1.0.0", "GuysWeForgotDre", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("Timestamp")]
[assembly: AssemblyDescription("Adds timestamp and day label to text messages in Schedule One")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Timestamp")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cc60df14-d512-4596-a069-db9075541120")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Timestamp;

[HarmonyPatch(typeof(Player), "SleepStart")]
public class SleepStartPatch
{
	private static void Prefix()
	{
		TimestampTexts.DaySent.Clear();
	}
}
[HarmonyPatch(typeof(Player), "SleepEnd")]
public class SleepEndPatch
{
	private static void Postfix()
	{
		Enumerator<MSGConversation> enumerator = MessagesApp.ActiveConversations.GetEnumerator();
		while (enumerator.MoveNext())
		{
			MSGConversation current = enumerator.Current;
			if (current != null && current.messageHistory.Count > 0)
			{
				Message val = TimestampTexts.CreateDayName(current.contactName);
				if (val != null)
				{
					current.SendMessage(val, false, false);
				}
			}
		}
	}
}
[HarmonyPatch(typeof(MSGConversation), "SendMessage")]
public class SendMessagePatch
{
	private static void Prefix(Message message, bool notify = true, bool network = true)
	{
		if (message != null)
		{
			message.text = TimestampTexts.SetTimestamp(message);
		}
	}
}
[HarmonyPatch(typeof(MSGConversation), "SendMessageChain")]
public class SendMessageChainPatch
{
	private static void Prefix(MessageChain messages, float initialDelay = 0f, bool notify = true, bool network = true)
	{
		for (int i = 0; i < messages.Messages.Count; i++)
		{
			messages.Messages[i] = TimestampTexts.SetTimestamp(messages.Messages[i], (ESenderType)1);
		}
	}
}
[HarmonyPatch(typeof(MSGConversation), "MoveToTop")]
public class MoveToTopPatch
{
	private static bool Prefix(MSGConversation __instance)
	{
		object obj;
		if (__instance == null)
		{
			obj = null;
		}
		else
		{
			NPC sender = __instance.sender;
			obj = ((sender != null) ? sender.fullName : null);
		}
		if (obj == null)
		{
			obj = null;
		}
		string text = (string)obj;
		if (string.IsNullOrEmpty(text) || !TimestampTexts.BlockMove.TryGetValue(text, out var _))
		{
			return true;
		}
		TimestampTexts.BlockMove.Remove(text);
		return false;
	}
}
[HarmonyPatch(typeof(MSGConversation), "RefreshPreviewText")]
public class MSGConversationRefreshPreviewTextPatch
{
	private static void Postfix(MSGConversation __instance)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (__instance != null && __instance.bubbles != null && __instance.bubbles.Count != 0)
		{
			EDay currentDay = NetworkSingleton<TimeManager>.Instance.CurrentDay;
			string value = ((object)(EDay)(ref currentDay)).ToString();
			int count = __instance.bubbles.Count;
			if (count > 1 && __instance.entryPreviewText.text.StartsWith(value))
			{
				__instance.entryPreviewText.text = __instance.bubbles[count - 2].text;
			}
		}
	}
}
public class TimestampTexts : MelonMod
{
	[CompilerGenerated]
	private sealed class <RestoreSoundLater>d__107 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AudioSourceController sound;

		public float volume;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RestoreSoundLater>d__107(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSecondsRealtime(0.1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				sound.VolumeMultiplier = volume;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static HashSet<string> DaySent = new HashSet<string>();

	public static HashSet<string> BlockMove = new HashSet<string>();

	private const string Filepath = "UserData/TimestampIl2Cpp.cfg";

	public static readonly Color Grey = new Color(0.4f, 0.4f, 0.4f);

	public static readonly string Default = $"[ {Mathf.Round(Grey.r * 255f)}.0, {Mathf.Round(Grey.g * 255f)}.0, {Mathf.Round(Grey.b * 2550f)}.0, 255.0, ]";

	public static MelonPreferences_Category DisplayPrefs { get; private set; }

	public static MelonPreferences_Category SentTextPrefs { get; private set; }

	public static MelonPreferences_Category RcvdTextPrefs { get; private set; }

	public static MelonPreferences_Entry<bool> ShowSentPref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowRcvdPref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowDayNamePref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowDayNumPref { get; private set; }

	public static MelonPreferences_Entry<bool> ShowAmPmPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentItalicsPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentIsSizedPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentIsColorPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentBracketPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentPrefixPref { get; private set; }

	public static MelonPreferences_Entry<bool> SentNewlinePref { get; private set; }

	public static MelonPreferences_Entry<int> SentSizePref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdItalicsPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdIsSizedPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdIsColorPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdBracketPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdPrefixPref { get; private set; }

	public static MelonPreferences_Entry<bool> RcvdNewlinePref { get; private set; }

	public static MelonPreferences_Entry<int> RcvdSizePref { get; private set; }

	public static MelonPreferences_Entry<Color> SentColorPref { get; private set; }

	public static MelonPreferences_Entry<Color> RcvdColorPref { get; private set; }

	public override void OnInitializeMelon()
	{
		InitializeSettings();
	}

	public static void InitializeSettings()
	{
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		DisplayPrefs = MelonPreferences.CreateCategory("TimestampTexts_Pref", "Display Options");
		SentTextPrefs = MelonPreferences.CreateCategory("TimestampTexts_Sent", "Sent Texts");
		RcvdTextPrefs = MelonPreferences.CreateCategory("TimestampTexts_Rcvd", "Received Texts");
		DisplayPrefs.SetFilePath("UserData/TimestampIl2Cpp.cfg");
		SentTextPrefs.SetFilePath("UserData/TimestampIl2Cpp.cfg");
		RcvdTextPrefs.SetFilePath("UserData/TimestampIl2Cpp.cfg");
		ShowSentPref = DisplayPrefs.CreateEntry<bool>("Pref1ShowSent", true, "Timestamp Sent Messages?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowRcvdPref = DisplayPrefs.CreateEntry<bool>("Pref2ShowRcvd", true, "Timestamp Received Messages?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowAmPmPref = DisplayPrefs.CreateEntry<bool>("Pref3ShowAmPm", true, "Include AM / PM Label?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowDayNamePref = DisplayPrefs.CreateEntry<bool>("Pref4ShowDay", true, "Show Day Name?", (string)null, false, false, (ValueValidator)null, (string)null);
		ShowDayNumPref = DisplayPrefs.CreateEntry<bool>("Pref5ShowDate", true, "Include Day Number?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentIsSizedPref = SentTextPrefs.CreateEntry<bool>("Sent1IsSized", true, "Change Text Size?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentSizePref = SentTextPrefs.CreateEntry<int>("Sent2Size", 28, "Timestamp Text Size:", (string)null, false, false, (ValueValidator)null, (string)null);
		SentIsColorPref = SentTextPrefs.CreateEntry<bool>("Sent3IsColor", true, "Use Color?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentColorPref = SentTextPrefs.CreateEntry<Color>("Sent4Color", Grey, "Timestamp Text Color:", (string)null, false, false, (ValueValidator)null, (string)null);
		SentItalicsPref = SentTextPrefs.CreateEntry<bool>("Sent5Italics", true, "Use Italics?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentBracketPref = SentTextPrefs.CreateEntry<bool>("Sent6Bracket", false, "Put in Brackets?", (string)null, false, false, (ValueValidator)null, (string)null);
		SentPrefixPref = SentTextPrefs.CreateEntry<bool>("Sent7Prefix", false, "Time before Message? (False for after)", (string)null, false, false, (ValueValidator)null, (string)null);
		SentNewlinePref = SentTextPrefs.CreateEntry<bool>("Sent8Newline", true, "Timestamp on Separate Line?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdIsSizedPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd1IsSized", true, "Change Text Size?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdSizePref = RcvdTextPrefs.CreateEntry<int>("Rcvd2Size", 28, "Timestamp Text Size:", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdIsColorPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd3IsColor", true, "Use Color?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdColorPref = RcvdTextPrefs.CreateEntry<Color>("Rcvd4Color", Grey, "Timestamp Text Color:", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdItalicsPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd5Italics", true, "Use Italics?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdBracketPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd6Bracket", false, "Put in Brackets?", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdPrefixPref = RcvdTextPrefs.CreateEntry<bool>("Rcvd7Prefix", false, "Time before Message? (False for after)", (string)null, false, false, (ValueValidator)null, (string)null);
		RcvdNewlinePref = RcvdTextPrefs.CreateEntry<bool>("Rcvd8Newline", true, "Timestamp on Separate Line?", (string)null, false, false, (ValueValidator)null, (string)null);
		((MelonPreferences_Entry)ShowSentPref).Comment = "Show Timestamp on sent messages when True (default true)";
		((MelonPreferences_Entry)ShowRcvdPref).Comment = "Show Timestamp on received messages when True (default true)";
		((MelonPreferences_Entry)ShowAmPmPref).Comment = "Show AM or PM after Timestamp when True (default true)";
		((MelonPreferences_Entry)ShowDayNamePref).Comment = "Show name of each day e.g. \"Tuesday\" as the first text of each conversation (default true)";
		((MelonPreferences_Entry)ShowDayNumPref).Comment = "Include day number (running count of days in current save) (default true)";
		((MelonPreferences_Entry)SentIsSizedPref).Comment = "Change size of sent Timestamp (set False to use default text message size) (default true)";
		((MelonPreferences_Entry)SentSizePref).Comment = "Custom font size for sent Timestamp, adjust to preference (default 28)";
		((MelonPreferences_Entry)SentIsColorPref).Comment = "Change color of sent Timestamp (set False to use default text message color) (default true)";
		((MelonPreferences_Entry)SentColorPref).Comment = "Custom color for sent Tiemstamp, adjust to preference (default " + Default + ")";
		((MelonPreferences_Entry)SentItalicsPref).Comment = "Show sent Timestamp in Italics (default true)";
		((MelonPreferences_Entry)SentBracketPref).Comment = "Show sent Timestamp in [brackets] (default false)";
		((MelonPreferences_Entry)SentPrefixPref).Comment = "Show Timestamp before sent message if True, after message if False (default false)";
		((MelonPreferences_Entry)SentNewlinePref).Comment = "Show Timestamp on separate line from sent message if True, inline if False (default true)";
		((MelonPreferences_Entry)RcvdIsSizedPref).Comment = "Change size of received Timestamp (set False to use default text message size) (default true)";
		((MelonPreferences_Entry)RcvdSizePref).Comment = "Custom font size for received Timestamp, adjust to preference (default 28)";
		((MelonPreferences_Entry)RcvdIsColorPref).Comment = "Change color of received Timestamp (set False to use default text message color) (default true)";
		((MelonPreferences_Entry)RcvdColorPref).Comment = "Custom color for received Tiemstamp, adjust to preference (default " + Default + ")";
		((MelonPreferences_Entry)RcvdItalicsPref).Comment = "Show received Timestamp in Italics (default true)";
		((MelonPreferences_Entry)RcvdBracketPref).Comment = "Show received Timestamp in [brackets] (default false)";
		((MelonPreferences_Entry)RcvdPrefixPref).Comment = "Show Timestamp before received message if True, after message if False (default false)";
		((MelonPreferences_Entry)RcvdNewlinePref).Comment = "Show Timestamp on separate line from received message if True, inline if False (default true)";
	}

	public static string SetTimestamp(Message message)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return SetTimestamp(message.text, message.sender);
	}

	public static string SetTimestamp(string message, ESenderType sender)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		bool flag = (int)sender == 0;
		bool num = (flag ? ShowSentPref.Value : ShowRcvdPref.Value);
		string text = TimeManager.Get12HourTime((float)NetworkSingleton<TimeManager>.Instance.CurrentTime, ShowAmPmPref.Value);
		EDay currentDay = NetworkSingleton<TimeManager>.Instance.CurrentDay;
		string value = ((object)(EDay)(ref currentDay)).ToString();
		if (!num || message.Contains(value) || message.Contains(text))
		{
			return message;
		}
		bool flag2 = (flag ? SentPrefixPref.Value : RcvdPrefixPref.Value);
		bool flag3 = (flag ? SentNewlinePref.Value : RcvdNewlinePref.Value);
		bool flag4 = (flag ? SentItalicsPref.Value : RcvdItalicsPref.Value);
		bool flag5 = (flag ? SentIsSizedPref.Value : RcvdIsSizedPref.Value);
		bool flag6 = (flag ? SentIsColorPref.Value : RcvdIsColorPref.Value);
		bool flag7 = (flag ? SentBracketPref.Value : RcvdBracketPref.Value);
		int num2 = (flag ? SentSizePref.Value : RcvdSizePref.Value);
		Color val = (flag ? SentColorPref.Value : RcvdColorPref.Value);
		string text2 = "#" + ColorUtility.ToHtmlStringRGB(val);
		if (flag7)
		{
			text = "[" + text + "]";
		}
		if (flag4)
		{
			text = "<i>" + text + "</i>";
		}
		if (flag5)
		{
			text = $"<size={num2}>{text}</size>";
		}
		if (flag6)
		{
			text = "<color=" + text2 + ">" + text + "</color>";
		}
		string text3 = (flag3 ? "\n" : " ");
		message = (flag2 ? (text + text3 + message) : (message + text3 + text));
		return message;
	}

	public static Message CreateDayName(string contact)
	{
		//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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		bool value = ShowDayNamePref.Value;
		string actualValue;
		bool flag = DaySent.TryGetValue(contact, out actualValue);
		if (!value || flag)
		{
			return null;
		}
		EDay currentDay = NetworkSingleton<TimeManager>.Instance.CurrentDay;
		string text = ((object)(EDay)(ref currentDay)).ToString();
		if (ShowDayNumPref.Value)
		{
			text = text + ", Day " + NetworkSingleton<TimeManager>.Instance.ElapsedDays;
		}
		DaySent.Add(contact);
		BlockMove.Add(contact);
		SilenceMessage();
		return new Message(text, (ESenderType)1, false, -1);
	}

	public static void SilenceMessage()
	{
		MessagesApp instance = PlayerSingleton<MessagesApp>.Instance;
		AudioSourceController val = ((instance != null) ? instance.MessageReceivedSound : null) ?? null;
		if (val != null)
		{
			float volumeMultiplier = val.VolumeMultiplier;
			val.VolumeMultiplier = 0f;
			MelonCoroutines.Start(RestoreSoundLater(val, volumeMultiplier));
		}
	}

	[IteratorStateMachine(typeof(<RestoreSoundLater>d__107))]
	private static IEnumerator RestoreSoundLater(AudioSourceController sound, float volume)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RestoreSoundLater>d__107(0)
		{
			sound = sound,
			volume = volume
		};
	}
}