Decompiled source of Preloading Splash v1.0.2

BepInEx/patchers/Preloading_Splash_Preloader.dll

Decompiled 8 hours ago
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Raylib_CsLo;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.PixelFormats;

[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("Preloading_Splash_Preloader")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Preloading_Splash_Preloader")]
[assembly: AssemblyTitle("Preloading_Splash_Preloader")]
[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.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;
		}
	}
}
public static class QADLogger
{
	[Conditional("DEBUG")]
	public static void Log(object message)
	{
		Console.WriteLine(message.ToString());
	}
}
public class SplashWindow
{
	public static float Progress = 0f;

	public static bool Close = false;

	public static bool TestMode = false;

	public static string Message = "Loading...";

	private int _width;

	private int _height;

	private int _fps;

	private bool _showLoadingBar;

	private bool _showLoadingInfo;

	private float _windowScale;

	private float _loadingTextScale;

	public static string ConfigFolderPath => Path.Combine(Paths.ConfigPath, "PreloadingSplash");

	public static string VertexShaderPath => Path.Combine(ConfigFolderPath, "vertex.vs");

	public static string FragmentShaderPath => Path.Combine(ConfigFolderPath, "fragment.fs");

	public static string ConfigPath => Path.Combine(ConfigFolderPath, "Config.txt");

	public static string FontPath => Path.Combine(ConfigFolderPath, "Font.ttf");

	public static string CoversPath => Path.Combine(ConfigFolderPath, "Covers");

	public static bool ForceWait { get; internal set; } = false;

	public static bool IsDone { get; internal set; } = false;

	public bool IsAlive { get; protected set; }

	public bool Loaded { get; protected set; }

	public void RecalculateSize(int imageWidth, int imageHeight)
	{
		int currentMonitor = Raylib.GetCurrentMonitor();
		int monitorWidth = Raylib.GetMonitorWidth(currentMonitor);
		int monitorHeight = Raylib.GetMonitorHeight(currentMonitor);
		float num = (float)monitorWidth / Math.Clamp(imageWidth, 1f, float.MaxValue);
		float num2 = (float)imageWidth * num;
		float num3 = (float)imageHeight * num;
		float num4 = (float)monitorHeight / Math.Clamp(imageHeight, 1f, float.MaxValue);
		float num5 = (float)imageWidth * num4;
		float num6 = (float)imageHeight * num4;
		if (num2 > (float)monitorWidth || num3 > (float)monitorHeight)
		{
			_width = (int)(num2 * _windowScale);
			_height = (int)(num3 * _windowScale);
		}
		else
		{
			_width = (int)(num5 * _windowScale);
			_height = (int)(num6 * _windowScale);
		}
		_width = Math.Clamp(_width, 1, int.MaxValue);
		_height = Math.Clamp(_height, 1, int.MaxValue);
		Raylib.SetWindowSize(_width, _height);
		Vector2 monitorPosition = Raylib.GetMonitorPosition(currentMonitor);
		Raylib.SetWindowPosition((int)(monitorPosition.X + (float)monitorWidth / 2f - (float)_width / 2f), (int)(monitorPosition.Y + (float)monitorHeight / 2f - (float)_height / 2f));
	}

	public unsafe SplashWindow()
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		//IL_0415: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Unknown result type (might be due to invalid IL or missing references)
		//IL_0431: Unknown result type (might be due to invalid IL or missing references)
		//IL_043f: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_04af: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0524: Unknown result type (might be due to invalid IL or missing references)
		//IL_0529: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0654: Unknown result type (might be due to invalid IL or missing references)
		//IL_0659: Unknown result type (might be due to invalid IL or missing references)
		//IL_0682: Unknown result type (might be due to invalid IL or missing references)
		//IL_0662: Unknown result type (might be due to invalid IL or missing references)
		//IL_0669: Unknown result type (might be due to invalid IL or missing references)
		//IL_0735: Unknown result type (might be due to invalid IL or missing references)
		//IL_0742: Unknown result type (might be due to invalid IL or missing references)
		//IL_074f: Unknown result type (might be due to invalid IL or missing references)
		//IL_075c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0769: Unknown result type (might be due to invalid IL or missing references)
		//IL_0776: Unknown result type (might be due to invalid IL or missing references)
		//IL_0783: Unknown result type (might be due to invalid IL or missing references)
		//IL_0790: Unknown result type (might be due to invalid IL or missing references)
		//IL_079d: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_084d: Unknown result type (might be due to invalid IL or missing references)
		//IL_085f: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
		IsAlive = true;
		Loaded = false;
		ValidateConfig();
		string[] array = File.ReadAllLines(ConfigPath);
		if (array.Length < 6)
		{
			SaveConfig();
		}
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i];
			int num = text.IndexOf('#');
			if (num >= 0)
			{
				text = text.Substring(0, num);
			}
			text = text.TrimEnd();
			array[i] = text;
		}
		_fps = int.Parse(array[0]);
		_showLoadingBar = bool.Parse(array[1]);
		_showLoadingInfo = bool.Parse(array[2]);
		_windowScale = Math.Clamp(float.Parse(array[3]), 0.1f, 8f);
		ForceWait = bool.Parse(array[4]);
		_loadingTextScale = float.Parse(array[5]);
		string[] array2 = Directory.EnumerateFiles(CoversPath, "*.*", SearchOption.AllDirectories).ToArray();
		bool flag = false;
		int num2 = 0;
		Texture[] array3 = (Texture[])(object)new Texture[array2.Length];
		for (int j = 0; j < array3.Length; j++)
		{
			Texture val = array3[j];
			val.width = -1;
			array3[j] = val;
		}
		Raylib.InitWindow(1, 1, "Splash");
		Raylib.SetWindowState((ConfigFlags)16);
		Raylib.SetWindowState((ConfigFlags)2048);
		Raylib.SetWindowState((ConfigFlags)8);
		Raylib.SetWindowState((ConfigFlags)256);
		Raylib.SetWindowState((ConfigFlags)4096);
		Raylib.ClearWindowState((ConfigFlags)4096);
		Raylib.SetTargetFPS(1000);
		Raylib.BeginDrawing();
		Raylib.ClearBackground(Raylib.BLANK);
		Raylib.EndDrawing();
		float num3 = 0f;
		Image<Rgba32> rawGif = null;
		float num4 = 0f;
		int num5 = 0;
		int num6 = 0;
		Random random = new Random(DateTimeOffset.Now.ToUnixTimeSeconds().GetHashCode());
		if (array2.Any((string f) => f.EndsWith(".gif", StringComparison.CurrentCultureIgnoreCase)))
		{
			num3 = -1f;
			flag = true;
			List<string> list = new List<string>();
			string[] array4 = array2;
			foreach (string text2 in array4)
			{
				if (text2.EndsWith(".gif", StringComparison.CurrentCultureIgnoreCase))
				{
					list.Add(text2);
				}
			}
			string text3 = list[random.Next(0, list.Count)];
			rawGif = Image.Load<Rgba32>(text3);
			num5 = ((Image)rawGif).Width;
			num6 = ((Image)rawGif).Height;
			num2 = ((ImageFrameCollection)rawGif.Frames).Count;
			Image val2 = Raylib.GenImageColor(num5, num6, Raylib.PURPLE);
			array3[0] = Raylib.LoadTextureFromImage(val2);
			Raylib.UnloadImage(val2);
			RecalculateSize(num5, num6);
		}
		else
		{
			num2 = 1;
			List<string> list2 = new List<string>();
			string[] array4 = array2;
			foreach (string text4 in array4)
			{
				bool num8 = text4.EndsWith(".png", StringComparison.CurrentCultureIgnoreCase);
				bool flag2 = text4.EndsWith(".bmp", StringComparison.CurrentCultureIgnoreCase);
				bool flag3 = text4.EndsWith(".tga", StringComparison.CurrentCultureIgnoreCase);
				bool flag4 = text4.EndsWith(".jpg", StringComparison.CurrentCultureIgnoreCase) | text4.EndsWith(".jpeg", StringComparison.CurrentCultureIgnoreCase);
				if (num8 || flag2 || flag3 || flag4)
				{
					list2.Add(text4);
				}
			}
			if (list2.Count == 0)
			{
				Console.WriteLine("[Preloading Splash] No files!");
				Raylib.CloseWindow();
				return;
			}
			string text5 = list2[random.Next(0, list2.Count)];
			array3[0] = Raylib.LoadTexture(text5);
			_width = Math.Max(array3[0].width, _width);
			_height = Math.Max(array3[0].height, _height);
		}
		Font val3 = Raylib.LoadFont(FontPath);
		Shader val4 = Raylib.LoadShader(VertexShaderPath, FragmentShaderPath);
		int shaderLocation = Raylib.GetShaderLocation(val4, "iCoverFrame");
		int shaderLocation2 = Raylib.GetShaderLocation(val4, "iResolution");
		int shaderLocation3 = Raylib.GetShaderLocation(val4, "iFrame");
		int shaderLocation4 = Raylib.GetShaderLocation(val4, "iFrameDelta");
		int shaderLocation5 = Raylib.GetShaderLocation(val4, "iFrameRate");
		int shaderLocation6 = Raylib.GetShaderLocation(val4, "iTime");
		int shaderLocation7 = Raylib.GetShaderLocation(val4, "iMouse");
		int shaderLocation8 = Raylib.GetShaderLocation(val4, "iDate");
		if (_fps < 1 && !flag)
		{
			num3 = new Random((int)(DateTimeOffset.Now.ToUnixTimeSeconds() / 60)).Next(0, array3.Length);
		}
		if (!flag)
		{
			int num9 = (int)Math.Clamp(num3, 0f, num2 - 1);
			Texture val5 = array3[num9];
			RecalculateSize(val5.width, val5.height);
		}
		int targetFPS = Math.Clamp(_fps, 60, 240);
		Raylib.SetTargetFPS(targetFPS);
		Vector2 vector = default(Vector2);
		int num10 = 0;
		Raylib.ClearWindowState((ConfigFlags)2048);
		if (!TestMode)
		{
			Raylib.SetWindowState((ConfigFlags)4096);
		}
		else
		{
			Raylib.ClearWindowState((ConfigFlags)4096);
		}
		Loaded = true;
		Memory<Rgba32> memory = default(Memory<Rgba32>);
		Rectangle val7 = default(Rectangle);
		Rectangle val8 = default(Rectangle);
		while (!Raylib.WindowShouldClose() && !Close)
		{
			num10++;
			Texture val6 = array3[0];
			if (flag)
			{
				num4 -= Raylib.GetFrameTime();
				if ((int)num3 == -1 || num4 <= 0f)
				{
					num3 += 1f;
					if (num3 > (float)(num2 - 1))
					{
						num3 = 0f;
						IsDone = true;
					}
					num4 = GetGifFrameDelay((int)num3) / 1000f;
					Console.WriteLine(num3);
					Console.WriteLine(num4);
					if (!rawGif.Frames[(int)num3].DangerousTryGetSinglePixelMemory(ref memory))
					{
						num4 = 0f;
						continue;
					}
					using MemoryHandle memoryHandle = memory.Pin();
					Raylib.UpdateTexture(val6, memoryHandle.Pointer);
				}
			}
			else
			{
				IsDone = true;
				int num11;
				int num12;
				if (num2 <= 1)
				{
					num3 = 0f;
					num11 = 0;
					num12 = 0;
				}
				else
				{
					num11 = (int)Math.Clamp(num3, 0f, num2 - 1);
					num3 += Raylib.GetFrameTime() * (float)_fps;
					if (num3 > (float)(num2 - 4))
					{
						IsDone = true;
					}
					if (num3 > (float)num2)
					{
						num3 = 0f;
					}
					num12 = (int)Math.Clamp(num3, 0f, num2 - 1);
				}
				val6 = array3[num12];
				if (num11 != num12)
				{
					RecalculateSize(val6.width, val6.height);
				}
			}
			Raylib.BeginDrawing();
			Raylib.ClearBackground(new Color(0, 0, 0, 255));
			if (Raylib.IsMouseButtonDown((MouseButton)0))
			{
				vector = Raylib.GetMousePosition();
			}
			float num13 = (float)Raylib.GetTime();
			Vector3 vector2 = new Vector3(_width, _height, _width / _height);
			float frameTime = Raylib.GetFrameTime();
			Vector4 vector3 = new Vector4(Raylib.GetMouseX(), Raylib.GetMouseY(), vector.X, vector.Y);
			DateTime now = DateTime.Now;
			Vector4 vector4 = new Vector4(now.Year, now.Month, now.Day, now.Hour * 60 * 60 + now.Minute * 60 + now.Second);
			Raylib.SetShaderValue<float>(val4, shaderLocation, &num3, (ShaderUniformDataType)0);
			Raylib.SetShaderValue<Vector3>(val4, shaderLocation2, &vector2, (ShaderUniformDataType)2);
			Raylib.SetShaderValue<int>(val4, shaderLocation3, &num10, (ShaderUniformDataType)0);
			Raylib.SetShaderValue<float>(val4, shaderLocation4, &frameTime, (ShaderUniformDataType)0);
			Raylib.SetShaderValue<int>(val4, shaderLocation5, &targetFPS, (ShaderUniformDataType)0);
			Raylib.SetShaderValue<float>(val4, shaderLocation6, &num13, (ShaderUniformDataType)0);
			Raylib.SetShaderValue<Vector4>(val4, shaderLocation7, &vector3, (ShaderUniformDataType)3);
			Raylib.SetShaderValue<Vector4>(val4, shaderLocation8, &vector4, (ShaderUniformDataType)3);
			Raylib.BeginShaderMode(val4);
			((Rectangle)(ref val7))..ctor(0f, 0f, (float)val6.width, (float)val6.height);
			((Rectangle)(ref val8))..ctor(0f, 0f, (float)_width, (float)_height);
			Raylib.DrawTexturePro(val6, val7, val8, default(Vector2), 0f, Raylib.WHITE);
			Raylib.EndShaderMode();
			if (_showLoadingBar)
			{
				Raylib.DrawRectangle(0, _height - 12, (int)((float)_width * Math.Clamp(Progress, 0f, 1f)), 12, new Color(255, 255, 255, 255));
			}
			if (_showLoadingInfo)
			{
				Raylib.DrawTextEx(val3, Message, new Vector2(4f, (float)_height - _loadingTextScale - 16f), _loadingTextScale, 1f, new Color(255, 255, 255, 255));
			}
			Raylib.EndDrawing();
		}
		IsAlive = false;
		Raylib.UnloadShader(val4);
		if (flag)
		{
			Raylib.UnloadTexture(array3[0]);
		}
		else
		{
			Texture[] array5 = array3;
			for (int num7 = 0; num7 < array5.Length; num7++)
			{
				Raylib.UnloadTexture(array5[num7]);
			}
		}
		Raylib.CloseWindow();
		float GetGifFrameDelay(int gifFrame)
		{
			return ((ImageFrame)rawGif.Frames[gifFrame]).Metadata.GetFormatMetadata<GifMetadata, GifFrameMetadata>((IImageFormat<GifMetadata, GifFrameMetadata>)(object)GifFormat.Instance).FrameDelay * 10;
		}
	}

	public static void ValidateConfig()
	{
		if (!Directory.Exists(ConfigFolderPath))
		{
			Directory.CreateDirectory(ConfigFolderPath);
		}
		if (!Directory.Exists(CoversPath))
		{
			Directory.CreateDirectory(CoversPath);
		}
		if (Directory.GetFiles(CoversPath).Length == 0)
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Preloading_Splash.0.png");
			using FileStream destination = new FileStream(Path.Combine(CoversPath, "0.png"), FileMode.Create, FileAccess.Write);
			stream?.CopyTo(destination);
		}
		if (!File.Exists(FontPath))
		{
			using Stream stream2 = Assembly.GetExecutingAssembly().GetManifestResourceStream("Preloading_Splash.Font.ttf");
			using FileStream destination2 = new FileStream(FontPath, FileMode.Create, FileAccess.Write);
			stream2?.CopyTo(destination2);
		}
		if (!File.Exists(ConfigPath))
		{
			SaveConfig(0f, loadingBar: true, loadingText: true, 16f, 0.3f, forcewait: false, validate: false);
		}
		if (!File.Exists(VertexShaderPath))
		{
			File.WriteAllText(VertexShaderPath, "#version 330\n// fyi raylib is the internal render-er\n\nin vec3 vertexPosition;\nin vec2 vertexTexCoord;\nin vec4 vertexColor;\n\nout vec2 fragTexCoord;\nout vec4 fragColor;\n\nuniform mat4 mvp;\n\nvoid main()\n{\n    fragTexCoord = vertexTexCoord;\n    fragColor = vertexColor;\n    gl_Position = mvp * vec4(vertexPosition, 1.0);\n}");
		}
		if (!File.Exists(FragmentShaderPath))
		{
			File.WriteAllText(FragmentShaderPath, "#version 330\n// fyi raylib is the internal render-er\n\nin vec2 fragTexCoord;\nin vec4 fragColor;\n\nuniform sampler2D texture0;\nuniform vec4 colDiffuse;\n\n// shadertoy-sorta-compatable-uniforms to help with adding cool shaders\n// altho u cant just paste a shadertoy shader in you wll need to tweak it for it to work\n// also no channel support sry\nuniform float iCoverFrame;\nuniform vec3 iResolution;\nuniform float iFrame;\nuniform float iFrameDelta;\nuniform float iFrameRate;\nuniform float iTime;\nuniform vec4 iMouse;\nuniform vec4 iDate;\n\nout vec4 finalColor;\n\nvoid main()\n{\n    vec4 texelColor = texture(texture0, fragTexCoord);\n    \n    finalColor = texelColor * fragColor * colDiffuse;\n}");
		}
	}

	public static void SaveConfig(float fps = 0f, bool loadingBar = true, bool loadingText = true, float loadingTextScale = 16f, float scale = 0.3f, bool forcewait = false, bool validate = true)
	{
		if (validate)
		{
			ValidateConfig();
		}
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.Append(((int)fps).ToString());
		stringBuilder.AppendLine(" # cover art fps 0 = pick random, >0 = animate from covers in covers folder (must be indexed properly)");
		stringBuilder.Append(loadingBar.ToString());
		stringBuilder.AppendLine(" # show loading bar");
		stringBuilder.Append(loadingText.ToString());
		stringBuilder.AppendLine(" # show loading text");
		stringBuilder.Append(scale.ToString(CultureInfo.CurrentCulture));
		stringBuilder.AppendLine(" # window scale");
		stringBuilder.Append(forcewait.ToString());
		stringBuilder.AppendLine(" # wait for the current splash animation to finish first");
		stringBuilder.Append(loadingTextScale.ToString());
		stringBuilder.AppendLine(" # loading text scale");
		File.WriteAllText(ConfigPath, stringBuilder.ToString());
	}
}
public static class SplashPatcher
{
	internal class LogListener : ILogListener, IDisposable
	{
		public void Dispose()
		{
		}

		public void LogEvent(object sender, LogEventArgs eventArgs)
		{
			bool flag = eventArgs.Source.SourceName == "BepInEx";
			ILogSource val = (ILogSource)((sender is ILogSource) ? sender : null);
			if (val != null)
			{
				flag = val.SourceName == "BepInEx";
			}
			if (!flag)
			{
				return;
			}
			SplashWindow.Message = eventArgs.Data.ToString();
			if (SplashWindow.Message.Contains("Loading"))
			{
				SplashWindow.Progress = (float)_loadedPluginCount / (float)_pluginCount;
				_loadedPluginCount++;
			}
			if (!SplashWindow.Message.Contains("Chainloader", StringComparison.CurrentCultureIgnoreCase) || !SplashWindow.Message.Contains("Complete", StringComparison.CurrentCultureIgnoreCase))
			{
				return;
			}
			SplashWindow.Message = "All mods loaded!";
			SplashWindow.Progress = 1f;
			_loadedPluginCount = _pluginCount;
			if (SplashWindow.ForceWait)
			{
				while (!SplashWindow.IsDone)
				{
					Thread.Sleep(1);
				}
			}
		}
	}

	private static int _pluginCount = 0;

	private static int _loadedPluginCount = 0;

	private static readonly string CurrentAssemblyName = Assembly.GetAssembly(typeof(Logger)).GetName().Name;

	public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" };

	public static void Patch(AssemblyDefinition assembly)
	{
	}

	private static bool HasBepinPlugins(AssemblyDefinition ass)
	{
		if (((IEnumerable<AssemblyNameReference>)ass.MainModule.AssemblyReferences).All((AssemblyNameReference r) => r.Name != CurrentAssemblyName))
		{
			return false;
		}
		if (ass.MainModule.GetTypeReferences().All((TypeReference r) => ((MemberReference)r).FullName != typeof(BepInPlugin).FullName))
		{
			return false;
		}
		return true;
	}

	public static void Initialize()
	{
		Logger.Listeners.Add((ILogListener)(object)new LogListener());
		if (!Directory.Exists(Path.Combine(Paths.ConfigPath, "PreloadingSplash")))
		{
			SplashWindow.SaveConfig();
		}
		Task.Run(delegate
		{
			new SplashWindow();
		}).ContinueWith(delegate
		{
		}, TaskContinuationOptions.OnlyOnFaulted);
	}

	public static void Finish()
	{
		Dictionary<string, List<PluginInfo>> dictionary = TypeLoader.FindPluginTypes<PluginInfo>(Paths.PluginPath, (Func<TypeDefinition, PluginInfo>)Chainloader.ToPluginInfo, (Func<AssemblyDefinition, bool>)HasBepinPlugins, "chainloader");
		HashSet<PluginInfo> hashSet = new HashSet<PluginInfo>();
		foreach (KeyValuePair<string, List<PluginInfo>> item in dictionary)
		{
			foreach (PluginInfo item2 in item.Value)
			{
				if (!hashSet.Contains(item2))
				{
					hashSet.Add(item2);
				}
			}
		}
		_pluginCount = hashSet.Count;
	}
}

Preloading_Splash.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[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("Preloading_Splash")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("Preloading Splash")]
[assembly: AssemblyTitle("Preloading_Splash")]
[assembly: AssemblyVersion("1.0.1.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 Preloading_Splash
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.triggeredidiot.preloadingsplash", "Preloading Splash", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction<Scene, LoadSceneMode> <>9__5_0;

			public static OnClick <>9__5_2;

			internal void <Awake>b__5_0(Scene _, LoadSceneMode _)
			{
				SplashWindow.Close = true;
			}

			internal void <Awake>b__5_2()
			{
				Application.OpenURL("file://" + SplashWindow.CoversPath);
			}
		}

		private PluginConfigurator config;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_015a: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Expected O, but got Unknown
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Expected O, but got Unknown
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			SceneManager.sceneLoaded += delegate
			{
				SplashWindow.Close = true;
			};
			config = PluginConfigurator.Create("Preloading Splash", "com.triggeredidiot.preloadingsplash");
			string location = Assembly.GetExecutingAssembly().Location;
			config.SetIconWithURL("file://" + Path.Combine(Path.GetDirectoryName(location) ?? Path.Combine(Paths.PluginPath, "PreloadingSplash"), "icon.png"));
			ConfigPanel val = new ConfigPanel(config.rootPanel, "Open Help", "infopanel");
			new ConfigHeader(val, "<size=16>The covers folder has 2 modes", 24);
			new ConfigHeader(val, "<size=16>Mode 1:", 24);
			new ConfigHeader(val, "<size=16> place ONLY PNGS in the covers folder", 24);
			new ConfigHeader(val, "<size=16> splash screen then picks a random image from the folder", 24);
			new ConfigHeader(val, "<size=16>Mode 2:", 24);
			new ConfigHeader(val, "<size=16> place ONLY GIFs in the covers folder", 24);
			new ConfigHeader(val, "<size=16> splash screen then picks a random gif from the folder", 24);
			new ConfigHeader(config.rootPanel, "<size=12>It is recommended you open and read the help screen before adding custom covers", 24);
			ButtonField val2 = new ButtonField(config.rootPanel, "Open Covers folder", "coversbtn");
			ButtonField previewBtn = new ButtonField(config.rootPanel, "Preview splash", "splashpreview");
			ConfigHeader previewNotice = new ConfigHeader(config.rootPanel, "<size=12>May be hidden as a sub-window of ultrakill or loading the gif, its recommended to not be in fullscreen while previewing", 24);
			((ConfigField)previewNotice).hidden = true;
			BoolField loadingBar = new BoolField(config.rootPanel, "Show Loading Bar", "loadingbar", true);
			BoolField loadingText = new BoolField(config.rootPanel, "Show Loading Text", "loadingbartext", true);
			FloatSliderField textScale = new FloatSliderField(config.rootPanel, "Loading Text Scale", "textscale", new Tuple<float, float>(8f, 64f), 16f);
			FloatSliderField scale = new FloatSliderField(config.rootPanel, "Splash screen scale", "scale", new Tuple<float, float>(0.1f, 0.85f), 0.3f);
			((ConfigField)new ConfigHeader(config.rootPanel, "<size=12>Can't change fps in gif mode", 24)).hidden = true;
			FloatSliderField fps = new FloatSliderField(config.rootPanel, "Cover Framerate", "fps", new Tuple<float, float>(0f, 60f), 0f);
			((ConfigField)fps).hidden = true;
			BoolField forcewait = new BoolField(config.rootPanel, "Force animation before loading game", "forcewait", false);
			new ConfigHeader(config.rootPanel, "<size=12>Requires one loop to play before the game can finish loading", 24);
			new ConfigHeader(config.rootPanel, "<size=12>Doesn't do anything for static covers", 24);
			((ConfigField)forcewait).interactable = true;
			object obj = <>c.<>9__5_2;
			if (obj == null)
			{
				OnClick val3 = delegate
				{
					Application.OpenURL("file://" + SplashWindow.CoversPath);
				};
				<>c.<>9__5_2 = val3;
				obj = (object)val3;
			}
			val2.onClick += (OnClick)obj;
			SplashWindow currentPreviewWindow = null;
			bool previewMode = false;
			previewBtn.onClick += (OnClick)delegate
			{
				if (currentPreviewWindow == null || currentPreviewWindow.Loaded || !currentPreviewWindow.IsAlive)
				{
					Save();
					previewMode = !previewMode;
					if (previewMode)
					{
						((ConfigField)previewNotice).hidden = false;
						previewBtn.text = "Close splash";
						SplashWindow.TestMode = true;
						SplashWindow.Close = false;
						Task.Run(delegate
						{
							//IL_0001: Unknown result type (might be due to invalid IL or missing references)
							//IL_000b: Expected O, but got Unknown
							currentPreviewWindow = new SplashWindow();
							currentPreviewWindow = null;
						}).ContinueWith(delegate(Task task)
						{
							currentPreviewWindow = null;
							Logger.LogError((object)task.Exception);
						}, TaskContinuationOptions.OnlyOnFaulted);
					}
					else
					{
						((ConfigField)previewNotice).hidden = true;
						previewBtn.text = "Preview splash";
						SplashWindow.Close = true;
						while (currentPreviewWindow != null)
						{
							Thread.Sleep(10);
						}
					}
				}
			};
			config.postConfigChange += new PostConfigChangeEvent(Save);
			Application.quitting += Save;
			Logger.LogInfo((object)"Plugin com.triggeredidiot.preloadingsplash is loaded! (well technically the prepatcher should have ran before the main plugin but whatever)");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			void Save()
			{
				SplashWindow.SaveConfig(fps.value, loadingBar.value, loadingText.value, textScale.value, scale.value, forcewait.value, true);
			}
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.triggeredidiot.preloadingsplash";

		public const string PLUGIN_NAME = "Preloading Splash";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}