Decompiled source of PeakLevelSelect v1.0.2

PeakLevelSelect.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PeakLevelSelect")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1fe36b16a92d0734a3fee0aa707864afa6aa4d7a")]
[assembly: AssemblyProduct("PeakLevelSelect")]
[assembly: AssemblyTitle("PeakLevelSelect")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace PeakLevelSelect
{
	[BepInPlugin("PeakLevelSelect", "PeakLevelSelect", "1.0.2")]
	public class PeakLevelSelectPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource logger;

		public static ConfigEntry<int> SelectedLevel { get; set; }

		public static ConfigEntry<int> SelectedAscent { get; set; }

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			SelectedLevel = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SelectedLevel", -2, "-2 = Random,-1 = Daily,0-14=Level_Num");
			SelectedAscent = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SelectedAscent", -2, "-2 = Default,-1-7 = AscentNum");
			Harmony.CreateAndPatchAll(typeof(GUIManagerPatch), (string)null);
		}
	}
	[HarmonyWrapSafe]
	public static class GUIManagerPatch
	{
		private static int todayLevelIndex;

		private static TMP_FontAsset font;

		private static Image image;

		private static TextMeshProUGUI dropDownText;

		private static TextMeshProUGUI To1;

		private static Image dropdownImage;

		private static Dictionary<string, List<string>> langTable { get; set; }

		private static List<GameObject> buttons { get; set; }

		[HarmonyPatch(typeof(BoardingPass), "UpdateAscent")]
		[HarmonyPostfix]
		public static void UpdateAscent(BoardingPass __instance)
		{
			PeakLevelSelectPlugin.SelectedAscent.Value = __instance.ascentIndex;
		}

		[HarmonyPatch(typeof(MapBaker), "GetLevel")]
		[HarmonyPrefix]
		public static void GetLevel(ref int levelIndex)
		{
			if (PeakLevelSelectPlugin.SelectedLevel.Value == -2)
			{
				levelIndex = Random.Range(0, SingletonAsset<MapBaker>.Instance.AllLevels.Length);
			}
			else if (PeakLevelSelectPlugin.SelectedLevel.Value == -1)
			{
				levelIndex = todayLevelIndex;
			}
			else if (PeakLevelSelectPlugin.SelectedLevel.Value < SingletonAsset<MapBaker>.Instance.AllLevels.Length)
			{
				levelIndex = PeakLevelSelectPlugin.SelectedLevel.Value;
			}
		}

		[HarmonyPatch(typeof(GUIManager), "Start")]
		[HarmonyPostfix]
		public static void Start()
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			langTable = new Dictionary<string, List<string>>();
			langTable.Add("Random", MakeList(((Language)0, "Random"), ((Language)9, "随机地图")));
			langTable.Add("Daily", MakeList(((Language)0, "Daily"), ((Language)9, "当天地图")));
			langTable.Add("Level", MakeList(((Language)0, "Level_{0}"), ((Language)9, "轮换{0}")));
			langTable.Add("Today", MakeList(((Language)0, "Today"), ((Language)9, "今日地图")));
			NextLevelService service = GameHandler.GetService<NextLevelService>();
			if (service != null && service.Data.IsSome)
			{
				int num = service.Data.Value.CurrentLevelIndex + NextLevelService.debugLevelIndexOffset;
				num %= SingletonAsset<MapBaker>.Instance.AllLevels.Length;
				todayLevelIndex = num;
			}
			else
			{
				todayLevelIndex = -3;
			}
			buttons = new List<GameObject>();
			GameObject val = GameObject.Find("GAME/GUIManager/Canvas_BoardingPass");
			BoardingPass component = val.GetComponent<BoardingPass>();
			GameObject val2 = GameObject.Find("GAME/GUIManager/Canvas_BoardingPass/BoardingPass/Panel/Ascent/IncrementButton");
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogError((object)"find IncrementButton fail!");
				return;
			}
			Transform transform = GameObject.Find("GAME/GUIManager/Canvas_BoardingPass/BoardingPass/Panel").transform;
			if ((Object)(object)transform == (Object)null)
			{
				Debug.LogError((object)"fail Panel fail!");
				return;
			}
			To1 = GameObject.Find("GAME/GUIManager/Canvas_BoardingPass/BoardingPass/Panel/To (1)").GetComponent<TextMeshProUGUI>();
			GameObject val3 = GameObject.Find("GAME/GUIManager/Canvas_BoardingPass/BoardingPass/Panel/BOARDING PASS");
			font = ((TMP_Text)val3.GetComponent<TextMeshProUGUI>()).font;
			GameObject val4 = CreateButton(val2, transform, GetText("Random"), new Vector2(140f, 75f), delegate
			{
				RandomInvoke();
			});
			buttons.Add(val4);
			float x = val4.GetComponent<RectTransform>().sizeDelta.x;
			string text = GetText("Daily");
			if (todayLevelIndex != -3)
			{
				text += $"({todayLevelIndex})";
			}
			GameObject item = CreateButton(val2, transform, text, new Vector2(140f + x + 20f, 75f), delegate
			{
				DailyInvoke();
			});
			buttons.Add(item);
			GameObject val5 = GameObject.Find("GAME/GUIManager/Canvas_BoardingPass/BoardingPass/Panel/Ascent/Reward");
			if ((Object)(object)val5 != (Object)null)
			{
				RectTransform component2 = val5.GetComponent<RectTransform>();
				component2.anchoredPosition = new Vector2(component2.anchoredPosition.x, -10f);
			}
			PeakLevelSelectPlugin.logger.LogInfo((object)"Create Button Sussecs!");
			CreateDropdown(transform);
			if (PeakLevelSelectPlugin.SelectedAscent.Value != -2)
			{
				component.ascentIndex = PeakLevelSelectPlugin.SelectedAscent.Value;
				component.UpdateAscent();
			}
		}

		private static void RandomInvoke()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)dropDownText).text = GetText("Random");
			PeakLevelSelectPlugin.SelectedLevel.Value = -2;
			((Graphic)buttons[0].GetComponent<Image>()).color = new Color(0.9804f, 0.8075f, 0.1922f, 1f);
			((TMP_Text)To1).text = "???";
		}

		private static void DailyInvoke()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)dropDownText).text = GetText("Daily");
			MapBaker instance = SingletonAsset<MapBaker>.Instance;
			if (todayLevelIndex != -3 && todayLevelIndex < instance.selectedBiomes.Count)
			{
				((TMP_Text)To1).text = todayLevelIndex.ToString();
				TextMeshProUGUI obj = dropDownText;
				((TMP_Text)obj).text = ((TMP_Text)obj).text + "(" + string.Join(",", from x in instance.selectedBiomes[todayLevelIndex].selectedBiomes
					where (int)x != 0 && (int)x != 3
					select LocalizedText.GetText(((object)(BiomeType)(ref x)).ToString(), true)) + ")";
			}
			else
			{
				((TMP_Text)To1).text = "0";
			}
			PeakLevelSelectPlugin.SelectedLevel.Value = -1;
			((Graphic)buttons[1].GetComponent<Image>()).color = new Color(0.9804f, 0.8075f, 0.1922f, 1f);
		}

		private static List<string> MakeList(params (Language lang, string text)[] items)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected I4, but got Unknown
			List<string> list = new List<string>(new string[14]);
			for (int i = 0; i < items.Length; i++)
			{
				var (val, value) = items[i];
				list[(int)val] = value;
			}
			for (int j = 0; j < 14; j++)
			{
				if (string.IsNullOrEmpty(list[j]))
				{
					list[j] = list[0];
				}
			}
			return list;
		}

		private static void CreateDropdown(Transform panel)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_011f: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Expected O, but got Unknown
			//IL_020b: 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_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: 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_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Expected O, but got Unknown
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: 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_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Expected O, but got Unknown
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: 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_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Expected O, but got Unknown
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: 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_0544: Expected O, but got Unknown
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Expected O, but got Unknown
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Expected O, but got Unknown
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0928: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Unknown result type (might be due to invalid IL or missing references)
			//IL_0887: Unknown result type (might be due to invalid IL or missing references)
			//IL_0889: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b8: Expected O, but got Unknown
			//IL_089b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = new GameObject("CustomDropdown");
				val.transform.SetParent(panel, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.anchorMin = new Vector2(0f, 0f);
				val2.anchorMax = new Vector2(0f, 0f);
				val2.pivot = new Vector2(0f, 0f);
				val2.anchoredPosition = new Vector2(520f, 75f);
				val2.sizeDelta = new Vector2(0f, 65f);
				Image val3 = val.AddComponent<Image>();
				val3.sprite = image.sprite;
				((Graphic)val3).color = ((Graphic)image).color;
				val3.type = image.type;
				val3.pixelsPerUnitMultiplier = image.pixelsPerUnitMultiplier;
				((Graphic)val3).material = ((Graphic)image).material;
				val3.overrideSprite = image.overrideSprite;
				((Graphic)val3).raycastTarget = ((Graphic)image).raycastTarget;
				dropdownImage = val3;
				GameObject val4 = new GameObject("Label");
				val4.transform.SetParent(val.transform, false);
				TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val5).fontSize = 14f;
				((TMP_Text)val5).font = font;
				((Graphic)val5).color = Color.white;
				((TMP_Text)val5).text = "";
				((TMP_Text)val5).alignment = (TextAlignmentOptions)513;
				dropDownText = val5;
				RectTransform component = ((Component)val5).GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = new Vector2(10f, 6f);
				component.offsetMax = new Vector2(-30f, -7f);
				GameObject val6 = new GameObject("Arrow");
				val6.transform.SetParent(val.transform, false);
				TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val7).font = font;
				((Graphic)val7).color = Color.white;
				((TMP_Text)val7).text = "▼";
				((TMP_Text)val7).fontSize = 24f;
				((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
				RectTransform component2 = ((Component)val7).GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(1f, 0.5f);
				component2.anchorMax = new Vector2(1f, 0.5f);
				component2.pivot = new Vector2(1f, 0.5f);
				component2.sizeDelta = new Vector2(20f, 20f);
				component2.anchoredPosition = new Vector2(-20f, 0f);
				GameObject val8 = new GameObject("Template");
				val8.transform.SetParent(val.transform, false);
				val8.SetActive(false);
				MapBaker instance = SingletonAsset<MapBaker>.Instance;
				RectTransform val9 = val8.AddComponent<RectTransform>();
				val9.anchorMin = new Vector2(0f, 0f);
				val9.anchorMax = new Vector2(1f, 0f);
				val9.pivot = new Vector2(0.5f, 1f);
				PeakLevelSelectPlugin.logger.LogInfo((object)$"AllLevels: {instance.AllLevels.Length}");
				val9.sizeDelta = new Vector2(0f, (float)(instance.AllLevels.Length * 25));
				Image val10 = val8.AddComponent<Image>();
				((Graphic)val10).color = new Color(0.2f, 0.2f, 0.2f);
				val8.AddComponent<RectMask2D>();
				GameObject val11 = new GameObject("Viewport");
				val11.transform.SetParent(val8.transform, false);
				RectTransform val12 = val11.AddComponent<RectTransform>();
				val12.anchorMin = Vector2.zero;
				val12.anchorMax = Vector2.one;
				val12.sizeDelta = Vector2.zero;
				Image val13 = val11.AddComponent<Image>();
				((Graphic)val13).color = Color.clear;
				((Graphic)val13).raycastTarget = false;
				GameObject val14 = new GameObject("Content");
				val14.transform.SetParent(val11.transform, false);
				RectTransform val15 = val14.AddComponent<RectTransform>();
				val15.anchorMin = new Vector2(0f, 1f);
				val15.anchorMax = new Vector2(1f, 1f);
				val15.pivot = new Vector2(0.5f, 1f);
				val15.anchoredPosition = Vector2.zero;
				val15.sizeDelta = new Vector2(0f, 0f);
				GameObject val16 = new GameObject("Item");
				val16.transform.SetParent(val14.transform, false);
				Toggle val17 = val16.AddComponent<Toggle>();
				RectTransform component3 = val16.GetComponent<RectTransform>();
				component3.anchorMin = new Vector2(0f, 1f);
				component3.anchorMax = new Vector2(1f, 1f);
				component3.pivot = new Vector2(0.5f, 1f);
				component3.sizeDelta = new Vector2(0f, 25f);
				GameObject val18 = new GameObject("Item Background");
				val18.transform.SetParent(val16.transform, false);
				Image val19 = val18.AddComponent<Image>();
				((Graphic)val19).color = new Color(0.3f, 0.3f, 0.3f);
				RectTransform component4 = val18.GetComponent<RectTransform>();
				component4.anchorMin = Vector2.zero;
				component4.anchorMax = Vector2.one;
				component4.offsetMin = Vector2.zero;
				component4.offsetMax = Vector2.zero;
				((Selectable)val17).targetGraphic = (Graphic)(object)val19;
				GameObject val20 = new GameObject("Item Checkmark");
				val20.transform.SetParent(val18.transform, false);
				Image val21 = val20.AddComponent<Image>();
				((Graphic)val21).color = Color.white;
				RectTransform component5 = val20.GetComponent<RectTransform>();
				component5.anchorMin = new Vector2(0f, 0.5f);
				component5.anchorMax = new Vector2(0f, 0.5f);
				component5.pivot = new Vector2(0f, 0.5f);
				component5.sizeDelta = new Vector2(20f, 20f);
				component5.anchoredPosition = new Vector2(10f, 0f);
				val17.graphic = (Graphic)(object)val21;
				GameObject val22 = new GameObject("Item Label");
				val22.transform.SetParent(val16.transform, false);
				TextMeshProUGUI val23 = val22.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val23).font = font;
				((TMP_Text)val23).fontSize = 14f;
				((Graphic)val23).color = Color.white;
				((TMP_Text)val23).text = "Option";
				RectTransform component6 = ((Component)val23).GetComponent<RectTransform>();
				component6.anchorMin = new Vector2(0f, 0f);
				component6.anchorMax = new Vector2(1f, 1f);
				component6.offsetMin = new Vector2(30f, 0f);
				component6.offsetMax = new Vector2(-10f, 0f);
				TMP_Dropdown val24 = val.AddComponent<TMP_Dropdown>();
				((Selectable)val24).targetGraphic = (Graphic)(object)val3;
				val24.captionText = (TMP_Text)(object)val5;
				val24.template = val9;
				val24.itemText = (TMP_Text)(object)val23;
				val24.itemImage = val21;
				val24.options.Clear();
				float num = 0f;
				GameObject val25 = GameObject.Find("GAME/GUIManager/Canvas_BoardingPass");
				val25.SetActive(true);
				val25.SetActive(false);
				for (int i = 0; i < instance.selectedBiomes.Count; i++)
				{
					string text = GetText("Level", i) + "(" + string.Join(",", from x in instance.selectedBiomes[i].selectedBiomes
						where (int)x != 0 && (int)x != 3
						select LocalizedText.GetText(((object)(BiomeType)(ref x)).ToString(), true)) + ")";
					if (i == todayLevelIndex)
					{
						text = "(" + GetText("Today") + ")" + text;
					}
					Vector2 preferredValues = ((TMP_Text)dropDownText).GetPreferredValues(text);
					if (preferredValues.x > num)
					{
						num = preferredValues.x;
					}
					val24.options.Add(new OptionData(text));
				}
				val2.sizeDelta = new Vector2(num + 80f, val2.sizeDelta.y);
				float num2 = 25f;
				float num3 = 8f;
				float num4 = Mathf.Min((float)instance.AllLevels.Length * num2, num3 * num2);
				val9.sizeDelta = new Vector2(0f, num4);
				ScrollRect val26 = val8.AddComponent<ScrollRect>();
				val26.content = val15;
				val26.viewport = val12;
				val26.horizontal = false;
				val26.vertical = true;
				val26.verticalScrollbar = null;
				val26.verticalScrollbarVisibility = (ScrollbarVisibility)0;
				val26.inertia = true;
				if ((Object)(object)val11.GetComponent<RectMask2D>() == (Object)null)
				{
					val11.AddComponent<RectMask2D>();
				}
				val15.sizeDelta = new Vector2(0f, (float)instance.AllLevels.Length * num2);
				((UnityEvent<int>)(object)val24.onValueChanged).AddListener((UnityAction<int>)delegate(int value)
				{
					//IL_0050: Unknown result type (might be due to invalid IL or missing references)
					//IL_008f: Unknown result type (might be due to invalid IL or missing references)
					((TMP_Text)To1).text = value.ToString();
					PeakLevelSelectPlugin.SelectedLevel.Value = value;
					foreach (GameObject button in buttons)
					{
						((Graphic)button.GetComponent<Image>()).color = new Color(0.1922f, 0.2941f, 0.9804f, 1f);
					}
					((Graphic)dropdownImage).color = new Color(0.9804f, 0.8075f, 0.1922f, 1f);
				});
				if (PeakLevelSelectPlugin.SelectedLevel.Value == -1)
				{
					DailyInvoke();
				}
				else if (PeakLevelSelectPlugin.SelectedLevel.Value == -2)
				{
					RandomInvoke();
				}
				else if (PeakLevelSelectPlugin.SelectedLevel.Value < val24.options.Count)
				{
					val24.value = PeakLevelSelectPlugin.SelectedLevel.Value;
					((TMP_Text)To1).text = val24.value.ToString();
					val24.RefreshShownValue();
					((Graphic)dropdownImage).color = new Color(0.9804f, 0.8075f, 0.1922f, 1f);
				}
			}
			catch (Exception ex)
			{
				PeakLevelSelectPlugin.logger.LogError((object)("CreateDropdown Exception: " + ex));
			}
		}

		public static string GetText(string key, params object[] args)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if (!langTable.TryGetValue(key, out List<string> value))
			{
				return (args.Length != 0) ? string.Format(key, args) : key;
			}
			string text = value[(int)LocalizedText.CURRENT_LANGUAGE];
			return (args.Length != 0) ? string.Format(text, args) : text;
		}

		private static GameObject CreateButton(GameObject referenceButton, Transform parent, string buttonText, Vector2 position, UnityAction<GameObject> onClick)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00e5: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			UnityAction<GameObject> onClick2 = onClick;
			GameObject button = Object.Instantiate<GameObject>(referenceButton);
			((Object)button).name = "Button_" + buttonText;
			button.transform.SetParent(parent, false);
			Object.Destroy((Object)(object)((Component)button.transform.Find("Image")).gameObject);
			Object.Destroy((Object)(object)((Component)button.transform).GetComponent<Animator>());
			if ((Object)(object)image == (Object)null)
			{
				image = button.GetComponent<Image>();
			}
			RectTransform component = button.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(170f, component.sizeDelta.y);
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(0f, 0f);
			component.pivot = new Vector2(0f, 0f);
			component.anchoredPosition = position;
			CreateButtonText(button, buttonText);
			Button component2 = button.GetComponent<Button>();
			((UnityEventBase)component2.onClick).RemoveAllListeners();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				//IL_0034: 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_006a: Unknown result type (might be due to invalid IL or missing references)
				foreach (GameObject button2 in buttons)
				{
					((Graphic)dropdownImage).color = new Color(0.1922f, 0.2941f, 0.9804f, 1f);
					if ((Object)(object)button2 == (Object)(object)button)
					{
						((Graphic)button2.GetComponent<Image>()).color = new Color(0.9804f, 0.8075f, 0.1922f, 1f);
					}
					else
					{
						((Graphic)button2.GetComponent<Image>()).color = new Color(0.1922f, 0.2941f, 0.9804f, 1f);
					}
				}
				onClick2.Invoke(button);
			});
			return button;
		}

		private static void CreateButtonText(GameObject button, string text)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Text (TMP)");
			val.transform.SetParent(button.transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = Vector2.zero;
			val2.anchorMax = Vector2.one;
			val2.offsetMin = Vector2.zero;
			val2.offsetMax = Vector2.zero;
			TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).text = text;
			((TMP_Text)val3).font = font;
			((Graphic)val3).color = Color.white;
			((TMP_Text)val3).fontStyle = (FontStyles)0;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val3).autoSizeTextContainer = true;
			((TMP_Text)val3).fontSize = 24f;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}