Decompiled source of Card Designer v0.1.0
CardDesigner.dll
Decompiled 35 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using OnTogetherMods.Shared; using PurrNet; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.TextCore; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CardDesigner")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+afd1688a3bd57e387e5fe395996dc0ff1135bbe6")] [assembly: AssemblyProduct("CardDesigner")] [assembly: AssemblyTitle("CardDesigner")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 OnTogetherMods.Shared { internal static class PanelStack { private const string TableKey = "OnTogetherMods.PanelStack.Panels"; private const string HiddenKey = "OnTogetherMods.PanelStack.Hidden"; private const string IconBarKey = "OnTogetherMods.IconBar.Rect"; private const float Margin = 20f; private const float FromRight = 0.15f; private const float Gap = 10f; private const int WorldScene = 2; public const int PhotoModeOrder = 0; public const int EmoteSyncOrder = 10; public const int TeleportSpotsOrder = 20; public const int SongPlayerOrder = 30; public const int TraceOverlayOrder = 40; public const int NameDesignerOrder = 50; public const int CardDesignerOrder = 55; public const int OutfitSlotsOrder = 60; public const int DeskSwarmOrder = 70; public const int SessionManagerOrder = 80; public const int FocusAnywhereOrder = 90; public const string CanvasPrefix = "OnTogetherMods "; private static int _hiddenFrame = -1; private static bool _gameUIHidden; private static FieldRef<UIManager, HideUIState> _eyeState; private static bool _eyeStateMissing; public static float Width => (float)Screen.width * 1080f / (float)Screen.height; public static bool Hidden { get { if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Hidden") is int num) || Time.frameCount > num) { return GameUIHidden; } return true; } } public static bool GameUIHidden { get { //IL_001a: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 int frameCount = Time.frameCount; if (_hiddenFrame != frameCount) { _hiddenFrame = frameCount; _gameUIHidden = false; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).buildIndex == 2) { UIManager i = MonoSingleton<UIManager>.I; _gameUIHidden = (Object)(object)i != (Object)null && (int)EyeState(i) > 0; } } return _gameUIHidden; } } public static bool IsModCanvas(Canvas canvas) { Canvas val = canvas; Transform parent = ((Component)canvas).transform.parent; while ((Object)(object)parent != (Object)null) { Canvas component = ((Component)parent).GetComponent<Canvas>(); val = (((Object)(object)component != (Object)null) ? component : val); parent = parent.parent; } return ((Object)((Component)val).gameObject).name.StartsWith("OnTogetherMods ", StringComparison.Ordinal); } private static HideUIState EyeState(UIManager ui) { if (_eyeState == null && !_eyeStateMissing) { try { _eyeState = AccessTools.FieldRefAccess<UIManager, HideUIState>("_hideUIState"); } catch (Exception) { _eyeStateMissing = true; } } if (_eyeState != null) { return _eyeState.Invoke(ui); } return (HideUIState)0; } public static void HideForCapture() { AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Hidden", Time.frameCount + 1); } public static Rect Place(string id, int order, Vector2 size) { //IL_001b: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) Hashtable hashtable = Panels(); int frameCount = Time.frameCount; hashtable[id] = new double[3] { order, size.y, frameCount }; float width = Width; float num = Mathf.Max(20f, width * 0.85f - size.x); float num2 = Bottom(num + size.x, frameCount) - size.y; foreach (DictionaryEntry item in hashtable) { string text = (string)item.Key; double[] array = (double[])item.Value; bool flag = (double)frameCount - array[2] <= 2.0; bool flag2 = array[0] < (double)order || (array[0] == (double)order && string.CompareOrdinal(text, id) < 0); if (text != id && flag && flag2) { num2 -= (float)array[1] + 10f; } } return new Rect(num, num2, size.x, size.y); } private static float Bottom(float windowRight, int frame) { float num = 1060f; if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array && (double)frame - array[4] <= 2.0) { float num2 = 1080f / (float)Screen.height; if (array[0] * (double)num2 < (double)(windowRight + 10f)) { num = Mathf.Min(num, (float)array[1] * num2 - 10f); } } return num; } public static Matrix4x4 Begin(out float width) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) float num = (float)Screen.height / 1080f; Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); width = (float)Screen.width / num; return matrix; } public static void End(Matrix4x4 previous) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.matrix = previous; } public static GUIStyle MakeStyle(TextAnchor alignment) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003f: 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_0050: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.box) { alignment = alignment, fontSize = 15, richText = true, wordWrap = false, padding = new RectOffset(12, 12, 10, 10) }; val.normal.textColor = Color.white; return val; } private static Hashtable Panels() { Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Panels") as Hashtable; if (hashtable == null) { hashtable = new Hashtable(); AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Panels", hashtable); } return hashtable; } } internal static class IconBar { public enum State { Plain, Open, On, Off } public enum Click { None, Left, Right } private struct Metrics { public float Unit; public int Art; public int Button; public int Gap; public int Margin; } private static class Patches { private static Action<InputManager, bool> _setMouse0Down; private static Action<InputManager, bool> _setMouse1; private static Action<InputManager, bool> _setMouse1Up; private static FieldRef<QuadPainterGPU, Vector2> _previousUV; private static bool _leftOnBar; private static bool _rightOnBar; public static void Apply(Harmony harmony) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown _setMouse0Down = Setter("IsMouseButton0Down"); _setMouse1 = Setter("IsMouseButton1"); _setMouse1Up = Setter("IsMouseButton1Up"); harmony.Patch((MethodBase)AccessTools.Method(typeof(InputManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "InputPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _previousUV = AccessTools.FieldRefAccess<QuadPainterGPU, Vector2>("previousUV"); harmony.Patch((MethodBase)AccessTools.Method(typeof(QuadPainterGPU), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "PaintPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void InputPostfix(InputManager __instance) { bool mouseOver = MouseOver; if (Input.GetMouseButtonDown(0)) { _leftOnBar = mouseOver; } if (Input.GetMouseButtonDown(1)) { _rightOnBar = mouseOver; } if (mouseOver) { _setMouse0Down(__instance, arg2: false); } if (_rightOnBar) { _setMouse1(__instance, arg2: false); _setMouse1Up(__instance, arg2: false); } if (!Input.GetMouseButton(0)) { _leftOnBar = false; } if (!Input.GetMouseButton(1)) { _rightOnBar = false; } } private static bool PaintPrefix(QuadPainterGPU __instance) { if (__instance.IsActive && (_leftOnBar || MouseOver)) { _previousUV.Invoke(__instance).x = -1f; return false; } return true; } private static Action<InputManager, bool> Setter(string property) { return (Action<InputManager, bool>)Delegate.CreateDelegate(typeof(Action<InputManager, bool>), AccessTools.PropertySetter(typeof(InputManager), property)); } } public const int PhotoModeOrder = 0; public const int EmoteSyncOrder = 10; public const int TeleportSpotsOrder = 20; public const int NameDesignerOrder = 30; public const int CardDesignerOrder = 32; public const int OutfitSlotsOrder = 35; public const int DeskSnapOrder = 40; public const int DeskSwarmOrder = 45; public const int FocusAnywhereOrder = 50; public const int SongPlayerOrder = 60; public const int TraceOverlayOrder = 70; public const int ChatRangeOrder = 80; public const int QuickHideOrder = 90; public const int SessionManagerOrder = 95; private const string RectKey = "OnTogetherMods.IconBar.Rect"; private const string TableKey = "OnTogetherMods.IconBar.Icons"; private const string PatchedKey = "OnTogetherMods.IconBar.Patched"; private const string BlockerKey = "OnTogetherMods.IconBar.Blocker"; private const string BlockerFrameKey = "OnTogetherMods.IconBar.BlockerFrame"; private const string HiddenKey = "OnTogetherMods.IconBar.HiddenUntil"; private const int WorldScene = 2; private const int TooltipDepth = -100; private static readonly Dictionary<char, Color32> Palette = new Dictionary<char, Color32> { { 'K', new Color32((byte)42, (byte)36, (byte)51, byte.MaxValue) }, { 'W', new Color32((byte)247, (byte)243, (byte)234, byte.MaxValue) }, { 'G', new Color32((byte)201, (byte)198, (byte)207, byte.MaxValue) }, { 'g', new Color32((byte)143, (byte)138, (byte)153, byte.MaxValue) }, { 'D', new Color32((byte)87, (byte)82, (byte)95, byte.MaxValue) }, { 'B', new Color32((byte)168, (byte)107, (byte)60, byte.MaxValue) }, { 'b', new Color32((byte)217, (byte)160, (byte)102, byte.MaxValue) }, { 'd', new Color32((byte)110, (byte)67, (byte)37, byte.MaxValue) }, { 'R', new Color32((byte)224, (byte)90, (byte)90, byte.MaxValue) }, { 'r', new Color32((byte)168, (byte)58, (byte)70, byte.MaxValue) }, { 'p', new Color32((byte)246, (byte)165, (byte)165, byte.MaxValue) }, { 'Y', new Color32((byte)245, (byte)208, (byte)97, byte.MaxValue) }, { 'y', new Color32((byte)201, (byte)150, (byte)50, byte.MaxValue) }, { 'O', new Color32((byte)232, (byte)146, (byte)74, byte.MaxValue) }, { 'L', new Color32((byte)159, (byte)214, (byte)245, byte.MaxValue) }, { 'U', new Color32((byte)74, (byte)143, (byte)217, byte.MaxValue) }, { 'u', new Color32((byte)47, (byte)90, (byte)158, byte.MaxValue) }, { 'N', new Color32((byte)116, (byte)192, (byte)105, byte.MaxValue) }, { 'n', new Color32((byte)63, (byte)138, (byte)74, byte.MaxValue) }, { 'P', new Color32((byte)246, (byte)207, (byte)174, byte.MaxValue) }, { 'V', new Color32((byte)154, (byte)114, (byte)214, byte.MaxValue) }, { 'v', new Color32((byte)105, (byte)72, (byte)160, byte.MaxValue) }, { 'S', new Color32((byte)233, (byte)139, (byte)181, byte.MaxValue) }, { 'H', new Color32((byte)60, (byte)48, (byte)56, byte.MaxValue) } }; private static readonly Color32 ButtonFill = new Color32((byte)28, (byte)26, (byte)34, (byte)200); private static readonly Color32 ButtonEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)30); private static readonly Color32 HoverFill = new Color32((byte)48, (byte)45, (byte)58, (byte)225); private static readonly Color32 HoverEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)80); private static readonly Color32 OpenFill = new Color32((byte)70, (byte)64, (byte)88, (byte)235); private static readonly Color32 OpenEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)150); private static readonly Color32 DotFill = new Color32((byte)140, (byte)220, (byte)120, byte.MaxValue); private static readonly Color32 DotEdge = new Color32((byte)20, (byte)40, (byte)20, byte.MaxValue); private static readonly Dictionary<string[], Texture2D[]> Icons = new Dictionary<string[], Texture2D[]>(); private static Texture2D _buttonTexture; private static Texture2D _hoverTexture; private static Texture2D _openTexture; private static Texture2D _dotTexture; private static GUIStyle _buttonStyle; private static GUIStyle _tipStyle; private static int _builtFor; private static int _cachedFrame = -1; private static bool _inWorld; private static bool _visible; private static int _pressedButton; private static bool RowHidden { get { if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.HiddenUntil") is int num) { return Time.frameCount <= num; } return false; } } public static bool MouseOver { get { //IL_003d: 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_005c: 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_006f: Unknown result type (might be due to invalid IL or missing references) if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || array[5] < 0.5 || (double)Time.frameCount - array[4] > 2.0) { return false; } Vector3 mousePosition = Input.mousePosition; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)array[0], (float)array[1], (float)array[2], (float)array[3]); return ((Rect)(ref val)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y)); } } public static Click Draw(string id, int order, string[] pixels, State state, string name, KeyCode key, string hint = null) { //IL_0086: 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_003d: 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_0049: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) int controlID = GUIUtility.GetControlID((FocusType)2); Event current = Event.current; Refresh(); if (!_inWorld) { Hide(controlID, current); UpdateBlocker(shown: false, default(Rect)); return Click.None; } Rect bar; Metrics m; Rect icon = Place(id, order, out bar, out m); Share(bar); UpdateBlocker(_visible, bar); if (!_visible) { Hide(controlID, current); return Click.None; } Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.identity; try { return Handle(controlID, current, icon, m, pixels, state, name, key, hint); } finally { GUI.matrix = matrix; } } public static void HideRow() { AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.HiddenUntil", Time.frameCount + 1); } public static string KeyText(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if ((int)key != 0) { return $" ({key})"; } return ""; } private static Click Handle(int control, Event e, Rect icon, Metrics m, string[] pixels, State state, string name, KeyCode key, string hint) { //IL_0003: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected I4, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) bool flag = ((Rect)(ref icon)).Contains(e.mousePosition); EventType typeForControl = e.GetTypeForControl(control); switch ((int)typeForControl) { default: { if ((int)typeForControl != 7) { break; } BuildStyles(m); bool flag2 = GUIUtility.hotControl == control; _buttonStyle.normal.background = ((state == State.Open || (flag2 && flag)) ? _openTexture : (flag ? _hoverTexture : _buttonTexture)); _buttonStyle.Draw(icon, false, false, false, false); Texture2D[] array = IconTextures(pixels); GUI.DrawTexture(new Rect(((Rect)(ref icon)).x + (((Rect)(ref icon)).width - (float)m.Art) / 2f, ((Rect)(ref icon)).y + (((Rect)(ref icon)).height - (float)m.Art) / 2f, (float)m.Art, (float)m.Art), (Texture)(object)((state == State.Off) ? array[1] : array[0])); if (state == State.On) { float num = Mathf.Max(1, Mathf.RoundToInt(2f * m.Unit)); float num2 = ((Texture)_dotTexture).width; GUI.DrawTexture(new Rect(((Rect)(ref icon)).xMax - num - num2, ((Rect)(ref icon)).yMax - num - num2, num2, num2), (Texture)(object)_dotTexture); } int num3; if (flag) { num3 = ((GUIUtility.hotControl == 0 || flag2) ? 1 : 0); if (num3 != 0) { DrawTooltip(icon, m, Tooltip(state, name, key, hint)); } } else { num3 = 0; } GUI.depth = ((num3 != 0) ? (-100) : 0); break; } case 0: if (flag && (e.button == 0 || e.button == 1)) { GUIUtility.hotControl = control; _pressedButton = e.button; e.Use(); } break; case 3: if (GUIUtility.hotControl == control) { e.Use(); } break; case 1: if (GUIUtility.hotControl != control) { break; } GUIUtility.hotControl = 0; e.Use(); if (flag && e.button == _pressedButton) { if (e.button != 0) { return Click.Right; } return Click.Left; } break; case 2: break; } return Click.None; } private static string Tooltip(State state, string name, KeyCode key, string hint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string text = name + KeyText(key); switch (state) { case State.On: text += ": on"; break; case State.Off: text += ": off"; break; } if (hint == null) { return text; } return text + "\n" + hint; } private static void DrawTooltip(Rect icon, Metrics m, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //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) //IL_0015: 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_0047: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) GUIContent val = new GUIContent(text); Vector2 val2 = _tipStyle.CalcSize(val); float num = Mathf.Clamp(((Rect)(ref icon)).center.x - val2.x / 2f, (float)m.Margin, Mathf.Max((float)m.Margin, (float)(Screen.width - m.Margin) - val2.x)); float num2 = ((Rect)(ref icon)).y - (float)m.Gap - val2.y; _tipStyle.Draw(new Rect(Mathf.Round(num), Mathf.Round(num2), val2.x, val2.y), val, false, false, false, false); } private static void Hide(int control, Event e) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (GUIUtility.hotControl == control) { GUIUtility.hotControl = 0; } if ((int)e.type == 7) { GUI.depth = 0; } } private static Metrics Measure() { float num = (float)Screen.height / 1080f; int num2 = Mathf.Max(1, Mathf.RoundToInt(2f * num)); int num3 = Mathf.Max(2, Mathf.RoundToInt(4f * num)); return new Metrics { Unit = num, Art = 16 * num2, Button = 16 * num2 + 2 * num3, Gap = Mathf.Max(2, Mathf.RoundToInt(6f * num)), Margin = Mathf.RoundToInt(20f * num) }; } private static Rect Place(string id, int order, out Rect bar, out Metrics m) { //IL_0132: 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_0160: Unknown result type (might be due to invalid IL or missing references) Hashtable hashtable = Table(); int frameCount = Time.frameCount; if (hashtable[id] is double[] array) { array[0] = order; array[1] = frameCount; } else { hashtable[id] = new double[2] { order, frameCount }; } int num = 0; int num2 = 0; foreach (DictionaryEntry item in hashtable) { string text = (string)item.Key; double[] array2 = (double[])item.Value; if (!((double)frameCount - array2[1] > 2.0)) { num2++; if (text != id && (array2[0] < (double)order || (array2[0] == (double)order && string.CompareOrdinal(text, id) < 0))) { num++; } } } m = Measure(); int num3 = num2 * m.Button + (num2 - 1) * m.Gap; int num4 = Screen.width - m.Margin - num3; int num5 = Screen.height - m.Margin - m.Button; bar = new Rect((float)num4, (float)num5, (float)num3, (float)m.Button); return new Rect((float)(num4 + num * (m.Button + m.Gap)), (float)num5, (float)m.Button, (float)m.Button); } private static void Share(Rect bar) { AppDomain currentDomain = AppDomain.CurrentDomain; int frameCount = Time.frameCount; if (!(currentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || (int)array[4] != frameCount || !(array[2] >= (double)((Rect)(ref bar)).width)) { currentDomain.SetData("OnTogetherMods.IconBar.Rect", new double[6] { ((Rect)(ref bar)).x, ((Rect)(ref bar)).y, ((Rect)(ref bar)).width, ((Rect)(ref bar)).height, frameCount, _visible ? 1 : 0 }); } } private static Hashtable Table() { Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Icons") as Hashtable; if (hashtable == null) { hashtable = new Hashtable(); AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.Icons", hashtable); } return hashtable; } private static void Refresh() { //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_0055: 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_0063: Invalid comparison between Unknown and I4 int frameCount = Time.frameCount; if (_cachedFrame != frameCount) { _cachedFrame = frameCount; Scene activeScene = SceneManager.GetActiveScene(); _inWorld = ((Scene)(ref activeScene)).buildIndex == 2; _visible = false; if (_inWorld && !PanelStack.Hidden && !RowHidden) { TaskManager i = MonoSingleton<TaskManager>.I; _visible = (Object)(object)i != (Object)null && ((int)i.LockState == 0 || (int)i.LockState == 5); } } } private static void UpdateBlocker(bool shown, Rect bar) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a4: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) AppDomain currentDomain = AppDomain.CurrentDomain; int frameCount = Time.frameCount; if (currentDomain.GetData("OnTogetherMods.IconBar.BlockerFrame") is int num && num == frameCount) { return; } currentDomain.SetData("OnTogetherMods.IconBar.BlockerFrame", frameCount); object? data = currentDomain.GetData("OnTogetherMods.IconBar.Blocker"); GameObject val = (GameObject)((data is GameObject) ? data : null); if ((Object)(object)val == (Object)null) { if (!shown) { return; } val = CreateBlocker(); currentDomain.SetData("OnTogetherMods.IconBar.Blocker", val); } if (shown) { RectTransform val2 = (RectTransform)val.transform.GetChild(0); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(((Rect)(ref bar)).x, (float)Screen.height - ((Rect)(ref bar)).yMax); if (val2.anchoredPosition != val3) { val2.anchoredPosition = val3; } if (val2.sizeDelta != ((Rect)(ref bar)).size) { val2.sizeDelta = ((Rect)(ref bar)).size; } } if (val.activeSelf != shown) { val.SetActive(shown); } } private static GameObject CreateBlocker() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_007e: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OnTogetherMods IconBar ClickBlocker"); Object.DontDestroyOnLoad((Object)(object)val); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32767; val.AddComponent<GraphicRaycaster>(); GameObject val2 = new GameObject("Area", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val2.transform.SetParent(val.transform, false); ((Graphic)val2.GetComponent<Image>()).color = Color.clear; RectTransform val3 = (RectTransform)val2.transform; val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.zero; val3.pivot = Vector2.zero; val.SetActive(false); return val; } public static void Patch() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown AppDomain currentDomain = AppDomain.CurrentDomain; if (currentDomain.GetData("OnTogetherMods.IconBar.Patched") != null) { return; } currentDomain.SetData("OnTogetherMods.IconBar.Patched", true); try { Patches.Apply(new Harmony("nelphei.ontogether.iconbar")); } catch (Exception arg) { Debug.LogError((object)$"[OnTogetherMods] Icon bar patches failed, so clicks on it may reach the game: {arg}"); } } private static Texture2D[] IconTextures(string[] pixels) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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) if (Icons.TryGetValue(pixels, out var value) && (Object)(object)value[0] != (Object)null && (Object)(object)value[1] != (Object)null) { return value; } Color32[] array = (Color32[])(object)new Color32[256]; Color32[] array2 = (Color32[])(object)new Color32[256]; for (int i = 0; i < 16; i++) { string text = ((i < pixels.Length) ? pixels[i] : ""); for (int j = 0; j < 16; j++) { char key = ((j < text.Length) ? text[j] : '.'); Color32 value2; Color32 val = (Color32)(Palette.TryGetValue(key, out value2) ? value2 : new Color32((byte)0, (byte)0, (byte)0, (byte)0)); int num = (15 - i) * 16 + j; array[num] = val; byte b = (byte)Mathf.RoundToInt(0.3f * (float)(int)val.r + 0.59f * (float)(int)val.g + 0.11f * (float)(int)val.b); array2[num] = new Color32(b, b, b, (byte)((float)(int)val.a * 0.45f)); } } value = (Texture2D[])(object)new Texture2D[2] { NewTexture(16, 16, array, (FilterMode)0), NewTexture(16, 16, array2, (FilterMode)0) }; Icons[pixels] = value; return value; } private static void BuildStyles(Metrics m) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0105: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) if (_builtFor != Screen.height || _buttonStyle == null || !((Object)(object)_buttonTexture != (Object)null) || !((Object)(object)_dotTexture != (Object)null)) { _builtFor = Screen.height; int num = Mathf.Max(2, Mathf.RoundToInt(6f * m.Unit)); Destroy(_buttonTexture); Destroy(_hoverTexture); Destroy(_openTexture); Destroy(_dotTexture); _buttonTexture = RoundedBox(num, ButtonFill, ButtonEdge); _hoverTexture = RoundedBox(num, HoverFill, HoverEdge); _openTexture = RoundedBox(num, OpenFill, OpenEdge); int num2 = Mathf.Max(2, Mathf.RoundToInt(3f * m.Unit)); _dotTexture = RoundedBox(num2, DotFill, DotEdge, 2 * num2); int num3 = num + 1; _buttonStyle = new GUIStyle { border = new RectOffset(num3, num3, num3, num3) }; _tipStyle = new GUIStyle { border = new RectOffset(num3, num3, num3, num3), padding = new RectOffset(Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(6f * m.Unit), Mathf.RoundToInt(6f * m.Unit)), fontSize = Mathf.Max(8, Mathf.RoundToInt(15f * m.Unit)), alignment = (TextAnchor)3, wordWrap = false, richText = false }; _tipStyle.normal.background = _hoverTexture; _tipStyle.normal.textColor = Color.white; } } private static Texture2D RoundedBox(int radius, Color32 fill, Color32 edge, int size = 0) { //IL_008c: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (size <= 0) { size = 2 * radius + 4; } Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num = (float)j + 0.5f; float num2 = (float)i + 0.5f; float num3 = Mathf.Max(Mathf.Max((float)radius - num, num - (float)(size - radius)), 0f); float num4 = Mathf.Max(Mathf.Max((float)radius - num2, num2 - (float)(size - radius)), 0f); float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) - (float)radius; float num6 = Mathf.Clamp01(0.5f - num5); Color val = Color.Lerp(Color32.op_Implicit(fill), Color32.op_Implicit(edge), Mathf.Clamp01(num5 + 1.5f)); val.a *= num6; array[i * size + j] = Color32.op_Implicit(val); } } return NewTexture(size, size, array, (FilterMode)1); } private static Texture2D NewTexture(int width, int height, Color32[] pixels, FilterMode filter) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0017: 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) //IL_002f: Expected O, but got Unknown Texture2D val = new Texture2D(width, height, (TextureFormat)4, false) { filterMode = filter, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(pixels); val.Apply(false, true); return val; } private static void Destroy(Texture2D texture) { if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); } } } internal sealed class ColorPicker { private const int SquareSize = 64; private const int StripSize = 128; public float H; public float S; public float V = 1f; private Texture2D _square; private Texture2D _strip; private float _squareHue = -1f; private int _dragging; public Color Value => Color.HSVToRGB(H, S, V); public void Set(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) float h = default(float); float num = default(float); float num2 = default(float); Color.RGBToHSV(color, ref h, ref num, ref num2); if (num > 0.001f && num2 > 0.001f) { H = h; } S = num; V = num2; } public bool Draw(Rect square, Rect strip) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected I4, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) int controlID = GUIUtility.GetControlID((FocusType)2); Event current = Event.current; bool result = false; EventType typeForControl = current.GetTypeForControl(controlID); switch ((int)typeForControl) { default: if ((int)typeForControl == 7) { Paint(square, strip); } break; case 0: if (current.button != 0) { break; } if (((Rect)(ref square)).Contains(current.mousePosition)) { _dragging = 1; } else { if (!((Rect)(ref strip)).Contains(current.mousePosition)) { break; } _dragging = 2; } GUIUtility.hotControl = controlID; GUIUtility.keyboardControl = 0; result = Move(current.mousePosition, square, strip); current.Use(); break; case 3: if (GUIUtility.hotControl == controlID) { result = Move(current.mousePosition, square, strip); current.Use(); } break; case 1: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; _dragging = 0; current.Use(); } break; case 2: break; } return result; } public void Destroy() { if ((Object)(object)_square != (Object)null) { Object.Destroy((Object)(object)_square); } if ((Object)(object)_strip != (Object)null) { Object.Destroy((Object)(object)_strip); } } private bool Move(Vector2 mouse, Rect square, Rect strip) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (_dragging == 1) { S = Mathf.Clamp01((mouse.x - ((Rect)(ref square)).x) / ((Rect)(ref square)).width); V = 1f - Mathf.Clamp01((mouse.y - ((Rect)(ref square)).y) / ((Rect)(ref square)).height); return true; } if (_dragging == 2) { H = Mathf.Clamp01(1f - (mouse.y - ((Rect)(ref strip)).y) / ((Rect)(ref strip)).height); return true; } return false; } private void Paint(Rect square, Rect strip) { //IL_012a: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_strip == (Object)null) { _strip = NewTexture(1, 128); Color32[] array = (Color32[])(object)new Color32[128]; for (int i = 0; i < 128; i++) { array[i] = Color32.op_Implicit(Color.HSVToRGB((float)i / 127f, 1f, 1f)); } _strip.SetPixels32(array); _strip.Apply(); } if ((Object)(object)_square == (Object)null) { _square = NewTexture(64, 64); } if (!Mathf.Approximately(_squareHue, H)) { Color32[] array2 = (Color32[])(object)new Color32[4096]; for (int j = 0; j < 64; j++) { for (int k = 0; k < 64; k++) { array2[j * 64 + k] = Color32.op_Implicit(Color.HSVToRGB(H, (float)k / 63f, (float)j / 63f)); } } _square.SetPixels32(array2); _square.Apply(); _squareHue = H; } GUI.DrawTexture(square, (Texture)(object)_square); GUI.DrawTexture(strip, (Texture)(object)_strip); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Rect)(ref square)).x + S * ((Rect)(ref square)).width, ((Rect)(ref square)).y + (1f - V) * ((Rect)(ref square)).height); Outline(new Rect(val.x - 5f, val.y - 5f, 10f, 10f), Color.black); Outline(new Rect(val.x - 4f, val.y - 4f, 8f, 8f), Color.white); float num = ((Rect)(ref strip)).y + (1f - H) * ((Rect)(ref strip)).height; Outline(new Rect(((Rect)(ref strip)).x - 3f, num - 3f, ((Rect)(ref strip)).width + 6f, 6f), Color.black); Outline(new Rect(((Rect)(ref strip)).x - 2f, num - 2f, ((Rect)(ref strip)).width + 4f, 4f), Color.white); } public static void Outline(Rect rect, Color color) { //IL_0000: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) Color color2 = GUI.color; GUI.color = color; Texture2D whiteTexture = Texture2D.whiteTexture; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)whiteTexture); GUI.color = color2; } public static void Fill(Rect rect, Color color) { //IL_0000: 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_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = color2; } private static Texture2D NewTexture(int width, int height) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return new Texture2D(width, height, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; } } internal static class NameDesignerLink { private const string OpenKey = "OnTogetherMods.NameDesignerLink.Open"; private const string CardKey = "OnTogetherMods.NameDesignerLink.Card"; private const string DesignerKey = "OnTogetherMods.NameDesignerLink.Designer"; public static bool HasDesigner => AppDomain.CurrentDomain.GetData("OnTogetherMods.NameDesignerLink.Open") is Action; public static bool CardShowing { get { Rect bounds; return CardBounds(out bounds); } } public static void OpenDesigner() { if (AppDomain.CurrentDomain.GetData("OnTogetherMods.NameDesignerLink.Open") is Action action) { action(); } } public static void ShowCard(Rect bounds) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Share("OnTogetherMods.NameDesignerLink.Card", bounds); } public static bool DesignerBounds(out Rect bounds) { return Read("OnTogetherMods.NameDesignerLink.Designer", out bounds); } public static void SetDesigner(Action open) { AppDomain.CurrentDomain.SetData("OnTogetherMods.NameDesignerLink.Open", open); } public static bool CardBounds(out Rect bounds) { return Read("OnTogetherMods.NameDesignerLink.Card", out bounds); } public static void ShowDesigner(Rect bounds) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Share("OnTogetherMods.NameDesignerLink.Designer", bounds); } private static void Share(string key, Rect bounds) { AppDomain.CurrentDomain.SetData(key, new double[5] { Time.frameCount, ((Rect)(ref bounds)).x, ((Rect)(ref bounds)).y, ((Rect)(ref bounds)).width, ((Rect)(ref bounds)).height }); } private static bool Read(string key, out Rect bounds) { //IL_0001: 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) bounds = default(Rect); if (!(AppDomain.CurrentDomain.GetData(key) is double[] array) || array.Length != 5 || (double)Time.frameCount - array[0] > 2.0) { return false; } bounds = new Rect((float)array[1], (float)array[2], (float)array[3], (float)array[4]); return true; } } } namespace CardDesigner { internal sealed class CardCanvas { private sealed class Row { public TextMeshProUGUI Label; public Image Box; public TextMeshProUGUI Text; public string Shown; public float Y; public float Height; } private const float CardPad = 28f; private const float LabelHeight = 46f; private const float LabelSize = 30f; private const float RowGap = 12f; private const float BoxWidth = 1211.7f; private const float ShortHeight = 99.9f; private const float QuoteHeight = 245.2f; private const float InsetX = 43f; private const float ShortInsetY = 6.5f; private const float QuoteInsetY = 41.5f; private const float CardFontSize = 47.93f; public const int Rows = 6; public const int QuoteRow = 5; private const string Invisible = "\u200b"; private readonly string _name; private GameObject _root; private RectTransform _back; private GameObject _dim; private int _dimFrame = -100; private RectTransform _editorRect; private Image _editorBack; private RectTransform _preview; private Image _cardImage; private readonly Row[] _rows = new Row[6]; private RectTransform _popup; private readonly List<TextMeshProUGUI> _cells = new List<TextMeshProUGUI>(); private readonly List<int> _cellFrames = new List<int>(); private int _nextCell; private int _backFrame = -100; private int _popupFrame = -100; private int _previewFrame = -100; private Sprite _cardSprite; private static readonly Color WindowColour = Color32.op_Implicit(new Color32((byte)30, (byte)28, (byte)36, byte.MaxValue)); private float _previewScale = 1f; private Vector2 _previewOrigin; private float _cardHeight; private Color _textColour = Color.black; private Color _placeholderColour = Color.grey; public CardInputField Editor { get; private set; } public int QuoteLines { get; private set; } public bool QuoteCut => QuoteLines > 3; private static float CardWidth => 1267.7f; private static float CardHeight { get { float num = 28f; for (int i = 0; i < 6; i++) { num += 46f + ((i == 5) ? 245.2f : 99.9f) + 12f; } return num - 12f + 28f; } } public float PreviewHeight => _cardHeight * _previewScale; public CardCanvas(string name) { //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) //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) _name = name; } public static Vector2 PreviewSize(float width) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) float num = width / CardWidth; return new Vector2(width, CardHeight * num); } public void Back(Rect rect) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) Prepare(); _nextCell = 0; Place(_back, rect); _backFrame = Time.frameCount; } public void Dim() { _dimFrame = Time.frameCount; SetActive(_dim, on: true); } public void PlaceEditor(Rect rect, TMP_FontAsset font, float fontSize, Color text, Color back) { //IL_0006: 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_009f: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) Place(_editorRect, rect); CardInputField editor = Editor; if ((Object)(object)font != (Object)null && (Object)(object)((TMP_InputField)editor).fontAsset != (Object)(object)font) { ((TMP_InputField)editor).fontAsset = font; } if (!Mathf.Approximately(((TMP_InputField)editor).pointSize, fontSize)) { ((TMP_InputField)editor).pointSize = fontSize; } if (((Graphic)((TMP_InputField)editor).textComponent).color != text) { ((Graphic)((TMP_InputField)editor).textComponent).color = text; ((TMP_InputField)editor).caretColor = text; ((TMP_InputField)editor).placeholder.color = new Color(text.r, text.g, text.b, 0.45f); } ((Graphic)_editorBack).color = back; } public void PlacePreview(Rect rect, TMP_FontAsset font, Color card, Color box, Color text, Color placeholder) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) _previewScale = ((Rect)(ref rect)).width / CardWidth; _previewOrigin = ((Rect)(ref rect)).position; _cardHeight = CardHeight; _preview.anchoredPosition = new Vector2(((Rect)(ref rect)).x, 0f - ((Rect)(ref rect)).y); ((Transform)_preview).localScale = new Vector3(_previewScale, _previewScale, 1f); _previewFrame = Time.frameCount; SetActive(((Component)_preview).gameObject, on: true); _textColour = text; _placeholderColour = placeholder; ((Graphic)_cardImage).color = card; Sprite val = Game.BoxSprite(); if ((Object)(object)val != (Object)(object)_cardSprite) { _cardSprite = val; Row[] rows = _rows; foreach (Row obj in rows) { obj.Box.sprite = val; obj.Box.type = (Type)(((Object)(object)val != (Object)null) ? 1 : 0); } _cardImage.sprite = val; _cardImage.type = (Type)(((Object)(object)val != (Object)null) ? 1 : 0); } Color color = ((0.299f * card.r + 0.587f * card.g + 0.114f * card.b > 0.6f) ? new Color(0.15f, 0.12f, 0.16f, 0.85f) : new Color(1f, 1f, 1f, 0.9f)); for (int j = 0; j < 6; j++) { Row row = _rows[j]; ((Graphic)row.Box).color = box; ((Graphic)row.Label).color = color; if ((Object)(object)font != (Object)null && (Object)(object)((TMP_Text)row.Text).font != (Object)(object)font) { ((TMP_Text)row.Text).font = font; ((TMP_Text)row.Label).font = font; row.Shown = null; } } } public void PreviewLine(int r, string text, string label) { //IL_003b: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Row row = _rows[r]; if (((TMP_Text)row.Label).text != label) { ((TMP_Text)row.Label).text = label; } bool flag = string.IsNullOrEmpty(text); Color val = (flag ? _placeholderColour : _textColour); if (((Graphic)row.Text).color != val) { ((Graphic)row.Text).color = val; } string text2 = (flag ? label : (text + "\u200b")); if (!(row.Shown == text2)) { row.Shown = text2; ((TMP_Text)row.Text).text = text2; if (r == 5) { CutQuote(row, flag ? "" : text); } } } private void CutQuote(Row row, string text) { QuoteLines = 0; if (text.Length == 0) { return; } ((TMP_Text)row.Text).ForceMeshUpdate(false, false); TMP_TextInfo textInfo = ((TMP_Text)row.Text).textInfo; QuoteLines = textInfo.lineCount; if (textInfo.lineCount > 3) { int lastCharacterIndex = textInfo.lineInfo[2].lastCharacterIndex; int num = textInfo.characterInfo[lastCharacterIndex].index + textInfo.characterInfo[lastCharacterIndex].stringLength; if (num >= 0 && num < text.Length) { ((TMP_Text)row.Text).text = text.Remove(num) + "\u200b"; } } } public Rect PreviewBox(int r) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) Row row = _rows[r]; return new Rect(_previewOrigin.x + 28f * _previewScale, _previewOrigin.y + row.Y * _previewScale, 1211.7f * _previewScale, row.Height * _previewScale); } public Rect PreviewLabel(int r) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) Row row = _rows[r]; return new Rect(_previewOrigin.x + 28f * _previewScale, _previewOrigin.y + (row.Y - 46f) * _previewScale, 1211.7f * _previewScale, 46f * _previewScale); } public void Popup(Rect rect) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Place(_popup, rect); _popupFrame = Time.frameCount; } public void Cell(Rect rect, string text, TMP_FontAsset font, float size) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (_nextCell >= _cells.Count) { _cells.Add(NewText("Cell", _root.transform, size, (TextAlignmentOptions)514)); _cellFrames.Add(-100); } TextMeshProUGUI val = _cells[_nextCell]; _cellFrames[_nextCell] = Time.frameCount; _nextCell++; if ((Object)(object)font != (Object)null && (Object)(object)((TMP_Text)val).font != (Object)(object)font) { ((TMP_Text)val).font = font; } if (((TMP_Text)val).text != text) { ((TMP_Text)val).text = text; } ((TMP_Text)val).fontSize = size; Place(((TMP_Text)val).rectTransform, rect); } public void LateUpdate() { if ((Object)(object)_root == (Object)null) { return; } int frameCount = Time.frameCount; bool flag = frameCount - _backFrame <= 1 && !PanelStack.Hidden; if (_root.activeSelf != flag) { _root.SetActive(flag); } if (flag) { SetActive(_dim, frameCount - _dimFrame <= 1); SetActive(((Component)_popup).gameObject, frameCount - _popupFrame <= 1); SetActive(((Component)_preview).gameObject, frameCount - _previewFrame <= 1); for (int i = 0; i < _cells.Count; i++) { SetActive(((Component)_cells[i]).gameObject, frameCount - _cellFrames[i] <= 1); } } } public void Destroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } private static void SetActive(GameObject go, bool on) { if (go.activeSelf != on) { go.SetActive(on); } } private static void Place(RectTransform t, Rect rect) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0033: 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) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Rect)(ref rect)).x, 0f - ((Rect)(ref rect)).y); if (t.anchoredPosition != val) { t.anchoredPosition = val; } if (t.sizeDelta != ((Rect)(ref rect)).size) { t.sizeDelta = ((Rect)(ref rect)).size; } } private void Prepare() { if ((Object)(object)_root == (Object)null) { Build(); } if (!_root.activeSelf && !PanelStack.Hidden) { _root.SetActive(true); } } private void Build() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0154: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("OnTogetherMods " + _name); _root.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_root); Canvas obj = _root.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32766; CanvasScaler obj2 = _root.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.screenMatchMode = (ScreenMatchMode)0; obj2.matchWidthOrHeight = 1f; _root.AddComponent<GraphicRaycaster>(); Image val = NewImage("Dim", _root.transform, new Color(0f, 0f, 0f, 0.55f), raycast: false); Stretch(((Graphic)val).rectTransform); _dim = ((Component)val).gameObject; _dim.SetActive(false); Image val2 = NewImage("Box", _root.transform, WindowColour, raycast: true); val2.sprite = RoundedSprite(); val2.type = (Type)1; _back = TopLeft(((Component)val2).gameObject); BuildEditor(); BuildPreview(); Image val3 = NewImage("Popup", _root.transform, new Color(0.08f, 0.07f, 0.1f, 0.96f), raycast: true); _popup = TopLeft(((Component)val3).gameObject); ((Component)val3).gameObject.SetActive(false); } private void BuildEditor() { //IL_0011: 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_0064: Expected O, but got Unknown //IL_007c: 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_008e: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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) _editorBack = NewImage("Editor", _root.transform, Color.white, raycast: true); GameObject gameObject = ((Component)_editorBack).gameObject; _editorRect = TopLeft(gameObject); GameObject val = new GameObject("Text Area", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val.transform.SetParent(gameObject.transform, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = new Vector2(12f, 10f); val2.offsetMax = new Vector2(-12f, -10f); TextMeshProUGUI val3 = NewText("Placeholder", val.transform, 24f, (TextAlignmentOptions)257); Stretch(((TMP_Text)val3).rectTransform); ((TMP_Text)val3).fontStyle = (FontStyles)2; ((TMP_Text)val3).text = "Type here..."; TextMeshProUGUI val4 = NewText("Text", val.transform, 24f, (TextAlignmentOptions)257); Stretch(((TMP_Text)val4).rectTransform); CardInputField cardInputField = gameObject.AddComponent<CardInputField>(); ((TMP_InputField)cardInputField).textViewport = val2; ((TMP_InputField)cardInputField).textComponent = (TMP_Text)(object)val4; ((TMP_InputField)cardInputField).placeholder = (Graphic)(object)val3; ((Selectable)cardInputField).transition = (Transition)0; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)cardInputField).navigation = navigation; ((TMP_InputField)cardInputField).lineType = (LineType)2; ((TMP_InputField)cardInputField).richText = true; ((TMP_InputField)cardInputField).isRichTextEditingAllowed = false; ((TMP_InputField)cardInputField).restoreOriginalTextOnEscape = false; ((TMP_InputField)cardInputField).resetOnDeActivation = false; ((TMP_InputField)cardInputField).onFocusSelectAll = false; ((TMP_InputField)cardInputField).keepTextSelectionVisible = true; ((TMP_InputField)cardInputField).customCaretColor = true; ((TMP_InputField)cardInputField).caretWidth = 2; ((TMP_InputField)cardInputField).selectionColor = new Color(0.35f, 0.55f, 1f, 0.45f); ((TMP_InputField)cardInputField).scrollSensitivity = 2f; ((TMP_InputField)cardInputField).characterLimit = 0; Editor = cardInputField; } private void BuildPreview() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_01a8: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Preview", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(_root.transform, false); _preview = TopLeft(val); _preview.sizeDelta = new Vector2(CardWidth, CardHeight); _cardImage = NewImage("Card", val.transform, Color.white, raycast: false); TopLeft(((Component)_cardImage).gameObject).sizeDelta = new Vector2(CardWidth, CardHeight); float num = 28f; for (int i = 0; i < 6; i++) { bool flag = i == 5; Row row = new Row { Height = (flag ? 245.2f : 99.9f) }; row.Label = NewText("Label", val.transform, 30f, (TextAlignmentOptions)1025); ((TMP_Text)row.Label).overflowMode = (TextOverflowModes)1; Place(TopLeft(((Component)row.Label).gameObject), new Rect(38f, num, 1191.7f, 40f)); num = (row.Y = num + 46f); row.Box = NewImage("Box", val.transform, Color.white, raycast: false); Place(TopLeft(((Component)row.Box).gameObject), new Rect(28f, num, 1211.7f, row.Height)); GameObject val2 = new GameObject("Text Area", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val2.transform.SetParent(((Component)row.Box).transform, false); RectTransform val3 = (RectTransform)val2.transform; val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; float num2 = (flag ? 41.5f : 6.5f); val3.offsetMin = new Vector2(43f, num2); val3.offsetMax = new Vector2(-43f, 0f - num2); row.Text = NewText("Text", val2.transform, 47.93f, (TextAlignmentOptions)(flag ? 257 : 513)); Stretch(((TMP_Text)row.Text).rectTransform); ((TMP_Text)row.Text).textWrappingMode = (TextWrappingModes)(flag ? 1 : 3); ((TMP_Text)row.Text).overflowMode = (TextOverflowModes)(!flag); _rows[i] = row; num += row.Height + 12f; } } private static Image NewImage(string name, Transform parent, Color colour, bool raycast) { //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_0046: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val.transform.SetParent(parent, false); Image component = val.GetComponent<Image>(); ((Graphic)component).color = colour; ((Graphic)component).raycastTarget = raycast; return component; } private static TextMeshProUGUI NewText(string name, Transform parent, float size, TextAlignmentOptions alignment) { //IL_0021: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(CanvasRenderer) }); val.transform.SetParent(parent, false); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).richText = true; ((TMP_Text)obj).fontSize = size; ((TMP_Text)obj).alignment = alignment; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).margin = Vector4.zero; return obj; } private static RectTransform TopLeft(GameObject go) { //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) //IL_000c: 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_001f: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown RectTransform val = (RectTransform)go.transform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; return val; } private static void Stretch(RectTransform t) { //IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) t.anchorMin = Vector2.zero; t.anchorMax = Vector2.one; t.offsetMin = Vector2.zero; t.offsetMax = Vector2.zero; } private static Sprite RoundedSprite() { //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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_006a: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[1024]; Vector2 val2 = default(Vector2); Vector2 val3 = default(Vector2); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { ((Vector2)(ref val2))..ctor((float)j + 0.5f, (float)i + 0.5f); ((Vector2)(ref val3))..ctor(Mathf.Clamp(val2.x, 8f, 24f), Mathf.Clamp(val2.y, 8f, 24f)); float num = Mathf.Clamp01(8f - Vector2.Distance(val2, val3) + 0.5f); array[i * 32 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(num * 255f)); } } val.SetPixels32(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(8f, 8f, 8f, 8f)); } } internal sealed class CardInputField : TMP_InputField { private bool _pasting; public static bool CtrlHeld { get { bool num = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305) || Input.GetKey((KeyCode)310) || Input.GetKey((KeyCode)309); bool flag = Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307) || Input.GetKey((KeyCode)313); if (num) { return !flag; } return false; } } protected override void Append(string input) { _pasting = true; try { ((TMP_InputField)this).Append(input); } finally { _pasting = false; } } protected override void Append(char input) { if (input != '\t' && (_pasting || !CtrlHeld)) { ((TMP_InputField)this).Append(input); } } } internal sealed class CardWindow : MonoBehaviour { private enum Popup { None, Colour, Highlight, Size, Emoji } private const string PanelId = "CardDesigner"; private const string HexFieldName = "CardDesigner.Hex"; private const float Pad = 12f; private const float LeftWidth = 640f; private const float Gutter = 16f; private const float RightWidth = 440f; private const float Width = 1120f; private const float HeaderHeight = 28f; private const float ToolHeight = 30f; private const float EditorHeight = 280f; private const float InfoHeight = 22f; private const float LabelHeight = 20f; private const float RowHeight = 30f; private const float SaveHeight = 22f; private const float Gap = 6f; private const float PresetsHeight = 75f; private const float Height = 525f; private const float PairGap = 20f; private const float StatusSeconds = 5f; private const float ConfirmSeconds = 3f; private const float EditorPadding = 12f; private const float EditorFontSize = 26.22802f; private static readonly string[] Swatches = new string[16] { "#FF5C5C", "#FF9F43", "#FFD93D", "#6BCB77", "#4D96FF", "#9B5DE5", "#F15BB5", "#00BBF9", "#FFADAD", "#FFD6A5", "#FDFFB6", "#CAFFBF", "#A0C4FF", "#BDB2FF", "#FFFFFF", "#303030" }; private static readonly string[] Highlights = new string[8] { "#FFE06699", "#9CF09C99", "#7FC8FF99", "#FF9ECF99", "#FFB36699", "#C9A7FF99", "#FFFFFFAA", "#00000066" }; private static readonly string[] Sizes = new string[9] { "40%", "50%", "60%", "70%", "80%", "90%", null, "120%", "150%" }; private static CardWindow _instance; private readonly CardCanvas _canvas = new CardCanvas("CardDesigner"); private readonly ColorPicker _picker = new ColorPicker(); private readonly PresetStore _presets = new PresetStore(); private readonly Emoji _emoji = new Emoji(); private readonly string[] _lines = new string[5] { "", "", "", "", "" }; private readonly string[] _loaded = new string[5] { "", "", "", "", "" }; private readonly History[] _history = new History[5]; private int _field = 4; private bool _loadedOnce; private bool _open; private bool _openedFromCard; private bool _iconClicked; private bool _cardButtonClicked; private int _scene = -1; private bool _hooked; private bool _loadEditor; private bool _codeView; private Popup _popup; private bool _symbolsTab; private string _hexText = "#FFFFFF"; private int _editorFrame = -100; private bool _hexTyping; private bool _clearFocus; private bool _refocus; private bool _pressFocused; private History.Step _known; private bool _isBold; private bool _isItalic; private bool _isUnderline; private bool _isStrike; private string _align; private string _size; private string _readText; private int _readAnchor = -1; private int _readFocus = -1; private bool _readCode; private int _confirmSlot = -1; private float _confirmUntil; private float _confirmResetUntil; private string _status; private float _statusUntil; private bool _loggedButton; private Rect _screenRect; private int _drawnFrame = -100; private GUIStyle _titleStyle; private GUIStyle _dimStyle; private GUIStyle _keyStyle; private GUIStyle _labelStyle; private GUIStyle _hintStyle; private GUIStyle _statusStyle; private GUIStyle _warnStyle; private GUIStyle _buttonStyle; private GUIStyle _toolStyle; private GUIStyle _presetStyle; private GUIStyle _fieldStyle; private GUIStyle _cardButtonStyle; internal static bool IsTyping { get { if ((Object)(object)_instance != (Object)null && _instance._open) { if (!_instance.EditorTyping) { return _instance._hexTyping; } return true; } return false; } } internal static bool HoldsKeys { get { if (IsTyping) { return !PanelStack.Hidden; } return false; } } internal static bool IsMouseOver { get; private set; } private static Settings S => Plugin.Settings; private bool EditorTyping => Time.frameCount - _editorFrame <= 1; private CardInputField Editor => _canvas.Editor; private bool Dirty { get { for (int i = 0; i < 5; i++) { if (_lines[i] != _loaded[i]) { return true; } } return false; } } private void Awake() { _instance = this; for (int i = 0; i < 5; i++) { _history[i] = new History(); } _presets.Load(); } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; IsMouseOver = false; } _canvas.Destroy(); _picker.Destroy(); } private void Update() { //IL_0000: 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_007e: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); int buildIndex = ((Scene)(ref activeScene)).buildIndex; if (buildIndex != _scene) { if (_open) { Close(); } _scene = buildIndex; } bool cardPageShowing = Game.CardPageShowing; if (!cardPageShowing) { _loggedButton = false; } if (_open && _openedFromCard && !cardPageShowing) { Close(); } bool cardButtonClicked = _cardButtonClicked; bool flag = _iconClicked || cardButtonClicked; _iconClicked = false; _cardButtonClicked = false; KeyCode value = S.WindowKey.Value; if (((int)value != 0 && Input.GetKeyDown(value) && !HoldsKeys && !IsChatOpen()) || flag) { if (_open) { Close(); } else { Open(cardButtonClicked); } } CardInputField editor = Editor; if (_open && _hooked && (Object)(object)editor != (Object)null) { if (((TMP_InputField)editor).isFocused) { _editorFrame = Time.frameCount; if (_hexTyping) { _clearFocus = true; } Shortcuts(); } _known = Snapshot(); ReadSelection(); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } UpdateMouseOver(); } private void LateUpdate() { _canvas.LateUpdate(); CardInputField editor = Editor; if (_refocus && (Object)(object)editor != (Object)null && ((Component)editor).gameObject.activeInHierarchy) { _refocus = false; if (!_hexTyping && !((TMP_InputField)editor).isFocused) { ((TMP_InputField)editor).ActivateInputField(); } } } private void UpdateMouseOver() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) bool num = _open && Time.frameCount - _drawnFrame <= 2 && !PanelStack.Hidden; Vector3 mousePosition = Input.mousePosition; IsMouseOver = num && ((Rect)(ref _screenRect)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y)); } private static bool IsChatOpen() { TaskManager i = MonoSingleton<TaskManager>.I; if ((Object)(object)i != (Object)null) { return i.IsWriting; } return false; } private void Shortcuts() { if (!CardInputField.CtrlHeld) { return; } bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Input.GetKeyDown((KeyCode)122)) { if (flag) { Redo(); } else { Undo(); } } else if (Input.GetKeyDown((KeyCode)121)) { Redo(); } else if (!_codeView && Input.GetKeyDown((KeyCode)98)) { ToggleFlag(Flag.Bold); } else if (!_codeView && Input.GetKeyDown((KeyCode)105)) { ToggleFlag(Flag.Italic); } else if (!_codeView && Input.GetKeyDown((KeyCode)117)) { ToggleFlag(Flag.Underline); } } private void Open(bool fromCard) { _open = true; _openedFromCard = fromCard; _status = null; _popup = Popup.None; _confirmSlot = -1; if (!_loadedOnce || !Dirty) { LoadCard(); } _loadEditor = true; } private void Close() { _open = false; _openedFromCard = false; _popup = Popup.None; _hexTyping = false; _clearFocus = true; _refocus = false; _confirmSlot = -1; CardInputField editor = Editor; EventSystem current = EventSystem.current; if ((Object)(object)editor != (Object)null && (Object)(object)current != (Object)null && (Object)(object)current.currentSelectedGameObject == (Object)(object)((Component)editor).gameObject) { current.SetSelectedGameObject((GameObject)null); } } private bool LoadCard() { string[] array = Game.ReadCard(); if (array == null) { return false; } for (int i = 0; i < 5; i++) { _lines[i] = array[i]; _loaded[i] = array[i]; } _loadedOnce = true; _loadEditor = true; return true; } private void ApplyCard() { for (int i = 0; i < 5; i++) { if (_lines[i].Length > 1000) { Status(Game.Label(i + 1) + " is too long. Shorten it first."); return; } } try { string[] obj = (string[])_lines.Clone(); bool flag = Game.ApplyCard(obj); Array.Copy(obj, _loaded, 5); Status(flag ? "Card applied. Everyone sees it now." : "Card saved. Everyone sees it when you join a world."); } catch (Exception ex) { Plugin.Log.LogError((object)ex); Status("Couldn't apply the card. See the BepInEx log."); } } private void ResetCard() { if (Time.unscaledTime >= _confirmResetUntil) { _confirmResetUntil = Time.unscaledTime + 3f; return; } _confirmResetUntil = 0f; string[] array = (string[])_lines.Clone(); if (!LoadCard()) { Status("Couldn't read your card."); return; } for (int i = 0; i < 5; i++) { if (array[i] != _lines[i]) { _history[i].Changed(new History.Step { Text = array[i] }); } } Status("Back to your card as it is now"); } private void SelectField(int field) { if (field != _field) { _field = field; _loadEditor = true; } _refocus = true; } private void LoadEditorNow() { CardInputField editor = Editor; string text = _lines[_field]; ((TMP_InputField)editor).SetTextWithoutNotify(text); ((TMP_InputField)editor).stringPosition = text.Length; _known = Snapshot(); } private void Hook() { _hooked = true; ((UnityEvent<string>)(object)((TMP_InputField)Editor).onValueChanged).AddListener((UnityAction<string>)OnTyped); } private void OnTyped(string text) { _history[_field].Typed(_known, Time.unscaledTime); _lines[_field] = text; _known = Snapshot(); } private History.Step Snapshot() { CardInputField editor = Editor; return new History.Step { Text = ((TMP_InputField)editor).text, Anchor = ((TMP_InputField)editor).selectionAnchorPosition, Focus = ((TMP_InputField)editor).selectionFocusPosition }; } private void SetEditorText(string text, int anchor, int focus) { CardInputField editor = Editor; ((TMP_InputField)editor).SetTextWithoutNotify(text); _lines[_field] = text; int num = Mathf.Max(0, ((TMP_InputField)editor).textComponent.textInfo.characterCount - 1); ((TMP_InputField)editor).selectionAnchorPosition = Mathf.Clamp(anchor, 0, num); ((TMP_InputField)editor).selectionFocusPosition = Mathf.Clamp(focus, 0, num); _known = Snapshot(); Refocus(); } private void Refocus() { if (_pressFocused || EditorTyping) { _refocus = true; } } private bool Selection(bool fresh, out int low, out int high, out int start, out int end) { low = (high = (start = (end = 0))); CardInputField editor = Editor; if ((Object)(object)editor == (Object)null) { return false; } string text = ((TMP_InputField)editor).text; TMP_Text textComponent = ((TMP_InputField)editor).textComponent; if (fresh && ((Component)textComponent).gameObject.activeInHierarchy) { textComponent.ForceMeshUpdate(false, false); } TMP_TextInfo textInfo = textComponent.textInfo; int characterCount = textInfo.characterCount; if (characterCount == 0) { return true; } int num = Mathf.Clamp(((TMP_InputField)editor).selectionAnchorPosition, 0, characterCount - 1); int num2 = Mathf.Clamp(((TMP_InputField)editor).selectionFocusPosition, 0, characterCount - 1); low = Mathf.Min(num, num2); high = Mathf.Max(num, num2); start = Mathf.Min(textInfo.characterInfo[low].index, text.Length); end = ((high > low) ? Mathf.Min(textInfo.characterInfo[high - 1].index + textInfo.characterInfo[high - 1].stringLength, text.Length) : start); return true; } private void ReadSelection() { CardInputField editor = Editor; if (!(((TMP_InputField)editor).text == _readText) || ((TMP_InputField)editor).selectionAnchorPosition != _readAnchor || ((TMP_InputField)editor).selectionFocusPosition != _readFocus || _codeView != _readCode) { _readText = ((TMP_InputField)editor).text; _readAnchor = ((TMP_InputField)editor).selectionAnchorPosition; _readFocus = ((TMP_InputField)editor).selectionFocusPosition; _readCode = _codeView; if (!_codeView && Selection(fresh: false, out var low, out var high, out var start, out var end)) { RichText richText = RichText.Parse(((TMP_InputField)editor).text); Range(richText, low, high, start, end, out var from, out var to); _isBold = richText.AllHave(from, to, Flag.Bold); _isItalic = richText.AllHave(from, to, Flag.Italic); _isUnderline = richText.AllHave(from, to, Flag.Underline); _isStrike = richText.AllHave(from, to, Flag.Strike); _size = richText.CommonSize(from, to); _align = richText.Align; } } } private static void Range(RichText doc, int low, int high, int start, int end, out int from, out int to) { if (high > low) { doc.PiecesBetween(start, end, out from, out to); return; } from = 0; to = doc.Count; } private void Restyle(Func<RichText, int, int, bool> change, bool newStep = true) { if ((Object)(object)Editor == (Object)null || _codeView || !Selection(fresh: true, out var low, out var high, out var start, out var end)) { return; } string text = ((TMP_InputField)Editor).text; RichText richText = RichText.Parse(text); Range(richText, low, high, start, end, out var from, out var to); if (from >= to) { Status("There's nothing to style in this line yet."); } else { if (!change(richText, from, to)) { return; } string text2 = richText.Write(); if (text2 == text) { Refocus(); return; } if (newStep) { _history[_field].Changed(Snapshot()); } int selectionAnchorPosition = ((TMP_InputField)Editor).selectionAnchorPosition; int selectionFocusPosition = ((TMP_InputField)Editor).selectionFocusPosition; SetEditorText(text2, selectionAnchorPosition, selectionFocusPosition); } } private void ToggleFlag(Flag flag) { Restyle(delegate(RichText doc, int from, int to) { doc.SetFlag(from, to, flag, !doc.AllHave(from, to, flag)); return true; }); } private void SetColour(string hex, bool newStep) { Restyle(delegate(RichText doc, int from, int to) { doc.SetColour(from, to, hex); return true; }, newStep); } private void Gradient() { Restyle(delegate(RichText doc, int from, int to) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) List<int> list = Letters(doc, from, to); if (list.Count < 2) { Status("A gradient needs at least 2 letters."); return false; } string color = doc.Pieces[list[0]].Style.Color; string color2 = doc.Pieces[list[list.Count - 1]].Style.Color; if (color == null || color2 == null || color == color2) { Status("Give the first and last letters different colours, then click Gradient."); return false; } Color val = RichText.ToColour(color); Color val2 = RichText.ToColour(color2); for (int i = 0; i < list.Count; i++) { doc.Pieces[list[i]].Style.Color = RichText.ToHex(Color.Lerp(val, val2, (float)i / ((float)list.Count - 1f))); } FillBlanks(doc, from, to); return true; }); } private void Rainbow() { Restyle(delegate(RichText doc, int from, int to) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) List<int> list = Letters(doc, from, to); if (list.Count == 0) { return false; } float num = ((_picker.S < 0.25f) ? 0.75f : _picker.S); float num2 = ((_picker.V < 0.35f) ? 1f : _picker.V); for (int i = 0; i < list.Count; i++) { float num3 = ((list.Count == 1) ? 0f : (0.8f * (float)i / ((float)list.Count - 1f))); doc.Pieces[list[i]].Style.Color = RichText.ToHex(Color.HSVToRGB(num3, num, num2)); } FillBlanks(doc, from, to); return true; }); } private static List<int> Letters(RichText doc, int from, int to) { List<int> list = new List<int>(); for (int i = from; i < to; i++) { if (!doc.Pieces[i].IsBlank && doc.Pieces[i].Kind != PieceKind.Sprite) { list.Add(i); } } return list; } private static void FillBlanks(RichText doc, int from, int to) { string text = null; for (int i = from; i < to; i++) { Piece piece = doc.Pieces[i]; if (piece.IsBlank || piece.Kind == PieceKind.Sprite) { if (text != null) { piece.Style.Color = text; } } else { text = piece.Style.Color; } } } private void SetAlign(string align) { Restyle(delegate(RichText doc, int from, int to) { doc.SetAlign(align); return true; }); } private void Insert(string text) { if (!((Object)(object)Editor == (Object)null) && Selection(fresh: true, out var low, out var _, out var start, out var end)) { string text2 = ((TMP_InputField)Editor).text.Remove(start, end - start).Insert(start, text); _history[_field].Changed(Snapshot()); int num = (_codeView ? (low + text.Length) : (low + 1)); SetEditorText(text2, num, num); } } private void Undo() { if (_history[_field].Undo(Snapshot(), out var back)) { SetEditorText(back.Text, back.Anchor, back.Focus); _refocus = true; } } private void Redo() { if (_history[_field].Redo(Snapshot(), out var forward)) { SetEditorText(forward.Text, forward.Anchor, forward.Focus); _refocus = true; } } private void ToggleCodeView() { _codeView = !_codeView; _popup = ((!_codeView || _popup == Popup.Emoji) ? _popup : Popup.None); CardInputField editor = Editor; if ((Object)(object)editor != (Object)null) { ((TMP_InputField)editor).richText = !_codeView; ((TMP_InputField)editor).textComponent.ForceMeshUpdate(false, false); ((TMP_InputField)editor).stringPosition = ((TMP_InputField)editor).text.Length; } Refocus(); } private void LoadPreset(int slot) { string[] array = _presets.Cards[slot]; if (array == null) { return; } for (int i = 0; i < 5; i++) { if (_lines[i] != array[i]) { _history[i].Changed(new History.Step { Text = _lines[i] }); _lines[i] = array[i]; } } _loadEditor = true; Status($"Loaded preset {slot + 1}. Click Apply card to use it."); } private void SavePreset(int slot) { if (_presets.Cards[slot] != null && (_confirmSlot != slot || !(Time.unscaledTime < _confirmUntil))) { _confirmSlot = slot; _confirmUntil = Time.unscaledTime + 3f; } else { _confirmSlot = -1; _presets.Cards[slot] = (string[])_lines.Clone(); Status(_presets.Save() ? $"Saved to preset {slot + 1}" : "Couldn't save the presets file. See the BepInEx log."); } } private static string PresetLabel(string[] card) { int[] array = new int[5] { 4, 2, 3, 1, 0 }; foreach (int num in array) { string text = RichText.Parse(card[num]).Plain().Trim(); if (text.Length > 0) { if (text.Length <= 14) { return text; } return text.Substring(0, 13) + "..."; } } return "(blank)"; } private void Status(string text) { _status = text; _statusUntil = Time.unscaledTime + 5f; } private void OnGUI() { //IL_00c3: 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_007a: Unknown result type (might be due to invalid IL or missing references