using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Wren23")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("Wren23")]
[assembly: AssemblyTitle("Wren23")]
[assembly: AssemblyVersion("0.1.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 Wren23
{
[BepInPlugin("sm3gm.wren23", "Readable Notes", "1.0.0")]
public class Plugin : BasePlugin
{
internal const string VER = "1.0.0";
internal static ManualLogSource LogSource;
internal static ConfigEntry<bool> StartClear;
public override void Load()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
LogSource = ((BasePlugin)this).Log;
StartClear = ((BasePlugin)this).Config.Bind<bool>("Text", "StartInClearText", true, "Open notes and documents in the clear text font. The window's own button still switches back to handwriting.");
((BasePlugin)this).AddComponent<ClearTextPresser>();
Harmony.CreateAndPatchAll(typeof(ClearTextByDefault), (string)null);
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Readable Notes ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
}
log.LogInfo(val);
}
}
[HarmonyPatch(typeof(InfoWindow), "Setup")]
internal static class ClearTextByDefault
{
private static void Postfix(InfoWindow __instance)
{
if (Plugin.StartClear.Value)
{
ClearTextPresser.Queue(__instance);
}
}
}
public class ClearTextPresser : MonoBehaviour
{
private const int WaitFrames = 2;
private static readonly List<(InfoWindow window, int frame)> pending = new List<(InfoWindow, int)>();
public ClearTextPresser(IntPtr ptr)
: base(ptr)
{
}
internal static void Queue(InfoWindow w)
{
pending.Add((w, Time.frameCount + 2));
}
private void Update()
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
bool flag = default(bool);
for (int num = pending.Count - 1; num >= 0; num--)
{
var (val, num2) = pending[num];
if (Time.frameCount >= num2)
{
pending.RemoveAt(num);
try
{
if (!((Object)(object)val == (Object)null) && !((Object)(object)val.clearTextButton == (Object)null) && ((Component)val.clearTextButton).gameObject.activeInHierarchy)
{
WindowContentController activeContent = val.activeContent;
if (!((Object)(object)activeContent == (Object)null) && !activeContent.clearTextMode)
{
val.OnClearTextButton();
}
}
}
catch (Exception ex)
{
ManualLogSource logSource = Plugin.LogSource;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(6, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[W23] ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
logSource.LogError(val2);
}
}
}
}
}
}