using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PurrNet;
using SimpleQOL.patches;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("tinyplume.SimpleQOL")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+821d00d86214a0823dde614b8257f95041fed24a")]
[assembly: AssemblyProduct("tinyplume.SimpleQOL")]
[assembly: AssemblyTitle("tinyplume.SimpleQOL")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 SimpleQOL
{
[BepInPlugin("tinyplume.SimpleQOL", "Simple QoL", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "tinyplume.SimpleQOL";
public const string modName = "Simple QoL";
public const string modVersion = "1.0.0.0";
private Harmony harmony = new Harmony("tinyplume.SimpleQOL");
public ManualLogSource mls = Logger.CreateLogSource("tinyplume.SimpleQOL");
public static ConfigEntry<bool> configUseTimeStamps { get; private set; }
public static ConfigEntry<bool> configUse24HourTime { get; private set; }
public static ConfigEntry<int> configTimestampSize { get; private set; }
public static ConfigEntry<string> configTimestampColor { get; private set; }
public static ConfigEntry<bool> configLeaveMessages { get; private set; }
private void Awake()
{
harmony.PatchAll(typeof(TextPatcher));
harmony.PatchAll(typeof(PlayerLeftPatch));
harmony.PatchAll(typeof(InputFieldPatch));
configUseTimeStamps = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseTimestamps", true, "Whether to use timestamps in chat.");
configUse24HourTime = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use24HourTime", true, "Whether to use the 24-hour time format (true) or 12-hour format (false).");
configTimestampSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "TimestampSize", 60, "The size percentage of the timestamps (e.g. 60 for 60%).");
configTimestampColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TimestampColor", "F5EDE1", "The hex color code for the timestamps.");
configLeaveMessages = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LeaveMessages", true, "Enable or disable on-leave notifications.");
mls.LogInfo((object)"Simple QoL loaded");
}
}
}
namespace SimpleQOL.patches
{
[HarmonyPatch(typeof(TMP_InputField))]
public class InputFieldPatch
{
[HarmonyPatch("OnEnable")]
[HarmonyPostfix]
public static void OnEnablePostfix(TMP_InputField __instance)
{
if (((Object)__instance).name == "InputField_SesionName" || ((Object)__instance).name == "InputField_SessionName")
{
__instance.characterLimit = 1500;
}
else if (((Object)__instance).name == "InputField_Name" || ((Object)__instance).name == "InputField_DateOfBirth" || ((Object)__instance).name == "InputField_HoroscopeSign" || ((Object)__instance).name == "InputField_Location" || ((Object)__instance).name == "InputField_AreaOfStudy" || ((Object)__instance).name == "InputField_FavoriteQuote")
{
__instance.characterLimit = 1000;
}
}
}
[HarmonyPatch(typeof(PlayerPanelController))]
internal class PlayerLeftPatch
{
[HarmonyPatch("DespawnHandle")]
[HarmonyPrefix]
public static void PlayerLeftNoti(NetworkTransform netTransform, PlayerPanelController __instance)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < __instance.PlayerSteamIDs.Count; i++)
{
if ((Object)(object)__instance.PlayerTransforms[i] == (Object)(object)netTransform)
{
byte[] name = __instance.IDInfos[i].Name;
if (Plugin.configLeaveMessages.Value)
{
NetworkSingleton<TextChannelManager>.I.AddNotification(Encoding.Unicode.GetString(name) + " has left the server.");
}
break;
}
}
}
}
[HarmonyPatch(typeof(TextChannelManager))]
public class TextPatcher
{
[HarmonyPatch("AddMessageUI")]
[HarmonyPrefix]
public static void MsgUIFix(ref string userName)
{
if (Plugin.configUseTimeStamps.Value)
{
string text = (Plugin.configUse24HourTime.Value ? "HH:mm" : "h:mm tt");
string text2 = $"<size={Plugin.configTimestampSize.Value}%><color=#{Plugin.configTimestampColor.Value}>" + DateTime.Now.ToString(text) + "</color></size> ";
userName = text2 + userName;
}
}
[HarmonyPatch("AddNotification")]
[HarmonyPrefix]
public static void NotifTextPatch(ref string text)
{
if (Plugin.configUseTimeStamps.Value)
{
string text2 = (Plugin.configUse24HourTime.Value ? "HH:mm" : "h:mm tt");
string text3 = $"<size={Plugin.configTimestampSize.Value}%><color=#{Plugin.configTimestampColor.Value}>" + DateTime.Now.ToString(text2) + "</color></size> ";
text = text3 + text;
}
}
}
}