Decompiled source of LogLibrary v1.1.0

plugins/LogLibrary.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
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 System.Text.Json;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using CustomMenuBarButtons;
using GTFO.API.Extensions;
using GTFO.API.JSON;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LogLibrary")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LogLibrary")]
[assembly: AssemblyTitle("LogLibrary")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 LogLibrary
{
	internal sealed class CM_PageLogLibrary : MonoBehaviour
	{
		private CM_PageBase page = null;

		private CM_Item[] RundownButtons;

		private CM_ScrollWindow[] LogSelectWindows;

		private CM_GlobalPopup ReadingWindow;

		private CM_ScrollWindow LogScroller;

		private CM_Item[] PageButtons = (CM_Item[])(object)new CM_Item[2];

		private List<string> CurrLogSplit;

		private int CurrLogPage = 0;

		private string CurrLogName;

		private CM_TimedButton AudioLogButton;

		private uint CurrentAudioLog = 0u;

		private bool AudioLogPlaying = false;

		private static CellSoundPlayer s_sound;

		private static Sprite AudioSprite;

		private Vector2 SelectionWindowSize = new Vector2(800f, 1000f);

		private PopupMessage popup = new PopupMessage
		{
			Header = "Header",
			UpperText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
			LowerText = "",
			BlinkInContent = false,
			PopupType = (PopupType)0
		};

		private const int occurrenceToSplitOn = 200;

		private const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public;

		public static LogsFileDTO LogInfos { get; set; }

		public static List<uint> ReadLogs { get; set; }

		internal void Init(CM_PageBase page)
		{
			this.page = page;
		}

		private void OnDisable()
		{
			HideAllLogSelectWindows();
			MainMenuGuiLayer.Current.PageSettings.ResetAllValueHolders();
		}

		public void Setup(MainMenuGuiLayer guiLayer)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (page.m_isSetup)
			{
				return;
			}
			GetLogInfo();
			page.m_spawnMenuBar = true;
			Patches.SetupBaseCall(page, guiLayer);
			SetupLogWindow();
			SetupLogSelectionWindows();
			RundownLogsDTO[] rundownLogs = LogInfos.RundownLogs;
			int num = rundownLogs.Length;
			RundownButtons = (CM_Item[])(object)new CM_Item[num];
			for (int i = 0; i < num; i++)
			{
				CM_Item val = (RundownButtons[i] = ((Il2CppObjectBase)((GuiLayer)page.m_guiLayer).AddRectComp("CM_ButtonFramed", (GuiAnchor)4, new Vector2(300f, (float)(-90 * i + 390)), (Transform)(object)page.m_movingContentHolder)).TryCast<CM_Item>());
				string sectionName = rundownLogs[i].SectionName;
				val.SetText(sectionName);
				val.ID = i + 1;
				val.OnBtnPressCallback += Action<int>.op_Implicit((Action<int>)delegate(int id)
				{
					DisplaySelectWindow(id - 1);
				});
				((RectTransformComp)val).SetScaleFactor(0.9f);
				val.UpdateColliderOffset();
			}
			AudioSprite = ((Component)((Il2CppArrayBase<PUI_Inventory>)(object)MainMenuGuiLayer.Current.PageMap.m_inventory)[0].m_voiceControls.m_muteToggleButton).GetComponent<SpriteRenderer>().sprite;
		}

		private void HideAllLogSelectWindows()
		{
			if (LogSelectWindows != null)
			{
				CM_ScrollWindow[] logSelectWindows = LogSelectWindows;
				foreach (CM_ScrollWindow val in logSelectWindows)
				{
					((RectTransformComp)val).SetVisible(false);
				}
			}
		}

		private void SetupLogWindow()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: 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_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			ReadingWindow = ((Il2CppObjectBase)((GuiLayer)page.m_guiLayer).AddRectComp("general/popup/CM_GlobalPopup_BoosterMissedPopup", (GuiAnchor)3, new Vector2(0f, 0f), (Transform)(object)page.m_staticContentHolder)).TryCast<CM_GlobalPopup>();
			((Object)((Component)ReadingWindow).gameObject).name = "CM_Popup_ReadLogPopup";
			ReadingWindow.m_closeButton.OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)delegate
			{
				((RectTransformComp)ReadingWindow).SetVisible(false);
				ResetAudioButton();
				CellSettingsManager.ApplyAndSave();
			});
			Vector3 localPosition = ((Component)ReadingWindow).transform.localPosition;
			localPosition.z = -5f;
			((Component)ReadingWindow).transform.localPosition = localPosition;
			float num = 1500f;
			float num2 = 600f;
			((RectTransformComp)ReadingWindow).SetSize(new Vector2(num, num2));
			UI_SpriteResizer component = ((Component)((Component)ReadingWindow).transform.FindChild("Background")).GetComponent<UI_SpriteResizer>();
			component.ResizeAllChildren(false);
			LogScroller = ((Il2CppObjectBase)((GuiLayer)page.m_guiLayer).AddRectComp("CM_ScrollWindow", (GuiAnchor)5, new Vector2(0f, 0f), ReadingWindow.m_contentHolder)).TryCast<CM_ScrollWindow>();
			((RectTransformComp)LogScroller).Setup();
			foreach (Renderer componentsInChild in ((Component)LogScroller).GetComponentsInChildren<Renderer>())
			{
				componentsInChild.sortingLayerID = SortingLayer.NameToID("GlobalPopupBG");
			}
			TextMeshPro upperText = ReadingWindow.m_upperText;
			((Component)((Component)LogScroller).transform.FindChild("Header")).gameObject.SetActive(false);
			((Component)((Component)LogScroller).transform.FindChild("Background")).gameObject.SetActive(false);
			RectTransform component2 = ((Component)upperText).GetComponent<RectTransform>();
			((Transform)component2).parent = ((Component)LogScroller.m_contentContainer).transform;
			component2.anchorMax = new Vector2(0.81f, 0.27f);
			component2.anchorMin = new Vector2(0.86f, 0f);
			component2.sizeDelta = new Vector2(num, num2);
			((RectTransformComp)LogScroller).SetSize(new Vector2(num, num2));
			((RectTransformComp)LogScroller).m_rectTrans.sizeDelta = new Vector2(num, num2);
			LogScroller.m_clipRect.sizeDelta = new Vector2(num, num2 - 20f);
			((TMP_Text)upperText).fontSizeMax = 22f;
			((TMP_Text)upperText).fontSizeMin = ((TMP_Text)upperText).fontSizeMax;
			((TMP_Text)upperText).lineSpacing = 20f;
			((TMP_Text)upperText).fontStyle = (FontStyles)0;
			LogScroller.m_posStart = -20f;
			LogScroller.m_windowHeight = num2 - 20f;
			LogScroller.m_contentContainerHeight = 1000f;
			LogScroller.OnWindowHeightUpdate();
			for (int i = 0; i < PageButtons.Length; i++)
			{
				CM_Item val = ((Il2CppObjectBase)((GuiLayer)page.m_guiLayer).AddRectComp("gui/player/boosters/PUI_ArrowButton", (GuiAnchor)6, new Vector2((float)(-50 + 100 * i), -50f), ReadingWindow.m_contentHolder)).Cast<CM_Item>();
				((Component)val).transform.Rotate(0f, 0f, (float)(90 + 180 * i));
				((Renderer)((Component)val).GetComponent<SpriteRenderer>()).sortingLayerID = SortingLayer.NameToID("GlobalPopupBG");
				if (i == 0)
				{
					val.OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)delegate
					{
						ChangeLogPage(-1);
					});
				}
				else
				{
					val.OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)delegate
					{
						ChangeLogPage(1);
					});
				}
				((Object)((Component)val).gameObject).name = "CM_ReadLogPage_" + (new string[2] { "Left", "Right" })[i];
				PageButtons[i] = val;
			}
			s_sound = new CellSoundPlayer();
			AudioLogButton = ((Il2CppObjectBase)((GuiLayer)page.m_guiLayer).AddRectComp("CM_TimedExpeditionButton", (GuiAnchor)7, new Vector2(0f, -125f), ReadingWindow.m_contentHolder)).TryCast<CM_TimedButton>();
			((RectTransformComp)AudioLogButton).Setup();
			((CM_Item)AudioLogButton).SetText("Play Audio");
			AudioLogButton.SOUND_CLICK_HOLD_DONE = 0u;
			CM_TimedButton audioLogButton = AudioLogButton;
			((CM_Item)audioLogButton).OnBtnPressCallback = ((CM_Item)audioLogButton).OnBtnPressCallback + Action<int>.op_Implicit((Action<int>)delegate
			{
				ToggleAudioLogPlayer();
			});
			GameObject dialogVolumeObject = Patches.DialogVolumeObject;
			dialogVolumeObject.transform.parent = ((Component)AudioLogButton).transform;
			RectTransform component3 = Patches.DialogVolumeObject.GetComponent<RectTransform>();
			((Transform)component3).localPosition = Vector2.op_Implicit(new Vector2(825f, 90f));
			((TMP_Text)((Component)dialogVolumeObject.transform.Find("Title/TitleText")).GetComponent<TextMeshPro>()).alignment = (TextAlignmentOptions)516;
			((Component)dialogVolumeObject.transform.Find("Background")).gameObject.SetActive(false);
			foreach (Renderer componentsInChild2 in ((Component)AudioLogButton).GetComponentsInChildren<Renderer>())
			{
				componentsInChild2.sortingLayerID = SortingLayer.NameToID("GlobalPopupBG");
			}
			((RectTransformComp)ReadingWindow).SetVisible(false);
		}

		private void SetupLogSelectionWindows()
		{
			//IL_002d: 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)
			LogSelectWindows = (CM_ScrollWindow[])(object)new CM_ScrollWindow[8];
			for (int i = 0; i < LogSelectWindows.Length; i++)
			{
				CM_ScrollWindow val = ((Il2CppObjectBase)((GuiLayer)page.m_guiLayer).AddRectComp("CM_ScrollWindow", (GuiAnchor)3, new Vector2(0f, 0f), (Transform)(object)page.m_movingContentHolder)).TryCast<CM_ScrollWindow>();
				((RectTransformComp)val).Setup();
				((RectTransformComp)val).SetSize(SelectionWindowSize);
				((RectTransformComp)val).SetVisible(false);
				LogSelectWindows[i] = val;
			}
		}

		[HideFromIl2Cpp]
		private iScrollWindowContent CreateScrollItem(string text, LogDTO log = null, bool clickable = false)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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)
			CM_SettingsItem val = ((Il2CppObjectBase)((GuiLayer)page.m_guiLayer).AddRectComp("settings/CM_SettingsItem", (GuiAnchor)1, new Vector2(0f, 0f), (Transform)(object)page.m_movingContentHolder)).TryCast<CM_SettingsItem>();
			((RectTransformComp)val).Setup();
			((CM_Item)val).SetText(text);
			((CM_Item)val).m_clickSound = clickable;
			((CM_Item)val).m_alphaTextOnHover = clickable;
			((CM_Item)val).OnHoverOut();
			if (log != null)
			{
				((CM_Item)val).SetOnBtnPressCallback(Action<int>.op_Implicit((Action<int>)delegate
				{
					ShowLog(log.filename, Text.Get(log.id), log.audio);
				}));
				if (log.audio != 0)
				{
					SpriteRenderer val2 = ((Component)val.m_inputAlign).gameObject.AddComponent<SpriteRenderer>();
					val2.sprite = AudioSprite;
					((Component)val2).transform.localScale = new Vector3(25f, 25f, 1f);
					Vector3 localPosition = ((Component)val2).transform.localPosition;
					localPosition.z = 0f;
					((Component)val2).transform.localPosition = localPosition;
					RectTransform component = ((Component)val2).GetComponent<RectTransform>();
					component.anchorMax = new Vector2(0f, 0.518f);
					component.anchorMin = new Vector2(-0.42f, 0f);
					Color color = val2.color;
					color.a = 0.5f;
					val2.color = color;
					((Renderer)val2).sortingLayerID = SortingLayer.NameToID("MenuPopupText");
				}
			}
			int num = 50;
			RectTransform component2 = ((Component)val.m_title).GetComponent<RectTransform>();
			Vector2 sizeDelta = component2.sizeDelta;
			sizeDelta.x = SelectionWindowSize.x - (float)num;
			component2.sizeDelta = sizeDelta;
			BoxCollider2D collider = ((CM_Item)val).m_collider;
			collider.size = sizeDelta;
			Vector2 offset = default(Vector2);
			((Vector2)(ref offset))..ctor(sizeDelta.x / 2f, sizeDelta.y / -2f);
			offset.x -= num;
			((Collider2D)collider).offset = offset;
			return ((Il2CppObjectBase)val).Cast<iScrollWindowContent>();
		}

		public void ShowLog(string logName, string text, uint audio = 0u)
		{
			CurrLogPage = 0;
			CurrLogName = logName;
			CurrLogSplit = SplitStringBySize(text);
			popup.UpperText = CurrLogSplit[CurrLogPage];
			SetWindowHeader();
			CM_Item[] pageButtons = PageButtons;
			foreach (CM_Item val in pageButtons)
			{
				((RectTransformComp)val).SetVisible(CurrLogSplit.Count > 1);
			}
			ReadingWindow.ShowMessage(popup, (CellSoundPlayer)null);
			((Component)ReadingWindow.m_headerText).gameObject.SetActive(true);
			CurrentAudioLog = audio;
			((RectTransformComp)AudioLogButton).SetVisible(audio != 0);
			UpdateLogScrollWindow();
			MainMenuGuiLayer.Current.PageSettings.ResetAllValueHolders();
		}

		private static int mod(int k, int n)
		{
			return ((k %= n) < 0) ? (k + n) : k;
		}

		private void ChangeLogPage(int pageChange)
		{
			CurrLogPage = mod(CurrLogPage + pageChange, CurrLogSplit.Count);
			popup.UpperText = CurrLogSplit[CurrLogPage];
			SetWindowHeader();
			ReadingWindow.ShowMessage(popup, (CellSoundPlayer)null);
			((Component)ReadingWindow.m_headerText).gameObject.SetActive(true);
			UpdateLogScrollWindow();
		}

		private void SetWindowHeader()
		{
			popup.Header = CurrLogName + ((CurrLogSplit.Count > 1) ? $" {CurrLogPage + 1} / {CurrLogSplit.Count}" : "");
		}

		private static List<string> SplitStringBySize(string input)
		{
			List<string> list = new List<string>();
			List<string> list2 = input.Split('\n').ToList();
			while (list2.Count > 0)
			{
				list.Add(string.Join('\n', list2.GetRange(0, Math.Min(200, list2.Count))));
				list2.RemoveRange(0, Math.Min(200, list2.Count));
			}
			return list;
		}

		private void UpdateLogScrollWindow()
		{
			LogScroller.ScrollFromHandle(float.NegativeInfinity);
			LogScroller.m_contentContainerHeight = ((TMP_Text)ReadingWindow.m_upperText).GetPreferredHeight() + 50f;
			LogScroller.OnWindowHeightUpdate();
		}

		public void DisplaySelectWindow(int id)
		{
			HideAllLogSelectWindows();
			UpdateReadLogs();
			CM_ScrollWindow val = LogSelectWindows[id];
			RundownLogsDTO rundownLogsDTO = LogInfos.RundownLogs[id];
			string sectionName = rundownLogsDTO.SectionName;
			List<iScrollWindowContent> list = new List<iScrollWindowContent>();
			val.SetHeader("<b>" + sectionName + " Logs</b>");
			bool flag = true;
			ExpeditionLogsDTO[] expeditions = rundownLogsDTO.Expeditions;
			foreach (ExpeditionLogsDTO expeditionLogsDTO in expeditions)
			{
				if (!flag)
				{
					list.Add(CreateScrollItem("<color=#202020>__________________________________________</color>"));
				}
				flag = false;
				list.Add(CreateScrollItem("   <b><u><color=white>" + expeditionLogsDTO.expedition + "</color></u></b>"));
				List<iScrollWindowContent> list2 = new List<iScrollWindowContent>();
				LogDTO[] logs = expeditionLogsDTO.logs;
				foreach (LogDTO logDTO in logs)
				{
					if (ReadLogs.Contains(logDTO.id) || LogInfos.Dev)
					{
						list.Add(CreateScrollItem("   " + logDTO.filename + " - Found in " + logDTO.zone, logDTO, clickable: true));
						continue;
					}
					list2.Add(CreateScrollItem($"   <color=#101010>{new string('?', logDTO.filename.Length)} - Found in {new string('?', logDTO.zone.Length)}</color>", null, clickable: true));
				}
				list.AddRange(list2);
			}
			val.SetContentItems(ListExtensions.ToIl2Cpp<iScrollWindowContent>(list), 0f);
			((RectTransformComp)LogSelectWindows[id]).SetVisible(true);
		}

		private void ToggleAudioLogPlayer()
		{
			if (AudioLogPlaying)
			{
				ResetAudioButton();
				return;
			}
			s_sound.Post(CurrentAudioLog, 1u, EventCallback.op_Implicit((Action<Object, AkCallbackType, AkCallbackInfo>)AudioDoneCallback), Object.op_Implicit(CurrentAudioLog));
			((CM_Item)AudioLogButton).SetText("Stop Audio");
			AudioLogPlaying = true;
		}

		private void ResetAudioButton()
		{
			s_sound.Stop();
			((CM_Item)AudioLogButton).SetText("Play Audio");
			AudioLogPlaying = false;
		}

		private void AudioDoneCallback(Object cookie, AkCallbackType type, AkCallbackInfo callbackInfo)
		{
			ResetAudioButton();
		}

		static CM_PageLogLibrary()
		{
			ReadLogs = new List<uint>();
			ClassInjector.RegisterTypeInIl2Cpp<CM_PageLogLibrary>();
		}

		public static void GetLogInfo()
		{
			if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value))
			{
				Type type = value.Instance?.GetType()?.Assembly?.GetType("MTFO.API.MTFOPathAPI") ?? null;
				if (type != null)
				{
					bool flag = (bool)(type.GetProperty("HasCustomPath", BindingFlags.Static | BindingFlags.Public)?.GetValue(null) ?? ((object)false));
					string text = (string)(type.GetProperty("CustomPath", BindingFlags.Static | BindingFlags.Public)?.GetValue(null) ?? null);
					if (flag && !string.IsNullOrEmpty(text))
					{
						string path = Path.Join(text, "LogLibrary", "Logs.json");
						if (File.Exists(path))
						{
							ReadLogInfosFile(path);
							Logger.Info("Using Modded Logs");
							ModdedLogManager.HasModdedLogs = true;
							return;
						}
					}
				}
			}
			string path2 = Path.Join(Paths.ConfigPath, "LogLibraryInfo.json");
			ReadLogInfosFile(path2);
		}

		public static void ReadLogInfosFile(string path)
		{
			LogInfos = JsonSerializer.Deserialize<LogsFileDTO>(File.ReadAllText(path), (JsonSerializerOptions)null);
			if (string.IsNullOrEmpty(LogInfos.Name))
			{
				Logger.Error("'Name' field in provided Log Info file is unset, please contact your rundown developer or access `(RundownFolder)/Custom/LogLibrary/Logs.json` to set it.\nFor now, it will use 'UNSET'.");
				LogInfos.Name = "UNSET";
			}
		}

		public static void UpdateReadLogs()
		{
			if (!ModdedLogManager.HasModdedLogs)
			{
				AchievementManager current = AchievementManager.Current;
				Enumerator<AchievementTask> enumerator = current.m_allAchievements.GetEnumerator();
				while (enumerator.MoveNext())
				{
					AchievementTask current2 = enumerator.Current;
					Achievement_ReadAllLogs val = ((Il2CppObjectBase)current2).TryCast<Achievement_ReadAllLogs>();
					if (val != null)
					{
						ReadLogs = val.m_readLogsOnStart.toManaged<uint>();
						return;
					}
				}
				Logger.Error("Isn't modded but didn't find achievement manager??");
			}
			ReadLogs = ModdedLogManager.GottenLogs;
		}
	}
	public class LogsFileDTO
	{
		public string Name { get; set; }

		public RundownLogsDTO[] RundownLogs { get; set; }

		public bool Dev { get; set; } = false;

	}
	public class RundownLogsDTO
	{
		public string SectionName { get; set; }

		public ExpeditionLogsDTO[] Expeditions { get; set; }
	}
	public class ExpeditionLogsDTO
	{
		public string expedition { get; set; }

		public LogDTO[] logs { get; set; }
	}
	public class LogDTO
	{
		public string filename { get; set; }

		public uint id { get; set; }

		public string zone { get; set; }

		public uint audio { get; set; }
	}
	[BepInPlugin("JarheadHME.LogLibrary", "LogLibrary", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		private Harmony _Harmony = null;

		public override void Load()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			_Harmony = new Harmony("LogLibrary.Harmony");
			_Harmony.PatchAll();
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin has loaded with ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_Harmony.GetPatchedMethods().Count());
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches!");
			}
			Logger.Info(val);
			MenuBarHandler.CreateButtons += CreateMenuButton;
		}

		private static void CreateMenuButton(MenuBarHandler menubar)
		{
			menubar.AddLeftButton<LogLibraryButton>((Func<MenuBarHandler, CM_MenuBarItem, LogLibraryButton>)((MenuBarHandler handler, CM_MenuBarItem item) => new LogLibraryButton(handler, item)), int.MaxValue, (eCM_MenuPage)18);
		}

		public override bool Unload()
		{
			_Harmony.UnpatchSelf();
			return ((BasePlugin)this).Unload();
		}
	}
	public sealed class LogLibraryButton : MenuBarCustomButton
	{
		public sealed override bool ShouldBeVisible => true;

		public LogLibraryButton(MenuBarHandler handler, CM_MenuBarItem item)
			: base(handler, item, "Library")
		{
		}

		protected sealed override void OnButtonClick(int id)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GuiManager.MainMenuLayer.ChangePage(CustomPage.EnumValues.CMP_LOGLIBRARY, false);
		}
	}
	public static class ListExtensions
	{
		public static List<T> toManaged<T>(this List<T> il2cppList)
		{
			List<T> list = new List<T>(il2cppList.Count);
			for (int i = 0; i < il2cppList.Count; i++)
			{
				list.Add(il2cppList[i]);
			}
			return list;
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_Logger = new ManualLogSource("LogLibrary");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}
	}
	public static class ModdedLogManager
	{
		public static List<uint> GottenLogs;

		public static List<uint> m_allLogs;

		public static readonly string DirPath;

		public static bool HasModdedLogs { get; set; }

		public static void WriteGottenLogFiles()
		{
			if (CM_PageLogLibrary.LogInfos.Dev)
			{
				return;
			}
			string path = RundownDataPath(Path.Join(DirPath, CM_PageLogLibrary.LogInfos.Name));
			using FileStream output = File.Open(path, FileMode.Create);
			using BinaryWriter binaryWriter = new BinaryWriter(output, Encoding.UTF8, leaveOpen: false);
			binaryWriter.Write(GottenLogs.Count);
			foreach (uint gottenLog in GottenLogs)
			{
				binaryWriter.Write(gottenLog);
			}
		}

		public static void ReadGottenLogFiles()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			string text = RundownDataPath(Path.Join(DirPath, CM_PageLogLibrary.LogInfos.Name));
			if (!File.Exists(text))
			{
				return;
			}
			using (FileStream input = File.Open(text, FileMode.Open))
			{
				using BinaryReader binaryReader = new BinaryReader(input, Encoding.UTF8, leaveOpen: false);
				int num = binaryReader.ReadInt32();
				for (int i = 0; i < num; i++)
				{
					uint item = binaryReader.ReadUInt32();
					if (!GottenLogs.Contains(item))
					{
						GottenLogs.Add(item);
					}
				}
			}
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Read ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(GottenLogs.Count);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" logs from ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
			}
			Logger.Info(val);
		}

		private static string RundownDataPath(string rundownName)
		{
			char[] invalidPathChars = Path.GetInvalidPathChars();
			char[] array = invalidPathChars;
			foreach (char oldChar in array)
			{
				rundownName = rundownName.Replace(oldChar, '_');
			}
			return Path.Combine(DirPath, rundownName);
		}

		static ModdedLogManager()
		{
			GottenLogs = new List<uint>();
			m_allLogs = new List<uint>();
			DirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GTFO-Modding", "LogLibrary");
			HasModdedLogs = false;
			if (!Directory.Exists(DirPath))
			{
				Directory.CreateDirectory(DirPath);
			}
			ReadGottenLogFiles();
			RundownLogsDTO[] rundownLogs = CM_PageLogLibrary.LogInfos.RundownLogs;
			foreach (RundownLogsDTO rundownLogsDTO in rundownLogs)
			{
				ExpeditionLogsDTO[] expeditions = rundownLogsDTO.Expeditions;
				foreach (ExpeditionLogsDTO expeditionLogsDTO in expeditions)
				{
					LogDTO[] logs = expeditionLogsDTO.logs;
					foreach (LogDTO logDTO in logs)
					{
						if (!m_allLogs.Contains(logDTO.id))
						{
							m_allLogs.Add(logDTO.id);
						}
					}
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		private static bool _baseCall;

		private static eSettingsSubMenuId prev_subMenuID;

		public static GameObject DialogVolumeObject { get; private set; }

		[HarmonyPatch(typeof(MainMenuGuiLayer), "Setup")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		public static void SetupPrefix()
		{
			CustomPage.EnumValues.Init();
		}

		[HarmonyPatch(typeof(MainMenuGuiLayer), "Setup")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		public static void SetupPostfix(MainMenuGuiLayer __instance)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected I4, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected I4, but got Unknown
			CM_PageBase val = GOUtil.SpawnChildAndGetComp<CM_PageBase>(Resources.Load<GameObject>("CM_PageEmpty_CellUI"), ((Component)((GuiLayer)__instance).GuiLayerBase).transform);
			((Object)((Component)val).gameObject).name = "CM_LogLibrary_CellUI";
			((Component)val).gameObject.AddComponent<CM_PageLogLibrary>().Init(val);
			((Il2CppArrayBase<CM_PageBase>)(object)__instance.m_pages)[(int)CustomPage.EnumValues.CMP_LOGLIBRARY] = val;
			((Il2CppArrayBase<CM_PageBase>)(object)__instance.m_pages)[(int)CustomPage.EnumValues.CMP_LOGLIBRARY].Setup(__instance);
		}

		[HarmonyPatch(typeof(CM_PageBase), "Setup")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		public static bool Setup(CM_PageBase __instance, MainMenuGuiLayer guiLayer)
		{
			if (_baseCall)
			{
				return true;
			}
			CM_PageLogLibrary component = ((Component)__instance).gameObject.GetComponent<CM_PageLogLibrary>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			component.Setup(guiLayer);
			return false;
		}

		public static void SetupBaseCall(CM_PageBase page, MainMenuGuiLayer guiLayer)
		{
			_baseCall = true;
			page.Setup(guiLayer);
			_baseCall = false;
		}

		[HarmonyPatch(typeof(CM_PageSettings), "CreateSubmenu")]
		[HarmonyPostfix]
		public static void SettingsPagePatch(CM_PageSettings __instance, uint textId, eSettingsSubMenuId subMenuId, List<iSettingsFieldData> settingsData, bool autoSaveEnabled = true, bool resetEnabled = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)DialogVolumeObject != (Object)null) && (int)subMenuId == 3)
			{
				iScrollWindowContent val = GOUtil.SpawnChildAndGetComp<iScrollWindowContent>(__instance.m_settingsItemPrefab);
				val.TextMeshRoot = ((Component)__instance).transform;
				CM_SettingsItem val2 = ((Il2CppObjectBase)val).Cast<CM_SettingsItem>();
				val2.SetupSettingsItem(__instance, ((Il2CppObjectBase)new SettingsFieldData
				{
					Id = (eCellSettingID)103,
					Type = (eSettingInputType)4
				}).Cast<iSettingsFieldData>());
				Text.AddTextUpdater(((Il2CppObjectBase)val2).Cast<ILocalizedTextUpdater>(), true);
				((RectTransformComp)val2).SetAnchor((GuiAnchor)1, true);
				((RectTransformComp)val2).ForcePopupLayer(true, (GameObject)null);
				__instance.m_allValueHolders.Add(((Il2CppObjectBase)((Component)val2).GetComponentInChildren<CM_SettingScrollReceiver>()).Cast<iSettingsValueHolder>());
				DialogVolumeObject = ((Component)val2).gameObject;
			}
		}

		[HarmonyPatch(typeof(CM_PageSettings), "SetFloatValue")]
		[HarmonyPrefix]
		public static void SetFloatPatchPrefix(CM_PageSettings __instance, eCellSettingID setting, float value)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			prev_subMenuID = __instance.m_currentSubMenuId;
			if ((int)setting == 103)
			{
				__instance.m_currentSubMenuId = (eSettingsSubMenuId)3;
			}
		}

		[HarmonyPatch(typeof(CM_PageSettings), "SetFloatValue")]
		[HarmonyPostfix]
		public static void SetFloatPatchPostfix(CM_PageSettings __instance, eCellSettingID setting, float value)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			__instance.m_currentSubMenuId = prev_subMenuID;
			CellSettingsManager.SettingsData.Audio.ApplyAllValues();
		}

		[HarmonyPatch(typeof(Achievement_ReadAllLogs), "OnReadLog")]
		[HarmonyPostfix]
		public static void SaveLogData(pLogRead data)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			uint iD = data.ID;
			if (ModdedLogManager.HasModdedLogs && ModdedLogManager.m_allLogs.Contains(iD) && !ModdedLogManager.GottenLogs.Contains(iD))
			{
				ModdedLogManager.GottenLogs.Add(iD);
				ModdedLogManager.WriteGottenLogFiles();
			}
		}
	}
	internal static class CustomPage
	{
		public static class EnumValues
		{
			public static readonly eCM_MenuPage CMP_LOGLIBRARY;

			[MethodImpl(MethodImplOptions.NoInlining)]
			internal static void Init()
			{
			}

			static EnumValues()
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				int valueLength = EnumUtil.GetValueLength<eCM_MenuPage>();
				EnumInjector.InjectEnumValues<eCM_MenuPage>(new Dictionary<string, object> { { "CMP_LOGLIBRARY", valueLength } });
				CMP_LOGLIBRARY = (eCM_MenuPage)valueLength;
			}
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "LogLibrary";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const int GitCommitsSinceTag = 0;

		public const bool GitIsDirty = false;
	}
}