Decompiled source of LordAshesLicenseAgreement v1.0.0

LaLaPlugin.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LaLaPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LaLaPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("LaLaPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[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 LordAshes;

[BepInPlugin("org.lordashes.plugins.lala", "Lord Ashes License Agreement Plugin", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class LaLaPlugin : BaseUnityPlugin
{
	public static class Utility
	{
		public static void PostOnMainPage(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nLord Ashes' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		private static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}
	}

	public const string Name = "Lord Ashes License Agreement Plugin";

	public const string Guid = "org.lordashes.plugins.lala";

	public const string Version = "1.0.0.0";

	public const string Author = "Lord Ashes";

	public const string Storage = ".Licenses";

	public static int state = 0;

	public static List<Texture2D> backgroundTextures = new List<Texture2D>();

	private static GUIStyle infoTextStyle = new GUIStyle();

	private void Awake()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"Lord Ashes License Agreement Plugin: Active.");
		infoTextStyle.fontSize = 32;
		infoTextStyle.normal.textColor = Color.black;
		if (!File.Exists(Environment.GetEnvironmentVariable("USERNAME") + ".LALA.Accept.txt"))
		{
			state = 1;
			int num = 0;
			while (File.Exists("LordAshesLegalAgreement." + num + ".png"))
			{
				backgroundTextures.Add(Image.LoadTexture("LordAshesLegalAgreement." + num + ".png", (CacheType)999));
				num++;
			}
			Utility.PostOnMainPage(((object)this).GetType());
		}
		else
		{
			LoggingPlugin.LogInfo("Lord Ashes License Agreement for " + Environment.GetEnvironmentVariable("USERNAME") + " Accepted On " + File.ReadAllText(Environment.GetEnvironmentVariable("USERNAME") + ".LALA.Accept.txt", (CacheType)999));
			Object.Destroy((Object)(object)this);
		}
	}

	private void OnGUI()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		if (state <= -2048)
		{
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)backgroundTextures[0], (ScaleMode)2);
		}
		else if (state <= -1024)
		{
			Object.Destroy((Object)(object)this);
		}
		else if (state < backgroundTextures.Count - 1)
		{
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)backgroundTextures[state], (ScaleMode)2);
			if (GUI.Button(new Rect((float)(Screen.width - 580), (float)(Screen.height - 220), 320f, 30f), "Next Page", infoTextStyle))
			{
				state++;
			}
		}
		else if (state == backgroundTextures.Count - 1)
		{
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)backgroundTextures[state], (ScaleMode)2);
			if (GUI.Button(new Rect(460f, (float)(Screen.height - 220), 320f, 30f), "Accept", infoTextStyle))
			{
				state++;
			}
			if (GUI.Button(new Rect((float)(Screen.width - 580), (float)(Screen.height - 220), 320f, 30f), "Reject", infoTextStyle))
			{
				state = -1024;
			}
		}
		else
		{
			if (state < backgroundTextures.Count)
			{
				return;
			}
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)backgroundTextures[backgroundTextures.Count - 1], (ScaleMode)2);
			state++;
			int num = (int)Math.Floor((double)state / 60.0);
			if (num > Environment.GetEnvironmentVariable("USERNAME").Length)
			{
				num = Environment.GetEnvironmentVariable("USERNAME").Length;
			}
			((Object)this).name = Environment.GetEnvironmentVariable("USERNAME").Substring(0, num);
			GUI.Label(new Rect((float)(Screen.width / 2 - 150), (float)(Screen.height / 2 + 120), (float)Screen.width, (float)Screen.height), ((Object)this).name, infoTextStyle);
			if (num == Environment.GetEnvironmentVariable("USERNAME").Length && GUI.Button(new Rect((float)(Screen.width - 580), (float)(Screen.height - 220), 320f, 30f), "Continue", infoTextStyle))
			{
				state = -2048;
				if (!Directory.Exists(Paths.PluginPath + "\\.Licenses"))
				{
					Directory.CreateDirectory(Paths.PluginPath + "\\.Licenses");
				}
				if (!Directory.Exists(Paths.PluginPath + "\\.Licenses\\CustomData"))
				{
					Directory.CreateDirectory(Paths.PluginPath + "\\.Licenses\\CustomData");
				}
				File.WriteAllText(Paths.PluginPath + "\\.Licenses\\CustomData\\" + Environment.GetEnvironmentVariable("USERNAME") + ".LALA.Accept.txt", DateTime.UtcNow.ToString(), (CacheType)999);
			}
		}
	}
}