using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("PrivateNotes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PrivateNotes")]
[assembly: AssemblyTitle("PrivateNotes")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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]
[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 PrivateNotes
{
[BepInPlugin("local.private_notes", "Private Notes", "1.5.0")]
public sealed class PrivateNotesPlugin : BasePlugin
{
public static ConfigEntry<KeyCode> ToggleKey { get; private set; }
public static ConfigEntry<string> MenuColor { get; private set; }
public static ConfigEntry<float> MenuOpacity { get; private set; }
public static ManualLogSource Logger { get; private set; }
public static NotesUi Ui { get; private set; }
public override void Load()
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BasePlugin)this).Log;
ToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)288, "Key used to open or close the 'Private Notes' window. Can also be changed in the Settings tab.");
MenuColor = ((BasePlugin)this).Config.Bind<string>("General", "MenuColor", "default", "Menu color as a 6-digit hex code such as 132ED1, or 'default'. Can also be changed in the Settings tab.");
MenuOpacity = ((BasePlugin)this).Config.Bind<float>("General", "MenuOpacity", 0.93f, new ConfigDescription("Transparency of the menu BACKGROUND from 0.05 (almost see-through) to 1 (solid). Can also be changed in the Settings tab.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
Ui = new NotesUi();
InputBlocker.Install();
ClassInjector.RegisterTypeInIl2Cpp<PrivateNotesBehaviour>();
((BasePlugin)this).AddComponent<PrivateNotesBehaviour>();
((BasePlugin)this).Log.LogInfo((object)("Private Notes loaded. Press " + ((object)ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " to open it."));
}
}
public sealed class PrivateNotesBehaviour : MonoBehaviour
{
public PrivateNotesBehaviour(IntPtr ptr)
: base(ptr)
{
}
public void Awake()
{
PrivateNotesPlugin.Logger.LogInfo((object)"Behaviour Awake (component is alive)");
}
public void Update()
{
PrivateNotesPlugin.Ui.Update();
}
public void OnGUI()
{
PrivateNotesPlugin.Ui.OnGUI();
}
public void OnApplicationQuit()
{
PrivateNotesPlugin.Ui.SaveAll();
}
public void OnDestroy()
{
PrivateNotesPlugin.Logger.LogWarning((object)"Behaviour OnDestroy (component was destroyed)");
PrivateNotesPlugin.Ui.SaveAll();
}
}
public static class InputBlocker
{
public static bool KeyboardPrefix()
{
try
{
return !PrivateNotesPlugin.Ui.BlocksKeyboardJoystick();
}
catch
{
return true;
}
}
public static bool ControllerPrefix()
{
try
{
return !PrivateNotesPlugin.Ui.BlocksKeyboard;
}
catch
{
return true;
}
}
public static bool MousePrefix()
{
try
{
return !PrivateNotesPlugin.Ui.BlocksMouse();
}
catch
{
return true;
}
}
public static void Install()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
try
{
Harmony harmony = new Harmony("local.private_notes.input");
Assembly assembly = typeof(PlayerControl).Assembly;
Patch(harmony, assembly, "KeyboardJoystick", "Update", "KeyboardPrefix");
Patch(harmony, assembly, "KeyboardJoystick", "HandleHud", "KeyboardPrefix");
Patch(harmony, assembly, "ControllerManager", "Update", "ControllerPrefix");
Patch(harmony, assembly, "PassiveButtonManager", "Update", "MousePrefix");
}
catch (Exception ex)
{
PrivateNotesPlugin.Logger.LogWarning((object)("Input blocker setup failed: " + ex.Message));
}
}
private static void Patch(Harmony harmony, Assembly assembly, string typeName, string methodName, string prefixName)
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
try
{
MethodInfo methodInfo = (assembly.GetType(typeName) ?? assembly.GetTypes().FirstOrDefault((Type t) => t.Name == typeName))?.GetMethod(methodName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
MethodInfo method = typeof(InputBlocker).GetMethod(prefixName, BindingFlags.Static | BindingFlags.Public);
if (methodInfo == null || method == null)
{
PrivateNotesPlugin.Logger.LogWarning((object)("Input blocker: " + typeName + "." + methodName + " not found, skipped"));
}
else
{
harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
PrivateNotesPlugin.Logger.LogInfo((object)("Input blocker installed on " + typeName + "." + methodName));
}
}
catch (Exception ex)
{
PrivateNotesPlugin.Logger.LogWarning((object)("Input blocker failed on " + typeName + "." + methodName + ": " + ex.Message));
}
}
}
public sealed class NotesUi
{
private struct Span
{
public int Start;
public int Length;
public Color Color;
}
private const float MinWidth = 560f;
private const float MinHeight = 340f;
private const float HeaderHeight = 30f;
private const float RowH = 22f;
private const float PadX = 8f;
private const float BoxTop = 70f;
private const float BottomReserve = 46f;
private const int WindowId = 721903;
private const float MinOpacity = 0.05f;
private const float BoxLineInset = 3f;
private const float BoxLineThickness = 2f;
private const float BoxTopOffsetY = 1f;
private const float BoxBottomOffsetY = 3f;
private readonly string _directory;
private readonly string _temporaryPath;
private readonly string _permanentPath;
private readonly string _layoutPath;
private string _temporaryText;
private string _permanentText;
private string _lastTemporarySaved;
private string _lastPermanentSaved;
private Rect _window = new Rect(140f, 100f, 700f, 480f);
private bool _visible;
private bool _permanentTab;
private bool _settingsTab;
private bool _rebinding;
private bool _hasTint;
private Color _menuTint = Color.white;
private bool _confirmClear;
private bool _resizing;
private bool _dragging;
private bool _selecting;
private bool _editorFocused;
private bool _focusRequest;
private bool _ensureCaretVisible;
private Vector2 _dragOffset;
private Vector2 _resizeStart;
private Vector2 _resizeStartSize;
private int _caret;
private int _selAnchor = -1;
private int _scrollY;
private float _scrollX;
private float _barWidth = 4f;
private float _opacity = 0.93f;
private bool _opacityDirty;
private bool _sliderBroken;
private bool _windowStyleBroken;
private GUIStyle? _windowStyle;
private static readonly Color BoxLineColor = new Color(1f, 1f, 1f, 0.9f);
private bool _fillBroken;
private bool _groupBroken;
private bool _boxFillBroken;
private float _underscoreWidth = 8f;
private readonly Dictionary<int, GUIStyle> _fillStyles = new Dictionary<int, GUIStyle>();
private readonly Dictionary<int, GUIStyle> _buttonFillStyles = new Dictionary<int, GUIStyle>();
private string _lastScene = "";
private bool _sawGameplay;
private float _playerRefresh;
private int _lastToggleFrame = -1;
private bool _loggedFirstGui;
private readonly HashSet<string> _loggedErrors = new HashSet<string>();
private readonly Dictionary<string, Color> _playerColors = new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, Color> _wordColors = new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase);
private List<string> _wordList = new List<string>();
private readonly Dictionary<int, GUIStyle> _colorStyles = new Dictionary<int, GUIStyle>();
private readonly WindowFunction _drawWindow;
private GUIStyle? _rowStyle;
private GUIStyle? _smallStyle;
private GUIStyle? _smallRightStyle;
private GUIStyle? _headerStyle;
private static readonly string[] ColorNames = new string[18]
{
"red", "blue", "green", "pink", "orange", "yellow", "black", "white", "purple", "brown",
"cyan", "lime", "maroon", "rose", "banana", "gray", "tan", "coral"
};
private static readonly Color[] PlayerPalette = (Color[])(object)new Color[18]
{
Hex("C51111"),
Hex("132ED1"),
Hex("117F2D"),
Hex("ED54BA"),
Hex("EF7D0D"),
Hex("F5F557"),
Hex("3F474E"),
Hex("D6E0F0"),
Hex("6B2FBB"),
Hex("71491E"),
Hex("38FEDB"),
Hex("50EF39"),
Hex("6B2F2F"),
Hex("FF8FA9"),
Hex("FFFFBE"),
Hex("8397A7"),
Hex("A18F7A"),
Hex("FF6B5B")
};
private string CurrentText => _permanentTab ? _permanentText : _temporaryText;
public bool BlocksKeyboard => _visible && (_editorFocused || _rebinding);
private static Color Hex(string value)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
try
{
int num = Convert.ToInt32(value.Substring(0, 2), 16);
int num2 = Convert.ToInt32(value.Substring(2, 2), 16);
int num3 = Convert.ToInt32(value.Substring(4, 2), 16);
return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, 1f);
}
catch
{
return Color.white;
}
}
public NotesUi()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
_drawWindow = DelegateSupport.ConvertDelegate<WindowFunction>((Delegate)new Action<int>(DrawWindow));
_directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AmongUs", "PrivateNotes");
try
{
Directory.CreateDirectory(_directory);
}
catch
{
}
_temporaryPath = Path.Combine(_directory, "temporary.txt");
_permanentPath = Path.Combine(_directory, "permanent.txt");
_layoutPath = Path.Combine(_directory, "window.layout");
_temporaryText = ReadFile(_temporaryPath);
_permanentText = ReadFile(_permanentPath);
_lastTemporarySaved = _temporaryText;
_lastPermanentSaved = _permanentText;
LoadLayout();
RebuildWordList();
ApplyMenuColorSetting();
try
{
_opacity = Mathf.Clamp(PrivateNotesPlugin.MenuOpacity.Value, 0.05f, 1f);
}
catch
{
_opacity = 0.93f;
}
}
private static string ColorToHex(Color c)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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)
return Mathf.RoundToInt(c.r * 255f).ToString("X2") + Mathf.RoundToInt(c.g * 255f).ToString("X2") + Mathf.RoundToInt(c.b * 255f).ToString("X2");
}
private static bool TryParseHex(string value, out Color color)
{
//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_0095: 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)
color = Color.white;
if (string.IsNullOrWhiteSpace(value))
{
return false;
}
string text = value.Trim().TrimStart('#');
if (text.Length != 6)
{
return false;
}
try
{
int num = Convert.ToInt32(text.Substring(0, 2), 16);
int num2 = Convert.ToInt32(text.Substring(2, 2), 16);
int num3 = Convert.ToInt32(text.Substring(4, 2), 16);
color = new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, 1f);
return true;
}
catch
{
return false;
}
}
private void ApplyMenuColorSetting()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_004e: Unknown result type (might be due to invalid IL or missing references)
_hasTint = false;
try
{
if (TryParseHex(PrivateNotesPlugin.MenuColor.Value, out var color))
{
_menuTint = new Color(color.r * 0.4f, color.g * 0.4f, color.b * 0.4f, 1f);
_hasTint = true;
}
}
catch (Exception e)
{
LogOnce("ApplyMenuColorSetting", e);
}
}
private Color BackgroundColor()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_002b: 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)
//IL_0037: 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_004b: Unknown result type (might be due to invalid IL or missing references)
Color val = (Color)(_hasTint ? _menuTint : new Color(0.12f, 0.12f, 0.14f, 1f));
return new Color(val.r, val.g, val.b, _opacity);
}
private GUIStyle? GetWindowStyle()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (_windowStyleBroken)
{
return null;
}
if (_windowStyle != null)
{
return _windowStyle;
}
try
{
GUIStyle val = new GUIStyle();
val.normal.textColor = Color.white;
_windowStyle = val;
return val;
}
catch (Exception e)
{
_windowStyleBroken = true;
LogOnce("GetWindowStyle", e);
return null;
}
}
private void SetBackgroundAlpha()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
try
{
GUI.backgroundColor = new Color(1f, 1f, 1f, _opacity);
}
catch (Exception e)
{
LogOnce("GUI.backgroundColor", e);
}
}
private void ResetBackgroundColor()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
try
{
GUI.backgroundColor = Color.white;
}
catch
{
}
}
private void SaveOpacityIfNeeded()
{
if (!_opacityDirty)
{
return;
}
_opacityDirty = false;
try
{
PrivateNotesPlugin.MenuOpacity.Value = _opacity;
}
catch (Exception e)
{
LogOnce("SaveOpacity", e);
}
}
private void SetMenuColor(string hexOrDefault)
{
PrivateNotesPlugin.MenuColor.Value = hexOrDefault;
ApplyMenuColorSetting();
}
private void LogOnce(string where, Exception e)
{
string item = where + ":" + e.GetType().Name + ":" + e.Message;
if (_loggedErrors.Add(item))
{
PrivateNotesPlugin.Logger.LogError((object)("[" + where + "] " + e));
}
}
private static string ReadFile(string path)
{
try
{
return File.Exists(path) ? File.ReadAllText(path).Replace("\r", "") : "";
}
catch
{
return "";
}
}
private void SetText(string value)
{
if (_permanentTab)
{
_permanentText = value;
}
else
{
_temporaryText = value;
}
SaveNotes();
}
public bool BlocksMouse()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (!_visible)
{
return false;
}
if (_dragging || _resizing || _selecting)
{
return true;
}
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y);
return ((Rect)(ref _window)).Contains(val);
}
public bool BlocksKeyboardJoystick()
{
if (BlocksKeyboard)
{
return true;
}
if (!BlocksMouse())
{
return false;
}
return Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1);
}
private void ToggleWindow(string source)
{
if (Time.frameCount != _lastToggleFrame && (!_visible || (!_editorFocused && !_rebinding)))
{
_lastToggleFrame = Time.frameCount;
_visible = !_visible;
_dragging = false;
_resizing = false;
_selecting = false;
_rebinding = false;
_editorFocused = false;
if (_visible)
{
_focusRequest = true;
}
PrivateNotesPlugin.Logger.LogInfo((object)("Toggle via " + source + ", visible = " + _visible));
}
}
public void Update()
{
//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_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
try
{
KeyCode value = PrivateNotesPlugin.ToggleKey.Value;
bool flag = false;
try
{
flag = Input.GetKeyDown(value);
}
catch (Exception e)
{
LogOnce("Input.GetKeyDown", e);
}
if (flag)
{
ToggleWindow("Update");
}
HandleMouse();
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
if (!string.Equals(name, _lastScene, StringComparison.Ordinal))
{
_lastScene = name;
PrivateNotesPlugin.Logger.LogInfo((object)("Scene: " + name));
if (IsGameplayScene(name))
{
_sawGameplay = true;
}
if (_sawGameplay && IsEndScene(name))
{
ClearTemporaryNotes();
_sawGameplay = false;
}
}
if (_visible && Time.unscaledTime >= _playerRefresh)
{
_playerRefresh = Time.unscaledTime + 0.75f;
RefreshPlayerColors();
}
}
catch (Exception e2)
{
LogOnce("Update", e2);
}
}
public void OnGUI()
{
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Invalid comparison between Unknown and I4
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: 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_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!_loggedFirstGui)
{
_loggedFirstGui = true;
PrivateNotesPlugin.Logger.LogInfo((object)"OnGUI is being called");
}
Event current = Event.current;
if (current != null && (int)current.type == 4)
{
if (_visible && _rebinding)
{
HandleRebindKey(current);
current.Use();
}
else if (current.keyCode == PrivateNotesPlugin.ToggleKey.Value)
{
ToggleWindow("OnGUI");
}
else if (_visible && _editorFocused && HandleEditorKey(current))
{
current.Use();
}
}
else if (current != null && (int)current.type == 6 && _visible && ((Rect)(ref _window)).Contains(current.mousePosition))
{
_scrollY += ((current.delta.y > 0f) ? 1 : (-1));
current.Use();
}
if (!_visible)
{
return;
}
EnsureStyles();
((Rect)(ref _window)).width = Mathf.Max(560f, ((Rect)(ref _window)).width);
((Rect)(ref _window)).height = Mathf.Max(340f, ((Rect)(ref _window)).height);
bool flag = !_hasTint;
GUIStyle val = (flag ? null : GetWindowStyle());
if (flag)
{
SetBackgroundAlpha();
}
try
{
if (val != null)
{
try
{
_window = GUI.Window(721903, _window, _drawWindow, "", val);
}
catch (Exception e)
{
_windowStyleBroken = true;
LogOnce("GUI.Window(style)", e);
_window = GUI.Window(721903, _window, _drawWindow, "PRIVATE NOTES");
}
}
else
{
_window = GUI.Window(721903, _window, _drawWindow, "PRIVATE NOTES");
}
}
finally
{
if (flag)
{
ResetBackgroundColor();
}
}
if (!_focusRequest)
{
return;
}
_focusRequest = false;
try
{
GUI.BringWindowToFront(721903);
}
catch (Exception e2)
{
LogOnce("BringWindowToFront", e2);
}
}
catch (Exception e3)
{
LogOnce("OnGUI", e3);
}
}
private void HandleRebindKey(Event e)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
if ((int)e.keyCode != 0)
{
_rebinding = false;
if ((int)e.keyCode != 27)
{
PrivateNotesPlugin.ToggleKey.Value = e.keyCode;
_lastToggleFrame = Time.frameCount;
PrivateNotesPlugin.Logger.LogInfo((object)("Toggle key changed to " + ((object)e.keyCode/*cast due to .constrained prefix*/).ToString()));
}
}
}
private static bool IsGameplayScene(string scene)
{
return scene.IndexOf("OnlineGame", StringComparison.OrdinalIgnoreCase) >= 0 || scene.IndexOf("LocalGame", StringComparison.OrdinalIgnoreCase) >= 0 || scene.IndexOf("Tutorial", StringComparison.OrdinalIgnoreCase) >= 0;
}
private static bool IsEndScene(string scene)
{
return scene.IndexOf("EndGame", StringComparison.OrdinalIgnoreCase) >= 0;
}
private void ClearTemporaryNotes()
{
_temporaryText = "";
_lastTemporarySaved = "";
if (!_permanentTab)
{
_caret = 0;
_selAnchor = -1;
}
try
{
if (File.Exists(_temporaryPath))
{
File.Delete(_temporaryPath);
}
}
catch
{
}
}
private void RebuildWordList()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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)
_wordColors.Clear();
for (int i = 0; i < ColorNames.Length && i < PlayerPalette.Length; i++)
{
_wordColors[ColorNames[i]] = PlayerPalette[i];
}
_wordColors["grey"] = PlayerPalette[15];
foreach (KeyValuePair<string, Color> playerColor in _playerColors)
{
_wordColors[playerColor.Key] = playerColor.Value;
}
_wordList = _wordColors.Keys.OrderByDescending((string x) => x.Length).ToList();
}
private void RefreshPlayerColors()
{
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
_playerColors.Clear();
try
{
foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<PlayerControl>()))
{
PlayerControl val = ((Il2CppObjectBase)item).TryCast<PlayerControl>();
if ((Object)(object)val == (Object)null)
{
continue;
}
object member = GetMember(val, "Data");
if (member == null)
{
continue;
}
string text = GetMember(member, "PlayerName")?.ToString();
if (!string.IsNullOrWhiteSpace(text))
{
object member2 = GetMember(member, "DefaultOutfit");
object obj = ((member2 == null) ? null : GetMember(member2, "ColorId"));
if (obj == null)
{
obj = GetMember(member, "ColorId");
}
if (obj != null && int.TryParse(obj.ToString(), out var result) && result >= 0 && result < PlayerPalette.Length)
{
_playerColors[text] = PlayerPalette[result];
}
}
}
}
catch (Exception e)
{
LogOnce("RefreshPlayerColors", e);
}
RebuildWordList();
}
private static object? GetMember(object instance, string name)
{
Type type = instance.GetType();
try
{
PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null)
{
return property.GetValue(instance);
}
return type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance);
}
catch
{
return null;
}
}
private List<Span> FindSpans(string line)
{
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
List<Span> list = new List<Span>();
int num = 0;
while (num < line.Length)
{
bool flag = num == 0 || (!char.IsLetterOrDigit(line[num - 1]) && line[num - 1] != '_');
bool flag2 = false;
if (flag)
{
foreach (string word in _wordList)
{
int num2 = num + word.Length;
if (num2 > line.Length || string.Compare(line, num, word, 0, word.Length, StringComparison.OrdinalIgnoreCase) != 0 || (num2 != line.Length && (char.IsLetterOrDigit(line[num2]) || line[num2] == '_')))
{
continue;
}
list.Add(new Span
{
Start = num,
Length = word.Length,
Color = _wordColors[word]
});
num = num2;
flag2 = true;
break;
}
}
if (!flag2)
{
num++;
}
}
return list;
}
private static int ColorKey(Color c)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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)
return (Mathf.RoundToInt(c.r * 255f) << 16) | (Mathf.RoundToInt(c.g * 255f) << 8) | Mathf.RoundToInt(c.b * 255f);
}
private GUIStyle GetColorStyle(Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_003a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
int key = ColorKey(color);
if (_colorStyles.TryGetValue(key, out GUIStyle value) && value != null)
{
return value;
}
GUIStyle val = new GUIStyle(_rowStyle);
val.normal.textColor = color;
val.hover.textColor = color;
val.active.textColor = color;
val.focused.textColor = color;
_colorStyles[key] = val;
return val;
}
private void DrawSegment(string line, int start, int length, float x, float y, float maxWidth, Color? color)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
float num = Measure(line.Substring(0, start));
float num2 = Mathf.Max(4f, maxWidth - num);
GUIStyle val = (GUIStyle)(color.HasValue ? ((object)GetColorStyle(color.Value)) : ((object)_rowStyle));
GUI.Label(new Rect(x + num, y, num2, 22f), line.Substring(start, length), val);
}
private void DrawRowText(string line, float x, float y, float maxWidth)
{
//IL_0032: 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 (line.Length == 0)
{
return;
}
List<Span> list = FindSpans(line);
if (list.Count == 0)
{
GUI.Label(new Rect(x, y, maxWidth, 22f), line, _rowStyle);
return;
}
int num = 0;
foreach (Span item in list)
{
if (item.Start > num)
{
DrawSegment(line, num, item.Start - num, x, y, maxWidth, null);
}
DrawSegment(line, item.Start, item.Length, x, y, maxWidth, item.Color);
num = item.Start + item.Length;
}
if (num < line.Length)
{
DrawSegment(line, num, line.Length - num, x, y, maxWidth, null);
}
}
private static void SetOffset(RectOffset offset, int left, int right, int top, int bottom)
{
offset.left = left;
offset.right = right;
offset.top = top;
offset.bottom = bottom;
}
private void EnsureStyles()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_00da: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Expected O, but got Unknown
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
if (_rowStyle != null)
{
return;
}
_rowStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 15,
wordWrap = false,
richText = false,
alignment = (TextAnchor)3,
clipping = (TextClipping)1
};
SetOffset(_rowStyle.padding, 0, 0, 0, 0);
SetOffset(_rowStyle.margin, 0, 0, 0, 0);
_smallStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 11,
wordWrap = true
};
_smallRightStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 11,
wordWrap = false,
alignment = (TextAnchor)5
};
_headerStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 15,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)3
};
try
{
_barWidth = _rowStyle.CalcSize(new GUIContent("|")).x;
_underscoreWidth = _rowStyle.CalcSize(new GUIContent("_")).x;
}
catch (Exception e)
{
LogOnce("CalcSize", e);
}
}
private GUIStyle GetFillStyle(Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
int key = (Mathf.RoundToInt(color.a * 255f) << 24) | ColorKey(color);
if (_fillStyles.TryGetValue(key, out GUIStyle value) && value != null)
{
return value;
}
Texture2D val = new Texture2D(1, 1);
((Object)val).hideFlags = (HideFlags)61;
val.SetPixel(0, 0, color);
val.Apply();
GUIStyle val2 = new GUIStyle();
val2.normal.background = val;
_fillStyles[key] = val2;
return val2;
}
private GUIStyle GetButtonFillStyle(Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
int key = (Mathf.RoundToInt(color.a * 255f) << 24) | ColorKey(color);
if (_buttonFillStyles.TryGetValue(key, out GUIStyle value) && value != null)
{
return value;
}
Texture2D val = new Texture2D(1, 1);
((Object)val).hideFlags = (HideFlags)61;
val.SetPixel(0, 0, color);
val.Apply();
GUIStyle val2 = new GUIStyle();
val2.normal.background = val;
val2.hover.background = val;
val2.active.background = val;
val2.focused.background = val;
_buttonFillStyles[key] = val2;
return val2;
}
private void FillRect(Rect rect, Color color)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (_fillBroken)
{
return;
}
if (!_boxFillBroken)
{
try
{
GUI.Box(rect, GUIContent.none, GetFillStyle(color));
return;
}
catch (Exception e)
{
_boxFillBroken = true;
LogOnce("FillRect(Box)", e);
}
}
try
{
GUI.color = color;
GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
}
catch (Exception e2)
{
_fillBroken = true;
LogOnce("FillRect(DrawTexture)", e2);
}
finally
{
try
{
GUI.color = Color.white;
}
catch
{
}
}
}
private void DrawUnderline(float x, float y, float width, Color color)
{
//IL_0047: 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 (!(width < 1f))
{
float num = ((_underscoreWidth > 1f) ? _underscoreWidth : 8f);
int count = Mathf.Max(1, Mathf.CeilToInt(width / num));
GUI.Label(new Rect(x, y + 2f, width, 22f), new string('_', count), GetColorStyle(color));
}
}
private static bool IsWordChar(char c)
{
return char.IsLetterOrDigit(c) || c == '_';
}
private static bool TryGetWordBefore(string line, int index, out int start, out int end)
{
end = index;
start = index;
while (start > 0 && IsWordChar(line[start - 1]))
{
start--;
}
return start < end;
}
private static bool TryGetWordAfter(string line, int index, out int start, out int end)
{
start = index + 1;
end = start;
while (end < line.Length && IsWordChar(line[end]))
{
end++;
}
return end > start;
}
private void DrawMarkers(string line, float textX, float rowX, float y, float rowWidth)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
if (line.IndexOf('!') < 0 && line.IndexOf('@') < 0)
{
return;
}
bool flag = false;
bool flag2 = false;
Color color = Color.white;
for (int i = 0; i < line.Length; i++)
{
switch (line[i])
{
case '!':
{
flag = true;
if (!flag2 && TryGetWordBefore(line, i, out var start2, out var end2))
{
string key2 = line.Substring(start2, end2 - start2);
if (_wordColors.TryGetValue(key2, out var value2))
{
color = value2;
flag2 = true;
}
}
break;
}
case '@':
{
if (TryGetWordAfter(line, i, out var start, out var end) || TryGetWordBefore(line, i, out start, out end))
{
string key = line.Substring(start, end - start);
Color value;
Color color2 = (_wordColors.TryGetValue(key, out value) ? value : Color.white);
float num = Measure(line.Substring(0, start));
float num2 = Measure(line.Substring(0, end));
DrawUnderline(textX + num, y, num2 - num, color2);
}
break;
}
}
}
if (flag)
{
DrawUnderline(rowX, y, rowWidth, color);
}
}
private bool TryBeginGroup(Rect rect)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (_groupBroken)
{
return false;
}
try
{
GUI.BeginGroup(rect);
return true;
}
catch (Exception e)
{
_groupBroken = true;
LogOnce("BeginGroup", e);
return false;
}
}
private void TryEndGroup(bool began)
{
if (!began)
{
return;
}
try
{
GUI.EndGroup();
}
catch (Exception e)
{
LogOnce("EndGroup", e);
}
}
private Rect EditorLocal()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
return new Rect(12f, 70f, ((Rect)(ref _window)).width - 24f, ((Rect)(ref _window)).height - 70f - 46f);
}
private static int VisibleRows(Rect box)
{
return Mathf.Max(1, (int)(((Rect)(ref box)).height / 22f));
}
private void SwitchTab(bool permanent)
{
_permanentTab = permanent;
_settingsTab = false;
_rebinding = false;
_confirmClear = false;
_caret = 0;
_selAnchor = -1;
_scrollY = 0;
_scrollX = 0f;
}
private void OpenSettings()
{
_settingsTab = true;
_rebinding = false;
_editorFocused = false;
_selecting = false;
_confirmClear = false;
_selAnchor = -1;
}
private void DrawWindow(int id)
{
//IL_0092: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: 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_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: 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_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0403: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
try
{
EnsureStyles();
float width = ((Rect)(ref _window)).width;
float height = ((Rect)(ref _window)).height;
ResetBackgroundColor();
if (_hasTint)
{
FillRect(new Rect(0f, 0f, width, height), BackgroundColor());
if (_fillBroken)
{
GUI.Box(new Rect(0f, 0f, width, height), GUIContent.none);
}
}
else
{
SetBackgroundAlpha();
GUI.Box(new Rect(0f, 0f, width, height), GUIContent.none);
ResetBackgroundColor();
}
GUI.Label(new Rect(12f, 3f, 250f, 28f), "PRIVATE NOTES", _headerStyle);
if (GUI.Button(new Rect(width - 34f, 4f, 26f, 22f), "X"))
{
_visible = false;
_editorFocused = false;
_rebinding = false;
SaveLayout();
return;
}
bool flag = !_settingsTab && !_permanentTab;
bool flag2 = !_settingsTab && _permanentTab;
bool settingsTab = _settingsTab;
if (GUI.Toggle(new Rect(12f, 36f, 105f, 26f), flag, "Temporary", GUI.skin.button) && !flag)
{
SwitchTab(permanent: false);
}
if (GUI.Toggle(new Rect(123f, 36f, 105f, 26f), flag2, "Permanent", GUI.skin.button) && !flag2)
{
SwitchTab(permanent: true);
}
if (GUI.Toggle(new Rect(234f, 36f, 105f, 26f), settingsTab, "Settings", GUI.skin.button) && !settingsTab)
{
OpenSettings();
}
string text = (_settingsTab ? "Change things as u disire :3" : (_permanentTab ? "Saved forever" : "Deleted once round ends"));
GUI.Label(new Rect(350f, 36f, width - 12f - 350f, 26f), text, _smallRightStyle);
if (_settingsTab)
{
DrawSettings(new Rect(12f, 70f, width - 24f, height - 70f - 30f));
}
else
{
DrawEditor(EditorLocal());
GUI.Label(new Rect(12f, height - 40f, width - 12f - 130f, 34f), "By Onde (donroi) - Press " + ((object)PrivateNotesPlugin.ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " to toggle window.", _smallStyle);
float num = width - 12f - 105f;
if (GUI.Button(new Rect(num, height - 38f, 105f, 26f), _confirmClear ? "Confirm clear" : "Clear notes"))
{
if (_confirmClear)
{
SetText("");
_caret = 0;
_selAnchor = -1;
_scrollY = 0;
_scrollX = 0f;
_confirmClear = false;
}
else
{
_confirmClear = true;
}
}
if (_confirmClear && GUI.Button(new Rect(num - 70f, height - 38f, 65f, 26f), "Cancel"))
{
_confirmClear = false;
}
}
GUI.Label(new Rect(width - 22f, height - 22f, 18f, 18f), "◢");
if (!_hasTint)
{
SetBackgroundAlpha();
}
}
catch (Exception e)
{
LogOnce("DrawWindow", e);
}
}
private void DrawSettings(Rect box)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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_01a1: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_0339: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0424: Unknown result type (might be due to invalid IL or missing references)
float x = ((Rect)(ref box)).x;
float y = ((Rect)(ref box)).y;
GUI.Label(new Rect(x, y, ((Rect)(ref box)).width, 24f), "MENU COLOR", _headerStyle);
y += 30f;
int num = Mathf.Max(1, (int)((((Rect)(ref box)).width + 8f) / 42f));
string value = PrivateNotesPlugin.MenuColor.Value;
Rect val = default(Rect);
for (int i = 0; i < PlayerPalette.Length; i++)
{
((Rect)(ref val))..ctor(x + (float)(i % num) * 42f, y + (float)(i / num) * 42f, 34f, 34f);
string text = ColorToHex(PlayerPalette[i]);
if (string.Equals(value, text, StringComparison.OrdinalIgnoreCase))
{
FillRect(new Rect(((Rect)(ref val)).x - 3f, ((Rect)(ref val)).y - 3f, 40f, 40f), Color.white);
}
bool flag;
try
{
flag = GUI.Button(val, GUIContent.none, GetButtonFillStyle(PlayerPalette[i]));
}
catch (Exception e)
{
LogOnce("ColorSwatch", e);
flag = GUI.Button(val, ColorNames[i].Substring(0, 1).ToUpperInvariant());
}
if (flag)
{
SetMenuColor(text);
}
}
int num2 = (PlayerPalette.Length + num - 1) / num;
y += (float)num2 * 42f + 4f;
if (GUI.Button(new Rect(x, y, 130f, 28f), _hasTint ? "Default" : "Default (active)"))
{
SetMenuColor("default");
}
y += 44f;
GUI.Label(new Rect(x, y, ((Rect)(ref box)).width, 24f), "MENU TRANSPARENCY", _headerStyle);
y += 30f;
float num3 = 1f - _opacity;
float num4 = num3;
if (!_sliderBroken)
{
try
{
num4 = GUI.HorizontalSlider(new Rect(x, y + 6f, 300f, 20f), num3, 0f, 0.95f);
}
catch (Exception e2)
{
_sliderBroken = true;
LogOnce("HorizontalSlider", e2);
}
}
if (_sliderBroken)
{
if (GUI.Button(new Rect(x, y, 40f, 26f), "-"))
{
num4 = Mathf.Max(0f, num3 - 0.05f);
}
if (GUI.Button(new Rect(x + 46f, y, 40f, 26f), "+"))
{
num4 = Mathf.Min(0.95f, num3 + 0.05f);
}
}
if (!Mathf.Approximately(num4, num3))
{
_opacity = Mathf.Clamp(1f - num4, 0.05f, 1f);
_opacityDirty = true;
}
GUI.Label(new Rect(x + 312f, y, 120f, 26f), Mathf.RoundToInt((1f - _opacity) * 100f) + "% transparent", _smallStyle);
y += 36f;
GUI.Label(new Rect(x, y, ((Rect)(ref box)).width, 24f), "MENU KEY", _headerStyle);
y += 30f;
string text2 = (_rebinding ? "Press any key... (Esc cancels)" : ("Key: " + ((object)PrivateNotesPlugin.ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " (click to change)"));
if (GUI.Button(new Rect(x, y, 300f, 30f), text2))
{
_rebinding = !_rebinding;
}
y += 38f;
GUI.Label(new Rect(x, y, ((Rect)(ref box)).width, 40f), "The key opens and closes this window. Both settings are saved automatically.", _smallStyle);
}
private void DrawEditor(Rect box)
{
//IL_0055: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_040b: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0483: Unknown result type (might be due to invalid IL or missing references)
//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
//IL_04df: Unknown result type (might be due to invalid IL or missing references)
if (_hasTint)
{
FillRect(box, new Color(0f, 0f, 0f, 0.3f * _opacity));
if (_fillBroken)
{
GUI.Box(box, GUIContent.none);
}
}
else
{
SetBackgroundAlpha();
GUI.Box(box, GUIContent.none);
ResetBackgroundColor();
}
bool flag = TryBeginGroup(box);
try
{
Vector2 val = (Vector2)(flag ? Vector2.zero : new Vector2(((Rect)(ref box)).x, ((Rect)(ref box)).y));
string currentText = CurrentText;
_caret = Mathf.Clamp(_caret, 0, currentText.Length);
if (_selAnchor > currentText.Length)
{
_selAnchor = currentText.Length;
}
string[] array = currentText.Split('\n');
int num = VisibleRows(box);
if (_ensureCaretVisible)
{
_ensureCaretVisible = false;
EnsureCaretVisible(currentText, array, box, num);
}
_scrollY = Mathf.Clamp(_scrollY, 0, Mathf.Max(0, array.Length - num));
if (!flag)
{
_scrollX = 0f;
}
_scrollX = Mathf.Max(0f, _scrollX);
float maxWidth = (flag ? 4000f : (((Rect)(ref box)).width - 16f));
int[] array2 = new int[array.Length];
int num2 = 0;
for (int i = 0; i < array.Length; i++)
{
array2[i] = num2;
num2 += array[i].Length + 1;
}
bool flag2 = HasSelection();
int start = 0;
int end = 0;
if (flag2)
{
GetSelection(currentText.Length, out start, out end);
}
for (int j = 0; j < num; j++)
{
int num3 = _scrollY + j;
float num4 = val.y + (float)j * 22f;
if (num3 >= array.Length)
{
continue;
}
string text = array[num3];
if (flag2)
{
int num5 = array2[num3];
int num6 = num5 + text.Length;
int num7 = Mathf.Max(start, num5);
int num8 = Mathf.Min(end, num6);
bool flag3 = end > num6 && start <= num6;
if (num7 < num8 || flag3)
{
float num9 = Measure(text.Substring(0, Mathf.Clamp(num7 - num5, 0, text.Length)));
float num10 = Measure(text.Substring(0, Mathf.Clamp(Mathf.Max(num7, num8) - num5, 0, text.Length)));
if (flag3)
{
num10 += 7f;
}
FillRect(new Rect(val.x + 8f - _scrollX + num9, num4 + 1f, num10 - num9, 20f), new Color(0.2f, 0.5f, 1f, 0.45f));
}
}
DrawRowText(text, val.x + 8f - _scrollX, num4, maxWidth);
DrawMarkers(text, val.x + 8f - _scrollX, val.x + 8f, num4, ((Rect)(ref box)).width - 16f);
DrawBoxes(text, val.x + 8f - _scrollX, num4);
}
if (currentText.Length == 0 && !_editorFocused)
{
GUI.Label(new Rect(val.x + 8f, val.y, ((Rect)(ref box)).width - 16f, 22f), "Type here..", GetColorStyle(new Color(0.55f, 0.55f, 0.55f, 1f)));
}
if (_editorFocused && (int)(Time.unscaledTime * 2f) % 2 == 0)
{
GetLineCol(currentText, _caret, out var line, out var col);
int num11 = line - _scrollY;
if (num11 >= 0 && num11 < num && line < array.Length)
{
string text2 = array[line];
float num12 = val.x + 8f - _scrollX + Measure(text2.Substring(0, Mathf.Clamp(col, 0, text2.Length)));
GUI.Label(new Rect(num12 - _barWidth / 2f, val.y + (float)num11 * 22f, 16f, 22f), "|", _rowStyle);
}
}
}
catch (Exception e)
{
LogOnce("DrawEditor", e);
}
finally
{
TryEndGroup(flag);
}
}
private float Measure(string s)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if (s.Length == 0)
{
return 0f;
}
if (_rowStyle == null)
{
return (float)s.Length * 8f;
}
try
{
float x = _rowStyle.CalcSize(new GUIContent(s + "|")).x;
float x2 = _rowStyle.CalcSize(new GUIContent("|")).x;
return Mathf.Max(0f, x - x2);
}
catch (Exception e)
{
LogOnce("Measure", e);
return (float)s.Length * 8f;
}
}
private static void GetLineCol(string text, int caret, out int line, out int col)
{
line = 0;
int num = 0;
int num2 = Mathf.Min(caret, text.Length);
for (int i = 0; i < num2; i++)
{
if (text[i] == '\n')
{
line++;
num = i + 1;
}
}
col = caret - num;
}
private static int IndexFromLineCol(string text, int line, int col)
{
int num = 0;
for (int i = 0; i < line; i++)
{
int num2 = text.IndexOf('\n', num);
if (num2 < 0)
{
break;
}
num = num2 + 1;
}
int num3 = text.IndexOf('\n', num);
if (num3 < 0)
{
num3 = text.Length;
}
return num + Mathf.Max(0, Mathf.Min(col, num3 - num));
}
private void EnsureCaretVisible(string text, string[] lines, Rect box, int visible)
{
GetLineCol(text, _caret, out var line, out var col);
if (line < _scrollY)
{
_scrollY = line;
}
else if (line >= _scrollY + visible)
{
_scrollY = line - visible + 1;
}
if (line < lines.Length)
{
float num = Measure(lines[line].Substring(0, Mathf.Min(col, lines[line].Length)));
float num2 = ((Rect)(ref box)).width - 16f;
if (num < _scrollX)
{
_scrollX = Mathf.Max(0f, num - 24f);
}
else if (num > _scrollX + num2)
{
_scrollX = num - num2 + 24f;
}
}
}
private bool HasSelection()
{
return _selAnchor >= 0 && _selAnchor != _caret;
}
private void GetSelection(int length, out int start, out int end)
{
int num = Mathf.Clamp(_selAnchor, 0, length);
int num2 = Mathf.Clamp(_caret, 0, length);
start = Mathf.Min(num, num2);
end = Mathf.Max(num, num2);
}
private bool DeleteSelection()
{
if (!HasSelection())
{
return false;
}
string currentText = CurrentText;
GetSelection(currentText.Length, out var start, out var end);
SetText(currentText.Remove(start, end - start));
_caret = start;
_selAnchor = -1;
_ensureCaretVisible = true;
return true;
}
private void CopySelection()
{
if (!HasSelection())
{
return;
}
string currentText = CurrentText;
GetSelection(currentText.Length, out var start, out var end);
try
{
GUIUtility.systemCopyBuffer = currentText.Substring(start, end - start);
}
catch (Exception e)
{
LogOnce("Clipboard.Copy", e);
}
}
private void Paste()
{
string text = "";
try
{
text = GUIUtility.systemCopyBuffer ?? "";
}
catch (Exception e)
{
LogOnce("Clipboard.Paste", e);
}
text = text.Replace("\r\n", "\n").Replace("\r", "\n");
if (text.Length > 0)
{
InsertText(text);
}
}
private void MoveCaret(int index, bool extendSelection)
{
if (extendSelection)
{
if (_selAnchor < 0)
{
_selAnchor = _caret;
}
}
else
{
_selAnchor = -1;
}
_caret = index;
_ensureCaretVisible = true;
}
private bool HandleEditorKey(Event e)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Invalid comparison between Unknown and I4
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Invalid comparison between Unknown and I4
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Invalid comparison between Unknown and I4
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Invalid comparison between Unknown and I4
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Invalid comparison between Unknown and I4
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Invalid comparison between Unknown and I4
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Invalid comparison between Unknown and I4
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Invalid comparison between Unknown and I4
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Invalid comparison between Unknown and I4
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Invalid comparison between Unknown and I4
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Invalid comparison between Unknown and I4
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Expected I4, but got Unknown
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Invalid comparison between Unknown and I4
string currentText = CurrentText;
_caret = Mathf.Clamp(_caret, 0, currentText.Length);
bool flag = (e.control || e.command) && !e.alt;
bool shift = e.shift;
if ((int)e.keyCode == 0)
{
char character = e.character;
if (character >= ' ' && character != '\u007f')
{
InsertText(character.ToString());
return true;
}
return false;
}
if (flag)
{
KeyCode keyCode = e.keyCode;
KeyCode val = keyCode;
if ((int)val <= 99)
{
if ((int)val == 97)
{
_selAnchor = 0;
_caret = currentText.Length;
_ensureCaretVisible = true;
return true;
}
if ((int)val == 99)
{
CopySelection();
return true;
}
}
else
{
if ((int)val == 118)
{
Paste();
return true;
}
if ((int)val == 120)
{
CopySelection();
DeleteSelection();
return true;
}
}
}
KeyCode keyCode2 = e.keyCode;
KeyCode val2 = keyCode2;
if ((int)val2 <= 13)
{
if ((int)val2 == 8)
{
if (!DeleteSelection() && _caret > 0)
{
SetText(currentText.Remove(_caret - 1, 1));
_caret--;
_ensureCaretVisible = true;
}
return true;
}
if ((int)val2 != 13)
{
goto IL_03ba;
}
}
else
{
if ((int)val2 == 27)
{
_editorFocused = false;
_selAnchor = -1;
return true;
}
if ((int)val2 == 127)
{
if (!DeleteSelection() && _caret < currentText.Length)
{
SetText(currentText.Remove(_caret, 1));
_ensureCaretVisible = true;
}
return true;
}
int end;
switch (val2 - 271)
{
case 0:
break;
case 5:
if (!shift && HasSelection())
{
GetSelection(currentText.Length, out var start, out end);
MoveCaret(start, extendSelection: false);
}
else
{
MoveCaret(Mathf.Max(0, _caret - 1), shift);
}
return true;
case 4:
if (!shift && HasSelection())
{
GetSelection(currentText.Length, out end, out var end2);
MoveCaret(end2, extendSelection: false);
}
else
{
MoveCaret(Mathf.Min(currentText.Length, _caret + 1), shift);
}
return true;
case 2:
case 3:
{
GetLineCol(currentText, _caret, out var line2, out var col);
int num = currentText.Split('\n').Length;
int line3 = Mathf.Clamp(line2 + (((int)e.keyCode != 273) ? 1 : (-1)), 0, num - 1);
MoveCaret(IndexFromLineCol(currentText, line3, col), shift);
return true;
}
case 7:
{
GetLineCol(currentText, _caret, out end, out var col2);
MoveCaret((!flag) ? (_caret - col2) : 0, shift);
return true;
}
case 8:
{
GetLineCol(currentText, _caret, out var line, out end);
MoveCaret(flag ? currentText.Length : IndexFromLineCol(currentText, line, 1073741823), shift);
return true;
}
default:
goto IL_03ba;
}
}
InsertText("\n");
return true;
IL_03ba:
return false;
}
private void InsertText(string value)
{
string text = CurrentText;
_caret = Mathf.Clamp(_caret, 0, text.Length);
if (HasSelection())
{
GetSelection(text.Length, out var start, out var end);
text = text.Remove(start, end - start);
_caret = start;
}
_selAnchor = -1;
text = text.Insert(_caret, value);
_caret += value.Length;
SetText(text);
_ensureCaretVisible = true;
}
private void DrawBoxes(string line, float textX, float y)
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
if (line.IndexOf('[') < 0)
{
return;
}
List<Span> list = FindSpans(line);
Stack<int> stack = new Stack<int>();
for (int i = 0; i < line.Length; i++)
{
if (line[i] == '[')
{
stack.Push(i);
}
else
{
if (line[i] != ']' || stack.Count <= 0)
{
continue;
}
int num = stack.Pop();
float num2 = Measure(line.Substring(0, num));
float num3 = Measure(line.Substring(0, i + 1));
float num4 = Mathf.Max(6f, num3 - num2);
Color color = BoxLineColor;
foreach (Span item in list)
{
if (item.Start > num && item.Start + item.Length <= i)
{
color = item.Color;
break;
}
}
float num5 = y + 3f + 1f;
float num6 = y + 22f - 3f - 2f + 3f;
FillRect(new Rect(textX + num2, num5, num4, 2f), color);
FillRect(new Rect(textX + num2, num6, num4, 2f), color);
}
}
}
private void HandleMouse()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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)
//IL_0105: 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_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: 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_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
if (!_visible)
{
_dragging = false;
_resizing = false;
_selecting = false;
return;
}
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y);
Rect val2 = EditorLocal();
Rect editorScreen = default(Rect);
((Rect)(ref editorScreen))..ctor(((Rect)(ref _window)).x + ((Rect)(ref val2)).x, ((Rect)(ref _window)).y + ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height);
if (Input.GetMouseButtonDown(0))
{
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(((Rect)(ref _window)).xMax - 24f, ((Rect)(ref _window)).yMax - 24f, 24f, 24f);
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(((Rect)(ref _window)).x, ((Rect)(ref _window)).y, ((Rect)(ref _window)).width - 38f, 30f);
if (((Rect)(ref val3)).Contains(val))
{
_resizing = true;
_resizeStart = val;
_resizeStartSize = new Vector2(((Rect)(ref _window)).width, ((Rect)(ref _window)).height);
}
else if (((Rect)(ref val4)).Contains(val))
{
_dragging = true;
_dragOffset = new Vector2(val.x - ((Rect)(ref _window)).x, val.y - ((Rect)(ref _window)).y);
}
if (((Rect)(ref _window)).Contains(val))
{
_focusRequest = true;
if (!_settingsTab && ((Rect)(ref editorScreen)).Contains(val))
{
_editorFocused = true;
_selecting = true;
_caret = CaretFromMouse(val, editorScreen);
_selAnchor = _caret;
_ensureCaretVisible = false;
}
else
{
_editorFocused = false;
}
}
else
{
_editorFocused = false;
_rebinding = false;
}
}
if (!Input.GetMouseButton(0))
{
SaveOpacityIfNeeded();
if (_dragging || _resizing)
{
SaveLayout();
}
_dragging = false;
_resizing = false;
if (_selecting)
{
_selecting = false;
if (_selAnchor == _caret)
{
_selAnchor = -1;
}
}
}
if (_selecting)
{
_caret = CaretFromMouse(val, editorScreen);
_ensureCaretVisible = true;
}
if (_dragging)
{
((Rect)(ref _window)).x = Mathf.Clamp(val.x - _dragOffset.x, 0f - ((Rect)(ref _window)).width + 120f, (float)Screen.width - 120f);
((Rect)(ref _window)).y = Mathf.Clamp(val.y - _dragOffset.y, 0f, (float)Screen.height - 30f);
}
else if (_resizing)
{
((Rect)(ref _window)).width = Mathf.Max(560f, _resizeStartSize.x + (val.x - _resizeStart.x));
((Rect)(ref _window)).height = Mathf.Max(340f, _resizeStartSize.y + (val.y - _resizeStart.y));
}
}
private int CaretFromMouse(Vector2 mouse, Rect editorScreen)
{
//IL_0012: 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)
string currentText = CurrentText;
string[] array = currentText.Split('\n');
float num = mouse.x - ((Rect)(ref editorScreen)).x;
float num2 = mouse.y - ((Rect)(ref editorScreen)).y;
int num3 = Mathf.Clamp(_scrollY + Mathf.FloorToInt(num2 / 22f), 0, array.Length - 1);
string text = array[num3];
float num4 = num - 8f + _scrollX;
int col = text.Length;
float num5 = 0f;
for (int i = 1; i <= text.Length; i++)
{
float num6 = Measure(text.Substring(0, i));
if (num6 >= num4)
{
col = ((num6 - num4 > num4 - num5) ? (i - 1) : i);
break;
}
num5 = num6;
}
return IndexFromLineCol(currentText, num3, col);
}
public void SaveAll()
{
SaveOpacityIfNeeded();
SaveNotes();
SaveLayout();
}
private void SaveNotes()
{
try
{
if (!string.Equals(_temporaryText, _lastTemporarySaved, StringComparison.Ordinal))
{
File.WriteAllText(_temporaryPath, _temporaryText);
_lastTemporarySaved = _temporaryText;
}
if (!string.Equals(_permanentText, _lastPermanentSaved, StringComparison.Ordinal))
{
File.WriteAllText(_permanentPath, _permanentText);
_lastPermanentSaved = _permanentText;
}
}
catch (Exception e)
{
LogOnce("SaveNotes", e);
}
}
private void LoadLayout()
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
try
{
if (File.Exists(_layoutPath))
{
string[] array = File.ReadAllText(_layoutPath).Split('|');
if (array.Length == 4)
{
float num = float.Parse(array[0], CultureInfo.InvariantCulture);
float num2 = float.Parse(array[1], CultureInfo.InvariantCulture);
float num3 = float.Parse(array[2], CultureInfo.InvariantCulture);
float num4 = float.Parse(array[3], CultureInfo.InvariantCulture);
num = Mathf.Clamp(num, 0f, 2000f);
num2 = Mathf.Clamp(num2, 0f, 1200f);
_window = new Rect(num, num2, Mathf.Max(560f, num3), Mathf.Max(340f, num4));
}
}
}
catch
{
}
}
private void SaveLayout()
{
try
{
string contents = string.Join("|", ((Rect)(ref _window)).x.ToString(CultureInfo.InvariantCulture), ((Rect)(ref _window)).y.ToString(CultureInfo.InvariantCulture), ((Rect)(ref _window)).width.ToString(CultureInfo.InvariantCulture), ((Rect)(ref _window)).height.ToString(CultureInfo.InvariantCulture));
File.WriteAllText(_layoutPath, contents);
}
catch
{
}
}
}
}