Decompiled source of TootTallySongDownloader v2.1.0

plugins/TootTallySongDownloader.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BaboonAPI.Hooks.Initializer;
using BaboonAPI.Hooks.Tracks;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Microsoft.FSharp.Core;
using TMPro;
using TootTallyCore;
using TootTallyCore.APIServices;
using TootTallyCore.Graphics;
using TootTallyCore.Graphics.ProgressCounters;
using TootTallyCore.Utils.Assets;
using TootTallyCore.Utils.Helpers;
using TootTallyCore.Utils.TootTallyModules;
using TootTallyCore.Utils.TootTallyNotifs;
using TootTallySettings;
using TootTallySongDownloader.Ui;
using UnityEngine;
using UnityEngine.Events;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TootTallySongDownloader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("In-game custom songs downloader")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("TootTallySongDownloader")]
[assembly: AssemblyTitle("TootTallySongDownloader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TootTallySongDownloader
{
	[BepInPlugin("TootTallySongDownloader", "TootTallySongDownloader", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin, ITootTallyModule
	{
		public static Plugin Instance;

		private const string CONFIG_NAME = "ModuleTemplate.cfg";

		private Harmony _harmony;

		public static TootTallySettingPage settingPage;

		public ConfigEntry<bool> ModuleConfigEnabled { get; set; }

		public bool IsConfigInitialized { get; set; }

		public string Name
		{
			get
			{
				return "TootTallySongDownloader";
			}
			set
			{
				Name = value;
			}
		}

		public static void LogInfo(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		public static void LogWarning(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogWarning((object)msg);
		}

		public static void LogError(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)msg);
		}

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				Instance = this;
				_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				GameInitializationEvent.Register(((BaseUnityPlugin)this).Info, (Action)TryInitialize);
			}
		}

		private void TryInitialize()
		{
			ModuleConfigEnabled = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Modules", "SongDownloader", true, "In-game custom songs downloader.");
			TootTallyModuleManager.AddModule((ITootTallyModule)(object)this);
		}

		public void LoadModule()
		{
			AssetManager.LoadAssets(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "Assets"));
			settingPage = TootTallySettingsManager.AddNewPage((TootTallySettingPage)(object)new SongDownloadPage());
			Plugin.TryAddThunderstoreIconToPageButton(((BaseUnityPlugin)Instance).Info.Location, Name, settingPage);
			LogInfo("Module loaded!");
		}

		public void UnloadModule()
		{
			_harmony.UnpatchSelf();
			settingPage.Remove();
			LogInfo("Module unloaded!");
		}
	}
	internal record DownloadState
	{
		internal record Waiting : DownloadState;

		internal record DownloadAvailable : DownloadState;

		internal record DownloadUnavailable : DownloadState;

		internal record Downloading : DownloadState
		{
			internal ProgressCounter Progress;

			[CompilerGenerated]
			protected override bool PrintMembers(StringBuilder builder)
			{
				return base.PrintMembers(builder);
			}
		}

		internal record Owned : DownloadState;
	}
	internal class SongDownloadObject : BaseTootTallySettingObject
	{
		private readonly SongRow _songRow;

		private readonly SongDataFromDB _song;

		public bool isDownloadAvailable;

		public bool isOwned;

		private Coroutine? _fileSizeCoroutine;

		public SongDownloadObject(Transform canvasTransform, SongDataFromDB song, TootTallySettingPage page)
			: base("Song" + song.track_ref, page)
		{
			_song = song;
			_songRow = SongRow.Create().WithParent(canvasTransform).WithSongName(song.name)
				.WithArtist(song.author)
				.WithDurationSeconds(song.song_length)
				.WithDifficulty(song.difficulty)
				.WithCharter(song.charter)
				.OnDownload(DownloadChart);
			if (FSharpOption<TromboneTrack>[TrackLookup.tryLookup(song.track_ref)] && !((SongDownloadPage)(object)base._page).IsAlreadyDownloaded(song.track_ref))
			{
				string link = FileHelper.GetDownloadLinkFromSongData(song);
				if (link != null)
				{
					_songRow.WithDownloadState(new DownloadState.Waiting());
					_fileSizeCoroutine = ((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)TootTallyAPIService.GetFileSize(link, (Action<FileData>)delegate(FileData fileData)
					{
						if (fileData != null)
						{
							if (!fileData.extension.Contains("zip"))
							{
								DisplaySongNotAvailable("File is not zip: " + fileData.extension + ".");
							}
							else
							{
								_fileSizeCoroutine = null;
								_songRow.WithFileSize(fileData.size).WithDownloadState(new DownloadState.DownloadAvailable());
							}
						}
						else
						{
							DisplaySongNotAvailable("Couldn't access file at " + link);
						}
					}));
				}
				else
				{
					DisplaySongNotAvailable("No download link found.");
				}
			}
			else
			{
				_songRow.WithDownloadState(new DownloadState.Owned());
			}
		}

		public void DisplaySongNotAvailable(string error)
		{
			Plugin.LogWarning(_song.track_ref + " cannot be downloaded: " + error);
			_songRow.WithDownloadState(new DownloadState.DownloadUnavailable());
		}

		public void SetActive(bool active)
		{
			_songRow.GameObject.SetActive(active);
		}

		public override void Dispose()
		{
			_songRow.Dispose();
			if (_fileSizeCoroutine != null)
			{
				((MonoBehaviour)Plugin.Instance).StopCoroutine(_fileSizeCoroutine);
			}
		}

		public void DownloadChart()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			ProgressCounter val = new ProgressCounter(Array.Empty<IProgressCountable>());
			_songRow.WithDownloadState(new DownloadState.Downloading
			{
				Progress = val
			});
			string text = _song.mirror ?? _song.download;
			((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)TootTallyAPIService.DownloadZipFromServer(text, val, (Action<byte[]>)delegate(byte[] data)
			{
				if (data != null)
				{
					string text2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location), "Downloads/");
					string text3 = $"{_song.id}.zip";
					if (!Directory.Exists(text2))
					{
						Directory.CreateDirectory(text2);
					}
					FileHelper.WriteBytesToFile(text2, text3, data);
					string text4 = Path.Combine(text2, text3);
					string text5 = Path.Combine(Paths.BepInExRootPath, "CustomSongs/");
					FileHelper.ExtractZipToDirectory(text4, text5);
					FileHelper.DeleteFile(text2, text3);
					isOwned = true;
					_songRow.WithDownloadState(new DownloadState.Owned());
					SongDownloadPage songDownloadPage = (SongDownloadPage)(object)base._page;
					songDownloadPage.AddTrackRefToDownloadedSong(_song.track_ref);
					SetActive(!songDownloadPage.ShowNotOwnedOnly);
				}
				else
				{
					TootTallyNotifManager.DisplayNotif("Download failed.", 6f);
					_songRow.WithDownloadState(new DownloadState.DownloadAvailable());
				}
			}));
		}
	}
	internal class SongDownloadPage : TootTallySettingPage
	{
		private const string DEFAULT_INPUT_TEXT = "SearchHere";

		private TMP_InputField _inputField;

		private GameObject _searchButton;

		private GameObject _nextButton;

		private GameObject _prevButton;

		private GameObject _downloadAllButton;

		private Toggle _toggleRated;

		private Toggle _toggleUnrated;

		private Toggle _toggleNotOwned;

		private LoadingIcon _loadingIcon;

		private List<string> _trackRefList;

		private List<string> _newDownloadedTrackRefs;

		private List<SongDownloadObject> _downloadObjectList;

		public bool ShowNotOwnedOnly => _toggleNotOwned.isOn;

		private static ColorBlock GetButtonColors
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				ColorBlock result = default(ColorBlock);
				((ColorBlock)(ref result)).normalColor = new Color(0.2f, 0.2f, 1f);
				((ColorBlock)(ref result)).highlightedColor = new Color(0.15f, 0.15f, 0.65f);
				((ColorBlock)(ref result)).pressedColor = new Color(0.5f, 0.5f, 0.75f);
				((ColorBlock)(ref result)).selectedColor = new Color(0.2f, 0.2f, 1f);
				((ColorBlock)(ref result)).fadeDuration = 0.08f;
				((ColorBlock)(ref result)).colorMultiplier = 1f;
				return result;
			}
		}

		public SongDownloadPage()
			: base("MoreSongs", "More Songs", 20f, new Color(0f, 0f, 0f, 0.1f), GetButtonColors)
		{
		}//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)


		public override void Initialize()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Expected O, but got Unknown
			((TootTallySettingPage)this).Initialize();
			_trackRefList = new List<string>();
			_newDownloadedTrackRefs = new List<string>();
			_downloadObjectList = new List<SongDownloadObject>();
			_inputField = TootTallySettingObjectFactory.CreateInputField(base._fullPanel.transform, base.name + "InputField", TootTallySettingPage.DEFAULT_OBJECT_SIZE, TootTallySettingPage.DEFAULT_FONTSIZE, "SearchHere", false);
			((UnityEvent<string>)(object)_inputField.onSubmit).AddListener((UnityAction<string>)delegate
			{
				Search(_inputField.text);
			});
			RectTransform component = ((Component)_inputField).GetComponent<RectTransform>();
			RectTransform component2 = ((Component)_inputField).GetComponent<RectTransform>();
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.72f, 0.7f);
			component2.anchorMax = val;
			component.anchorMin = val;
			_loadingIcon = GameObjectFactory.CreateLoadingIcon(base._fullPanel.transform, new Vector2(-300f, -75f), new Vector2(128f, 128f), AssetManager.GetSprite("icon.png"), false, "SongSearchLoadingSwirly");
			_searchButton = ((Component)GameObjectFactory.CreateCustomButton(base._fullPanel.transform, new Vector2(-375f, -175f), TootTallySettingPage.DEFAULT_OBJECT_SIZE, "Search", base.name + "SearchButton", (Action)delegate
			{
				Search(_inputField.text);
			})).gameObject;
			_toggleRated = TootTallySettingObjectFactory.CreateToggle(base._fullPanel.transform, base.name + "ToggleRated", new Vector2(200f, 60f), "Rated", (ConfigEntry<bool>)null);
			RectTransform component3 = ((Component)_toggleRated).GetComponent<RectTransform>();
			RectTransform component4 = ((Component)_toggleRated).GetComponent<RectTransform>();
			((Vector2)(ref val))..ctor(0.63f, 0.58f);
			component4.anchorMax = val;
			component3.anchorMin = val;
			((UnityEvent<bool>)(object)_toggleRated.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				if (value)
				{
					_toggleUnrated.SetIsOnWithoutNotify(!value);
				}
			});
			_toggleUnrated = TootTallySettingObjectFactory.CreateToggle(base._fullPanel.transform, base.name + "ToggleUnrated", new Vector2(200f, 60f), "Unrated", (ConfigEntry<bool>)null);
			RectTransform component5 = ((Component)_toggleUnrated).GetComponent<RectTransform>();
			RectTransform component6 = ((Component)_toggleUnrated).GetComponent<RectTransform>();
			((Vector2)(ref val))..ctor(0.63f, 0.5f);
			component6.anchorMax = val;
			component5.anchorMin = val;
			((UnityEvent<bool>)(object)_toggleUnrated.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
			{
				if (value)
				{
					_toggleRated.SetIsOnWithoutNotify(!value);
				}
			});
			_toggleNotOwned = TootTallySettingObjectFactory.CreateToggle(base._fullPanel.transform, base.name + "ToggleNotOwned", new Vector2(200f, 60f), "Not Owned", (ConfigEntry<bool>)null);
			RectTransform component7 = ((Component)_toggleNotOwned).GetComponent<RectTransform>();
			RectTransform component8 = ((Component)_toggleNotOwned).GetComponent<RectTransform>();
			((Vector2)(ref val))..ctor(0.63f, 0.42f);
			component8.anchorMax = val;
			component7.anchorMin = val;
			((UnityEvent<bool>)(object)_toggleNotOwned.onValueChanged).AddListener((UnityAction<bool>)OnNotOwnedToggle);
			_downloadAllButton = ((Component)GameObjectFactory.CreateCustomButton(base._fullPanel.transform, new Vector2(-1330f, -87f), new Vector2(200f, 60f), "Download All", "DownloadAllButton", (Action)DownloadAll)).gameObject;
			_downloadAllButton.SetActive(false);
			((UnityEvent)base._backButton.button.onClick).AddListener((UnityAction)delegate
			{
				if (_newDownloadedTrackRefs.Count > 0)
				{
					TootTallyNotifManager.DisplayNotif("New tracks detected, Reloading songs...\nLagging is normal.", 6f);
					_newDownloadedTrackRefs.Clear();
					((MonoBehaviour)Plugin.Instance).Invoke("ReloadTracks", 0.35f);
				}
			});
			base._scrollableSliderHandler.accelerationMult = 0.09f;
			((HorizontalOrVerticalLayoutGroup)base.gridPanel.GetComponent<VerticalLayoutGroup>()).spacing = 8f;
		}

		public override void OnShow()
		{
			_loadingIcon.StartRecursiveAnimation();
		}

		public override void OnHide()
		{
			_loadingIcon.StopRecursiveAnimation(true);
		}

		private void Search(string input, bool searchWithFilter = true)
		{
			if (input == "SearchHere")
			{
				input = "";
			}
			_downloadObjectList.Clear();
			_downloadAllButton.SetActive(false);
			((TootTallySettingPage)this).RemoveAllObjects();
			_searchButton.SetActive(false);
			_loadingIcon.Show();
			if ((Object)(object)_nextButton != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)_nextButton);
				_nextButton = null;
			}
			if ((Object)(object)_prevButton != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)_prevButton);
				_prevButton = null;
			}
			_trackRefList.Clear();
			if (searchWithFilter)
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)TootTallyAPIService.SearchSongWithFilters(input, _toggleRated.isOn, _toggleUnrated.isOn, (Action<SongInfoFromDB>)OnSearchInfoRecieved));
			}
			else
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine((IEnumerator)TootTallyAPIService.SearchSongByURL(input, (Action<SongInfoFromDB>)OnSearchInfoRecieved));
			}
		}

		private void OnSearchInfoRecieved(SongInfoFromDB? searchInfo)
		{
			//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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			SongInfoFromDB searchInfo2 = searchInfo;
			_searchButton.SetActive(true);
			_loadingIcon.Hide();
			base._verticalSlider.value = 0f;
			if (searchInfo2 == null)
			{
				return;
			}
			searchInfo2.results.OrderByDescending((SongDataFromDB x) => x.id).ToList()?.ForEach(AddSongToPage);
			((Component)base._verticalSlider).gameObject.SetActive(searchInfo2.results.Length > 5);
			((Behaviour)base._scrollableSliderHandler).enabled = searchInfo2.results.Length > 5;
			if (searchInfo2.next != null)
			{
				_nextButton = ((Component)GameObjectFactory.CreateCustomButton(base._fullPanel.transform, new Vector2(-350f, -175f), new Vector2(50f, 50f), ">>", base.name + "NextButton", (Action)delegate
				{
					Search(searchInfo2.next, searchWithFilter: false);
				})).gameObject;
			}
			if (searchInfo2.previous != null)
			{
				_prevButton = ((Component)GameObjectFactory.CreateCustomButton(base._fullPanel.transform, new Vector2(-700f, -175f), new Vector2(50f, 50f), "<<", base.name + "PrevButton", (Action)delegate
				{
					Search(searchInfo2.previous, searchWithFilter: false);
				})).gameObject;
			}
		}

		public void UpdateDownloadAllButton()
		{
			if (!_downloadAllButton.activeSelf)
			{
				_downloadAllButton.SetActive(_downloadObjectList.Any((SongDownloadObject o) => o.isDownloadAvailable));
			}
		}

		private void DownloadAll()
		{
			_downloadAllButton.SetActive(false);
			CollectionExtensions.Do<SongDownloadObject>(_downloadObjectList.Where((SongDownloadObject o) => o.isDownloadAvailable), (Action<SongDownloadObject>)delegate(SongDownloadObject o)
			{
				o.DownloadChart();
			});
		}

		private void AddSongToPage(SongDataFromDB song)
		{
			if (!_trackRefList.Contains(song.track_ref))
			{
				_trackRefList.Add(song.track_ref);
				SongDownloadObject songDownloadObject = new SongDownloadObject(base.gridPanel.transform, song, (TootTallySettingPage)(object)this);
				songDownloadObject.SetActive(!_toggleNotOwned.isOn || !songDownloadObject.isOwned);
				_downloadObjectList.Add(songDownloadObject);
				((TootTallySettingPage)this).AddSettingObjectToList((BaseTootTallySettingObject)(object)songDownloadObject);
			}
		}

		private void OnNotOwnedToggle(bool value)
		{
			_downloadObjectList.ForEach(delegate(SongDownloadObject x)
			{
				x.SetActive(!value || !x.isOwned);
			});
		}

		public void AddTrackRefToDownloadedSong(string trackref)
		{
			_newDownloadedTrackRefs.Add(trackref);
		}

		public bool IsAlreadyDownloaded(string trackref)
		{
			return _newDownloadedTrackRefs.Contains(trackref);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TootTallySongDownloader";

		public const string PLUGIN_NAME = "TootTallySongDownloader";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace TootTallySongDownloader.Ui
{
	public class DownloadButton
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__12_0;

			internal void <Create>b__12_0()
			{
				Debug.Log((object)"OHAI!");
			}
		}

		private readonly GameObject _gameObject;

		private readonly Button _button;

		private readonly Image _fillImage;

		private readonly Image _downloadIconImage;

		private readonly TMP_Text _filesizeText;

		private readonly Image _altIconImage;

		private readonly LoadingIcon _loadingIcon;

		private readonly ProgressPieGraphic _progressPie;

		private DownloadState _downloadState = new DownloadState.Waiting();

		private RectTransform Transform => (RectTransform)_gameObject.transform;

		private DownloadButton(GameObject gameObject, Button button, Image fillImage, Image downloadIconImage, TMP_Text filesizeText, Image altIconImage, LoadingIcon loadingIcon, ProgressPieGraphic progressPie)
		{
			_gameObject = gameObject;
			_button = button;
			_fillImage = fillImage;
			_downloadIconImage = downloadIconImage;
			_filesizeText = filesizeText;
			_altIconImage = altIconImage;
			_loadingIcon = loadingIcon;
			_progressPie = progressPie;
		}

		internal static DownloadButton Create()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Expected O, but got Unknown
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Expected O, but got Unknown
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: 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_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Expected O, but got Unknown
			//IL_04aa: 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_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: 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_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Expected O, but got Unknown
			//IL_0519: 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_051c: 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_052e: 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_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Expected O, but got Unknown
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Expected O, but got Unknown
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			GameObject val = new GameObject("DownloadButton", new Type[5]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(GraphicRaycaster),
				typeof(LayoutElement),
				typeof(Button)
			});
			Transform transform = val.transform;
			LayoutElement component = val.GetComponent<LayoutElement>();
			component.preferredWidth = 64f;
			Button component2 = val.GetComponent<Button>();
			ButtonClickedEvent onClick = component2.onClick;
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					Debug.Log((object)"OHAI!");
				};
				<>c.<>9__12_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			GameObject val3 = new GameObject("PanelFill", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform val4 = (RectTransform)val3.transform;
			((Transform)val4).SetParent(transform, false);
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = Vector2.zero;
			Image component3 = val3.GetComponent<Image>();
			Texture2D texture = AssetManager.GetTexture("RoundedBoxRightFill.png");
			component3.sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.one * 0.5f, 100f, 1u, (SpriteMeshType)0, new Vector4(4f, 4f, 4f, 4f), false);
			component3.type = (Type)1;
			((Graphic)component3).color = new Color(0.91f, 0.212f, 0.333f);
			((Selectable)component2).targetGraphic = (Graphic)(object)component3;
			GameObject val5 = new GameObject("PanelBorder", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform val6 = (RectTransform)val5.transform;
			((Transform)val6).SetParent(transform, false);
			val6.anchorMin = Vector2.zero;
			val6.anchorMax = Vector2.one;
			val6.offsetMin = Vector2.zero;
			val6.offsetMax = Vector2.zero;
			Image component4 = val5.GetComponent<Image>();
			Texture2D texture2 = AssetManager.GetTexture("RoundedBoxRightBorder.png");
			component4.sprite = Sprite.Create(texture2, new Rect(0f, 0f, (float)((Texture)texture2).width, (float)((Texture)texture2).height), Vector2.one * 0.5f, 100f, 1u, (SpriteMeshType)0, new Vector4(4f, 4f, 4f, 4f), false);
			component4.type = (Type)1;
			((Graphic)component4).color = new Color(0.91f, 0.212f, 0.333f);
			GameObject val7 = new GameObject("DownloadIcon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val7.SetActive(false);
			Image component5 = val7.GetComponent<Image>();
			component5.sprite = AssetManager.GetSprite("Download64.png");
			Vector2 val8 = Vector2.one * 0.5f;
			RectTransform val9 = (RectTransform)val7.transform;
			((Transform)val9).SetParent(transform, false);
			Vector2 anchorMin = (val9.anchorMax = val8);
			val9.anchorMin = anchorMin;
			val9.offsetMin = new Vector2(-18f, -10f);
			val9.offsetMax = new Vector2(18f, 26f);
			TMP_Text val11 = GameObjectFactory.CreateSingleText(transform, "FilesizeText", "12.3 MB", (TextFont)0);
			((Component)val11).gameObject.SetActive(false);
			RectTransform rectTransform = val11.rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = new Vector2(1f, 0f);
			rectTransform.offsetMin = Vector2.one * 4f;
			rectTransform.offsetMax = new Vector2(-4f, 24f);
			val11.fontSize = 14f;
			val11.alignment = (TextAlignmentOptions)1026;
			val11.overflowMode = (TextOverflowModes)2;
			val11.enableWordWrapping = false;
			GameObject val12 = new GameObject("AltIcon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val12.SetActive(false);
			Vector2 val13 = Vector2.one * 24f;
			RectTransform val14 = (RectTransform)val12.transform;
			((Transform)val14).SetParent(transform, false);
			anchorMin = (val14.anchorMax = val8);
			val14.anchorMin = anchorMin;
			val14.offsetMin = -val13;
			val14.offsetMax = val13;
			LoadingIcon val16 = GameObjectFactory.CreateLoadingIcon(transform, Vector2.zero, Vector2.one * 48f, AssetManager.GetSprite("IconMono.png"), true, "LoadingIcon");
			RectTransform val17 = (RectTransform)val16.iconHolder.transform;
			anchorMin = (val17.anchorMax = val8);
			val17.anchorMin = anchorMin;
			val17.offsetMin = -val13;
			val17.offsetMax = val13;
			GameObject val19 = new GameObject("ProgressPie", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(ProgressPieGraphic)
			});
			val19.SetActive(false);
			RectTransform val20 = (RectTransform)val19.transform;
			((Transform)val20).SetParent(transform, false);
			anchorMin = (val20.anchorMax = val8);
			val20.anchorMin = anchorMin;
			val20.offsetMin = -val13;
			val20.offsetMax = val13;
			return new DownloadButton(val, component2, component3, component5, val11, val12.GetComponent<Image>(), val16, val19.GetComponent<ProgressPieGraphic>());
		}

		internal DownloadButton WithParent(Transform parent)
		{
			((Transform)Transform).SetParent(parent, false);
			return this;
		}

		internal DownloadButton WithFilesize(long numBytes)
		{
			_filesizeText.text = FileHelper.SizeSuffix(numBytes, 1);
			return this;
		}

		internal DownloadButton WithDownloadState(DownloadState state)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: 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_0332: Unknown result type (might be due to invalid IL or missing references)
			_downloadState = state;
			if (!(state is DownloadState.DownloadAvailable))
			{
				if (!(state is DownloadState.DownloadUnavailable))
				{
					if (!(state is DownloadState.Downloading downloading))
					{
						if (!(state is DownloadState.Owned))
						{
							if (!(state is DownloadState.Waiting))
							{
								throw new ArgumentOutOfRangeException("state");
							}
							((Component)_downloadIconImage).gameObject.SetActive(false);
							((Component)_filesizeText).gameObject.SetActive(false);
							((Component)_altIconImage).gameObject.SetActive(false);
							_loadingIcon.iconHolder.SetActive(true);
							_loadingIcon.StartRecursiveAnimation();
							((Component)_progressPie).gameObject.SetActive(false);
							((Graphic)_fillImage).color = new Color(0.102f, 0.102f, 0.102f);
						}
						else
						{
							((Component)_downloadIconImage).gameObject.SetActive(false);
							((Component)_filesizeText).gameObject.SetActive(false);
							((Component)_altIconImage).gameObject.SetActive(true);
							_loadingIcon.iconHolder.SetActive(false);
							_loadingIcon.StopRecursiveAnimation(true);
							((Component)_progressPie).gameObject.SetActive(false);
							((Graphic)_fillImage).color = new Color(0.102f, 0.102f, 0.102f);
							_altIconImage.sprite = AssetManager.GetSprite("PageTick64.png");
						}
					}
					else
					{
						((Component)_downloadIconImage).gameObject.SetActive(false);
						((Component)_filesizeText).gameObject.SetActive(false);
						((Component)_altIconImage).gameObject.SetActive(false);
						_loadingIcon.iconHolder.SetActive(false);
						_loadingIcon.StopRecursiveAnimation(true);
						((Component)_progressPie).gameObject.SetActive(true);
						downloading.Progress.AddCounter((IProgressCountable)(object)_progressPie);
						((Graphic)_fillImage).color = new Color(0.102f, 0.102f, 0.102f);
					}
				}
				else
				{
					((Component)_downloadIconImage).gameObject.SetActive(false);
					((Component)_filesizeText).gameObject.SetActive(false);
					((Component)_altIconImage).gameObject.SetActive(true);
					_loadingIcon.iconHolder.SetActive(false);
					_loadingIcon.StopRecursiveAnimation(true);
					((Component)_progressPie).gameObject.SetActive(false);
					((Graphic)_fillImage).color = new Color(0.102f, 0.102f, 0.102f);
					_altIconImage.sprite = AssetManager.GetSprite("PageBroken64.png");
				}
			}
			else
			{
				((Component)_downloadIconImage).gameObject.SetActive(true);
				((Component)_filesizeText).gameObject.SetActive(true);
				((Component)_altIconImage).gameObject.SetActive(false);
				_loadingIcon.iconHolder.SetActive(false);
				_loadingIcon.StopRecursiveAnimation(true);
				((Component)_progressPie).gameObject.SetActive(false);
				((Graphic)_fillImage).color = new Color(0.91f, 0.212f, 0.333f);
			}
			return this;
		}

		internal void OnDownload(Action callback)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			Action callback2 = callback;
			((UnityEvent)_button.onClick).AddListener((UnityAction)delegate
			{
				if (_downloadState is DownloadState.DownloadAvailable)
				{
					callback2();
				}
			});
		}
	}
	public class MainBody
	{
		private readonly GameObject _gameObject;

		private readonly TMP_Text _songNameText;

		private readonly TMP_Text _artistText;

		private readonly StatDisplay _durationStatDisplay;

		private readonly StatDisplay _difficultyStatDisplay;

		private readonly StatDisplay _charterStatDisplay;

		private RectTransform Transform => (RectTransform)_gameObject.transform;

		private MainBody(GameObject gameObject, TMP_Text songNameText, TMP_Text artistText, StatDisplay durationStatDisplay, StatDisplay difficultyStatDisplay, StatDisplay charterStatDisplay)
		{
			_gameObject = gameObject;
			_songNameText = songNameText;
			_artistText = artistText;
			_durationStatDisplay = durationStatDisplay;
			_difficultyStatDisplay = difficultyStatDisplay;
			_charterStatDisplay = charterStatDisplay;
		}

		internal static MainBody Create()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b6: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01c8: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Expected O, but got Unknown
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: 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_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Expected O, but got Unknown
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Expected O, but got Unknown
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("MainBody", new Type[4]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(GraphicRaycaster),
				typeof(LayoutElement)
			});
			RectTransform val2 = (RectTransform)val.transform;
			LayoutElement component = val.GetComponent<LayoutElement>();
			component.flexibleWidth = 1f;
			GameObject val3 = new GameObject("PanelFill", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform val4 = (RectTransform)val3.transform;
			((Transform)val4).SetParent((Transform)(object)val2, false);
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = Vector2.zero;
			Image component2 = val3.GetComponent<Image>();
			Texture2D texture = AssetManager.GetTexture("RoundedBoxLeftFill.png");
			component2.sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.one * 0.5f, 100f, 1u, (SpriteMeshType)0, Vector4.one * 4f, false);
			component2.type = (Type)1;
			((Graphic)component2).color = new Color(0.102f, 0.102f, 0.102f);
			GameObject val5 = new GameObject("PanelBorder", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform val6 = (RectTransform)val5.transform;
			((Transform)val6).SetParent((Transform)(object)val2, false);
			val6.anchorMin = Vector2.zero;
			val6.anchorMax = Vector2.one;
			val6.offsetMin = Vector2.zero;
			val6.offsetMax = Vector2.zero;
			Image component3 = val5.GetComponent<Image>();
			Texture2D texture2 = AssetManager.GetTexture("RoundedBoxLeftBorder.png");
			component3.sprite = Sprite.Create(texture2, new Rect(0f, 0f, (float)((Texture)texture2).width, (float)((Texture)texture2).height), Vector2.one * 0.5f, 100f, 1u, (SpriteMeshType)0, Vector4.one * 4f, false);
			component3.type = (Type)1;
			((Graphic)component3).color = new Color(0.91f, 0.212f, 0.333f);
			TMP_Text val7 = GameObjectFactory.CreateSingleText((Transform)(object)val2, "SongName", "", (TextFont)0);
			RectTransform rectTransform = val7.rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 1f);
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = new Vector2(8f, -36f);
			rectTransform.offsetMax = new Vector2(-208f, 0f);
			val7.fontSize = 24f;
			val7.alignment = (TextAlignmentOptions)1025;
			val7.overflowMode = (TextOverflowModes)1;
			val7.enableWordWrapping = false;
			TMP_Text val8 = GameObjectFactory.CreateSingleText((Transform)(object)val2, "Artist", "", (TextFont)0);
			RectTransform rectTransform2 = val8.rectTransform;
			rectTransform2.anchorMin = Vector2.zero;
			rectTransform2.anchorMax = new Vector2(1f, 0f);
			rectTransform2.offsetMin = Vector2.one * 8f;
			rectTransform2.offsetMax = new Vector2(-208f, 58f);
			val8.fontSize = 18f;
			val8.alignment = (TextAlignmentOptions)1025;
			val8.overflowMode = (TextOverflowModes)1;
			val8.enableWordWrapping = false;
			((Graphic)val8).color = new Color(1f, 1f, 1f, 0.5f);
			GameObject val9 = new GameObject("RightTopBox", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			});
			RectTransform val10 = (RectTransform)val9.transform;
			((Transform)val10).SetParent((Transform)(object)val2, false);
			val10.anchorMin = new Vector2(1f, 0f);
			val10.anchorMax = Vector2.one;
			val10.offsetMin = new Vector2(-208f, 8f);
			val10.offsetMax = Vector2.one * -8f;
			HorizontalLayoutGroup component4 = val9.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false;
			((LayoutGroup)component4).childAlignment = (TextAnchor)2;
			((HorizontalOrVerticalLayoutGroup)component4).spacing = 8f;
			StatDisplay durationStatDisplay = StatDisplay.Create().WithParent((Transform)(object)val10).WithIcon("time64.png");
			StatDisplay difficultyStatDisplay = StatDisplay.Create().WithParent((Transform)(object)val10).WithIcon("stardiff64.png");
			GameObject val11 = new GameObject("RightBottomBox", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			});
			RectTransform val12 = (RectTransform)val11.transform;
			((Transform)val12).SetParent((Transform)(object)val2, false);
			val12.anchorMin = new Vector2(1f, 0f);
			val12.anchorMax = Vector2.one;
			val12.offsetMin = new Vector2(-208f, 8f);
			val12.offsetMax = Vector2.one * -8f;
			HorizontalLayoutGroup component5 = val11.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component5).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandHeight = false;
			((LayoutGroup)component5).childAlignment = (TextAnchor)8;
			((HorizontalOrVerticalLayoutGroup)component5).spacing = 8f;
			StatDisplay charterStatDisplay = StatDisplay.Create().WithParent((Transform)(object)val12).WithIcon("Pencil64.png");
			return new MainBody(val, val7, val8, durationStatDisplay, difficultyStatDisplay, charterStatDisplay);
		}

		internal MainBody WithParent(Transform parent)
		{
			((Transform)Transform).SetParent(parent, false);
			return this;
		}

		internal MainBody WithSongName(string text)
		{
			_songNameText.text = text;
			return this;
		}

		internal MainBody WithArtist(string text)
		{
			_artistText.text = text;
			return this;
		}

		internal MainBody WithDurationSeconds(float seconds)
		{
			TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
			string text = string.Format("{0}{1}:{2:00}", (timeSpan.Hours != 0) ? (timeSpan.Hours + ":") : "", (timeSpan.Minutes != 0) ? ((object)timeSpan.Minutes) : "0", (timeSpan.Seconds != 0) ? ((object)timeSpan.Seconds) : "00");
			_durationStatDisplay.WithText(text);
			return this;
		}

		internal MainBody WithDifficulty(float difficulty)
		{
			_difficultyStatDisplay.WithText(difficulty.ToString("n2"));
			return this;
		}

		internal MainBody WithCharter(string charterDisplayName)
		{
			_charterStatDisplay.WithText(charterDisplayName);
			return this;
		}
	}
	public class MoreInfoButton
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__4_0;

			internal void <Create>b__4_0()
			{
				TootTallyNotifManager.DisplayNotif("Coming soon... Sorry!", 6f);
				Plugin.LogInfo("NOT IMPLEMENTED YET!! OHAI!");
			}
		}

		private readonly GameObject _gameObject;

		private RectTransform Transform => (RectTransform)_gameObject.transform;

		private MoreInfoButton(GameObject gameObject)
		{
			_gameObject = gameObject;
		}

		internal static MoreInfoButton Create()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: 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_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			GameObject val = new GameObject("MoreInfoButton", new Type[5]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(GraphicRaycaster),
				typeof(LayoutElement),
				typeof(Button)
			});
			Transform transform = val.transform;
			LayoutElement component = val.GetComponent<LayoutElement>();
			component.preferredWidth = 24f;
			Button component2 = val.GetComponent<Button>();
			ButtonClickedEvent onClick = component2.onClick;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					TootTallyNotifManager.DisplayNotif("Coming soon... Sorry!", 6f);
					Plugin.LogInfo("NOT IMPLEMENTED YET!! OHAI!");
				};
				<>c.<>9__4_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			GameObject val3 = new GameObject("PanelFill", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform val4 = (RectTransform)val3.transform;
			((Transform)val4).SetParent(transform, false);
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = Vector2.zero;
			Image component3 = val3.GetComponent<Image>();
			Texture2D texture = AssetManager.GetTexture("HBoxMidFill.png");
			component3.sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), Vector2.one * 0.5f, 100f, 1u, (SpriteMeshType)0, Vector4.one * 4f, false);
			component3.type = (Type)1;
			((Graphic)component3).color = new Color(0.557f, 0.129f, 0.204f);
			((Selectable)component2).targetGraphic = (Graphic)(object)component3;
			GameObject val5 = new GameObject("PanelBorder", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform val6 = (RectTransform)val5.transform;
			((Transform)val6).SetParent(transform, false);
			val6.anchorMin = Vector2.zero;
			val6.anchorMax = Vector2.one;
			val6.offsetMin = Vector2.zero;
			val6.offsetMax = Vector2.zero;
			Image component4 = val5.GetComponent<Image>();
			Texture2D texture2 = AssetManager.GetTexture("HBoxMidBorder.png");
			component4.sprite = Sprite.Create(texture2, new Rect(0f, 0f, (float)((Texture)texture2).width, (float)((Texture)texture2).height), Vector2.one * 0.5f, 100f, 1u, (SpriteMeshType)0, Vector4.one * 4f, false);
			component4.type = (Type)1;
			((Graphic)component4).color = new Color(0.91f, 0.212f, 0.333f);
			GameObject val7 = new GameObject("Icon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			RectTransform val8 = (RectTransform)val7.transform;
			((Transform)val8).SetParent(transform, false);
			val8.anchorMin = Vector2.one * 0.5f;
			val8.anchorMax = Vector2.one * 0.5f;
			val8.offsetMin = new Vector2(-3f, -11.5f);
			val8.offsetMax = new Vector2(3f, 11.5f);
			val7.GetComponent<Image>().sprite = AssetManager.GetSprite("MoreInfoIcon.png");
			return new MoreInfoButton(val);
		}

		internal MoreInfoButton WithParent(Transform parent)
		{
			((Transform)Transform).SetParent(parent, false);
			return this;
		}
	}
	public class ProgressPieGraphic : MaskableGraphic, IProgressCountable
	{
		private float _fillPercent = 0f;

		internal float FillPercent
		{
			get
			{
				return _fillPercent;
			}
			set
			{
				_fillPercent = value;
				((Graphic)this).SetVerticesDirty();
			}
		}

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00c7: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00ef: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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)
			vh.Clear();
			Rect rect = ((Graphic)this).rectTransform.rect;
			Vector2 center = ((Rect)(ref rect)).center;
			float num = Mathf.Min(((Rect)(ref rect)).width, ((Rect)(ref rect)).height) / 2f;
			UIVertex val = default(UIVertex);
			val.position = Vector2.op_Implicit(center);
			val.color = Color32.op_Implicit(((Graphic)this).color);
			UIVertex val2 = val;
			vh.AddVert(val2);
			for (float num2 = 0f; num2 < (float)Math.PI * 2f * FillPercent; num2 += 0.025f)
			{
				int currentVertCount = vh.currentVertCount;
				int num3 = currentVertCount + 1;
				Vector2 val3 = new Vector2(Mathf.Sin(num2), Mathf.Cos(num2)) * num;
				Vector2 val4 = new Vector2(Mathf.Sin(num2 + 0.025f), Mathf.Cos(num2 + 0.025f)) * num;
				val = default(UIVertex);
				val.position = Vector2.op_Implicit(val3);
				val.color = Color32.op_Implicit(((Graphic)this).color);
				UIVertex val5 = val;
				val = default(UIVertex);
				val.position = Vector2.op_Implicit(val4);
				val.color = Color32.op_Implicit(((Graphic)this).color);
				UIVertex val6 = val;
				vh.AddVert(val5);
				vh.AddVert(val6);
				vh.AddTriangle(0, currentVertCount, num3);
			}
		}

		public void OnProgressCounterFinish(ProgressCounter sender, double elapsed)
		{
			FillPercent = 100f;
			sender.RemoveCounter((IProgressCountable)(object)this);
		}

		public void OnProgressCounterUpdate(ProgressCounter sender, float progress)
		{
			FillPercent = progress;
		}
	}
	public class SongRow : IDisposable
	{
		internal readonly GameObject GameObject;

		private readonly MainBody _mainBody;

		private readonly DownloadButton _downloadButton;

		private RectTransform Transform => (RectTransform)GameObject.transform;

		private SongRow(GameObject gameObject, MainBody mainBody, DownloadButton downloadButton)
		{
			GameObject = gameObject;
			_mainBody = mainBody;
			_downloadButton = downloadButton;
		}

		internal static SongRow Create()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("SongRow", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			});
			RectTransform val2 = (RectTransform)val.transform;
			val2.sizeDelta = new Vector2(1050f, 64f);
			HorizontalLayoutGroup component = val.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = true;
			MainBody mainBody = MainBody.Create().WithParent((Transform)(object)val2);
			MoreInfoButton.Create().WithParent((Transform)(object)val2);
			DownloadButton downloadButton = DownloadButton.Create().WithParent((Transform)(object)val2);
			return new SongRow(val, mainBody, downloadButton);
		}

		internal SongRow WithParent(Transform parent)
		{
			((Transform)Transform).SetParent(parent, false);
			return this;
		}

		internal SongRow WithSongName(string text)
		{
			_mainBody.WithSongName(text);
			return this;
		}

		internal SongRow WithArtist(string text)
		{
			_mainBody.WithArtist(text);
			return this;
		}

		internal SongRow WithDurationSeconds(float seconds)
		{
			_mainBody.WithDurationSeconds(seconds);
			return this;
		}

		internal SongRow WithDifficulty(float difficulty)
		{
			_mainBody.WithDifficulty(difficulty);
			return this;
		}

		internal SongRow WithCharter(string charterDisplayName)
		{
			_mainBody.WithCharter(charterDisplayName);
			return this;
		}

		internal SongRow WithDownloadState(DownloadState state)
		{
			_downloadButton.WithDownloadState(state);
			return this;
		}

		internal SongRow WithFileSize(long fileDataSize)
		{
			_downloadButton.WithFilesize(fileDataSize);
			return this;
		}

		internal SongRow OnDownload(Action callback)
		{
			_downloadButton.OnDownload(callback);
			return this;
		}

		public void Dispose()
		{
			Object.DestroyImmediate((Object)(object)GameObject);
		}
	}
	public class StatDisplay
	{
		private readonly GameObject _gameObject;

		private readonly Image _image;

		private readonly TMP_Text _text;

		private RectTransform Transform => (RectTransform)_gameObject.transform;

		private StatDisplay(GameObject gameObject, Image image, TMP_Text text)
		{
			_gameObject = gameObject;
			_image = image;
			_text = text;
		}

		internal static StatDisplay Create()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			GameObject val = new GameObject("StatDisplay", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			});
			Transform transform = val.transform;
			HorizontalLayoutGroup component = val.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)component).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component).spacing = 4f;
			GameObject val2 = new GameObject("Icon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			RectTransform val3 = (RectTransform)val2.transform;
			((Transform)val3).SetParent(transform, false);
			TMP_Text val4 = GameObjectFactory.CreateSingleText(transform, "Text", "", (TextFont)0);
			val4.fontSize = 18f;
			val4.enableWordWrapping = false;
			val4.autoSizeTextContainer = true;
			return new StatDisplay(val, val2.GetComponent<Image>(), val4);
		}

		internal StatDisplay WithParent(Transform parent)
		{
			((Transform)Transform).SetParent(parent, false);
			return this;
		}

		internal StatDisplay WithIcon(string assetKey)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			_image.sprite = AssetManager.GetSprite(assetKey);
			((RectTransform)((Component)_image).transform).sizeDelta = Vector2.one * 20f;
			return this;
		}

		internal StatDisplay WithText(string text)
		{
			_text.text = text;
			return this;
		}
	}
}
namespace TootTallySongDownloader.SongDownloader
{
	public class ChartPackDownloadPage : TootTallySettingPage
	{
		private const string DEFAULT_INPUT_TEXT = "SearchHere";

		private TMP_InputField _inputField;

		private GameObject _searchButton;

		private GameObject _nextButton;

		private GameObject _prevButton;

		private LoadingIcon _loadingIcon;

		private List<string> _newDownloadedTrackRefs;

		private static ColorBlock GetButtonColors
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				ColorBlock result = default(ColorBlock);
				((ColorBlock)(ref result)).normalColor = new Color(0.2f, 0.2f, 1f);
				((ColorBlock)(ref result)).highlightedColor = new Color(0.15f, 0.15f, 0.65f);
				((ColorBlock)(ref result)).pressedColor = new Color(0.5f, 0.5f, 0.75f);
				((ColorBlock)(ref result)).selectedColor = new Color(0.2f, 0.2f, 1f);
				((ColorBlock)(ref result)).fadeDuration = 0.08f;
				((ColorBlock)(ref result)).colorMultiplier = 1f;
				return result;
			}
		}

		public ChartPackDownloadPage()
			: base("Chart Packs", "Chart Packs", 20f, new Color(0f, 0f, 0f, 0.1f), GetButtonColors)
		{
		}//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)


		public override void Initialize()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			((TootTallySettingPage)this).Initialize();
			_inputField = TootTallySettingObjectFactory.CreateInputField(base._fullPanel.transform, base.name + "InputField", TootTallySettingPage.DEFAULT_OBJECT_SIZE, TootTallySettingPage.DEFAULT_FONTSIZE, "SearchHere", false);
			((UnityEvent<string>)(object)_inputField.onSubmit).AddListener((UnityAction<string>)delegate
			{
				Search(_inputField.text);
			});
			RectTransform component = ((Component)_inputField).GetComponent<RectTransform>();
			RectTransform component2 = ((Component)_inputField).GetComponent<RectTransform>();
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.72f, 0.7f);
			component2.anchorMax = val;
			component.anchorMin = val;
			_loadingIcon = GameObjectFactory.CreateLoadingIcon(base._fullPanel.transform, new Vector2(-300f, -75f), new Vector2(128f, 128f), AssetManager.GetSprite("icon.png"), false, "SongSearchLoadingSwirly");
			_searchButton = ((Component)GameObjectFactory.CreateCustomButton(base._fullPanel.transform, new Vector2(-375f, -175f), TootTallySettingPage.DEFAULT_OBJECT_SIZE, "Search", base.name + "SearchButton", (Action)delegate
			{
				Search(_inputField.text);
			})).gameObject;
			((UnityEvent)base._backButton.button.onClick).AddListener((UnityAction)delegate
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: 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_008e: Expected O, but got Unknown
				if (_newDownloadedTrackRefs.Count > 0)
				{
					TootTallyNotifManager.DisplayNotif("New tracks detected, Reloading songs...\nLagging is normal.", 6f);
					_newDownloadedTrackRefs.Clear();
					Plugin.Instance.reloadManager.ReloadAll((IProgressCallbacks)new ProgressCallbacks
					{
						onComplete = delegate
						{
							TootTallyNotifManager.DisplayNotif("Reloading complete!", 6f);
						},
						onError = delegate(Exception err)
						{
							TootTallyNotifManager.DisplayNotif("Reloading failed! " + err.Message, 6f);
						}
					});
				}
			});
		}

		public override void OnShow()
		{
			_loadingIcon.StartRecursiveAnimation();
		}

		public override void OnHide()
		{
			_loadingIcon.StopRecursiveAnimation(true);
		}

		private void Search(string input, bool searchWithFilter = true)
		{
			if (input == "SearchHere")
			{
				input = "";
			}
			((TootTallySettingPage)this).RemoveAllObjects();
			_searchButton.SetActive(false);
			_loadingIcon.Show();
			if ((Object)(object)_nextButton != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)_nextButton);
				_nextButton = null;
			}
			if ((Object)(object)_prevButton != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)_prevButton);
				_prevButton = null;
			}
		}
	}
}