using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
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.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("UnityLogViewer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("In-game log viewer for BepInEx")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+3a4a0129279e9af3cf8a761294c5f7bdbc7dc3b7")]
[assembly: AssemblyProduct("UnityLogViewer")]
[assembly: AssemblyTitle("UnityLogViewer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.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 UnityLogViewer
{
public class LogViewerUI : MonoBehaviour
{
private struct HighlightRule
{
public Regex Pattern;
public string Color;
}
private bool isVisible = Plugin.ShowWindow.Value;
private bool isPinned;
private Rect windowRect;
private Vector2 scrollPosition;
private string filterText = "";
private bool filterDirty = true;
private readonly List<string> logLines = new List<string>();
private readonly List<string> filteredLines = new List<string>();
private bool autoScroll = true;
private bool pendingScrollToBottom;
private readonly List<string> renderedLines = new List<string>();
private bool renderDirty = true;
private readonly List<HighlightRule> highlightRules = new List<HighlightRule>();
private bool highlightsDirty = true;
private const int WindowID = 99701;
private const float WindowHeaderHeight = 98f;
private const float PinnedHeaderHeight = 26f;
private float lineHeight = 20f;
private int scrollFirstVisible;
private int scrollLastVisible;
private bool isResizing;
private const float ResizeHandleSize = 20f;
private const float MinWidth = 400f;
private const float MinHeight = 300f;
private Texture2D bgTexture;
private int lastOpacity = -1;
private GUIStyle logStyle;
private GUIStyle closeButtonStyle;
private GUIStyle pinButtonStyle;
private GUIStyle pinnedWindowStyle;
private bool stylesInitialized;
private Rect lastSavedRect;
private readonly List<string> validFontNames = new List<string>();
private int fontSelectorIndex;
private bool fontDropdownOpen;
private Rect fontDropdownRect;
private Vector2 fontDropdownScrollPos;
private const int FontDropdownWindowID = 99702;
private int MaxLines => Plugin.BufferSize.Value;
private void Awake()
{
//IL_002e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Expected O, but got Unknown
windowRect = new Rect((float)Plugin.WindowX.Value, (float)Plugin.WindowY.Value, (float)Plugin.WindowWidth.Value, (float)Plugin.WindowHeight.Value);
lastSavedRect = windowRect;
filterText = Plugin.Filter.Value ?? "";
isPinned = Plugin.Pinned.Value;
Plugin.Filter.SettingChanged += delegate
{
filterText = Plugin.Filter.Value ?? "";
filterDirty = true;
};
Plugin.ShowWindow.SettingChanged += delegate
{
isVisible = Plugin.ShowWindow.Value;
};
Plugin.Pinned.SettingChanged += delegate
{
isPinned = Plugin.Pinned.Value;
};
Plugin.WindowX.SettingChanged += delegate
{
((Rect)(ref windowRect)).x = Plugin.WindowX.Value;
};
Plugin.WindowY.SettingChanged += delegate
{
((Rect)(ref windowRect)).y = Plugin.WindowY.Value;
};
Plugin.WindowWidth.SettingChanged += delegate
{
((Rect)(ref windowRect)).width = Plugin.WindowWidth.Value;
};
Plugin.WindowHeight.SettingChanged += delegate
{
((Rect)(ref windowRect)).height = Plugin.WindowHeight.Value;
};
for (int i = 0; i < 8; i++)
{
Plugin.HighlightPattern[i].SettingChanged += delegate
{
highlightsDirty = true;
renderDirty = true;
};
Plugin.HighlightColor[i].SettingChanged += delegate
{
highlightsDirty = true;
renderDirty = true;
};
}
Plugin.FontName.SettingChanged += delegate
{
int num = validFontNames.IndexOf(Plugin.FontName.Value);
if (num >= 0)
{
fontSelectorIndex = num;
}
};
Application.logMessageReceived += new LogCallback(OnLogMessageReceived);
}
private void BuildValidFontList()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
validFontNames.Clear();
validFontNames.Add("");
string[] oSInstalledFontNames = Font.GetOSInstalledFontNames();
Array.Sort(oSInstalledFontNames, (IComparer<string>?)StringComparer.OrdinalIgnoreCase);
Application.logMessageReceived -= new LogCallback(OnLogMessageReceived);
string[] array = oSInstalledFontNames;
foreach (string text in array)
{
bool warned = false;
LogCallback val = (LogCallback)delegate(string msg, string _, LogType type)
{
//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
if ((int)type == 2 || (int)type == 0)
{
warned = true;
}
};
Application.logMessageReceived += val;
Font font = Font.CreateDynamicFontFromOSFont(text, 13);
new GUIStyle(GUI.skin.label)
{
font = font,
fontSize = 13
}.CalcSize(new GUIContent("Ag"));
Application.logMessageReceived -= val;
if (!warned)
{
validFontNames.Add(text);
}
}
Application.logMessageReceived += new LogCallback(OnLogMessageReceived);
fontSelectorIndex = Math.Max(0, validFontNames.IndexOf(Plugin.FontName.Value));
StringBuilder stringBuilder = new StringBuilder();
for (int j = 1; j < validFontNames.Count; j++)
{
if (j > 1)
{
stringBuilder.Append(", ");
}
stringBuilder.Append(validFontNames[j]);
}
Plugin.Log.LogInfo((object)((validFontNames.Count > 1) ? $"[UnityLogViewer] {validFontNames.Count - 1} usable font(s): {stringBuilder}" : "[UnityLogViewer] No usable OS fonts found; using default UI font."));
}
private void OnLogMessageReceived(string message, string stackTrace, LogType type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected I4, but got Unknown
string text;
switch ((int)type)
{
case 0:
case 4:
text = "[ERROR] ";
break;
case 2:
text = "[WARNING] ";
break;
default:
text = "";
break;
}
logLines.Add(text + message);
if (logLines.Count > MaxLines)
{
logLines.RemoveRange(0, logLines.Count - MaxLines);
}
filterDirty = true;
if (autoScroll)
{
pendingScrollToBottom = true;
}
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = Plugin.ToggleShortcut.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
Plugin.ShowWindow.Value = !Plugin.ShowWindow.Value;
}
if (filterDirty)
{
RebuildFilteredLines();
}
if (renderDirty)
{
RebuildRenderedLines();
}
if (pendingScrollToBottom)
{
scrollPosition.y = 1E+09f;
pendingScrollToBottom = false;
}
}
private void RebuildHighlightRules()
{
highlightRules.Clear();
for (int i = 0; i < 8; i++)
{
string value = Plugin.HighlightPattern[i].Value;
string value2 = Plugin.HighlightColor[i].Value;
if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(value2))
{
try
{
highlightRules.Add(new HighlightRule
{
Pattern = new Regex(value, RegexOptions.IgnoreCase),
Color = value2
});
}
catch (ArgumentException)
{
}
}
}
highlightsDirty = false;
}
private void RebuildFilteredLines()
{
filteredLines.Clear();
if (string.IsNullOrEmpty(filterText))
{
filteredLines.AddRange(logLines);
}
else
{
try
{
Regex regex = new Regex(filterText, RegexOptions.IgnoreCase);
for (int i = 0; i < logLines.Count; i++)
{
if (regex.IsMatch(logLines[i]))
{
filteredLines.Add(logLines[i]);
}
}
}
catch (ArgumentException)
{
for (int j = 0; j < logLines.Count; j++)
{
if (logLines[j].IndexOf(filterText, StringComparison.OrdinalIgnoreCase) >= 0)
{
filteredLines.Add(logLines[j]);
}
}
}
}
filterDirty = false;
renderDirty = true;
}
private static string EscapeRichText(string text)
{
return text.Replace("<", "\u200b<");
}
private string GetColorForLine(string line)
{
for (int i = 0; i < highlightRules.Count; i++)
{
if (highlightRules[i].Pattern.IsMatch(line))
{
return highlightRules[i].Color;
}
}
return null;
}
private void RebuildRenderedLines()
{
if (highlightsDirty)
{
RebuildHighlightRules();
}
renderedLines.Clear();
for (int i = 0; i < filteredLines.Count; i++)
{
string text = EscapeRichText(filteredLines[i]);
string colorForLine = GetColorForLine(filteredLines[i]);
renderedLines.Add((colorForLine != null) ? ("<color=" + colorForLine + ">" + text + "</color>") : text);
}
renderDirty = false;
}
private Texture2D MakeBgTexture(int opacity)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//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)
byte b = (byte)(opacity * 255 / 100);
Texture2D val = new Texture2D(1, 1);
val.SetPixel(0, 0, Color32.op_Implicit(new Color32((byte)0, (byte)0, (byte)0, b)));
val.Apply();
return val;
}
private void InitStyles()
{
//IL_0044: 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_0051: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
//IL_0131: 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)
//IL_0145: Expected O, but got Unknown
//IL_014b: Expected O, but got Unknown
BuildValidFontList();
string text = ((fontSelectorIndex > 0 && fontSelectorIndex < validFontNames.Count) ? validFontNames[fontSelectorIndex] : null);
GUIStyle val = new GUIStyle(GUI.skin.label)
{
richText = true,
wordWrap = false,
fontSize = 13
};
val.normal.textColor = Color.white;
val.padding = new RectOffset(4, 4, 2, 2);
val.margin = new RectOffset(0, 0, 0, 0);
val.font = (string.IsNullOrEmpty(text) ? null : Font.CreateDynamicFontFromOSFont(text, 13));
logStyle = val;
lineHeight = logStyle.CalcSize(new GUIContent("Ag")).y;
closeButtonStyle = new GUIStyle(GUI.skin.button)
{
fontSize = 14,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
pinButtonStyle = new GUIStyle(GUI.skin.button)
{
fontSize = 12,
alignment = (TextAnchor)4
};
pinnedWindowStyle = new GUIStyle(GUI.skin.box)
{
padding = new RectOffset(4, 4, 4, 4)
};
stylesInitialized = true;
}
private void UpdateBgTexture()
{
int value = Plugin.BackgroundOpacity.Value;
if (value != lastOpacity)
{
if ((Object)(object)bgTexture != (Object)null)
{
Object.Destroy((Object)(object)bgTexture);
}
bgTexture = MakeBgTexture(value);
lastOpacity = value;
if (stylesInitialized)
{
pinnedWindowStyle.normal.background = bgTexture;
}
}
}
private void OnGUI()
{
//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)
//IL_0065: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
if (!isVisible)
{
fontDropdownOpen = false;
return;
}
if (!stylesInitialized)
{
InitStyles();
}
UpdateBgTexture();
if (isPinned)
{
DrawPinnedWindow();
}
else
{
Color backgroundColor = GUI.backgroundColor;
float num = (float)Plugin.BackgroundOpacity.Value / 100f;
GUI.backgroundColor = new Color(backgroundColor.r, backgroundColor.g, backgroundColor.b, num);
GUI.Window(99701, windowRect, new WindowFunction(DrawWindow), "Log Viewer");
GUI.backgroundColor = backgroundColor;
HandleResize();
}
SaveWindowRectIfChanged();
if (fontDropdownOpen)
{
DrawFontDropdown();
}
}
private void SaveWindowRectIfChanged()
{
//IL_00ca: 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)
if (((Rect)(ref windowRect)).x != ((Rect)(ref lastSavedRect)).x || ((Rect)(ref windowRect)).y != ((Rect)(ref lastSavedRect)).y || ((Rect)(ref windowRect)).width != ((Rect)(ref lastSavedRect)).width || ((Rect)(ref windowRect)).height != ((Rect)(ref lastSavedRect)).height)
{
Plugin.WindowX.Value = (int)((Rect)(ref windowRect)).x;
Plugin.WindowY.Value = (int)((Rect)(ref windowRect)).y;
Plugin.WindowWidth.Value = (int)((Rect)(ref windowRect)).width;
Plugin.WindowHeight.Value = (int)((Rect)(ref windowRect)).height;
lastSavedRect = windowRect;
}
}
private void DrawVirtualScrollContent(float viewHeight)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Invalid comparison between Unknown and I4
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
float num = lineHeight;
int count = renderedLines.Count;
float num2 = (float)count * num;
scrollPosition.y = Mathf.Min(scrollPosition.y, Mathf.Max(0f, num2 - viewHeight));
if ((int)Event.current.type == 8)
{
scrollFirstVisible = Mathf.Max(0, (int)(scrollPosition.y / num) - 1);
scrollLastVisible = Mathf.Min(count - 1, scrollFirstVisible + (int)(viewHeight / num) + 3);
}
scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(viewHeight) });
if (scrollFirstVisible > 0)
{
GUILayout.Space((float)scrollFirstVisible * num);
}
for (int i = scrollFirstVisible; i <= scrollLastVisible; i++)
{
GUILayout.Label(renderedLines[i], logStyle, Array.Empty<GUILayoutOption>());
}
int num3 = count - scrollLastVisible - 1;
if (num3 > 0)
{
GUILayout.Space((float)num3 * num);
}
GUILayout.EndScrollView();
}
private void DrawPinnedWindow()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
pinnedWindowStyle.normal.background = bgTexture;
GUILayout.BeginArea(windowRect, pinnedWindowStyle);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.FlexibleSpace();
if (GUILayout.Button("□", pinButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(26f),
GUILayout.Height(18f)
}))
{
isPinned = false;
Plugin.Pinned.Value = false;
}
GUILayout.EndHorizontal();
DrawVirtualScrollContent(Mathf.Max(50f, ((Rect)(ref windowRect)).height - 26f));
GUILayout.EndArea();
}
private void ApplyFont(int index)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
fontSelectorIndex = index;
string text = ((index > 0 && index < validFontNames.Count) ? validFontNames[index] : null);
Plugin.FontName.Value = text ?? "";
logStyle.font = (string.IsNullOrEmpty(text) ? null : Font.CreateDynamicFontFromOSFont(text, 13));
lineHeight = logStyle.CalcSize(new GUIContent("Ag")).y;
renderDirty = true;
}
private void DrawWindow(int windowID)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
if (GUI.Button(new Rect(((Rect)(ref windowRect)).width - 25f, 2f, 22f, 18f), "X", closeButtonStyle))
{
Plugin.ShowWindow.Value = false;
return;
}
if (GUI.Button(new Rect(((Rect)(ref windowRect)).width - 53f, 2f, 26f, 18f), "■", pinButtonStyle))
{
isPinned = true;
Plugin.Pinned.Value = true;
return;
}
if (validFontNames.Count > 1)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Font:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
string text = ((fontSelectorIndex > 0) ? validFontNames[fontSelectorIndex] : "(default)");
if (GUILayout.Button(text + " ▼", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
{
fontDropdownOpen = !fontDropdownOpen;
if (fontDropdownOpen)
{
Rect lastRect = GUILayoutUtility.GetLastRect();
float num = GUI.skin.window.border.top;
float num2 = Mathf.Min((float)validFontNames.Count * 22f + 6f, 200f);
fontDropdownRect = new Rect(((Rect)(ref windowRect)).x + ((Rect)(ref lastRect)).x, ((Rect)(ref windowRect)).y + num + ((Rect)(ref lastRect)).yMax, ((Rect)(ref lastRect)).width, num2);
}
}
GUILayout.EndHorizontal();
}
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Filter:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
string text2 = GUILayout.TextField(filterText, Array.Empty<GUILayoutOption>());
if (text2 != filterText)
{
filterText = text2;
filterDirty = true;
}
if (GUILayout.Button("⌫", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }))
{
filterText = "";
filterDirty = true;
}
if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
{
logLines.Clear();
filteredLines.Clear();
renderedLines.Clear();
scrollPosition = Vector2.zero;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label($"{filteredLines.Count} / {logLines.Count} lines", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) });
GUILayout.FlexibleSpace();
bool flag = GUILayout.Toggle(autoScroll, "Auto-scroll", Array.Empty<GUILayoutOption>());
if (flag != autoScroll)
{
autoScroll = flag;
if (autoScroll)
{
pendingScrollToBottom = true;
}
}
GUILayout.EndHorizontal();
float num3 = ((validFontNames.Count > 1) ? 98f : 72f);
DrawVirtualScrollContent(Mathf.Max(50f, ((Rect)(ref windowRect)).height - num3));
GUI.Label(new Rect(((Rect)(ref windowRect)).width - 20f, ((Rect)(ref windowRect)).height - 20f, 20f, 20f), "◢");
GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width - 58f, 25f));
}
private void DrawFontDropdown()
{
//IL_0006: 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_003d: 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_0058: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if ((int)Event.current.type == 0 && !((Rect)(ref fontDropdownRect)).Contains(Event.current.mousePosition))
{
fontDropdownOpen = false;
return;
}
fontDropdownRect = GUI.Window(99702, fontDropdownRect, (WindowFunction)delegate
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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)
fontDropdownScrollPos = GUILayout.BeginScrollView(fontDropdownScrollPos, Array.Empty<GUILayoutOption>());
for (int i = 0; i < validFontNames.Count; i++)
{
string text = ((i == 0) ? "(default)" : validFontNames[i]);
if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
{
ApplyFont(i);
fontDropdownOpen = false;
}
}
GUILayout.EndScrollView();
}, "");
}
private void HandleResize()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Invalid comparison between Unknown and I4
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Invalid comparison between Unknown and I4
Event current = Event.current;
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref windowRect)).x + ((Rect)(ref windowRect)).width - 20f, ((Rect)(ref windowRect)).y + ((Rect)(ref windowRect)).height - 20f, 20f, 20f);
if ((int)current.type == 0 && ((Rect)(ref val)).Contains(current.mousePosition))
{
isResizing = true;
current.Use();
}
if (isResizing && ((int)current.type == 3 || (int)current.type == 1))
{
((Rect)(ref windowRect)).width = Mathf.Max(400f, current.mousePosition.x - ((Rect)(ref windowRect)).x);
((Rect)(ref windowRect)).height = Mathf.Max(300f, current.mousePosition.y - ((Rect)(ref windowRect)).y);
if ((int)current.type == 1)
{
isResizing = false;
}
current.Use();
}
}
private void OnDestroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
Application.logMessageReceived -= new LogCallback(OnLogMessageReceived);
if ((Object)(object)bgTexture != (Object)null)
{
Object.Destroy((Object)(object)bgTexture);
}
}
}
[BepInPlugin("com.malafein.unitylogviewer", "UnityLogViewer", "0.0.2")]
public class Plugin : BaseUnityPlugin
{
internal class ConfigurationManagerAttributes
{
public int? Order;
}
public const string ModGUID = "com.malafein.unitylogviewer";
public const string ModName = "UnityLogViewer";
public const string ModVersion = "0.0.2";
public static ConfigEntry<KeyboardShortcut> ToggleShortcut;
public static ConfigEntry<bool> ShowWindow;
public static ConfigEntry<string> Filter;
public static ConfigEntry<int> BackgroundOpacity;
public static ConfigEntry<bool> Pinned;
public static ConfigEntry<int> BufferSize;
public static ConfigEntry<string> FontName;
public static ConfigEntry<int> WindowX;
public static ConfigEntry<int> WindowY;
public static ConfigEntry<int> WindowWidth;
public static ConfigEntry<int> WindowHeight;
public const int HighlightSlotCount = 8;
public static ConfigEntry<string>[] HighlightPattern = new ConfigEntry<string>[8];
public static ConfigEntry<string>[] HighlightColor = new ConfigEntry<string>[8];
internal static ManualLogSource Log;
private void Awake()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0078: 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_00a8: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Expected O, but got Unknown
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Expected O, but got Unknown
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Expected O, but got Unknown
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Expected O, but got Unknown
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Expected O, but got Unknown
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Expected O, but got Unknown
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Expected O, but got Unknown
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Expected O, but got Unknown
//IL_0473: Unknown result type (might be due to invalid IL or missing references)
//IL_047d: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"UnityLogViewer 0.0.2 is loading...");
ShowWindow = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowWindow", false, new ConfigDescription("Toggle the log viewer window on/off. Use this if the hotkey doesn't work with your game's input system.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 65
}
}));
ToggleShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleShortcut", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), new ConfigDescription("Keyboard shortcut to toggle log view.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 60
}
}));
Filter = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Filter", "", new ConfigDescription("Optional filter, supports regular expressions.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 50
}
}));
FontName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FontName", "", new ConfigDescription("Font to use for log text. Leave empty for the default UI font. Check the BepInEx log at startup for a list of fonts available on this system.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 45
}
}));
Pinned = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Pinned", false, new ConfigDescription("Pin the log view in place. Hides window decorations and disables interaction.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 40
}
}));
BufferSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "BufferSize", 500, new ConfigDescription("Maximum number of log lines to keep in the buffer.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 5000), new object[1]
{
new ConfigurationManagerAttributes
{
Order = 20
}
}));
BackgroundOpacity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "BackgroundOpacity", 80, new ConfigDescription("Background opacity of the log view window (0-100).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
{
new ConfigurationManagerAttributes
{
Order = 10
}
}));
WindowX = ((BaseUnityPlugin)this).Config.Bind<int>("Window", "WindowX", 833, new ConfigDescription("Horizontal position of the log viewer window.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 40
}
}));
WindowY = ((BaseUnityPlugin)this).Config.Bind<int>("Window", "WindowY", 1019, new ConfigDescription("Vertical position of the log viewer window.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 30
}
}));
WindowWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Window", "WindowWidth", 1507, new ConfigDescription("Width of the log viewer window.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 20
}
}));
WindowHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Window", "WindowHeight", 300, new ConfigDescription("Height of the log viewer window.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 10
}
}));
string[] array = new string[8] { "\\[ERROR\\]", "\\[WARNING\\]", "\\[DEBUG\\]|\\[DBG\\]", "\\[INFO\\]", "", "", "", "" };
string[] array2 = new string[8] { "red", "yellow", "cyan", "white", "", "", "", "" };
for (int i = 0; i < 8; i++)
{
int num = i + 1;
int num2 = (8 - i) * 2;
HighlightPattern[i] = ((BaseUnityPlugin)this).Config.Bind<string>("Highlighting", $"Highlight{num}Pattern", array[i], new ConfigDescription($"Regex pattern for highlight rule {num}. Leave empty to disable.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = num2
}
}));
HighlightColor[i] = ((BaseUnityPlugin)this).Config.Bind<string>("Highlighting", $"Highlight{num}Color", array2[i], new ConfigDescription($"Color for highlight rule {num} (e.g. red, yellow, cyan, green, blue, magenta, orange, white, or #RRGGBB hex).", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = num2 - 1
}
}));
}
if (!Application.isBatchMode)
{
((Component)this).gameObject.AddComponent<LogViewerUI>();
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"UnityLogViewer loaded!");
}
}
}