Decompiled source of AntroBetterConsole v1.1.0

Antro.BetterConsole.dll

Decompiled 3 days ago
using System;
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.RegularExpressions;
using BepInEx;
using BepInEx.IL2CPP;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnhollowerRuntimeLib;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.BetterConsole")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.BetterConsole")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.BetterConsole")]
[assembly: AssemblyTitle("Antro.BetterConsole")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Antro.BetterConsole
{
	[BepInPlugin("Antro.BetterConsole", "Antro Better Console", "1.9.7")]
	public class Plugin : BasePlugin
	{
		public static Plugin Instance;

		public static BetterConsoleUI UI;

		public override void Load()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Instance = this;
			ClassInjector.RegisterTypeInIl2Cpp<BetterConsoleUI>();
			GameObject val = new GameObject("AntroConsole_UI");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			UI = val.AddComponent<BetterConsoleUI>();
			LoadHistoryFromDisk();
			ConsoleListener item = new ConsoleListener();
			Logger.Listeners.Add((ILogListener)(object)item);
			((BasePlugin)this).Log.LogInfo((object)"Antro.BetterConsole v1.9.7 loaded. Multi-select filters enabled.");
		}

		private void LoadHistoryFromDisk()
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			string path = Path.Combine(Paths.BepInExRootPath, "LogOutput.log");
			if (!File.Exists(path))
			{
				return;
			}
			try
			{
				using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
				using StreamReader streamReader = new StreamReader(stream);
				Regex regex = new Regex("^\\[(\\w+)\\s*:(.+?)\\].*?$");
				string text;
				while ((text = streamReader.ReadLine()) != null)
				{
					Match match = regex.Match(text);
					if (match.Success)
					{
						LogLevel lvl = (LogLevel)16;
						try
						{
							lvl = (LogLevel)Enum.Parse(typeof(LogLevel), match.Groups[1].Value.Trim(), ignoreCase: true);
						}
						catch
						{
						}
						int num = text.IndexOf(']') + 1;
						string msg = ((num < text.Length) ? text.Substring(num).Trim() : "");
						if ((Object)(object)UI != (Object)null)
						{
							UI.AddLog(new LogEntry(msg, match.Groups[2].Value.Trim(), lvl)
							{
								Timestamp = "History"
							});
						}
					}
				}
			}
			catch
			{
			}
		}
	}
	public class ConsoleListener : ILogListener, IDisposable
	{
		public LogLevel LogLevelFilter => (LogLevel)63;

		public void LogEvent(object sender, LogEventArgs eventArgs)
		{
			if ((Object)(object)Plugin.UI != (Object)null)
			{
				Plugin.UI.AddLog(new LogEntry(eventArgs));
			}
		}

		public void Dispose()
		{
		}
	}
	public class LogEntry
	{
		public string Message;

		public string Source;

		public LogLevel Level;

		public string Timestamp;

		public int Count = 1;

		public Color DisplayColor;

		public float CachedHeight = 0f;

		public LogEntry(LogEventArgs args)
			: this((args.Data != null) ? args.Data.ToString() : "null", (args.Source != null) ? args.Source.SourceName : "Unknown", args.Level)
		{
		}//IL_0036: Unknown result type (might be due to invalid IL or missing references)


		public LogEntry(string msg, string src, LogLevel lvl)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			Message = msg;
			Source = src;
			Level = lvl;
			Timestamp = DateTime.Now.ToString("HH:mm:ss");
			DisplayColor = GetColor(lvl, msg, src);
		}

		private Color GetColor(LogLevel level, string msg, string src)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_0117: Invalid comparison between Unknown and I4
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_011c: Invalid comparison between Unknown and I4
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			if ((int)level == 2 || (int)level == 1)
			{
				return new Color(1f, 0.4f, 0.4f);
			}
			if ((int)level == 4)
			{
				return new Color(1f, 0.9f, 0.3f);
			}
			string text = msg.ToLower();
			string text2 = src.ToLower();
			if (text.Contains("loaded") || text.Contains("success") || text.Contains("init"))
			{
				return new Color(0.5f, 1f, 0.5f);
			}
			if (text2.Contains("net") || text2.Contains("packet"))
			{
				return new Color(0.4f, 0.8f, 1f);
			}
			if (text2.Contains("harmony") || text2.Contains("bep"))
			{
				return new Color(0.8f, 0.5f, 1f);
			}
			if ((int)level == 32 || (int)level == 16)
			{
				return new Color(0.75f, 0.75f, 0.75f);
			}
			return Color.white;
		}
	}
	public class BetterConsoleUI : MonoBehaviour
	{
		private bool _isVisible = false;

		private Rect _windowRect = new Rect(50f, 50f, 1000f, 700f);

		private bool _showSearch = false;

		private Rect _searchRect = new Rect(50f, 50f, 300f, 60f);

		private string _searchQuery = "";

		private int _currentSearchIndex = -1;

		private List<LogEntry> _allLogs = new List<LogEntry>();

		private List<LogEntry> _filteredLogs = new List<LogEntry>();

		private List<string> _sortedSources = new List<string>();

		private HashSet<string> _knownSources = new HashSet<string>();

		private HashSet<LogLevel> _visibleLevels = new HashSet<LogLevel>();

		private Vector2 _logScrollPos;

		private Vector2 _filterScrollPos;

		private HashSet<string> _selectedSources = new HashSet<string>();

		private bool _isShowAllMode = true;

		private bool _autoScroll = true;

		private bool _needsRefresh = false;

		private float _lastWindowWidth = 0f;

		private float _totalScrollHeight = 0f;

		private HashSet<int> _selectedIndices = new HashSet<int>();

		private int _lastClickedIndex = -1;

		private const int MAX_LOGS = 5000;

		private const float MIN_ROW_HEIGHT = 24f;

		private GUIStyle _labelStyle;

		private GUIStyle _msgStyle;

		private GUIStyle _sourceStyle;

		private Texture2D _whitePixel;

		private Texture2D _blackPixel;

		public BetterConsoleUI(IntPtr ptr)
			: base(ptr)
		{
		}//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)


		private void Awake()
		{
			_visibleLevels.Add((LogLevel)2);
			_visibleLevels.Add((LogLevel)1);
			_visibleLevels.Add((LogLevel)4);
			_visibleLevels.Add((LogLevel)8);
			_visibleLevels.Add((LogLevel)16);
			_visibleLevels.Add((LogLevel)32);
			((Rect)(ref _searchRect)).x = Screen.width / 2 - 150;
			((Rect)(ref _searchRect)).y = Screen.height / 2 - 30;
		}

		private void Update()
		{
			//IL_0116: 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)
			if (Input.GetKeyDown((KeyCode)292))
			{
				_isVisible = !_isVisible;
				if (_isVisible)
				{
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
					_needsRefresh = true;
					_lastWindowWidth = 0f;
				}
			}
			if (!_isVisible)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)99) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
			{
				CopySelection();
			}
			if (!Input.GetKeyDown((KeyCode)102) || (!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305)))
			{
				return;
			}
			_showSearch = !_showSearch;
			if (_showSearch)
			{
				if (((Rect)(ref _searchRect)).x < 0f || ((Rect)(ref _searchRect)).y < 0f)
				{
					_searchRect = new Rect(100f, 100f, 300f, 60f);
				}
			}
			else
			{
				GUI.FocusControl((string)null);
			}
		}

		public void AddLog(LogEntry entry)
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (!_knownSources.Contains(entry.Source))
			{
				_knownSources.Add(entry.Source);
				_sortedSources.Add(entry.Source);
				_sortedSources.Sort();
			}
			int num = Mathf.Min(_allLogs.Count, 15);
			bool flag = false;
			for (int i = 0; i < num; i++)
			{
				LogEntry logEntry = _allLogs[_allLogs.Count - 1 - i];
				if (logEntry.Message == entry.Message && logEntry.Source == entry.Source && logEntry.Level == entry.Level)
				{
					logEntry.Count++;
					if (entry.Timestamp != "History")
					{
						logEntry.Timestamp = entry.Timestamp;
					}
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				if (_msgStyle != null && ((Rect)(ref _windowRect)).width > 100f)
				{
					CalcRowHeight(entry, ((Rect)(ref _windowRect)).width);
				}
				_allLogs.Add(entry);
				if (_allLogs.Count > 5000)
				{
					_allLogs.RemoveAt(0);
				}
			}
			_needsRefresh = true;
			if (_autoScroll && _isVisible)
			{
				_logScrollPos.y = float.MaxValue;
			}
		}

		private void RefreshFilter()
		{
			HashSet<LogEntry> hashSet = new HashSet<LogEntry>();
			foreach (int selectedIndex in _selectedIndices)
			{
				if (selectedIndex >= 0 && selectedIndex < _filteredLogs.Count)
				{
					hashSet.Add(_filteredLogs[selectedIndex]);
				}
			}
			IEnumerable<LogEntry> source = _allLogs;
			if (!_isShowAllMode)
			{
				source = source.Where((LogEntry x) => _selectedSources.Contains(x.Source));
			}
			_filteredLogs = source.Where((LogEntry x) => _visibleLevels.Contains(x.Level)).ToList();
			RecalculateTotalHeight();
			_selectedIndices.Clear();
			_lastClickedIndex = -1;
			for (int i = 0; i < _filteredLogs.Count; i++)
			{
				if (hashSet.Contains(_filteredLogs[i]))
				{
					_selectedIndices.Add(i);
					if (_lastClickedIndex == -1)
					{
						_lastClickedIndex = i;
					}
				}
			}
			_needsRefresh = false;
		}

		private void RecalculateAllHeights(float winWidth)
		{
			if (_msgStyle == null)
			{
				return;
			}
			foreach (LogEntry allLog in _allLogs)
			{
				CalcRowHeight(allLog, winWidth);
			}
			RecalculateTotalHeight();
		}

		private void RecalculateTotalHeight()
		{
			_totalScrollHeight = 0f;
			foreach (LogEntry filteredLog in _filteredLogs)
			{
				_totalScrollHeight += ((filteredLog.CachedHeight > 0f) ? filteredLog.CachedHeight : 24f);
			}
		}

		private void CalcRowHeight(LogEntry log, float winWidth)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			float num = 65f;
			float num2 = 140f;
			float num3 = 25f;
			float num4 = 20f;
			float num5 = winWidth - num - num2 - num3 - num4;
			if (num5 < 100f)
			{
				num5 = 100f;
			}
			string text = log.Message + ((log.Count > 1) ? $" (x{log.Count})" : "");
			float num6 = _msgStyle.CalcHeight(new GUIContent(text), num5);
			float num7 = _sourceStyle.CalcHeight(new GUIContent("[" + log.Source + "]"), num2);
			log.CachedHeight = Mathf.Max(Mathf.Max(num6, num7), 20f) + 4f;
		}

		private void CopySelection()
		{
			if (_selectedIndices.Count == 0 || _filteredLogs.Count == 0)
			{
				return;
			}
			List<int> list = _selectedIndices.ToList();
			list.Sort();
			StringBuilder stringBuilder = new StringBuilder();
			foreach (int item in list)
			{
				if (item >= 0 && item < _filteredLogs.Count)
				{
					LogEntry logEntry = _filteredLogs[item];
					string text = ((logEntry.Count > 1) ? $" (x{logEntry.Count})" : "");
					stringBuilder.AppendLine("[" + logEntry.Timestamp + "] [" + logEntry.Source + "] " + logEntry.Message + text);
				}
			}
			GUIUtility.systemCopyBuffer = stringBuilder.ToString();
			((BasePlugin)Plugin.Instance).Log.LogInfo((object)"Logs copied to clipboard!");
		}

		private void ToggleLevel(LogLevel lvl1, LogLevel lvl2 = 0)
		{
			//IL_0007: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (_visibleLevels.Contains(lvl1))
			{
				_visibleLevels.Remove(lvl1);
				if ((int)lvl2 > 0)
				{
					_visibleLevels.Remove(lvl2);
				}
			}
			else
			{
				_visibleLevels.Add(lvl1);
				if ((int)lvl2 > 0)
				{
					_visibleLevels.Add(lvl2);
				}
			}
			_needsRefresh = true;
		}

		private void PerformSearch(bool forward)
		{
			if (string.IsNullOrEmpty(_searchQuery) || _filteredLogs.Count == 0)
			{
				return;
			}
			int num = (forward ? (_currentSearchIndex + 1) : (_currentSearchIndex - 1));
			int count = _filteredLogs.Count;
			string query = _searchQuery.ToLower();
			if (num >= count)
			{
				num = 0;
			}
			if (num < 0)
			{
				num = count - 1;
			}
			int num2 = -1;
			if (forward)
			{
				for (int i = num; i < count; i++)
				{
					if (MatchesSearch(_filteredLogs[i], query))
					{
						num2 = i;
						break;
					}
				}
				if (num2 == -1)
				{
					for (int j = 0; j < num; j++)
					{
						if (MatchesSearch(_filteredLogs[j], query))
						{
							num2 = j;
							break;
						}
					}
				}
			}
			else
			{
				for (int num3 = num; num3 >= 0; num3--)
				{
					if (MatchesSearch(_filteredLogs[num3], query))
					{
						num2 = num3;
						break;
					}
				}
				if (num2 == -1)
				{
					for (int num4 = count - 1; num4 > num; num4--)
					{
						if (MatchesSearch(_filteredLogs[num4], query))
						{
							num2 = num4;
							break;
						}
					}
				}
			}
			if (num2 != -1)
			{
				_currentSearchIndex = num2;
				ScrollToLog(num2);
				_selectedIndices.Clear();
				_selectedIndices.Add(num2);
				_lastClickedIndex = num2;
				_autoScroll = false;
			}
		}

		private bool MatchesSearch(LogEntry log, string query)
		{
			return log.Message.ToLower().Contains(query) || log.Source.ToLower().Contains(query);
		}

		private void ScrollToLog(int index)
		{
			float num = 0f;
			for (int i = 0; i < index; i++)
			{
				num += ((_filteredLogs[i].CachedHeight > 0f) ? _filteredLogs[i].CachedHeight : 24f);
			}
			_logScrollPos.y = num;
		}

		private string HighlightText(string input)
		{
			if (!_showSearch || string.IsNullOrEmpty(_searchQuery))
			{
				return input;
			}
			try
			{
				string pattern = Regex.Escape(_searchQuery);
				return Regex.Replace(input, pattern, "<color=#FF00FF><b>$0</b></color>", RegexOptions.IgnoreCase);
			}
			catch
			{
				return input;
			}
		}

		private void OnGUI()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: 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_02b3: Unknown result type (might be due to invalid IL or missing references)
			if (_isVisible)
			{
				if ((Object)(object)_whitePixel == (Object)null)
				{
					_whitePixel = new Texture2D(1, 1);
					_whitePixel.SetPixel(0, 0, Color.white);
					_whitePixel.Apply();
				}
				if ((Object)(object)_blackPixel == (Object)null)
				{
					_blackPixel = new Texture2D(1, 1);
					_blackPixel.SetPixel(0, 0, Color.black);
					_blackPixel.Apply();
				}
				if (_labelStyle == null)
				{
					_labelStyle = new GUIStyle(GUI.skin.label);
					_labelStyle.alignment = (TextAnchor)3;
					_labelStyle.richText = true;
					_labelStyle.clipping = (TextClipping)1;
					_labelStyle.fontSize = 12;
				}
				if (_msgStyle == null)
				{
					_msgStyle = new GUIStyle(GUI.skin.label);
					_msgStyle.alignment = (TextAnchor)0;
					_msgStyle.wordWrap = true;
					_msgStyle.richText = true;
					_msgStyle.fontSize = 12;
				}
				if (_sourceStyle == null)
				{
					_sourceStyle = new GUIStyle(GUI.skin.button);
					_sourceStyle.alignment = (TextAnchor)3;
					_sourceStyle.wordWrap = true;
					_sourceStyle.richText = true;
					_sourceStyle.fontSize = 12;
					RectOffset val = new RectOffset();
					val.left = 4;
					val.right = 4;
					val.top = 2;
					val.bottom = 2;
					_sourceStyle.padding = val;
				}
				GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.8f);
				GUI.contentColor = Color.white;
				_windowRect = GUI.Window(89123, _windowRect, WindowFunction.op_Implicit((Action<int>)DrawWindow), $"Antro Console | Rows: {_filteredLogs.Count} | Selected: {_selectedIndices.Count}");
				if (_showSearch)
				{
					GUI.backgroundColor = new Color(0.15f, 0.15f, 0.15f, 1f);
					GUI.contentColor = Color.white;
					_searchRect = GUI.Window(89124, _searchRect, WindowFunction.op_Implicit((Action<int>)DrawSearchWindow), "Find");
					GUI.BringWindowToFront(89124);
				}
			}
		}

		private void DrawSearchWindow(int id)
		{
			//IL_0015: 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_0051: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = new Color(0.1f, 0.1f, 0.1f, 1f);
			GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref _searchRect)).width, ((Rect)(ref _searchRect)).height), (Texture)(object)_whitePixel);
			GUI.color = Color.white;
			float num = 20f;
			float num2 = 25f;
			float num3 = 5f;
			GUI.SetNextControlName("SearchInput");
			string text = GUI.TextField(new Rect(num3, num, ((Rect)(ref _searchRect)).width - num2 * 3f - num3 * 4f, num2), _searchQuery);
			if (text != _searchQuery)
			{
				_searchQuery = text;
			}
			float num4 = ((Rect)(ref _searchRect)).width - num2 * 3f - num3 * 2f;
			if (GUI.Button(new Rect(num4, num, num2, num2), "<"))
			{
				PerformSearch(forward: false);
			}
			if (GUI.Button(new Rect(num4 + num2 + num3, num, num2, num2), ">"))
			{
				PerformSearch(forward: true);
			}
			if (GUI.Button(new Rect(num4 + num2 * 2f + num3 * 2f, num, num2, num2), "X"))
			{
				_showSearch = false;
				GUI.FocusControl((string)null);
			}
			GUI.DragWindow();
		}

		private void DrawWindow(int id)
		{
			//IL_008d: 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_0132: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: 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_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: 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_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: 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_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: 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_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			if (Mathf.Abs(((Rect)(ref _windowRect)).width - _lastWindowWidth) > 1f)
			{
				_lastWindowWidth = ((Rect)(ref _windowRect)).width;
				RecalculateAllHeights(((Rect)(ref _windowRect)).width);
			}
			if (_needsRefresh)
			{
				RefreshFilter();
			}
			float width = ((Rect)(ref _windowRect)).width;
			float height = ((Rect)(ref _windowRect)).height;
			float num = 10f;
			float num2 = 25f;
			if (GUI.Button(new Rect(num, num2, 110f, 25f), "Disable All Mods"))
			{
				_isShowAllMode = false;
				_selectedSources.Clear();
				_needsRefresh = true;
			}
			bool flag = GUI.Toggle(new Rect(num + 115f, num2, 80f, 25f), _autoScroll, "AutoScroll");
			if (flag != _autoScroll)
			{
				_autoScroll = flag;
				if (_autoScroll)
				{
					_logScrollPos.y = float.MaxValue;
				}
			}
			if (GUI.Button(new Rect(num + 200f, num2, 50f, 25f), "Find"))
			{
				_showSearch = !_showSearch;
			}
			float num3 = num + 260f;
			float num4 = width - num3 - 15f;
			float num5 = 45f;
			float num6 = 60f;
			foreach (string sortedSource in _sortedSources)
			{
				if (sortedSource != "BepInEx" && sortedSource != "Unhollower")
				{
					num6 += (float)sortedSource.Length * 8f + 25f;
				}
			}
			_filterScrollPos = GUI.BeginScrollView(new Rect(num3, num2, num4, num5), _filterScrollPos, new Rect(0f, 0f, num6, 25f), true, false);
			float num7 = 0f;
			GUI.color = (_isShowAllMode ? Color.green : Color.white);
			if (GUI.Button(new Rect(num7, 0f, 50f, 25f), "ALL"))
			{
				_isShowAllMode = true;
				_selectedSources.Clear();
				_needsRefresh = true;
			}
			num7 += 55f;
			foreach (string sortedSource2 in _sortedSources)
			{
				if (sortedSource2 == "BepInEx" || sortedSource2 == "Unhollower")
				{
					continue;
				}
				bool flag2 = _selectedSources.Contains(sortedSource2);
				if (_isShowAllMode)
				{
					GUI.color = Color.white;
				}
				else
				{
					GUI.color = (flag2 ? Color.cyan : Color.gray);
				}
				float num8 = (float)sortedSource2.Length * 8f + 20f;
				if (GUI.Button(new Rect(num7, 0f, num8, 25f), sortedSource2))
				{
					if (_isShowAllMode)
					{
						_isShowAllMode = false;
						_selectedSources.Clear();
						_selectedSources.Add(sortedSource2);
					}
					else if (flag2)
					{
						_selectedSources.Remove(sortedSource2);
					}
					else
					{
						_selectedSources.Add(sortedSource2);
					}
					_needsRefresh = true;
				}
				num7 += num8 + 5f;
			}
			GUI.color = Color.white;
			GUI.EndScrollView();
			float num9 = num2 + 50f;
			float num10 = 80f;
			DrawLevelToggle(num, num9, new Color(1f, 0.4f, 0.4f), "Error", (LogLevel)2, (LogLevel)1);
			DrawLevelToggle(num + num10, num9, new Color(1f, 0.9f, 0.3f), "Warning", (LogLevel)4, (LogLevel)0);
			DrawLevelToggle(num + num10 * 5f, num9, Color.white, "Message", (LogLevel)8, (LogLevel)0);
			DrawLevelToggle(num + num10 * 6f, num9, new Color(0.75f, 0.75f, 0.75f), "Info", (LogLevel)16, (LogLevel)32);
			DrawLegendBox(num + num10 * 2f, num9, new Color(0.5f, 1f, 0.5f), "Success");
			DrawLegendBox(num + num10 * 3f, num9, new Color(0.4f, 0.8f, 1f), "Network");
			DrawLegendBox(num + num10 * 4f, num9, new Color(0.8f, 0.5f, 1f), "System");
			GUI.Label(new Rect(width - 250f, num9, 240f, 20f), "Shift+Click | Ctrl+Click | Ctrl+F", _labelStyle);
			float num11 = num9 + 30f;
			float num12 = height - num11 - 10f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num, num11, width - 20f, num12);
			GUI.Box(val, "");
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(0f, 0f, ((Rect)(ref val)).width - 20f, _totalScrollHeight);
			_logScrollPos = GUI.BeginScrollView(val, _logScrollPos, val2);
			float num13 = 0f;
			float y = _logScrollPos.y;
			float num14 = _logScrollPos.y + num12;
			bool control = Event.current.control;
			bool shift = Event.current.shift;
			for (int i = 0; i < _filteredLogs.Count; i++)
			{
				LogEntry logEntry = _filteredLogs[i];
				float num15 = ((logEntry.CachedHeight > 0f) ? logEntry.CachedHeight : 24f);
				if (num13 + num15 > y && num13 < num14)
				{
					DrawLogItem(i, logEntry, num13, num15, ((Rect)(ref val2)).width, control, shift);
				}
				num13 += num15;
			}
			GUI.EndScrollView();
			GUI.DragWindow();
		}

		private void DrawLogItem(int index, LogEntry log, float y, float h, float width, bool ctrl, bool shift)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, y, width, h);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(70f, y + 2f, 140f, h - 4f);
			bool flag = ((Rect)(ref val2)).Contains(Event.current.mousePosition);
			if (_selectedIndices.Contains(index))
			{
				GUI.color = new Color(0.2f, 0.4f, 0.9f, 0.4f);
				GUI.DrawTexture(val, (Texture)(object)_whitePixel);
				GUI.color = Color.white;
			}
			if (!flag)
			{
				GUI.backgroundColor = Color.clear;
				if (GUI.Button(val, GUIContent.none))
				{
					HandleSelection(index, ctrl, shift);
					_autoScroll = false;
				}
				GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.8f);
			}
			GUI.color = Color.white;
			GUI.Label(new Rect(2f, y + 2f, 65f, 20f), "[" + log.Timestamp + "]", _labelStyle);
			GUI.color = new Color(0.3f, 0.7f, 1f);
			string text = HighlightText("[" + log.Source + "]");
			if (GUI.Button(val2, text, _sourceStyle) && !shift)
			{
				_isShowAllMode = false;
				_selectedSources.Clear();
				_selectedSources.Add(log.Source);
				_needsRefresh = true;
				_autoScroll = false;
				_selectedIndices.Clear();
			}
			GUI.color = log.DisplayColor;
			string input = log.Message + ((log.Count > 1) ? $" (x{log.Count})" : "");
			string text2 = HighlightText(input);
			GUI.Label(new Rect(215f, y + 2f, width - 215f, h - 4f), text2, _msgStyle);
		}

		private void HandleSelection(int idx, bool ctrl, bool shift)
		{
			if (ctrl)
			{
				if (_selectedIndices.Contains(idx))
				{
					_selectedIndices.Remove(idx);
				}
				else
				{
					_selectedIndices.Add(idx);
				}
				_lastClickedIndex = idx;
			}
			else if (shift && _lastClickedIndex != -1)
			{
				_selectedIndices.Clear();
				int num = Mathf.Min(_lastClickedIndex, idx);
				int num2 = Mathf.Max(_lastClickedIndex, idx);
				for (int i = num; i <= num2; i++)
				{
					_selectedIndices.Add(i);
				}
			}
			else
			{
				_selectedIndices.Clear();
				_selectedIndices.Add(idx);
				_lastClickedIndex = idx;
			}
		}

		private void DrawLegendBox(float x, float y, Color c, string txt)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = c;
			GUI.Label(new Rect(x, y, 80f, 20f), "■ " + txt, _labelStyle);
			GUI.color = Color.white;
		}

		private void DrawLevelToggle(float x, float y, Color c, string txt, LogLevel lvl1, LogLevel lvl2 = 0)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = (Color)(_visibleLevels.Contains(lvl1) ? c : new Color(c.r, c.g, c.b, 0.3f));
			if (GUI.Button(new Rect(x, y, 80f, 20f), "■ " + txt, _labelStyle))
			{
				ToggleLevel(lvl1, lvl2);
			}
			GUI.color = Color.white;
		}
	}
}