Decompiled source of UpdatesCheckerMono v1.1.0

UpdatesCheckerMono.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(UpdatesChecker), "UpdatesCheckerMono", "1.1.0", "DiumStream", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyMetadata("NexusModID", "1055")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
public class UpdatesChecker : MelonMod
{
	private const string API_URL = "https://api.nexusmods.com/v2/graphql";

	private const string CACHE_FILE = "UserData/UpdatesChecker/UpdateChecker.json";

	private const string INCOMPATIBLE_FILE = "UserData/UpdatesChecker/incompatibles.json";

	private static readonly HttpClient client = new HttpClient();

	public static List<ModUpdate> updatesAvailable = new List<ModUpdate>();

	public static List<ModInfo> incompatibleMods = new List<ModInfo>();

	public static UpdatesChecker instance = null;

	private LanguageOption _lastLanguage;

	public override void OnInitializeMelon()
	{
		Config.Load();
		instance = this;
		_lastLanguage = Config.Language.Value;
		MelonLogger.Msg(Lang.Get("checking_updates"));
		string path = Path.GetDirectoryName("UserData/UpdatesChecker/UpdateChecker.json") ?? throw new InvalidOperationException("Invalid cache path");
		Directory.CreateDirectory(path);
		ModsUI.Initialize((MelonMod)(object)this);
		MelonCoroutines.Start(StartupUpdateCheck());
	}

	public override void OnUpdate()
	{
		if (Config.Language.Value != _lastLanguage)
		{
			MelonLogger.Msg($"Language changed: {_lastLanguage} -> {Config.Language.Value}. Reloading UI...");
			_lastLanguage = Config.Language.Value;
			if ((Object)(object)ModsUI.modWindow != (Object)null)
			{
				Object.Destroy((Object)(object)ModsUI.modWindow);
				ModsUI.modWindow = null;
			}
			if ((Object)(object)ModsUI.incompatibleModsWindow != (Object)null)
			{
				Object.Destroy((Object)(object)ModsUI.incompatibleModsWindow);
				ModsUI.incompatibleModsWindow = null;
			}
			if ((Object)(object)ModsUI.modButton != (Object)null)
			{
				Object.Destroy((Object)(object)ModsUI.modButton);
				ModsUI.modButton = null;
			}
			if ((Object)(object)ModsUI.incompatibleModsButton != (Object)null)
			{
				Object.Destroy((Object)(object)ModsUI.incompatibleModsButton);
				ModsUI.incompatibleModsButton = null;
			}
			ModsUI.buttonInitialized = false;
			ModsUI.isInitializing = false;
			ModsUI.Initialize((MelonMod)(object)this);
		}
	}

	private IEnumerator StartupUpdateCheck()
	{
		yield return CheckForUpdatesAsync();
		SaveCache();
		GameObject? modWindow = ModsUI.modWindow;
		if (modWindow != null && modWindow.activeSelf)
		{
			ModsUI.UpdateWindowContent();
		}
	}

	public IEnumerator CheckForUpdatesAsync()
	{
		Task task;
		try
		{
			task = CheckForUpdates();
		}
		catch (Exception ex2)
		{
			Exception ex = ex2;
			MelonLogger.Error(Lang.Get("cache_error", ex.Message));
			yield break;
		}
		while (!task.IsCompleted)
		{
			yield return null;
		}
		if (task.Exception != null)
		{
			MelonLogger.Error(Lang.Get("cache_error", task.Exception.InnerException?.Message ?? task.Exception.Message));
			yield break;
		}
		MelonLogger.Msg(Lang.Get("updates_found", updatesAvailable.Count));
		SaveCache();
		GameObject? modWindow = ModsUI.modWindow;
		if (modWindow != null && modWindow.activeSelf)
		{
			ModsUI.UpdateWindowContent();
		}
	}

	public async Task CheckForUpdates()
	{
		updatesAvailable.Clear();
		List<ModInfo> mods = GetInstalledMods();
		Dictionary<int, string> latestVersions = await FetchLatestVersions(mods);
		foreach (ModInfo mod in mods)
		{
			if (mod.NexusID <= 0)
			{
				continue;
			}
			if (latestVersions.TryGetValue(mod.NexusID, out string latestVersion))
			{
				if (!VersionMatch(mod.Version, latestVersion))
				{
					updatesAvailable.Add(new ModUpdate
					{
						ModName = mod.Name,
						CurrentVersion = mod.Version,
						LatestVersion = latestVersion
					});
					if (mod.Name == "UpdatesCheckerMono")
					{
						LogSelfCheckResult(mod.Version, latestVersion);
					}
				}
			}
			else
			{
				MelonLogger.Warning(Lang.Get("invalid_api_response", mod.Name));
			}
			latestVersion = null;
		}
	}

	private async Task<Dictionary<int, string>> FetchLatestVersions(List<ModInfo> mods)
	{
		List<Dictionary<string, object>> ids = new List<Dictionary<string, object>>();
		foreach (ModInfo mod in mods)
		{
			if (mod.NexusID > 0)
			{
				ids.Add(new Dictionary<string, object>
				{
					{ "gameDomain", "schedule1" },
					{ "modId", mod.NexusID }
				});
			}
		}
		string query = "\r\n            query legacyModsByDomain($ids: [CompositeDomainWithIdInput!]!) {\r\n              legacyModsByDomain(ids: $ids) {\r\n                nodes {\r\n                  modId\r\n                  version\r\n                }\r\n              }\r\n            }\r\n        ";
		var payload = new
		{
			query = query,
			variables = new { ids }
		};
		StringContent content = new StringContent(JsonConvert.SerializeObject((object)payload), Encoding.UTF8, "application/json");
		HttpResponseMessage response = await client.PostAsync("https://api.nexusmods.com/v2/graphql", (HttpContent)(object)content);
		if (!response.IsSuccessStatusCode)
		{
			MelonLogger.Error($"GraphQL request failed: {response.StatusCode}");
			return new Dictionary<int, string>();
		}
		GraphQLModsResponse data = JsonConvert.DeserializeObject<GraphQLModsResponse>(await response.Content.ReadAsStringAsync());
		Dictionary<int, string> versions = new Dictionary<int, string>();
		if (data?.data?.legacyModsByDomain?.nodes != null)
		{
			foreach (GraphQLModNode node in data.data.legacyModsByDomain.nodes)
			{
				versions[node.modId] = node.version;
			}
		}
		return versions;
	}

	private void SaveCache()
	{
		try
		{
			File.WriteAllText("UserData/UpdatesChecker/UpdateChecker.json", JsonConvert.SerializeObject((object)updatesAvailable, (Formatting)1));
			File.WriteAllText("UserData/UpdatesChecker/incompatibles.json", JsonConvert.SerializeObject((object)incompatibleMods, (Formatting)1));
		}
		catch (Exception ex)
		{
			MelonLogger.Error(Lang.Get("cache_save_error", ex.Message));
		}
	}

	private void LogSelfCheckResult(string current, string latest)
	{
		string text = (VersionMatch(current, latest) ? "✓ Up to date" : ("⚠\ufe0f Update available: " + current + " → " + latest));
		MelonLogger.Msg("[Auto-Check] UpdatesCheckerMono " + text);
	}

	private bool VersionMatch(string current, string latest)
	{
		try
		{
			Version version = new Version(current);
			Version version2 = new Version(latest);
			return version >= version2;
		}
		catch
		{
			return string.Equals(current, latest, StringComparison.OrdinalIgnoreCase);
		}
	}

	private List<ModInfo> GetInstalledMods()
	{
		List<ModInfo> list = new List<ModInfo>();
		incompatibleMods.Clear();
		int selfNexusId = GetSelfNexusId();
		if (selfNexusId > 0)
		{
			list.Add(new ModInfo
			{
				Name = "UpdatesCheckerMono",
				Version = "1.1.0",
				NexusID = selfNexusId,
				IsCompatible = true
			});
		}
		foreach (MelonMod registeredMelon in MelonTypeBase<MelonMod>.RegisteredMelons)
		{
			if (!(((MelonBase)registeredMelon).Info.Name == "UpdatesCheckerMono"))
			{
				int nexusIdFromMod = GetNexusIdFromMod(registeredMelon);
				bool flag = nexusIdFromMod > 0;
				ModInfo item = new ModInfo
				{
					Name = ((MelonBase)registeredMelon).Info.Name,
					Version = ((MelonBase)registeredMelon).Info.Version,
					NexusID = nexusIdFromMod,
					IsCompatible = flag
				};
				list.Add(item);
				if (!flag)
				{
					incompatibleMods.Add(item);
					MelonLogger.Warning("[Incompatible] " + ((MelonBase)registeredMelon).Info.Name + " - No NexusModID");
				}
			}
		}
		return list;
	}

	private int GetSelfNexusId()
	{
		try
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			IEnumerable<AssemblyMetadataAttribute> customAttributes = executingAssembly.GetCustomAttributes<AssemblyMetadataAttribute>();
			foreach (AssemblyMetadataAttribute item in customAttributes)
			{
				if (item.Key.Equals("NexusModID", StringComparison.OrdinalIgnoreCase))
				{
					if (int.TryParse(item.Value, out var result))
					{
						return result;
					}
					MelonLogger.Error(Lang.Get("invalid_nexusid", "UpdateChecker", item.Value ?? "null"));
					return -1;
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error(Lang.Get("cache_error", ex.Message));
		}
		return -1;
	}

	private int GetNexusIdFromMod(MelonMod mod)
	{
		try
		{
			Assembly assembly = ((MelonBase)mod).MelonAssembly.Assembly;
			IEnumerable<AssemblyMetadataAttribute> customAttributes = assembly.GetCustomAttributes<AssemblyMetadataAttribute>();
			foreach (AssemblyMetadataAttribute item in customAttributes)
			{
				if (item.Key.Equals("NexusModID", StringComparison.OrdinalIgnoreCase))
				{
					if (int.TryParse(item.Value, out var result))
					{
						return result;
					}
					MelonLogger.Error(Lang.Get("invalid_nexusid", ((MelonBase)mod).Info.Name, item.Value ?? "null"));
					return -1;
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error(Lang.Get("cache_error", ex.Message));
		}
		return -1;
	}
}
public class ModInfo
{
	public string Name { get; set; } = string.Empty;


	public string Version { get; set; } = string.Empty;


	public int NexusID { get; set; }

	public bool IsCompatible { get; set; }
}
public class ModUpdate
{
	public string ModName { get; set; } = string.Empty;


	public string CurrentVersion { get; set; } = string.Empty;


	public string LatestVersion { get; set; } = string.Empty;

}
public class GraphQLModsResponse
{
	public GraphQLModsData? data { get; set; }
}
public class GraphQLModsData
{
	public GraphQLLegacyModsByDomain? legacyModsByDomain { get; set; }
}
public class GraphQLLegacyModsByDomain
{
	public List<GraphQLModNode>? nodes { get; set; }
}
public class GraphQLModNode
{
	public int modId { get; set; }

	public string? version { get; set; }
}
public enum LanguageOption
{
	English,
	French,
	Russian
}
public static class Config
{
	public static MelonPreferences_Category Category { get; private set; }

	public static MelonPreferences_Entry<LanguageOption> Language { get; private set; }

	public static void Load()
	{
		Category = MelonPreferences.CreateCategory("UpdatesChecker_Settings", "Updates Checker");
		Language = Category.CreateEntry<LanguageOption>("Language", LanguageOption.English, "Language", "UI Language (English/French/Russian)", false, false, (ValueValidator)null, (string)null);
	}

	public static string GetLanguage()
	{
		LanguageOption value = Language.Value;
		if (1 == 0)
		{
		}
		string result = value switch
		{
			LanguageOption.English => "en", 
			LanguageOption.French => "fr", 
			LanguageOption.Russian => "ru", 
			_ => "en", 
		};
		if (1 == 0)
		{
		}
		return result;
	}
}
public static class Lang
{
	public static string Get(string key, params object[] args)
	{
		LanguageOption value = Config.Language.Value;
		if (1 == 0)
		{
		}
		string text2;
		switch (value)
		{
		case LanguageOption.French:
		{
			if (1 == 0)
			{
			}
			string text = key switch
			{
				"update_checker" => "UPDATE CHECKER", 
				"all_up_to_date" => "✅ Tous les mods sont à jour", 
				"updates_found" => "{0} mises à jour trouvées", 
				"first_launch" => "Premier lancement - Vérification des mises à jour...", 
				"checking_updates" => "Vérification des mises à jour...", 
				"main_menu_not_found" => "Menu principal introuvable - Bouton flottant utilisé", 
				"cache_loaded" => "Cache chargé : {0} mises à jour enregistrées", 
				"empty_cache" => "Cache vide ou invalide - Réinitialisation", 
				"cache_error" => "Erreur lecture cache : {0}", 
				"cache_save_error" => "Erreur sauvegarde cache : {0}", 
				"rate_limit" => "Limite API atteinte - Pause de 60s", 
				"http_code" => "{0} - Code HTTP {1}", 
				"invalid_api_response" => "{0} - Réponse API invalide", 
				"error_mod" => "Erreur {0}: {1}", 
				"no_nexusid" => "{0} - Aucun NexusModID trouvé", 
				"invalid_nexusid" => "Format NexusID invalide dans {0}: {1}", 
				"current_version" => "Version actuelle", 
				"new_version" => "Nouvelle version", 
				"version" => "Version", 
				"missing_nexusmodid" => "⚠\ufe0f NexusModID Manquant", 
				"back" => "Retour", 
				"close" => "Fermer", 
				"incompatible_mods" => "Incompatible Mods", 
				_ => key, 
			};
			if (1 == 0)
			{
			}
			text2 = text;
			break;
		}
		case LanguageOption.Russian:
		{
			if (1 == 0)
			{
			}
			string text = key switch
			{
				"update_checker" => "ПРОВЕРКА ОБНОВЛЕНИЙ", 
				"all_up_to_date" => "✅ Все моды обновлены", 
				"updates_found" => "Найдено обновлений: {0}", 
				"first_launch" => "Первый запуск - проверка обновлений...", 
				"checking_updates" => "Проверка обновлений...", 
				"main_menu_not_found" => "Главное меню не найдено - используется плавающая кнопка", 
				"cache_loaded" => "Кэш загружен: {0} обновлений сохранено", 
				"empty_cache" => "Пустой кэш - сброс", 
				"cache_error" => "Ошибка чтения кэша: {0}", 
				"cache_save_error" => "Ошибка сохранения кэша: {0}", 
				"rate_limit" => "Лимит API - пауза 60 секунд", 
				"http_code" => "{0} - HTTP код {1}", 
				"invalid_api_response" => "{0} - Некорректный ответ API", 
				"error_mod" => "Ошибка {0}: {1}", 
				"no_nexusid" => "{0} - NexusModID не найден", 
				"invalid_nexusid" => "Некорректный NexusID в {0}: {1}", 
				"current_version" => "Текущая версия", 
				"new_version" => "Новая версия", 
				"version" => "версия", 
				"missing_nexusmodid" => "⚠\ufe0f Имеется NexusModID", 
				"back" => "Назад", 
				"close" => "Закрыть", 
				"incompatible_mods" => "Несовместимые моды", 
				_ => key, 
			};
			if (1 == 0)
			{
			}
			text2 = text;
			break;
		}
		default:
		{
			if (1 == 0)
			{
			}
			string text = key switch
			{
				"update_checker" => "UPDATE CHECKER", 
				"all_up_to_date" => "✅ All mods are up to date", 
				"updates_found" => "{0} updates found", 
				"first_launch" => "First Launch - Checking for Updates...", 
				"checking_updates" => "Checking for updates...", 
				"main_menu_not_found" => "MainMenu not found - Fallback on floating button", 
				"cache_loaded" => "Cache loaded : {0} saved updates", 
				"empty_cache" => "Empty or Invalid Cache - Reset", 
				"cache_error" => "Cache read error : {0}", 
				"cache_save_error" => "Cache save error : {0}", 
				"rate_limit" => "API rate limit reached - 60s pause", 
				"http_code" => "{0} - HTTP Code {1}", 
				"invalid_api_response" => "{0} - Invalid API response", 
				"error_mod" => "Error {0}: {1}", 
				"no_nexusid" => "{0} - No NexusModID found", 
				"invalid_nexusid" => "Invalid NexusID format in {0}: {1}", 
				"current_version" => "Current version", 
				"new_version" => "New version", 
				"version" => "Version", 
				"missing_nexusmodid" => "⚠\ufe0f Missing NexusModID", 
				"back" => "back", 
				"close" => "Close", 
				"incompatible_mods" => "Incompatible Mods", 
				_ => key, 
			};
			if (1 == 0)
			{
			}
			text2 = text;
			break;
		}
		}
		if (1 == 0)
		{
		}
		string format = text2;
		return string.Format(format, args);
	}
}
public static class ModsUI
{
	public static class RoundedCorners
	{
		public static Texture2D CreateRoundedTexture(int width, int height, int radius, Color color)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(width, height);
			Color[] array = (Color[])(object)new Color[width * height];
			float num = radius * radius;
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					bool flag = false;
					if (j < radius && i < radius)
					{
						flag = (float)((j - radius) * (j - radius) + (i - radius) * (i - radius)) > num;
					}
					else if (j < radius && i > height - radius)
					{
						flag = (float)((j - radius) * (j - radius) + (i - (height - radius)) * (i - (height - radius))) > num;
					}
					else if (j > width - radius && i < radius)
					{
						flag = (float)((j - (width - radius)) * (j - (width - radius)) + (i - radius) * (i - radius)) > num;
					}
					else if (j > width - radius && i > height - radius)
					{
						flag = (float)((j - (width - radius)) * (j - (width - radius)) + (i - (height - radius)) * (i - (height - radius))) > num;
					}
					array[i * width + j] = (flag ? Color.clear : color);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}
	}

	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static UnityAction <>9__12_0;

		public static UnityAction <>9__13_0;

		public static UnityAction <>9__19_0;

		internal void <CreateLeftMenuButton>b__12_0()
		{
			ToggleWindow();
		}

		internal void <CreateIncompatibleModsButton>b__13_0()
		{
			ToggleIncompatibleModsWindow();
		}

		internal void <CreateIncompatibleModsWindow>b__19_0()
		{
			if ((Object)(object)modWindow != (Object)null)
			{
				modWindow.SetActive(true);
			}
			if ((Object)(object)incompatibleModsWindow != (Object)null)
			{
				incompatibleModsWindow.SetActive(false);
			}
			SetBankAndUpdateButtonsActive(state: false);
		}
	}

	public static GameObject? modButton;

	public static GameObject? modWindow;

	public static GameObject? incompatibleModsButton;

	public static GameObject? incompatibleModsWindow;

	public static RectTransform? contentReference;

	public static bool buttonInitialized;

	public static bool isInitializing;

	private static bool isAnimating;

	public static void Initialize(MelonMod instance)
	{
		if (!isInitializing)
		{
			isInitializing = true;
			MelonLogger.Msg("Initializing Custom UI...");
			MelonCoroutines.Start(MenuDelayedInit());
		}
	}

	public static IEnumerator MenuDelayedInit()
	{
		yield return (object)new WaitForSeconds(3f);
		int num;
		if (!buttonInitialized)
		{
			Scene activeScene = SceneManager.GetActiveScene();
			num = ((((Scene)(ref activeScene)).name != "Menu") ? 1 : 0);
		}
		else
		{
			num = 1;
		}
		if (num == 0)
		{
			if ((Object)(object)modButton != (Object)null)
			{
				modButton.SetActive(false);
				modButton = null;
			}
			if ((Object)(object)modWindow != (Object)null)
			{
				modWindow.SetActive(false);
			}
			FindMainMenu();
			isInitializing = false;
		}
	}

	public static void FindMainMenu()
	{
		try
		{
			GameObject val = GameObject.Find("MainMenu");
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Warning(Lang.Get("main_menu_not_found"));
				return;
			}
			Transform val2 = val.transform.Find("Home");
			if ((Object)(object)val2 == (Object)null)
			{
				MelonLogger.Warning("Home menu not found under MainMenu!");
				return;
			}
			GameObject gameObject = ((Component)val2).gameObject;
			CreateLeftMenuButton(gameObject);
			buttonInitialized = true;
		}
		catch (Exception ex)
		{
			MelonLogger.Error("FindMainMenu error: " + ex.Message + "\n" + ex.StackTrace);
		}
	}

	public static void CreateLeftMenuButton(GameObject mainMenu)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Expected O, but got Unknown
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Expected O, but got Unknown
		try
		{
			if ((Object)(object)modButton != (Object)null)
			{
				return;
			}
			modButton = new GameObject("UpdateButtons");
			modButton.transform.SetParent(mainMenu.transform, false);
			RectTransform val = modButton.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(0f, 0.5f);
			val.anchorMax = new Vector2(0f, 0.5f);
			val.pivot = new Vector2(0f, 0.5f);
			val.anchoredPosition = new Vector2(45f, -10f);
			val.sizeDelta = new Vector2(200f, 60f);
			Image val2 = modButton.AddComponent<Image>();
			((Graphic)val2).color = new Color(0f, 0f, 0f, 0.01f);
			GameObject val3 = new GameObject("Text");
			val3.transform.SetParent(modButton.transform, false);
			Text val4 = val3.AddComponent<Text>();
			val4.text = Lang.Get("update_checker");
			val4.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			((Graphic)val4).color = Color.white;
			val4.alignment = (TextAnchor)4;
			val4.fontSize = 24;
			val4.fontStyle = (FontStyle)1;
			RectTransform component = val3.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			Button val5 = modButton.AddComponent<Button>();
			((Selectable)val5).targetGraphic = (Graphic)(object)val2;
			((UnityEventBase)val5.onClick).RemoveAllListeners();
			ButtonClickedEvent onClick = val5.onClick;
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				UnityAction val6 = delegate
				{
					ToggleWindow();
				};
				<>c.<>9__12_0 = val6;
				obj = (object)val6;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			if ((Object)(object)modWindow == (Object)null)
			{
				modWindow = CreateWindow(mainMenu);
				modWindow.SetActive(false);
			}
			CreateIncompatibleModsButton(modWindow);
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Erreur CreateLeftMenuButton: " + ex.Message);
		}
	}

	public static void CreateIncompatibleModsButton(GameObject parent)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Expected O, but got Unknown
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Expected O, but got Unknown
		try
		{
			if ((Object)(object)incompatibleModsButton != (Object)null)
			{
				return;
			}
			incompatibleModsButton = new GameObject("IncompatibleModsButton");
			incompatibleModsButton.transform.SetParent(parent.transform, false);
			RectTransform val = incompatibleModsButton.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(0.5f, 0f);
			val.anchorMax = new Vector2(0.5f, 0f);
			val.pivot = new Vector2(0.5f, 0f);
			val.anchoredPosition = new Vector2(0f, 70f);
			val.sizeDelta = new Vector2(180f, 40f);
			Image val2 = incompatibleModsButton.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.8f, 0.2f, 0.2f, 0.7f);
			val2.sprite = Sprite.Create(RoundedCorners.CreateRoundedTexture(180, 40, 8, ((Graphic)val2).color), new Rect(0f, 0f, 180f, 40f), new Vector2(0.5f, 0.5f));
			GameObject val3 = new GameObject("Text");
			val3.transform.SetParent(incompatibleModsButton.transform, false);
			Text val4 = val3.AddComponent<Text>();
			val4.text = Lang.Get("incompatible_mods");
			val4.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			((Graphic)val4).color = Color.white;
			val4.alignment = (TextAnchor)4;
			val4.fontSize = 16;
			val4.fontStyle = (FontStyle)1;
			RectTransform component = val3.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			Button val5 = incompatibleModsButton.AddComponent<Button>();
			((Selectable)val5).targetGraphic = (Graphic)(object)val2;
			((UnityEventBase)val5.onClick).RemoveAllListeners();
			ButtonClickedEvent onClick = val5.onClick;
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				UnityAction val6 = delegate
				{
					ToggleIncompatibleModsWindow();
				};
				<>c.<>9__13_0 = val6;
				obj = (object)val6;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
		}
		catch (Exception ex)
		{
			MelonLogger.Error("CreateIncompatibleModsButton error: " + ex.Message);
		}
	}

	private static IEnumerator AnimateWindowOpen(GameObject window, float duration = 0.18f)
	{
		if (!isAnimating)
		{
			isAnimating = true;
			CanvasGroup cg = window.GetComponent<CanvasGroup>() ?? window.AddComponent<CanvasGroup>();
			window.SetActive(true);
			cg.alpha = 0f;
			window.transform.localScale = Vector3.one * 0.85f;
			float t = 0f;
			while (t < duration)
			{
				t += Time.unscaledDeltaTime;
				float p = (cg.alpha = Mathf.Clamp01(t / duration));
				window.transform.localScale = Vector3.Lerp(Vector3.one * 0.85f, Vector3.one, p);
				yield return null;
			}
			cg.alpha = 1f;
			window.transform.localScale = Vector3.one;
			isAnimating = false;
		}
	}

	private static IEnumerator AnimateWindowClose(GameObject window, float duration = 0.18f)
	{
		if (!isAnimating)
		{
			isAnimating = true;
			CanvasGroup cg = window.GetComponent<CanvasGroup>() ?? window.AddComponent<CanvasGroup>();
			float t = 0f;
			while (t < duration)
			{
				t += Time.unscaledDeltaTime;
				float p = Mathf.Clamp01(t / duration);
				cg.alpha = 1f - p;
				window.transform.localScale = Vector3.Lerp(Vector3.one, Vector3.one * 0.85f, p);
				yield return null;
			}
			cg.alpha = 0f;
			window.transform.localScale = Vector3.one * 0.85f;
			window.SetActive(false);
			isAnimating = false;
		}
	}

	private static IEnumerator CloseWindowAndReactivateHome(GameObject window)
	{
		yield return AnimateWindowClose(window);
		SetBankAndUpdateButtonsActive(state: true);
	}

	public static void ToggleWindow()
	{
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (isAnimating)
			{
				return;
			}
			if ((Object)(object)modWindow == (Object)null)
			{
				GameObject? obj = modButton;
				object obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					Transform parent = obj.transform.parent;
					obj2 = ((parent != null) ? ((Component)parent).gameObject : null);
				}
				if (obj2 == null)
				{
					obj2 = GetOrCreateCanvas();
				}
				GameObject parent2 = (GameObject)obj2;
				modWindow = CreateWindow(parent2);
			}
			if (!modWindow.activeSelf)
			{
				MelonCoroutines.Start(AnimateWindowOpen(modWindow));
				RectTransform component = modWindow.GetComponent<RectTransform>();
				component.anchoredPosition = Vector2.zero;
				UpdateWindowContent();
				SetBankAndUpdateButtonsActive(state: false);
			}
			else
			{
				MelonCoroutines.Start(CloseWindowAndReactivateHome(modWindow));
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("ToggleWindow Error: " + ex.Message);
		}
	}

	public static void ToggleIncompatibleModsWindow()
	{
		try
		{
			if (isAnimating)
			{
				return;
			}
			if ((Object)(object)incompatibleModsWindow == (Object)null)
			{
				GameObject? obj = modWindow;
				object obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					Transform parent = obj.transform.parent;
					obj2 = ((parent != null) ? ((Component)parent).gameObject : null);
				}
				if (obj2 == null)
				{
					obj2 = GetOrCreateCanvas();
				}
				GameObject parent2 = (GameObject)obj2;
				incompatibleModsWindow = CreateIncompatibleModsWindow(parent2);
			}
			bool flag = !incompatibleModsWindow.activeSelf;
			incompatibleModsWindow.SetActive(flag);
			if ((Object)(object)modWindow != (Object)null)
			{
				modWindow.SetActive(!flag);
			}
			SetBankAndUpdateButtonsActive(!flag);
			if (flag)
			{
				UpdateIncompatibleModsContent();
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("ToggleIncompatibleModsWindow Error: " + ex.Message);
		}
	}

	public static GameObject CreateIncompatibleModsWindow(GameObject parent)
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Expected O, but got Unknown
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Expected O, but got Unknown
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_02a7: Expected O, but got Unknown
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Expected O, but got Unknown
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_045d: Unknown result type (might be due to invalid IL or missing references)
		//IL_048c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0496: Expected O, but got Unknown
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Expected O, but got Unknown
		if ((Object)(object)incompatibleModsWindow != (Object)null)
		{
			return incompatibleModsWindow;
		}
		GameObject window = CreateWindow(parent);
		((Object)window).name = "IncompatibleModsWindow";
		incompatibleModsWindow = window;
		Text componentInChildren = window.GetComponentInChildren<Text>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.text = Lang.Get("incompatible_mods");
			((Graphic)componentInChildren).color = new Color(1f, 0.4f, 0.4f);
		}
		GameObject val = new GameObject("BackButton");
		val.transform.SetParent(window.transform, false);
		RectTransform val2 = val.AddComponent<RectTransform>();
		val2.anchorMin = new Vector2(0.5f, 0f);
		val2.anchorMax = new Vector2(0.5f, 0f);
		val2.pivot = new Vector2(0.5f, 0f);
		val2.anchoredPosition = new Vector2(0f, 70f);
		val2.sizeDelta = new Vector2(180f, 40f);
		Image val3 = val.AddComponent<Image>();
		((Graphic)val3).color = new Color(0.2f, 0.2f, 0.8f, 0.7f);
		val3.sprite = Sprite.Create(RoundedCorners.CreateRoundedTexture(180, 40, 8, ((Graphic)val3).color), new Rect(0f, 0f, 180f, 40f), new Vector2(0.5f, 0.5f));
		GameObject val4 = new GameObject("Text");
		val4.transform.SetParent(val.transform, false);
		Text val5 = val4.AddComponent<Text>();
		val5.text = Lang.Get("back");
		val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		((Graphic)val5).color = Color.white;
		val5.alignment = (TextAnchor)4;
		val5.fontSize = 16;
		val5.fontStyle = (FontStyle)1;
		RectTransform component = val4.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Button val6 = val.AddComponent<Button>();
		((UnityEventBase)val6.onClick).RemoveAllListeners();
		ButtonClickedEvent onClick = val6.onClick;
		object obj = <>c.<>9__19_0;
		if (obj == null)
		{
			UnityAction val7 = delegate
			{
				if ((Object)(object)modWindow != (Object)null)
				{
					modWindow.SetActive(true);
				}
				if ((Object)(object)incompatibleModsWindow != (Object)null)
				{
					incompatibleModsWindow.SetActive(false);
				}
				SetBankAndUpdateButtonsActive(state: false);
			};
			<>c.<>9__19_0 = val7;
			obj = (object)val7;
		}
		((UnityEvent)onClick).AddListener((UnityAction)obj);
		GameObject val8 = new GameObject("CloseButton");
		val8.transform.SetParent(window.transform, false);
		RectTransform val9 = val8.AddComponent<RectTransform>();
		val9.anchorMin = new Vector2(0.5f, 0f);
		val9.anchorMax = new Vector2(0.5f, 0f);
		val9.pivot = new Vector2(0.5f, 0f);
		val9.anchoredPosition = new Vector2(0f, 20f);
		val9.sizeDelta = new Vector2(180f, 40f);
		Image val10 = val8.AddComponent<Image>();
		((Graphic)val10).color = new Color(0.8f, 0.2f, 0.2f, 0.7f);
		val10.sprite = Sprite.Create(RoundedCorners.CreateRoundedTexture(180, 40, 8, ((Graphic)val10).color), new Rect(0f, 0f, 180f, 40f), new Vector2(0.5f, 0.5f));
		GameObject val11 = new GameObject("Text");
		val11.transform.SetParent(val8.transform, false);
		Text val12 = val11.AddComponent<Text>();
		val12.text = Lang.Get("close");
		val12.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		((Graphic)val12).color = Color.white;
		val12.alignment = (TextAnchor)4;
		val12.fontSize = 16;
		val12.fontStyle = (FontStyle)1;
		RectTransform component2 = val11.GetComponent<RectTransform>();
		component2.anchorMin = Vector2.zero;
		component2.anchorMax = Vector2.one;
		component2.offsetMin = Vector2.zero;
		component2.offsetMax = Vector2.zero;
		Button val13 = val8.AddComponent<Button>();
		((UnityEventBase)val13.onClick).RemoveAllListeners();
		((UnityEvent)val13.onClick).AddListener((UnityAction)delegate
		{
			MelonCoroutines.Start(CloseWindowAndReactivateHome(window));
		});
		return window;
	}

	public static GameObject CreateWindow(GameObject parent)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Expected O, but got Unknown
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Expected O, but got Unknown
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: Expected O, but got Unknown
		//IL_041c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Expected O, but got Unknown
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_051b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0530: Unknown result type (might be due to invalid IL or missing references)
		//IL_0537: Expected O, but got Unknown
		//IL_0580: 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_05bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Expected O, but got Unknown
		GameObject window = new GameObject("ModsWindow");
		window.transform.SetParent(parent.transform, false);
		window.AddComponent<CanvasGroup>();
		RectTransform val = window.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(0.5f, 0.5f);
		val.anchorMax = new Vector2(0.5f, 0.5f);
		val.pivot = new Vector2(0.5f, 0.5f);
		val.sizeDelta = new Vector2(460f, 600f);
		val.anchoredPosition = Vector2.zero;
		Image val2 = window.AddComponent<Image>();
		((Graphic)val2).color = new Color(0.08f, 0.08f, 0.08f, 0.98f);
		val2.sprite = Sprite.Create(RoundedCorners.CreateRoundedTexture(460, 600, 20, ((Graphic)val2).color), new Rect(0f, 0f, 460f, 600f), new Vector2(0.5f, 0.5f));
		GameObject val3 = new GameObject("Title");
		val3.transform.SetParent(window.transform, false);
		RectTransform val4 = val3.AddComponent<RectTransform>();
		val4.anchorMin = new Vector2(0.5f, 1f);
		val4.anchorMax = new Vector2(0.5f, 1f);
		val4.pivot = new Vector2(0.5f, 1f);
		val4.anchoredPosition = new Vector2(0f, -20f);
		val4.sizeDelta = new Vector2(400f, 40f);
		Text val5 = val3.AddComponent<Text>();
		val5.text = Lang.Get("update_checker");
		val5.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		((Graphic)val5).color = new Color(0.9f, 0.95f, 1f);
		val5.alignment = (TextAnchor)1;
		val5.fontSize = 28;
		val5.fontStyle = (FontStyle)1;
		GameObject val6 = new GameObject("ScrollView");
		val6.transform.SetParent(window.transform, false);
		RectTransform val7 = val6.AddComponent<RectTransform>();
		val7.anchorMin = new Vector2(0f, 0f);
		val7.anchorMax = new Vector2(1f, 1f);
		val7.offsetMin = new Vector2(20f, 125f);
		val7.offsetMax = new Vector2(-20f, -70f);
		ScrollRect val8 = val6.AddComponent<ScrollRect>();
		val8.movementType = (MovementType)2;
		val8.inertia = false;
		val8.scrollSensitivity = 25f;
		((Graphic)val6.AddComponent<Image>()).color = new Color(0.12f, 0.12f, 0.12f, 0.5f);
		Mask val9 = val6.AddComponent<Mask>();
		val9.showMaskGraphic = false;
		GameObject val10 = new GameObject("Content");
		val10.transform.SetParent(val6.transform, false);
		RectTransform val11 = val10.AddComponent<RectTransform>();
		val11.anchorMin = new Vector2(0.5f, 1f);
		val11.anchorMax = new Vector2(0.5f, 1f);
		val11.pivot = new Vector2(0.5f, 1f);
		val11.sizeDelta = new Vector2(400f, 0f);
		VerticalLayoutGroup val12 = val10.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)val12).padding = new RectOffset(10, 10, 10, 10);
		((HorizontalOrVerticalLayoutGroup)val12).spacing = 15f;
		((LayoutGroup)val12).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)val12).childControlHeight = false;
		((HorizontalOrVerticalLayoutGroup)val12).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val12).childForceExpandHeight = false;
		((HorizontalOrVerticalLayoutGroup)val12).childForceExpandWidth = false;
		ContentSizeFitter val13 = val10.AddComponent<ContentSizeFitter>();
		val13.verticalFit = (FitMode)2;
		val8.content = val11;
		val8.viewport = val7;
		GameObject val14 = new GameObject("CloseButton");
		val14.transform.SetParent(window.transform, false);
		RectTransform val15 = val14.AddComponent<RectTransform>();
		val15.anchorMin = new Vector2(0.5f, 0f);
		val15.anchorMax = new Vector2(0.5f, 0f);
		val15.pivot = new Vector2(0.5f, 0f);
		val15.anchoredPosition = new Vector2(0f, 20f);
		val15.sizeDelta = new Vector2(180f, 40f);
		Image val16 = val14.AddComponent<Image>();
		((Graphic)val16).color = new Color(0.8f, 0.2f, 0.2f, 0.7f);
		val16.sprite = Sprite.Create(RoundedCorners.CreateRoundedTexture(180, 40, 8, ((Graphic)val16).color), new Rect(0f, 0f, 180f, 40f), new Vector2(0.5f, 0.5f));
		GameObject val17 = new GameObject("Text");
		val17.transform.SetParent(val14.transform, false);
		Text val18 = val17.AddComponent<Text>();
		val18.text = Lang.Get("close");
		val18.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		((Graphic)val18).color = Color.white;
		val18.alignment = (TextAnchor)4;
		val18.fontSize = 16;
		val18.fontStyle = (FontStyle)1;
		RectTransform component = val17.GetComponent<RectTransform>();
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
		Button val19 = val14.AddComponent<Button>();
		((UnityEventBase)val19.onClick).RemoveAllListeners();
		((UnityEvent)val19.onClick).AddListener((UnityAction)delegate
		{
			MelonCoroutines.Start(CloseWindowAndReactivateHome(window));
		});
		return window;
	}

	private static void SetBankAndUpdateButtonsActive(bool state)
	{
		GameObject val = GameObject.Find("MainMenu");
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Transform val2 = val.transform.Find("Home");
		if (!((Object)(object)val2 == (Object)null))
		{
			Transform val3 = val2.Find("Bank");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).gameObject.SetActive(state);
			}
			Transform val4 = val2.Find("UpdateButtons");
			if ((Object)(object)val4 != (Object)null)
			{
				((Component)val4).gameObject.SetActive(state);
			}
		}
	}

	public static void UpdateIncompatibleModsContent()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)incompatibleModsWindow == (Object)null)
			{
				return;
			}
			ScrollRect componentInChildren = incompatibleModsWindow.GetComponentInChildren<ScrollRect>();
			if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.content == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)componentInChildren.content).gameObject;
			RectTransform component = gameObject.GetComponent<RectTransform>();
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = new Vector2(400f, 0f);
			for (int num = gameObject.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = gameObject.transform.GetChild(num);
				Object.Destroy((Object)(object)((Component)child).gameObject);
			}
			if (!UpdatesChecker.incompatibleMods.Any())
			{
				CreateTextElement(gameObject, "Aucun mod incompatible trouvé");
				return;
			}
			foreach (ModInfo incompatibleMod in UpdatesChecker.incompatibleMods)
			{
				CreateTextElement(gameObject, "<b><size=18>" + incompatibleMod.Name + "</size></b>\n<color=#ff5555>" + Lang.Get("missing_nexusmodid") + "</color>\n<color=#aaaaaa>" + Lang.Get("version") + ": " + incompatibleMod.Version + "</color>\n<color=#555555>────────────────────</color>");
			}
			float num2 = (float)UpdatesChecker.incompatibleMods.Count * 95f;
			component.sizeDelta = new Vector2(400f, num2);
			LayoutRebuilder.ForceRebuildLayoutImmediate(component);
		}
		catch (Exception ex)
		{
			MelonLogger.Error("UpdateIncompatibleModsContent error: " + ex.Message);
		}
	}

	public static void UpdateWindowContent()
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)modWindow == (Object)null)
			{
				return;
			}
			Transform val = modWindow.transform.Find("ScrollView/Content");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject gameObject = ((Component)val).gameObject;
			RectTransform component = gameObject.GetComponent<RectTransform>();
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = new Vector2(400f, 0f);
			for (int num = gameObject.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = gameObject.transform.GetChild(num);
				Object.Destroy((Object)(object)((Component)child).gameObject);
			}
			IEnumerable<ModUpdate> updatesAvailable = UpdatesChecker.updatesAvailable;
			IEnumerable<ModUpdate> enumerable = updatesAvailable ?? Enumerable.Empty<ModUpdate>();
			if (!enumerable.Any())
			{
				CreateTextElement(gameObject, Lang.Get("all_up_to_date"));
				return;
			}
			foreach (ModUpdate item in enumerable)
			{
				CreateTextElement(gameObject, "<b><size=18>" + item.ModName + "</size></b>\n<color=#aaaaaa>" + Lang.Get("current_version") + ": " + item.CurrentVersion + "</color>\n<color=#4CAF50>" + Lang.Get("new_version") + ": " + item.LatestVersion + "</color>\n<color=#555555>────────────────────</color>");
			}
			float num2 = (float)enumerable.Count() * 95f;
			component.sizeDelta = new Vector2(400f, num2);
			LayoutRebuilder.ForceRebuildLayoutImmediate(component);
		}
		catch (Exception ex)
		{
			MelonLogger.Error("UpdateWindowContent error: " + ex.Message);
		}
	}

	public static void CreateTextElement(GameObject parent, string text)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Expected O, but got Unknown
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = new GameObject("UpdateElement");
			val.transform.SetParent(parent.transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.5f, 1f);
			val2.anchorMax = new Vector2(0.5f, 1f);
			val2.pivot = new Vector2(0.5f, 1f);
			val2.sizeDelta = new Vector2(380f, 80f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.08f, 0.08f, 0.08f, 0.95f);
			val3.sprite = Sprite.Create(RoundedCorners.CreateRoundedTexture(380, 80, 12, ((Graphic)val3).color), new Rect(0f, 0f, 380f, 80f), new Vector2(0.5f, 0.5f));
			GameObject val4 = new GameObject("Text");
			val4.transform.SetParent(val.transform, false);
			RectTransform val5 = val4.AddComponent<RectTransform>();
			val5.anchorMin = Vector2.zero;
			val5.anchorMax = Vector2.one;
			val5.offsetMin = new Vector2(10f, 5f);
			val5.offsetMax = new Vector2(-10f, -5f);
			Text val6 = val4.AddComponent<Text>();
			val6.text = text;
			val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			((Graphic)val6).color = new Color(0.95f, 0.95f, 0.95f, 1f);
			val6.fontSize = 16;
			val6.supportRichText = true;
			val6.alignment = (TextAnchor)4;
			LayoutElement val7 = val.AddComponent<LayoutElement>();
			val7.minHeight = 80f;
			val7.preferredHeight = 80f;
			val7.preferredWidth = 380f;
			Outline val8 = val4.AddComponent<Outline>();
			((Shadow)val8).effectColor = new Color(0f, 0f, 0f, 0.3f);
			((Shadow)val8).effectDistance = new Vector2(1f, -1f);
		}
		catch (Exception ex)
		{
			MelonLogger.Error("CreateTextElement error: " + ex.GetType().Name + " - " + ex.Message);
		}
	}

	public static GameObject GetOrCreateCanvas()
	{
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		try
		{
			GameObject val = GameObject.Find("Canvas");
			if ((Object)(object)val == (Object)null)
			{
				val = new GameObject("Canvas");
				Canvas val2 = val.AddComponent<Canvas>();
				val2.renderMode = (RenderMode)0;
				val.AddComponent<CanvasScaler>();
				val.AddComponent<GraphicRaycaster>();
				if ((Object)(object)Object.FindObjectOfType<EventSystem>() == (Object)null)
				{
					GameObject val3 = new GameObject("EventSystem");
					val3.AddComponent<EventSystem>();
					val3.AddComponent<StandaloneInputModule>();
				}
			}
			return val;
		}
		catch (Exception ex)
		{
			MelonLogger.Error("GetOrCreateCanvas error: " + ex.Message);
			return ((Component)new GameObject("FallbackCanvas").AddComponent<Canvas>()).gameObject;
		}
	}
}
public static class PluginInfo
{
	public const string PLUGIN_AUTHOR = "DiumStream";

	public const string PLUGIN_NAME = "UpdatesCheckerMono";

	public const string PLUGIN_VERSION = "1.1.0";
}