Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LudsPinManager v1.2.1
LudsPinManager.dll
Decompiled a day 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LudsPinManager { internal static class LudsTheme { public const float DefaultScale = 0.576f; public const float DefaultOpacity = 0.96f; public const float PanelMaxBrightness = 0.4f; public static readonly string[] PresetNames = new string[7] { "Gold", "Ember", "Emerald", "Frost", "Crimson", "Amethyst", "Monotone" }; private static readonly string[] PresetAccent = new string[7] { "FFB83B", "FF7A2E", "4FD18B", "6EC6FF", "FF5A5A", "B58CFF", "E6E6E6" }; private static readonly string[] PresetPanel = new string[7] { "050403", "0A0403", "030805", "03060A", "0A0304", "06030A", "0B0B0B" }; public static string AccentHex = PresetAccent[0]; public static string PanelHex = PresetPanel[0]; public static float Opacity = 0.96f; public static float Scale = 0.576f; public static int Align = 1; public static int AlignY = 1; private static Color accent = Color.white; private static Color panelBase = Color.black; private static string modName = ""; private static Func<bool> useShared = () => true; private static string loadedPath = ""; private static DateTime loadedStamp; private static float nextCheck; private static float nextApply; private static bool unsaved; private static bool rebuildOnCommit; private static bool hold; private static float heldScale; private static bool pending; public static bool Hold { get { return hold; } set { if (value && !hold) { heldScale = Scale; } hold = value; } } public static float LayoutScale => Scale; public static Vector2 LayoutAnchor => new Vector2((float)Align * 0.5f, 1f - (float)AlignY * 0.5f); public static Vector2 LayoutPosition => new Vector2((float)(1 - Align) * 40f, (float)(AlignY - 1) * 40f); public static int Version { get; private set; } public static Color Accent => accent; public static Color Panel => Rgb(panelBase, Opacity); public static Color Field => Rgb(panelBase * 5.7f, Mathf.Max(0.99f * Opacity, 0.85f)); public static Color ButtonFill => Rgb(panelBase * 1.5f, Mathf.Max(0.92f * Opacity, 0.65f)); public static Color ButtonHover => Rgb(accent * 0.3f, 0.94f); public static Color Border => Rgb(accent * 0.85f, 0.8f); public static Color Divider => Rgb(accent * 0.85f, 0.85f); public static Color Row => new Color(0f, 0f, 0f, 0.5f * Opacity); public static Color ListBg => new Color(0f, 0f, 0f, Mathf.Max(0.4f * Opacity, ScrimAlpha)); public static Color PanelSolid => Rgb(panelBase, 1f); public static float ScrimAlpha => 0.55f * (1f - Mathf.Clamp01(Opacity / 0.6f)); public static Color Scrim => new Color(0f, 0f, 0f, ScrimAlpha); private static string CurrentPath => Path.Combine(Paths.ConfigPath, useShared() ? "luds.theme.ini" : ("luds." + modName + ".theme.ini")); private static Color Rgb(Color c, float a) { //IL_0000: 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_0016: 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) return new Color(Mathf.Clamp01(c.r), Mathf.Clamp01(c.g), Mathf.Clamp01(c.b), Mathf.Clamp01(a)); } public static void Init(string mod, Func<bool> shared) { modName = mod; useShared = shared; Load(); } public static bool Tick() { if (pending && !hold && Time.unscaledTime >= nextApply) { pending = false; nextApply = Time.unscaledTime + 0.08f; return true; } if (Time.unscaledTime < nextCheck) { return false; } nextCheck = Time.unscaledTime + 0.25f; string currentPath = CurrentPath; DateTime dateTime = (File.Exists(currentPath) ? File.GetLastWriteTimeUtc(currentPath) : DateTime.MinValue); if (currentPath != loadedPath || dateTime != loadedStamp) { Load(); if (hold) { pending = true; return false; } return true; } return false; } public static void Mutate(Action change, bool save = true, bool rebuild = true) { change(); Clamp(); if (save) { Save(); } else { unsaved = true; } if (rebuild) { pending = true; } else { rebuildOnCommit = true; } } public static void SaveNow() { if (unsaved) { Save(); } if (rebuildOnCommit) { rebuildOnCommit = false; pending = true; } } public static void ApplyPreset(int index) { index = (index % PresetNames.Length + PresetNames.Length) % PresetNames.Length; Mutate(delegate { AccentHex = PresetAccent[index]; PanelHex = PresetPanel[index]; }); } public static int PresetIndex() { for (int i = 0; i < PresetNames.Length; i++) { if (string.Equals(AccentHex, PresetAccent[i], StringComparison.OrdinalIgnoreCase) && string.Equals(PanelHex, PresetPanel[i], StringComparison.OrdinalIgnoreCase)) { return i; } } return -1; } public static void Reset() { Mutate(SetDefaults); } public static bool TryHex(string text, out string hex) { hex = text.Trim().TrimStart(new char[1] { '#' }).ToUpperInvariant(); int result; if (hex.Length == 6) { return int.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result); } return false; } private static string LimitBrightness(string hex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(FromHex(hex), ref num, ref num2, ref num3); if (!(num3 <= 0.4f)) { return ColorUtility.ToHtmlStringRGB(Color.HSVToRGB(num, num2, 0.4f)); } return hex; } private static Color FromHex(string hex) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) int num = int.Parse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture); return new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f); } private static void SetDefaults() { AccentHex = PresetAccent[0]; PanelHex = PresetPanel[0]; Opacity = 0.96f; Scale = 0.576f; Align = 1; AlignY = 1; } private static void Clamp() { //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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (!TryHex(AccentHex, out AccentHex)) { AccentHex = PresetAccent[0]; } if (!TryHex(PanelHex, out PanelHex)) { PanelHex = PresetPanel[0]; } PanelHex = LimitBrightness(PanelHex); Color val = FromHex(AccentHex); if (Mathf.Max(new float[3] { val.r, val.g, val.b }) < 0.35f) { AccentHex = PresetAccent[0]; } Opacity = Mathf.Clamp(Mathf.Round(Opacity * 100f) / 100f, 0f, 1f); Scale = Mathf.Clamp(Scale, 0.3456f, 0.80639994f); Align = Mathf.Clamp(Align, 0, 2); AlignY = Mathf.Clamp(AlignY, 0, 2); accent = FromHex(AccentHex); panelBase = FromHex(PanelHex); Version++; } private static void Load() { SetDefaults(); string text = (loadedPath = CurrentPath); try { if (File.Exists(text)) { string[] array = File.ReadAllLines(text); foreach (string text2 in array) { int num = text2.IndexOf('='); if (num <= 0) { continue; } string text3 = text2.Substring(0, num).Trim(); string text4 = text2.Substring(num + 1).Trim(); float result; bool flag = float.TryParse(text4, NumberStyles.Float, CultureInfo.InvariantCulture, out result); switch (text3) { case "Accent": AccentHex = text4; break; case "Panel": PanelHex = text4; break; case "Opacity": if (flag) { Opacity = result; } break; case "Scale": if (flag) { Scale = result; } break; case "Align": if (flag) { Align = (int)result; } break; case "AlignY": if (flag) { AlignY = (int)result; } break; } } } loadedStamp = (File.Exists(text) ? File.GetLastWriteTimeUtc(text) : DateTime.MinValue); } catch (Exception ex) { Debug.LogWarning((object)("Luds theme: could not read " + text + ": " + ex.Message)); } Clamp(); } private static void Save() { string currentPath = CurrentPath; try { string contents = string.Join(Environment.NewLine, "Accent=" + AccentHex, "Panel=" + PanelHex, "Opacity=" + Opacity.ToString("0.##", CultureInfo.InvariantCulture), "Scale=" + Scale.ToString("0.####", CultureInfo.InvariantCulture), "Align=" + Align, "AlignY=" + AlignY) + Environment.NewLine; File.WriteAllText(currentPath, contents); loadedPath = currentPath; loadedStamp = File.GetLastWriteTimeUtc(currentPath); unsaved = false; } catch (Exception ex) { Debug.LogWarning((object)("Luds theme: could not write " + currentPath + ": " + ex.Message)); } } } internal static class LudsColorExtensions { public static Color A(this Color c, float alpha) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0013: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, alpha); } } internal sealed class ThemeHost { public Func<Transform, string, Color, bool, Image> Image; public Func<Transform, string, string, bool, float, Color, TextAlignmentOptions, TextMeshProUGUI> Text; public Func<Transform, string, Action, RectTransform> Button; public Func<Transform, Color, List<Image>> Border; public Func<Image, string, TMP_InputField> Input; public Func<bool> GetSync; public Action<bool> SetSync; public Func<RectTransform?> Anchor; public Action? ApplyLayout; public Func<bool> HostOpen; public string Title = ""; public Color Cream; public Color Dim; public float Width; public bool HorizontalPosition; } internal static class LudsThemeUI { private class GearButton : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { private Image icon; private Color rest; private float hover; private bool over; private int seenVersion = -1; public void Init(Image icon, Color rest) { //IL_0008: 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) this.icon = icon; this.rest = rest; } private void OnEnable() { hover = 0f; over = false; } private void Update() { //IL_0078: 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_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) //IL_00a2: 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) float num = (over ? 1f : 0f); if (hover != num || seenVersion != LudsTheme.Version) { seenVersion = LudsTheme.Version; hover = Mathf.MoveTowards(hover, num, Time.unscaledDeltaTime * 9f); float num2 = 1f - Mathf.Pow(1f - hover, 3f); ((Graphic)icon).color = Color.Lerp(rest.A(0.8f), LudsTheme.Accent, num2); ((Transform)((Graphic)icon).rectTransform).localScale = Vector3.one * (1f + 0.1f * num2); } } public void OnPointerEnter(PointerEventData eventData) { over = true; } public void OnPointerExit(PointerEventData eventData) { over = false; } public void OnPointerClick(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { Toggle(); } } } private class ColorBinding : MonoBehaviour { private Graphic graphic; private Func<Color> color; public void Init(Graphic graphic, Func<Color> color) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) this.graphic = graphic; this.color = color; graphic.color = color(); } private void Update() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) graphic.color = color(); } } private class TextBinding : MonoBehaviour { private TextMeshProUGUI text; private Func<string> value; public void Init(TextMeshProUGUI text, Func<string> value) { this.text = text; this.value = value; } private void Update() { string text = value(); if (((TMP_Text)this.text).text != text) { ((TMP_Text)this.text).text = text; } } } private class FieldFollower : MonoBehaviour { private TMP_InputField field; private Func<string> value; public void Init(TMP_InputField field, Func<string> value) { this.field = field; this.value = value; } private void Update() { if (!field.isFocused) { string text = value(); if (field.text != text) { field.SetTextWithoutNotify(text); } } } } private class Clickable : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { private Action onClick; public void Init(Action onClick) { this.onClick = onClick; } public void OnPointerClick(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { onClick(); } } } private class PageFollower : MonoBehaviour { private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4]; private void LateUpdate() { //IL_00a9: 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_00be: 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) RectTransform val = ((host != null && host.HostOpen()) ? host.Anchor() : null); if ((Object)(object)val == (Object)null || (Object)(object)pageRect == (Object)null) { Hide(); return; } host.ApplyLayout?.Invoke(); val.GetWorldCorners(corners); float num = Mathf.Exp(0.5f * Mathf.Log((float)Screen.width / 1920f) + 0.5f * Mathf.Log((float)Screen.height / 1080f)); ((Transform)pageRect).position = corners[0]; ((Transform)pageRect).localScale = Vector3.one * (((Transform)val).lossyScale.x / num); for (int i = 0; i < ((Transform)val).childCount; i++) { GameObject gameObject = ((Component)((Transform)val).GetChild(i)).gameObject; if (gameObject.activeSelf) { gameObject.SetActive(false); hidden.Add(gameObject); } } } } private class ColourWheel : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IDragHandler, IPointerUpHandler { private RectTransform wheel; private RectTransform marker; private int seenStamp = -1; public void Init(RectTransform wheel, RectTransform marker) { this.wheel = wheel; this.marker = marker; } private void Update() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) int num = LudsTheme.Version * 2 + (editAccent ? 1 : 0); if (!picking && num != seenStamp && !string.Equals(HexFromState(), TargetHex, StringComparison.OrdinalIgnoreCase) && LudsTheme.TryHex(TargetHex, out string hex)) { float hue = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(new Color((float)int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber) / 255f, (float)int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber) / 255f, (float)int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber) / 255f), ref hue, ref num2, ref num3); if (num2 > 0.001f && num3 > 0.001f) { LudsThemeUI.hue = hue; } saturation = num2; brightness = num3; } if (!picking) { seenStamp = num; } Rect rect = wheel.rect; float num4 = ((Rect)(ref rect)).width * 0.5f; float num5 = LudsThemeUI.hue * 2f * (float)Math.PI; marker.anchoredPosition = new Vector2(Mathf.Cos(num5), Mathf.Sin(num5)) * saturation * num4; } private void Pick(PointerEventData eventData) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(wheel, eventData.position, eventData.pressEventCamera, ref val)) { Rect rect = wheel.rect; float num = ((Rect)(ref rect)).width * 0.5f; Vector2 val2 = val; rect = wheel.rect; val = val2 - ((Rect)(ref rect)).center; hue = Mathf.Repeat(Mathf.Atan2(val.y, val.x) / ((float)Math.PI * 2f), 1f); saturation = Mathf.Clamp01(((Vector2)(ref val)).magnitude / num); brightness = (editAccent ? 1f : 0.4f); CommitColour(); } } public void OnPointerDown(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { picking = true; Pick(eventData); } } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { Pick(eventData); } } public void OnPointerUp(PointerEventData eventData) { picking = false; LudsTheme.SaveNow(); } } private class ThemeSlider : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IDragHandler, IPointerUpHandler { private RectTransform track; private RectTransform fill; private RectTransform handle; private float min; private float max; private Func<float> get; private Action<float> set; private float startX; private float startValue; private float pixelsPerUnit; public void Init(RectTransform track, RectTransform fill, RectTransform handle, float min, float max, Func<float> get, Action<float> set) { this.track = track; this.fill = fill; this.handle = handle; this.min = min; this.max = max; this.get = get; this.set = set; } private void Update() { //IL_0029: 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_004a: 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) float num = Mathf.InverseLerp(min, max, get()); fill.anchorMax = new Vector2(num, 1f); RectTransform obj = handle; Rect rect = track.rect; obj.anchoredPosition = new Vector2(10f + num * ((Rect)(ref rect)).width, 0f); } private void Begin(PointerEventData eventData) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0069: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00f4: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; track.GetWorldCorners(array); float num = Mathf.Max(1f, RectTransformUtility.WorldToScreenPoint(eventData.pressEventCamera, array[3]).x - RectTransformUtility.WorldToScreenPoint(eventData.pressEventCamera, array[0]).x); pixelsPerUnit = num / (max - min); Vector2 val = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(track, eventData.position, eventData.pressEventCamera, ref val)) { Rect rect = track.rect; float xMin = ((Rect)(ref rect)).xMin; rect = track.rect; float num2 = Mathf.InverseLerp(xMin, ((Rect)(ref rect)).xMax, val.x); startValue = Mathf.Round(Mathf.Lerp(min, max, num2)); set(startValue); } else { startValue = get(); } startX = eventData.position.x; } private void Drag(PointerEventData eventData) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) set(Mathf.Clamp(Mathf.Round(startValue + (eventData.position.x - startX) / pixelsPerUnit), min, max)); } public void OnPointerDown(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { Begin(eventData); } } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { Drag(eventData); } } public void OnPointerUp(PointerEventData eventData) { LudsTheme.SaveNow(); } } public static bool Active; private static ThemeHost? host; private static GameObject? canvasObject; private static RectTransform? pageRect; private static Vector2 builtSize; private static readonly List<TMP_InputField> fields = new List<TMP_InputField>(); private static readonly List<GameObject> hidden = new List<GameObject>(); private static Sprite? gearSprite; private static Sprite? wheelSprite; private static Sprite? markerSprite; private static bool editAccent = true; private static float hue; private static float saturation; private static float brightness = 1f; private static bool picking; public static bool IsTyping { get { if (!Active) { return false; } foreach (TMP_InputField field in fields) { if ((Object)(object)field != (Object)null && field.isFocused) { return true; } } return false; } } private static string TargetHex { get { if (!editAccent) { return LudsTheme.PanelHex; } return LudsTheme.AccentHex; } } public static void Register(ThemeHost h) { host = h; } public static void Toggle() { if (Active) { Hide(); } else { Show(); } } public static void Show() { //IL_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) RectTransform val = ((host != null) ? host.Anchor() : null); if (host == null || (Object)(object)val == (Object)null) { return; } Rect rect; if (!((Object)(object)canvasObject == (Object)null)) { Vector2 val2 = builtSize; rect = val.rect; if (!(val2 != ((Rect)(ref rect)).size)) { goto IL_0081; } } if ((Object)(object)canvasObject != (Object)null) { Object.Destroy((Object)(object)canvasObject); } ThemeHost? h = host; rect = val.rect; BuildPage(h, ((Rect)(ref rect)).size); goto IL_0081; IL_0081: Active = true; LudsTheme.Hold = true; canvasObject.SetActive(true); } public static void Hide() { Active = false; LudsTheme.Hold = false; if ((Object)(object)canvasObject != (Object)null) { canvasObject.SetActive(false); } foreach (GameObject item in hidden) { if ((Object)(object)item != (Object)null) { item.SetActive(true); } } hidden.Clear(); foreach (TMP_InputField field in fields) { if ((Object)(object)field != (Object)null) { field.DeactivateInputField(false); } } } public static void AddGear(Transform panel, ThemeHost h) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00bd: 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_00ee: Unknown result type (might be due to invalid IL or missing references) Register(h); Image val = h.Image(panel, "SettingsButton", new Color(0f, 0f, 0f, 0f), arg4: true); Place(((Graphic)val).rectTransform, h.Width - 30f - 52f, 24f, 52f, 52f); Image val2 = h.Image(((Component)val).transform, "Icon", Color.white, arg4: false); val2.sprite = GearSprite(); val2.preserveAspect = true; ((Graphic)val2).rectTransform.anchorMin = Vector2.zero; ((Graphic)val2).rectTransform.anchorMax = Vector2.one; ((Graphic)val2).rectTransform.offsetMin = new Vector2(6f, 6f); ((Graphic)val2).rectTransform.offsetMax = new Vector2(-6f, -6f); ((Component)val).gameObject.AddComponent<GearButton>().Init(val2, h.Cream); } private static Sprite GearSprite() { //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) //IL_0026: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gearSprite != (Object)null) { return gearSprite; } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = 0; for (int k = 0; k < 9; k++) { float num2 = (float)j + ((float)(k % 3) + 0.5f) / 3f - 32f; float num3 = (float)i + ((float)(k / 3) + 0.5f) / 3f - 32f; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Atan2(num3, num2); float num6 = 21f + 7f * Mathf.Clamp01(Mathf.Cos(num5 * 8f) * 2.2f + 0.4f); if (num4 <= num6 && num4 >= 9f) { num++; } } array[i * 64 + j] = new Color(1f, 1f, 1f, (float)num / 9f); } } val.SetPixels(array); val.Apply(); gearSprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); return gearSprite; } private static Sprite WheelSprite() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)wheelSprite != (Object)null) { return wheelSprite; } Texture2D val = new Texture2D(192, 192, (TextureFormat)4, false) { filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[36864]; float num = 95f; for (int i = 0; i < 192; i++) { for (int j = 0; j < 192; j++) { float num2 = (float)j + 0.5f - 96f; float num3 = (float)i + 0.5f - 96f; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Atan2(num3, num2) / ((float)Math.PI * 2f); Color val2 = Color.HSVToRGB((num5 < 0f) ? (num5 + 1f) : num5, Mathf.Clamp01(num4 / num), 1f); val2.a = Mathf.Clamp01(num - num4 + 0.5f); array[i * 192 + j] = val2; } } val.SetPixels(array); val.Apply(); wheelSprite = Sprite.Create(val, new Rect(0f, 0f, 192f, 192f), new Vector2(0.5f, 0.5f), 100f); return wheelSprite; } private static Sprite MarkerSprite() { //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) //IL_0026: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0109: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)markerSprite != (Object)null) { return markerSprite; } Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[1024]; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float num = Mathf.Sqrt(((float)j + 0.5f - 16f) * ((float)j + 0.5f - 16f) + ((float)i + 0.5f - 16f) * ((float)i + 0.5f - 16f)); float num2 = Mathf.Clamp01(Mathf.Min(num - 8.5f, 12.5f - num) + 0.5f); float num3 = Mathf.Clamp01(Mathf.Min(num - 7f, 14f - num) + 0.5f); array[i * 32 + j] = ((num2 > 0f) ? new Color(1f, 1f, 1f, num2) : new Color(0f, 0f, 0f, num3 * 0.8f)); } } val.SetPixels(array); val.Apply(); markerSprite = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f); return markerSprite; } private static void BuildPage(ThemeHost h, Vector2 size) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0056: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) fields.Clear(); builtSize = size; float x = size.x; canvasObject = new GameObject("Luds Theme UI " + h.Title, new Type[1] { typeof(RectTransform) }); Object.DontDestroyOnLoad((Object)(object)canvasObject); Canvas obj = canvasObject.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 600; CanvasScaler obj2 = canvasObject.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.screenMatchMode = (ScreenMatchMode)0; obj2.matchWidthOrHeight = 0.5f; canvasObject.AddComponent<GraphicRaycaster>(); Image val = h.Image(canvasObject.transform, "Page", new Color(0f, 0f, 0f, 0f), arg4: true); pageRect = ((Graphic)val).rectTransform; RectTransform? obj3 = pageRect; RectTransform? obj4 = pageRect; Vector2 val2 = (pageRect.pivot = Vector2.zero); Vector2 anchorMin = (obj4.anchorMax = val2); obj3.anchorMin = anchorMin; pageRect.sizeDelta = size; ((Component)val).gameObject.AddComponent<PageFollower>(); TextMeshProUGUI obj5 = h.Text(((Component)val).transform, "Title", h.Title + " Settings", arg4: true, 48f, LudsTheme.Accent, (TextAlignmentOptions)514); ((TMP_Text)obj5).enableAutoSizing = true; ((TMP_Text)obj5).fontSizeMin = 24f; ((TMP_Text)obj5).fontSizeMax = 48f; Place(((TMP_Text)obj5).rectTransform, 40f, 16f, x - 80f, 64f); Bind((Graphic)(object)obj5, () => LudsTheme.Accent); Image obj6 = h.Image(((Component)val).transform, "Divider", LudsTheme.Divider, arg4: false); Place(((Graphic)obj6).rectTransform, 90f, 86f, x - 180f, 2f); Bind((Graphic)(object)obj6, () => LudsTheme.Divider); float num = 340f; float num2 = x - 40f - num; float num3 = 104f; PresetRow(h, ((Component)val).transform, x, num3, num2, num); num3 += 54f; ColourBlock(h, ((Component)val).transform, num3, x); num3 += 214f; SliderRow(h, ((Component)val).transform, x, "Opacity", num3, num2, num, 0f, 100f, () => LudsTheme.Opacity * 100f, delegate(float v) { LudsTheme.Mutate(delegate { LudsTheme.Opacity = v / 100f; }, save: false, rebuild: false); }, (float v) => Mathf.RoundToInt(v) + "%"); num3 += 50f; SliderRow(h, ((Component)val).transform, x, "Size", num3, num2, num, 60f, 140f, () => LudsTheme.Scale / 0.576f * 100f, delegate(float v) { LudsTheme.Mutate(delegate { LudsTheme.Scale = v / 100f * 0.576f; }, save: false, rebuild: false); }, (float v) => Mathf.RoundToInt(v) + "%"); num3 += 50f; MoveRow(h, ((Component)val).transform, x, num3, num2, num); num3 += 114f; if (Chainloader.PluginInfos.Values.Count((PluginInfo p) => p.Metadata.Name.StartsWith("Luds")) >= 2) { Strip(h, ((Component)val).transform, x, num3, 56f); Place(((TMP_Text)h.Text(((Component)val).transform, "SyncLabel", "Sync look", arg4: false, 26f, h.Cream, (TextAlignmentOptions)4097)).rectTransform, 40f, num3 - 2f, num2 - 50f, 30f); Place(((TMP_Text)h.Text(((Component)val).transform, "SyncNote", "With other Luds mods", arg4: false, 18f, h.Dim, (TextAlignmentOptions)4097)).rectTransform, 40f, num3 + 24f, num2 - 50f, 24f); RectTransform obj7 = h.Button(((Component)val).transform, h.GetSync() ? "On" : "Off", delegate { h.SetSync(!h.GetSync()); }); Place(obj7, x - 40f - 150f, num3 + 2f, 150f, 44f); Follow(((Component)obj7).GetComponentInChildren<TextMeshProUGUI>(), () => (!h.GetSync()) ? "Off" : "On"); num3 += 56f; } num3 += 18f; Place(h.Button(((Component)val).transform, "Reset", LudsTheme.Reset), x * 0.5f - 208f, num3, 200f, 52f); Place(h.Button(((Component)val).transform, "Done", Hide), x * 0.5f + 8f, num3, 200f, 52f); } private static void MoveRow(ThemeHost h, Transform parent, float width, float y, float left, float controlWidth) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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) Strip(h, parent, width, y, 108f); Place(((TMP_Text)h.Text(parent, "MoveLabel", "Menu position", arg4: false, 26f, h.Cream, (TextAlignmentOptions)4097)).rectTransform, 40f, y + 20f, left - 50f, 30f); Place(((TMP_Text)h.Text(parent, "MoveNote", "Snap to the screen", arg4: false, 18f, h.Dim, (TextAlignmentOptions)4097)).rectTransform, 40f, y + 48f, left - 50f, 24f); int num = ((!h.HorizontalPosition) ? 1 : 3); float num2 = (float)num * 50f + (float)(num - 1) * 8f; float num3 = left + controlWidth - num2; for (int i = 0; i < 3; i++) { for (int j = 0; j < num; j++) { int cx = (h.HorizontalPosition ? j : LudsTheme.Align); int cy = i; Image val = h.Image(parent, "Cell" + cx + cy, LudsTheme.Accent, arg4: true); Bind((Graphic)(object)val, () => (LudsTheme.Align != cx || LudsTheme.AlignY != cy) ? LudsTheme.Accent.A(0.22f) : LudsTheme.Accent); h.Border(((Component)val).transform, new Color(0f, 0f, 0f, 0.7f)); Place(((Graphic)val).rectTransform, num3 + (float)j * 58f, y + 3f + (float)i * 34f, 50f, 26f); ((Component)val).gameObject.AddComponent<Clickable>().Init(delegate { LudsTheme.Mutate(delegate { if (h.HorizontalPosition) { LudsTheme.Align = cx; } LudsTheme.AlignY = cy; }); }); } } } private static void PresetRow(ThemeHost h, Transform parent, float width, float y, float left, float controlWidth) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) Label(h, parent, "Preset", y); Place(h.Button(parent, "-", delegate { LudsTheme.ApplyPreset(LudsTheme.PresetIndex() - 1); }), left, y, 60f, 44f); TextMeshProUGUI obj = h.Text(parent, "PresetValue", "", arg4: false, 26f, LudsTheme.Accent, (TextAlignmentOptions)514); Place(((TMP_Text)obj).rectTransform, left + 64f, y, controlWidth - 128f, 44f); Bind((Graphic)(object)obj, () => LudsTheme.Accent); Follow(obj, () => (LudsTheme.PresetIndex() >= 0) ? LudsTheme.PresetNames[LudsTheme.PresetIndex()] : "Custom"); Place(h.Button(parent, "+", delegate { LudsTheme.ApplyPreset(LudsTheme.PresetIndex() + 1); }), left + controlWidth - 60f, y, 60f, 44f); } private static void Strip(ThemeHost h, Transform parent, float width, float y, float height) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) Place(((Graphic)h.Image(parent, "Strip", new Color(0f, 0f, 0f, 0.35f), arg4: false)).rectTransform, 24f, y - 4f, width - 48f, height); } private static void Label(ThemeHost h, Transform parent, string text, float y) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) Strip(h, parent, builtSize.x, y, 48f); Place(((TMP_Text)h.Text(parent, text + "Label", text, arg4: false, 26f, h.Cream, (TextAlignmentOptions)4097)).rectTransform, 40f, y, 200f, 44f); } private static string HexFromState() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ColorUtility.ToHtmlStringRGB(Color.HSVToRGB(hue, saturation, brightness)); } private static void CommitColour() { if (!editAccent) { brightness = Mathf.Min(brightness, 0.4f); } string hex = HexFromState(); if (editAccent) { LudsTheme.Mutate(delegate { LudsTheme.AccentHex = hex; }, save: false, rebuild: false); } else { LudsTheme.Mutate(delegate { LudsTheme.PanelHex = hex; }, save: false, rebuild: false); } } private static void ColourBlock(ThemeHost h, Transform parent, float y, float width) { //IL_0026: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) Place(((Graphic)h.Image(parent, "ColourStrip", new Color(0f, 0f, 0f, 0.35f), arg4: false)).rectTransform, 24f, y - 4f, width - 48f, 210f); Image val = h.Image(parent, "Wheel", Color.white, arg4: true); val.sprite = WheelSprite(); float num = width - 40f - 190f; Place(((Graphic)val).rectTransform, num, y + 2f, 190f, 190f); Image val2 = h.Image(((Component)val).transform, "Marker", Color.white, arg4: false); val2.sprite = MarkerSprite(); RectTransform rectTransform = ((Graphic)val2).rectTransform; RectTransform rectTransform2 = ((Graphic)val2).rectTransform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); rectTransform2.anchorMax = val3; rectTransform.anchorMin = val3; ((Graphic)val2).rectTransform.sizeDelta = new Vector2(26f, 26f); ((Component)val).gameObject.AddComponent<ColourWheel>().Init(((Graphic)val).rectTransform, ((Graphic)val2).rectTransform); float num2 = 40f; float num3 = num - 24f - num2; float num4 = (num3 - 10f) / 2f; Tile(h, parent, "Accent", accentTile: true, num2, y + 44f, num4); Tile(h, parent, "Panel", accentTile: false, num2 + num4 + 10f, y + 44f, num4); Image val4 = h.Image(parent, "HexInput", new Color(0f, 0f, 0f, 0.6f), arg4: true); h.Border(((Component)val4).transform, new Color(0f, 0f, 0f, 0.85f)); Place(((Graphic)val4).rectTransform, num2, y + 106f, num3, 44f); TMP_InputField field = h.Input(val4, "RRGGBB"); field.characterLimit = 7; field.SetTextWithoutNotify("#" + TargetHex); ((UnityEvent<string>)(object)field.onEndEdit).AddListener((UnityAction<string>)delegate(string entered) { if (LudsTheme.TryHex(entered, out string hex)) { if (editAccent) { LudsTheme.Mutate(delegate { LudsTheme.AccentHex = hex; }); } else { LudsTheme.Mutate(delegate { LudsTheme.PanelHex = hex; }); } } field.SetTextWithoutNotify("#" + TargetHex); }); fields.Add(field); ((Component)field).gameObject.AddComponent<FieldFollower>().Init(field, () => "#" + TargetHex); } private static void Tile(ThemeHost h, Transform parent, string name, bool accentTile, float x, float y, float width) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) Func<Color> colour = () => (!accentTile) ? LudsTheme.PanelSolid : LudsTheme.Accent; Image val = h.Image(parent, name + "Tile", colour(), arg4: true); Bind((Graphic)(object)val, colour); Place(((Graphic)val).rectTransform, x, y, width, 46f); foreach (Image item in h.Border(((Component)val).transform, Color.white)) { Bind((Graphic)(object)item, () => (Color)((editAccent != accentTile) ? LudsTheme.Border : new Color(0.95f, 0.9f, 0.8f, 1f))); } TextMeshProUGUI val2 = h.Text(((Component)val).transform, "Label", name, arg4: false, 24f, Color.white, (TextAlignmentOptions)514); ((TMP_Text)val2).rectTransform.anchorMin = Vector2.zero; ((TMP_Text)val2).rectTransform.anchorMax = Vector2.one; RectTransform rectTransform = ((TMP_Text)val2).rectTransform; Vector2 offsetMin = (((TMP_Text)val2).rectTransform.offsetMax = Vector2.zero); rectTransform.offsetMin = offsetMin; Bind((Graphic)(object)val2, delegate { //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_0018: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Color val3 = colour(); return (!(val3.r * 0.3f + val3.g * 0.59f + val3.b * 0.11f > 0.5f)) ? new Color(0.97f, 0.93f, 0.85f) : new Color(0.05f, 0.04f, 0.03f); }); ((Component)val).gameObject.AddComponent<Clickable>().Init(delegate { editAccent = accentTile; }); } private static void SliderRow(ThemeHost h, Transform parent, float width, string text, float y, float left, float controlWidth, float min, float max, Func<float> get, Action<float> set, Func<float, string> format) { Label(h, parent, text, y); Slider(h, parent, left, y, controlWidth - 90f, min, max, get, set, format, 86f); } private static void Slider(ThemeHost h, Transform parent, float x, float y, float trackWidth, float min, float max, Func<float> get, Action<float> set, Func<float, string> format, float valueWidth) { //IL_0036: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) Image val = h.Image(parent, "Slider", new Color(0f, 0f, 0f, 0f), arg4: true); Place(((Graphic)val).rectTransform, x, y, trackWidth, 44f); Image val2 = h.Image(((Component)val).transform, "Track", new Color(0f, 0f, 0f, 0.6f), arg4: false); ((Graphic)val2).rectTransform.anchorMin = new Vector2(0f, 0.5f); ((Graphic)val2).rectTransform.anchorMax = new Vector2(1f, 0.5f); ((Graphic)val2).rectTransform.offsetMin = new Vector2(10f, -5f); ((Graphic)val2).rectTransform.offsetMax = new Vector2(-10f, 5f); h.Border(((Component)val2).transform, new Color(0f, 0f, 0f, 0.85f)); Image val3 = h.Image(((Component)val2).transform, "Fill", LudsTheme.Accent, arg4: false); Bind((Graphic)(object)val3, () => LudsTheme.Accent.A(0.85f)); ((Graphic)val3).rectTransform.anchorMin = Vector2.zero; ((Graphic)val3).rectTransform.anchorMax = new Vector2(0f, 1f); Vector2 val4 = (((Graphic)val3).rectTransform.offsetMin = (((Graphic)val3).rectTransform.offsetMax = Vector2.zero)); Image val6 = h.Image(((Component)val).transform, "Handle", LudsTheme.Accent, arg4: false); Bind((Graphic)(object)val6, () => LudsTheme.Accent); RectTransform rectTransform = ((Graphic)val6).rectTransform; RectTransform rectTransform2 = ((Graphic)val6).rectTransform; ((Vector2)(ref val4))..ctor(0f, 0.5f); rectTransform2.anchorMax = val4; rectTransform.anchorMin = val4; ((Graphic)val6).rectTransform.sizeDelta = new Vector2(16f, 32f); h.Border(((Component)val6).transform, new Color(0f, 0f, 0f, 0.7f)); ((Component)val).gameObject.AddComponent<ThemeSlider>().Init(((Graphic)val2).rectTransform, ((Graphic)val3).rectTransform, ((Graphic)val6).rectTransform, min, max, get, set); TextMeshProUGUI obj = h.Text(parent, "SliderValue", "", arg4: false, 26f, LudsTheme.Accent, (TextAlignmentOptions)4100); Place(((TMP_Text)obj).rectTransform, x + trackWidth + 4f, y, valueWidth, 44f); Bind((Graphic)(object)obj, () => LudsTheme.Accent); Follow(obj, () => format(get())); } private static void Bind(Graphic graphic, Func<Color> color) { ((Component)graphic).gameObject.AddComponent<ColorBinding>().Init(graphic, color); } public static void Live(Graphic graphic, Func<Color> color) { Bind(graphic, color); } private static void Follow(TextMeshProUGUI? text, Func<string> value) { if ((Object)(object)text != (Object)null) { ((Component)text).gameObject.AddComponent<TextBinding>().Init(text, value); } } private static void Place(RectTransform rt, float left, float top, float width, float height) { //IL_0014: 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_001b: 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_0022: 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_003a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rt.pivot = val; Vector2 anchorMin = (rt.anchorMax = val); rt.anchorMin = anchorMin; rt.anchoredPosition = new Vector2(left, 0f - top); rt.sizeDelta = new Vector2(width, height); } public static void StyleScrollbar(Scrollbar bar) { Image component = ((Component)bar).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { component.sprite = null; component.type = (Type)0; Live((Graphic)(object)component, () => new Color(0f, 0f, 0f, 0.35f * LudsTheme.Opacity)); } Image val = (((Object)(object)bar.handleRect != (Object)null) ? ((Component)bar.handleRect).GetComponent<Image>() : null); if ((Object)(object)val != (Object)null) { val.sprite = null; val.type = (Type)0; Live((Graphic)(object)val, () => LudsTheme.Accent.A(0.85f)); } Image[] componentsInChildren = ((Component)bar).GetComponentsInChildren<Image>(true); foreach (Image val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)(object)component && (Object)(object)val2 != (Object)(object)val) { val2.sprite = null; Live((Graphic)(object)val2, () => new Color(0f, 0f, 0f, 0f)); } } ((Selectable)bar).transition = (Transition)0; } } [BepInPlugin("ludspinmanager.valheim.plugin", "Luds Pin Manager", "1.2.1")] public class PinManagerPlugin : BaseUnityPlugin { public const string Guid = "ludspinmanager.valheim.plugin"; internal static PinManagerPlugin Instance; internal static ConfigEntry<KeyboardShortcut> OpenKey; internal static ConfigEntry<bool> ShowButton; internal static ConfigEntry<bool> SyncTheme; private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) Instance = this; OpenKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Open hotkey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Opens the large map and the pin manager together from the game, and opens or closes the pin manager while the map is open."); ShowButton = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Pins button", true, "Show a Pins button at the bottom of the large map."); SyncTheme = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "Use shared Luds theme", true, "If on, the menu look is shared with other Luds mods (BepInEx/config/luds.theme.ini). If off, this mod keeps its own look."); LudsTheme.Init("pins", () => SyncTheme.Value); new Harmony("ludspinmanager.valheim.plugin").PatchAll(); } private void Update() { PinUI.Tick(); } private void OnDestroy() { PinUI.Destroy(); } } internal static class Patches { [HarmonyPatch(typeof(Minimap), "InTextInput")] private static class TypingBlocksMapKeys { private static void Postfix(ref bool __result) { if (PinUI.IsTyping) { __result = true; } } } [HarmonyPatch(typeof(Minimap), "SetMapMode")] private static class EscapeClosesManagerFirst { private static bool Prefix(MapMode mode) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 if (PinUI.IsOpen && (int)mode != 2 && Input.GetKeyDown((KeyCode)27)) { PinUI.Close(); return false; } return true; } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] private static class WheelOverPanel { private static void Postfix(ref float __result) { if (PinUI.PointerOverPanel) { __result = 0f; } } } [HarmonyPatch(typeof(Game), "Start")] private static class PrewarmUI { private static void Postfix(Game __instance) { ((MonoBehaviour)__instance).StartCoroutine(PinUI.Prewarm()); } } } internal static class PinUI { private class PinRow : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { public class StarClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public PinRow Row; public void OnPointerClick(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { Row.StartFavorite(); } } } private PinData? pin; private Image highlight; private Image accent; private Image icon; private TextMeshProUGUI nameText; private TextMeshProUGUI distanceText; private RectTransform nameRect; private float hover; private float selectedValue; private bool over; private bool isSelected; private const float NameLeft = 104f; private Image star; private float favoriteTime = -1f; private bool becomingFavorite; private PencilButton pencil; private Image? renameBg; private TMP_InputField? renameInput; private bool renaming; public bool IsRenameFocused { get { if (renaming && (Object)(object)renameInput != (Object)null) { return renameInput.isFocused; } return false; } } public static PinRow Create(Transform parent) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) Image val = MakeImage(parent, "Row", null, LudsTheme.Row, raycast: true); ((Component)val).gameObject.AddComponent<LayoutElement>().preferredHeight = 52f; PinRow pinRow = ((Component)val).gameObject.AddComponent<PinRow>(); pinRow.highlight = MakeImage(((Component)val).transform, "Highlight", null, LudsTheme.Accent.A(0f)); Stretch(((Graphic)pinRow.highlight).rectTransform, 0f, 0f, 0f, 0f); pinRow.accent = MakeImage(((Component)val).transform, "Accent", null, LudsTheme.Accent.A(0f)); ((Graphic)pinRow.accent).rectTransform.anchorMin = Vector2.zero; ((Graphic)pinRow.accent).rectTransform.anchorMax = new Vector2(0f, 1f); ((Graphic)pinRow.accent).rectTransform.pivot = new Vector2(0f, 0.5f); ((Graphic)pinRow.accent).rectTransform.sizeDelta = new Vector2(4f, 0f); pinRow.icon = MakeImage(((Component)val).transform, "Icon", null, Color.white); RectTransform rectTransform = ((Graphic)pinRow.icon).rectTransform; RectTransform rectTransform2 = ((Graphic)pinRow.icon).rectTransform; RectTransform rectTransform3 = ((Graphic)pinRow.icon).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); rectTransform3.pivot = val2; Vector2 anchorMin = (rectTransform2.anchorMax = val2); rectTransform.anchorMin = anchorMin; ((Graphic)pinRow.icon).rectTransform.anchoredPosition = new Vector2(58f, 0f); ((Graphic)pinRow.icon).rectTransform.sizeDelta = new Vector2(36f, 36f); Image val4 = (pinRow.star = MakeImage(((Component)val).transform, "Star", StarSprite(filled: false), Color.white, raycast: true)); RectTransform rectTransform4 = ((Graphic)val4).rectTransform; RectTransform rectTransform5 = ((Graphic)val4).rectTransform; RectTransform rectTransform6 = ((Graphic)val4).rectTransform; ((Vector2)(ref val2))..ctor(0f, 0.5f); rectTransform6.pivot = val2; anchorMin = (rectTransform5.anchorMax = val2); rectTransform4.anchorMin = anchorMin; ((Graphic)val4).rectTransform.anchoredPosition = new Vector2(13f, 0f); ((Graphic)val4).rectTransform.sizeDelta = new Vector2(33f, 33f); ((Component)val4).gameObject.AddComponent<StarClick>().Row = pinRow; pinRow.nameText = MakeText(((Component)val).transform, "Name", "", heading: false, 28f, Cream, (TextAlignmentOptions)4097); pinRow.pencil = PencilButton.Create(((Component)val).transform, pinRow); Stretch(((TMP_Text)pinRow.nameText).rectTransform, 104f, 0f, 262f, 0f); pinRow.nameRect = ((TMP_Text)pinRow.nameText).rectTransform; pinRow.distanceText = MakeText(((Component)val).transform, "Distance", "", heading: false, 26f, new Color(0.88f, 0.82f, 0.7f), (TextAlignmentOptions)4100); Stretch(((TMP_Text)pinRow.distanceText).rectTransform, 0f, 0f, 14f, 0f); ((TMP_Text)pinRow.distanceText).rectTransform.anchorMin = new Vector2(1f, 0f); ((TMP_Text)pinRow.distanceText).rectTransform.offsetMin = new Vector2(-180f, 0f); return pinRow; } public void StartFavorite() { if (pin != null && !favoriteAnimating) { favoriteAnimating = true; becomingFavorite = !IsFavorite(pin); star.sprite = StarSprite(becomingFavorite); favoriteTime = 0f; } } public void Configure(PinData data, bool select, bool favorite) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (favoriteTime >= 0f) { favoriteAnimating = false; } favoriteTime = -1f; ((Transform)((Graphic)star).rectTransform).localScale = Vector3.one; star.sprite = StarSprite(favorite); if ((Object)(object)renamingRow == (Object)(object)this) { renamingRow = null; } renaming = false; ((Component)nameText).gameObject.SetActive(true); Image? obj = renameBg; if (obj != null) { ((Component)obj).gameObject.SetActive(false); } pin = data; isSelected = select; over = false; hover = 0f; selectedValue = (select ? 1f : 0f); icon.sprite = data.m_icon; ((Behaviour)icon).enabled = (Object)(object)data.m_icon != (Object)null; ((TMP_Text)nameText).text = Label(data); ((TMP_Text)nameText).fontStyle = (FontStyles)(data.m_checked ? 64 : 0); ((Graphic)nameText).color = (data.m_checked ? Dim : Cream); nameRect.offsetMin = new Vector2(104f, 0f); Apply(); if ((Object)(object)Player.m_localPlayer != (Object)null) { UpdateDistance(((Component)Player.m_localPlayer).transform.position); } } public void RefreshSelection(HashSet<PinData> set) { if (pin != null) { isSelected = set.Contains(pin); } } public void UpdateDistance(Vector3 player) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (pin != null) { Vector3 val = pin.m_pos - player; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; ((TMP_Text)distanceText).text = ((magnitude >= 1000f) ? ((magnitude / 1000f).ToString("0.0") + " km") : (Mathf.RoundToInt(magnitude) + " m")); } } private void Update() { //IL_0082: 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_00ae: Unknown result type (might be due to invalid IL or missing references) if (favoriteTime >= 0f) { favoriteTime += Time.unscaledDeltaTime; float num = favoriteTime / 0.22f; if (num >= 1f) { favoriteTime = -1f; favoriteAnimating = false; ((Transform)((Graphic)star).rectTransform).localScale = Vector3.one; if (pin != null) { ToggleFavorite(pin); Refresh(force: true); } return; } ((Transform)((Graphic)star).rectTransform).localScale = Vector3.one * (1f + (becomingFavorite ? 0.3f : 0.12f) * Mathf.Sin(num * (float)Math.PI)); } float num2 = (over ? 1f : 0f); float num3 = (isSelected ? 1f : 0f); if (!Mathf.Approximately(hover, num2) || !Mathf.Approximately(selectedValue, num3)) { hover = Mathf.MoveTowards(hover, num2, Time.unscaledDeltaTime * 8f); selectedValue = Mathf.MoveTowards(selectedValue, num3, Time.unscaledDeltaTime * 8f); Apply(); } } private void Apply() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) float num = Ease(hover); float num2 = Ease(selectedValue); ((Graphic)highlight).color = LudsTheme.Accent.A(Mathf.Max(0.22f * num2, 0.2f * num)); ((Graphic)accent).color = LudsTheme.Accent.A(Mathf.Max(num2, num)); nameRect.offsetMin = new Vector2(104f + 8f * num, 0f); pencil.SetRowHover(num); } public void BeginRename() { if (pin != null) { if ((Object)(object)renamingRow != (Object)null && (Object)(object)renamingRow != (Object)(object)this) { renamingRow.EndRename(commit: true); } EnsureRenameInput(); renamingRow = this; renaming = true; ((Component)nameText).gameObject.SetActive(false); ((Component)renameBg).gameObject.SetActive(true); renameInput.SetTextWithoutNotify(pin.m_name ?? ""); renameInput.ActivateInputField(); ((Selectable)renameInput).Select(); } } public void EndRename(bool commit) { if (!renaming) { return; } renaming = false; if ((Object)(object)renamingRow == (Object)(object)this) { renamingRow = null; } string text = renameInput.text.Trim(); renameInput.DeactivateInputField(false); ((Component)renameBg).gameObject.SetActive(false); ((Component)nameText).gameObject.SetActive(true); if (commit && pin != null && text != (pin.m_name ?? "")) { PinData val = pin; string name = text; PinData val2 = Replace(val, null, name); if (selected.Remove(val)) { selected.Add(val2); } if (lastClicked == val) { lastClicked = val2; } Refresh(force: true); } } private void EnsureRenameInput() { //IL_001c: 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_0042: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)renameInput != (Object)null)) { renameBg = MakeImage(((Component)this).transform, "RenameBg", null, LudsTheme.Field.A(0.98f), raycast: true); RectTransform rectTransform = ((Graphic)renameBg).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(100f, 6f); rectTransform.offsetMax = new Vector2(-206f, -6f); AddBorder(((Component)renameBg).transform, LudsTheme.Divider, 2f); RectTransform val = NewRect("Text Area", ((Component)renameBg).transform); Stretch(val, 12f, 2f, 12f, 2f); ((Component)val).gameObject.AddComponent<RectMask2D>(); TextMeshProUGUI val2 = MakeText((Transform)(object)val, "Placeholder", "Pin name", heading: false, 26f, Dim, (TextAlignmentOptions)4097); Stretch(((TMP_Text)val2).rectTransform, 0f, 0f, 0f, 0f); TextMeshProUGUI val3 = MakeText((Transform)(object)val, "Text", "", heading: false, 26f, Cream, (TextAlignmentOptions)4097); Stretch(((TMP_Text)val3).rectTransform, 0f, 0f, 0f, 0f); renameInput = ((Component)renameBg).gameObject.AddComponent<TMP_InputField>(); renameInput.textViewport = val; renameInput.textComponent = (TMP_Text)(object)val3; renameInput.placeholder = (Graphic)(object)val2; ((Selectable)renameInput).transition = (Transition)0; renameInput.fontAsset = bodyFont; renameInput.pointSize = 26f; renameInput.characterLimit = 40; renameInput.customCaretColor = true; renameInput.caretColor = Gold; renameInput.selectionColor = LudsTheme.Accent.A(0.35f); ((UnityEvent<string>)(object)renameInput.onSubmit).AddListener((UnityAction<string>)delegate { EndRename(commit: true); }); ((UnityEvent<string>)(object)renameInput.onEndEdit).AddListener((UnityAction<string>)delegate { EndRename(!Input.GetKey((KeyCode)27)); }); ((Component)renameBg).gameObject.SetActive(false); } } public void OnPointerEnter(PointerEventData eventData) { over = true; } public void OnPointerExit(PointerEventData eventData) { over = false; } public void OnPointerClick(PointerEventData eventData) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (pin != null) { RowClicked(this, pin, eventData.button); } } } private class PencilButton : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { private PinRow row; private RectTransform visual; private Image icon; private float rowHover; private float hover; private bool over; private int seenVersion = -1; private float seenRowHover = -1f; public static PencilButton Create(Transform parent, PinRow row) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) Image val = MakeImage(parent, "Rename", null, new Color(0f, 0f, 0f, 0f), raycast: true); RectTransform rectTransform = ((Graphic)val).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(1f, 0.5f); rectTransform.pivot = val2; Vector2 anchorMin = (rectTransform.anchorMax = val2); rectTransform.anchorMin = anchorMin; rectTransform.anchoredPosition = new Vector2(-206f, 0f); rectTransform.sizeDelta = new Vector2(44f, 40f); PencilButton pencilButton = ((Component)val).gameObject.AddComponent<PencilButton>(); pencilButton.row = row; pencilButton.visual = NewRect("Visual", ((Component)val).transform); Stretch(pencilButton.visual, 0f, 0f, 0f, 0f); pencilButton.icon = MakeImage((Transform)(object)pencilButton.visual, "Icon", PencilSprite(), Color.white); Stretch(((Graphic)pencilButton.icon).rectTransform, 8f, 6f, 8f, 6f); pencilButton.icon.preserveAspect = true; return pencilButton; } public void SetRowHover(float value) { rowHover = value; } private void Update() { //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_00b0: 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_00dc: Unknown result type (might be due to invalid IL or missing references) float num = (over ? 1f : 0f); if (hover != num || seenRowHover != rowHover || seenVersion != LudsTheme.Version) { seenVersion = LudsTheme.Version; seenRowHover = rowHover; hover = Mathf.MoveTowards(hover, num, Time.unscaledDeltaTime * 10f); float num2 = Mathf.Max(Ease(hover), 0.25f * rowHover); ((Graphic)icon).color = Color.Lerp(new Color(1f, 1f, 1f, 0.75f), LudsTheme.Accent, num2); ((Transform)visual).localScale = Vector3.one * (1f + 0.15f * Ease(hover)); } } public void OnPointerEnter(PointerEventData eventData) { over = true; } public void OnPointerExit(PointerEventData eventData) { over = false; } public void OnPointerClick(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)eventData.button == 0) { row.BeginRename(); } } } internal class ButtonView : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler { private RectTransform visual; private Image fill; private List<Image> borders; private TextMeshProUGUI label; private Action onClick; private float hover; private float press; private float selectedValue; private bool over; private bool down; public bool Interactable = true; public bool Selected; public bool Danger; public void Init(RectTransform visual, Image fill, List<Image> borders, TextMeshProUGUI label, Action onClick) { this.visual = visual; this.fill = fill; this.borders = borders; this.label = label; this.onClick = onClick; } public void SetLabel(string text) { if (((TMP_Text)label).text != text) { ((TMP_Text)label).text = text; } } private void OnEnable() { hover = (press = 0f); over = (down = false); } private void Update() { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01bd: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) float unscaledDeltaTime = Time.unscaledDeltaTime; hover = Mathf.MoveTowards(hover, (over && Interactable) ? 1f : 0f, unscaledDeltaTime * 9f); press = Mathf.MoveTowards(press, (down && Interactable) ? 1f : 0f, unscaledDeltaTime * 14f); selectedValue = Mathf.MoveTowards(selectedValue, Selected ? 1f : 0f, unscaledDeltaTime * 9f); float num = Mathf.Max(Ease(hover), Ease(selectedValue)); Color val = (Color)(Danger ? new Color(1f, 0.36f, 0.25f) : Gold); float num2 = (Interactable ? 1f : 0.4f); Color val2 = (Color)(Danger ? new Color(val.r * 0.3f, val.g * 0.3f, val.b * 0.3f, 0.94f) : LudsTheme.ButtonHover); ((Graphic)fill).color = Color.Lerp(LudsTheme.ButtonFill, val2, num); Color color = Color.Lerp(LudsTheme.Border, new Color(val.r, val.g, val.b, 1f), num); color.a *= num2; foreach (Image border in borders) { ((Graphic)border).color = color; } Color color2 = Color.Lerp(Cream, val, num); color2.a = num2; ((Graphic)label).color = color2; ((Transform)visual).localScale = Vector3.one * (1f + 0.05f * Ease(hover) - 0.06f * press); } public void OnPointerEnter(PointerEventData eventData) { over = true; } public void OnPointerExit(PointerEventData eventData) { over = (down = false); } public void OnPointerDown(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 down = (int)eventData.button == 0; } public void OnPointerUp(PointerEventData eventData) { down = false; } public void OnPointerClick(PointerEventData eventData) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (Interactable && (int)eventData.button == 0) { onClick(); } } } private const float PanelWidth = 780f; private const float PanelHeight = 1020f; private static readonly Color Cream = new Color(0.95f, 0.9f, 0.8f); private static readonly Color Dim = new Color(0.66f, 0.6f, 0.5f); public static bool IsOpen; private static GameObject? canvasObject; private static GameObject? panelObject; private static GameObject? pinsButtonObject; private static RectTransform? panelRect; private static RectTransform? content; private static RectTransform? pinsButtonRect; private static CanvasGroup? panelGroup; private static CanvasGroup? pinsButtonGroup; private static ScrollRect? scroll; private static TMP_InputField? search; private static TextMeshProUGUI? countLabel; private static TextMeshProUGUI? selectionLabel; private static ButtonView? crossButton; private static ButtonView? deleteButton; private static ButtonView? selectAllButton; private static ButtonView? clearButton; private static readonly List<ButtonView> filterChips = new List<ButtonView>(); private static readonly List<ButtonView> iconButtons = new List<ButtonView>(); private static readonly List<PinType> iconTypes = new List<PinType> { (PinType)0, (PinType)1, (PinType)2, (PinType)3, (PinType)6 }; private static TMP_FontAsset? bodyFont; private static TMP_FontAsset? headFont; private static Material? bodyMaterial; private static Material? headMaterial; private static float panelAnim; private static float buttonAnim; private static float scrollTarget; private static float lastScrollY; private static float lastRefresh; private static float lastSignature; private static float deleteArmedUntil; private static PinType? filterType; private static string query = ""; private static List<PinData> entries = new List<PinData>(); private static List<PinData> favoritePins = new List<PinData>(); private static List<PinData> otherPins = new List<PinData>(); private static readonly HashSet<PinData> selected = new HashSet<PinData>(); private static PinData? lastClicked; private static readonly List<PinRow> rows = new List<PinRow>(); private static readonly HashSet<PinType> hiddenTypes = new HashSet<PinType> { (PinType)12, (PinType)7, (PinType)10, (PinType)8, (PinType)11, (PinType)13, (PinType)5 }; private static float distanceStamp; private static RectTransform? mapShiftRect; private static float mapBaseRight; private static float mapBaseLeft; private static float mapBaseUnit = 1f; private static float lastMapE; private static bool mapMoved; private static Vector2 mapBaseOffsetMax; private static Vector2 mapBaseOffsetMin; private const string FavoritesKey = "LudsPinManager Favorites"; private static bool favoriteAnimating; private static Sprite? starSprite; private static Sprite? starEmptySprite; private static readonly List<GameObject> sectionObjects = new List<GameObject>(); private static PinRow? renamingRow; private static Sprite? pencilSprite; private static float PanelScale => LudsTheme.LayoutScale; private static Color Gold => LudsTheme.Accent; private static Color LineColor => LudsTheme.Border.A(0.6f); public static bool IsTyping { get { if (IsOpen) { if (!LudsThemeUI.IsTyping && (!((Object)(object)search != (Object)null) || !search.isFocused)) { if ((Object)(object)renamingRow != (Object)null) { return renamingRow.IsRenameFocused; } return false; } return true; } return false; } } public static bool PointerOverPanel { get { //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) if (IsOpen && (Object)(object)panelRect != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(panelRect, Vector2.op_Implicit(Input.mousePosition)); } return false; } } public static IEnumerator Prewarm() { yield return (object)new WaitForSeconds(3f); try { Build(); } catch (Exception ex) { Debug.LogWarning((object)("PinManager: could not build the UI: " + ex)); } } public static void Destroy() { if ((Object)(object)canvasObject != (Object)null) { Object.Destroy((Object)(object)canvasObject); } } public static void Open() { if ((Object)(object)panelObject == (Object)null) { Build(); } if (!((Object)(object)panelObject == (Object)null) && !((Object)(object)Minimap.instance == (Object)null)) { LudsThemeUI.Hide(); query = ""; search.SetTextWithoutNotify(""); filterType = null; selected.Clear(); lastClicked = null; IsOpen = true; panelObject.SetActive(true); Refresh(force: true); scrollTarget = 0f; } } public static void Close() { IsOpen = false; if ((Object)(object)search != (Object)null) { search.DeactivateInputField(false); } renamingRow?.EndRename(commit: false); } public static void Tick() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) if (LudsTheme.Tick()) { ApplyTheme(); } bool flag = false; KeyboardShortcut value; if ((Object)(object)Minimap.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null && (int)Minimap.instance.m_mode != 2) { value = PinManagerPlugin.OpenKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && ((Character)Player.m_localPlayer).TakeInput() && !Minimap.InTextInput()) { Minimap.instance.SetMapMode((MapMode)2); Open(); flag = true; } } if ((Object)(object)canvasObject == (Object)null) { return; } bool flag2 = (Object)(object)Minimap.instance != (Object)null && (int)Minimap.instance.m_mode == 2 && (Object)(object)Player.m_localPlayer != (Object)null; if (IsOpen && !flag2) { Close(); } if (flag2 && !flag) { value = PinManagerPlugin.OpenKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && !Minimap.InTextInput()) { if (IsOpen) { Close(); } else { Open(); } } } AnimatePanel(); AnimatePinsButton(flag2 && !IsOpen && PinManagerPlugin.ShowButton.Value); if (!IsOpen) { return; } if (Input.GetKeyDown((KeyCode)27) && IsTyping) { if (!((Object)(object)search != (Object)null) || !search.isFocused || search.text.Length <= 0) { Close(); return; } search.text = ""; } HandleWheel(); if (Time.realtimeSinceStartup - lastRefresh > 1f) { Refresh(force: false); } if ((Object)(object)deleteButton != (Object)null && deleteArmedUntil > 0f && Time.unscaledTime > deleteArmedUntil) { deleteArmedUntil = 0f; UpdateEditBar(); } if (!(Time.unscaledTime - distanceStamp > 0.5f)) { return; } distanceStamp = Time.unscaledTime; Vector3 position = ((Component)Player.m_localPlayer).transform.position; foreach (PinRow row in rows) { row.UpdateDistance(position); } } private static float Ease(float t) { return 1f - Mathf.Pow(1f - t, 3f); } private static void AnimatePanel() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)panelObject == (Object)null) && !((Object)(object)panelGroup == (Object)null) && !((Object)(object)panelRect == (Object)null) && (IsOpen || !(panelAnim <= 0f) || panelObject.activeSelf)) { panelAnim = Mathf.MoveTowards(panelAnim, IsOpen ? 1f : 0f, Time.unscaledDeltaTime / (IsOpen ? 0.2f : 0.12f)); float num = Ease(panelAnim); panelGroup.alpha = num; panelGroup.blocksRaycasts = IsOpen; panelGroup.interactable = IsOpen; RectTransform? obj = panelRect; RectTransform? obj2 = panelRect; Vector2 val = (panelRect.pivot = LudsTheme.LayoutAnchor); Vector2 anchorMin = (obj2.anchorMax = val); obj.anchorMin = anchorMin; panelRect.anchoredPosition = LudsTheme.LayoutPosition; ((Transform)panelRect).localScale = Vector3.one * PanelScale * (0.92f + 0.08f * num); ShiftMap(num); if (panelAnim <= 0f && !IsOpen && panelObject.activeSelf) { panelObject.SetActive(false); } } } private static void ShiftMap(float e) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_largeRoot == (Object)null) && !((Object)(object)panelRect == (Object)null)) { RectTransform val = (RectTransform)instance.m_largeRoot.transform; if ((Object)(object)mapShiftRect != (Object)(object)val) { mapShiftRect = val; mapMoved = false; } if (!mapMoved) { Vector3[] array = (Vector3[])(object)new Vector3[4]; (((Object)(object)instance.m_mapImageLarge != (Object)null) ? ((Graphic)instance.m_mapImageLarge).rectTransform : val).GetWorldCorners(array); mapBaseRight = array[2].x; mapBaseLeft = array[0].x; Transform parent = ((Transform)val).parent; mapBaseUnit = Mathf.Max(0.0001f, ((Object)(object)parent != (Object)null) ? parent.lossyScale.x : 1f); mapBaseOffsetMax = val.offsetMax; mapBaseOffsetMin = val.offsetMin; } float num = (40f + 780f * PanelScale) * CanvasUnit() + 16f; float num2 = ((LudsTheme.Align == 2) ? Mathf.Max(0f, (mapBaseRight - ((float)Screen.width - num)) / mapBaseUnit) : 0f); float num3 = ((LudsTheme.Align == 0) ? Mathf.Max(0f, (num - mapBaseLeft) / mapBaseUnit) : 0f); mapMoved = e > 0f; val.offsetMax = new Vector2(mapBaseOffsetMax.x - num2 * e, mapBaseOffsetMax.y); val.offsetMin = new Vector2(mapBaseOffsetMin.x + num3 * e, mapBaseOffsetMin.y); if (!Mathf.Approximately(e, lastMapE)) { lastMapE = e; instance.m_pinUpdateRequired = true; LayoutRebuilder.ForceRebuildLayoutImmediate(val); } } } private static void AnimatePinsButton(bool show) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pinsButtonObject == (Object)null) && !((Object)(object)pinsButtonGroup == (Object)null) && !((Object)(object)pinsButtonRect == (Object)null)) { Minimap instance = Minimap.instance; float num = 0f; if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_largeRoot != (Object)null && instance.m_largeRoot.activeInHierarchy) { num = (((Object)(object)instance.m_mapImageLarge != (Object)null) ? ((Graphic)instance.m_mapImageLarge).canvasRenderer.GetInheritedAlpha() : 1f); } if (num <= 0f) { buttonAnim = 0f; } else { buttonAnim = Mathf.MoveTowards(buttonAnim, show ? 1f : 0f, Time.unscaledDeltaTime / (show ? 0.2f : 0.12f)); } bool flag = num > 0f && (show || buttonAnim > 0f); if (pinsButtonObject.activeSelf != flag) { pinsButtonObject.SetActive(flag); } float num2 = Ease(buttonAnim); pinsButtonGroup.alpha = num2 * num; pinsButtonGroup.blocksRaycasts = show; ((Transform)pinsButtonRect).localScale = Vector3.one * PanelScale * (0.92f + 0.08f * num2); } } private static void HandleWheel() { //IL_0028: 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_0042: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_013c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)content == (Object)null) && !((Object)(object)scroll == (Object)null) && !((Object)(object)panelRect == (Object)null)) { float y = Input.mouseScrollDelta.y; Rect rect = scroll.viewport.rect; float height = ((Rect)(ref rect)).height; rect = content.rect; float num = Mathf.Max(0f, ((Rect)(ref rect)).height - height); if (y != 0f && PointerOverPanel) { scrollTarget = Mathf.Clamp(scrollTarget - Mathf.Sign(y) * 52f, 0f, num); } Vector2 anchoredPosition = content.anchoredPosition; if (Mathf.Abs(anchoredPosition.y - lastScrollY) > 0.5f) { scrollTarget = anchoredPosition.y; } scrollTarget = Mathf.Clamp(scrollTarget, 0f, num); anchoredPosition.y = Mathf.Lerp(anchoredPosition.y, scrollTarget, 1f - Mathf.Exp(-14f * Time.unscaledDeltaTime)); if (Mathf.Abs(anchoredPosition.y - scrollTarget) < 0.3f) { anchoredPosition.y = scrollTarget; } content.anchoredPosition = anchoredPosition; lastScrollY = anchoredPosition.y; } } private static string Label(PinData pin) { if (string.IsNullOrWhiteSpace(pin.m_name)) { return "(unnamed)"; } string text = ((Localization.instance != null) ? Localization.instance.Localize(pin.m_name) : pin.m_name); text = text.Trim().TrimStart('$', '#').Replace('_', ' ') .Trim(); if (text.Length != 0) { return text; } return "(unnamed)"; } private static string FavoriteKey(PinData pin) { return pin.m_pos.x.ToString("0.#", CultureInfo.InvariantCulture) + "," + pin.m_pos.z.ToString("0.#", CultureInfo.InvariantCulture); } private static List<string> FavoriteKeys() { if (!((Object)(object)Player.m_localPlayer != (Object)null) || !Player.m_localPlayer.m_customData.TryGetValue("LudsPinManager Favorites", out var value)) { return new List<string>(); } return value.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList(