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 Oof v0.7.1
BepInEx/plugins/FinnWeightUI/Finn.WeightUi.dll
Decompiled 5 days 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.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Finn.WeightUi.Core; using GUIFramework; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Finn.WeightUi")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.7.1.0")] [assembly: AssemblyInformationalVersion("0.7.1+a4716757482938b2288b5c91bc99d3959e90fbcd")] [assembly: AssemblyProduct("Finn.WeightUi")] [assembly: AssemblyTitle("Finn.WeightUi")] [assembly: AssemblyVersion("0.7.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Finn.WeightUi { internal sealed class GridRenderer : IDisposable { private sealed class Cell : IDisposable { internal readonly InventoryElement Native; internal GameObject Background; internal GameObject Label; internal TextMeshProUGUI Text; internal RawImage Badge; internal Texture2D BadgeTexture; internal BoundedLeaseCache<(string, long, long), Texture2D>.Lease PatternLease; internal BoundedLeaseCache<string, byte[]>.Lease MaskLease; internal Sprite Sprite; internal Matrix4x4 IconMatrix; internal Rect IconRect; internal Rect CellRect; internal ItemData Item; internal string MaskKey = ""; internal double Weight = double.NaN; internal int Generation = -1; internal bool Seen; internal bool Pending; internal bool KeepVisible; internal bool MaskAttempted; internal bool PreserveAspect; internal Texture2D Texture => PatternLease?.Value; internal byte[] Mask => MaskLease?.Value; internal Cell(InventoryElement native) { Native = native; } internal void EnsureBackground() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) if (!Object.op_Implicit((Object)(object)Background)) { Background = Create("Finn.WeightUi.Pattern"); PlaceBackground(); RectTransform val = (RectTransform)Background.transform; val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; Vector2 offsetMin = (val.offsetMax = Vector2.zero); val.offsetMin = offsetMin; ((Graphic)Background.AddComponent<RawImage>()).raycastTarget = false; } } internal void Attach(BoundedLeaseCache<(string, long, long), Texture2D>.Lease lease) { try { EnsureBackground(); Background.GetComponent<RawImage>().texture = (Texture)(object)lease.Value; } catch { lease.Dispose(); throw; } BoundedLeaseCache<(string, long, long), Texture2D>.Lease patternLease = PatternLease; PatternLease = lease; patternLease?.Dispose(); } internal void ReleaseMask() { MaskLease?.Dispose(); MaskLease = null; } internal void PlaceBackground() { if (Object.op_Implicit((Object)(object)Background)) { int siblingIndex = ((Component)Native.m_icon).transform.GetSiblingIndex(); int siblingIndex2 = Background.transform.GetSiblingIndex(); Background.transform.SetSiblingIndex((siblingIndex2 < siblingIndex) ? (siblingIndex - 1) : siblingIndex); } } internal void EnsureLabel() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Label)) { Label = Create("Finn.WeightUi.Weight"); Image obj = Label.AddComponent<Image>(); ((Graphic)obj).raycastTarget = false; ((Graphic)obj).color = new Color(0f, 0f, 0f, 0.94f); GameObject val = new GameObject("Number", new Type[1] { typeof(RectTransform) }); try { val.transform.SetParent(Label.transform, false); val.layer = Label.layer; } catch { Object.Destroy((Object)(object)val); throw; } Text = val.AddComponent<TextMeshProUGUI>(); ((Graphic)Text).raycastTarget = false; ((TMP_Text)Text).richText = false; ((TMP_Text)Text).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)Text).overflowMode = (TextOverflowModes)3; ((Graphic)Text).color = new Color(0.933f, 0.914f, 0.875f, 1f); } } internal void EnsureBadge() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00c2: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0100: Expected O, but got Unknown //IL_01b3: 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) if (Object.op_Implicit((Object)(object)Badge)) { return; } GameObject val = new GameObject("Finn.WeightUi.WeightGlyph", new Type[1] { typeof(RectTransform) }); try { val.transform.SetParent(Label.transform, false); val.layer = Label.layer; } catch { Object.Destroy((Object)(object)val); throw; } Badge = val.AddComponent<RawImage>(); ((Graphic)Badge).raycastTarget = false; ((Graphic)Badge).color = ((Graphic)Text).color; RectTransform rectTransform = ((Graphic)Badge).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.anchoredPosition = Vector2.zero; BadgeTexture = new Texture2D(16, 16, (TextureFormat)4, false) { name = "Finn.WeightUi.WeightGlyph", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color32[] array = (Color32[])(object)new Color32[256]; for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { int num = 15 - i; bool flag = num >= 1 && num <= 5 && j >= 5 && j <= 10 && (num < 2 || num > 4 || j < 7 || j > 8); int num2 = ((num < 6) ? 16 : Math.Max(2, 5 - (num - 6) / 3)); bool flag2 = num >= 5 && num <= 14 && j >= num2 && j <= 15 - num2; array[i * 16 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)((flag || flag2) ? 255u : 0u)); } } BadgeTexture.SetPixels32(array); BadgeTexture.Apply(false, true); Badge.texture = (Texture)(object)BadgeTexture; } private GameObject Create(string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); try { val.SetActive(false); val.layer = ((Component)Native).gameObject.layer; val.transform.SetParent(((Component)Native).transform, false); CanvasGroup obj = val.AddComponent<CanvasGroup>(); obj.interactable = false; obj.blocksRaycasts = false; return val; } catch { Object.Destroy((Object)(object)val); throw; } } internal void Hide() { KeepVisible = false; if (Object.op_Implicit((Object)(object)Background)) { Background.SetActive(false); Background.GetComponent<RawImage>().texture = null; } PatternLease?.Dispose(); PatternLease = null; ReleaseMask(); MaskAttempted = false; if (Object.op_Implicit((Object)(object)Label)) { Label.SetActive(false); } } public void Dispose() { Hide(); ReleaseMask(); Object[] obj = new Object[3] { (Object)Background, (Object)Label, (Object)BadgeTexture }; Background = null; Label = null; BadgeTexture = null; Badge = null; Text = null; Sprite = null; Item = null; Exception ex = null; Object[] array = (Object[])(object)obj; foreach (Object val in array) { try { if (!Object.op_Implicit(val)) { continue; } try { GameObject val2 = (GameObject)(object)((val is GameObject) ? val : null); if (val2 != null) { val2.SetActive(false); } } finally { Object.Destroy(val); } } catch (Exception ex2) { if (ex == null) { ex = ex2; } } } if (ex != null) { throw ex; } } } internal const int MaxCells = 256; private readonly FieldInfo elementsField; private readonly Dictionary<InventoryElement, Cell> cells = new Dictionary<InventoryElement, Cell>(); private readonly List<Cell> ordered = new List<Cell>(); private readonly List<InventoryElement> retired = new List<InventoryElement>(); private readonly RoundRobinCursor cursor = new RoundRobinCursor(); private readonly SafeWeightReader weights = new SafeWeightReader(); private readonly PatternRaster raster = new PatternRaster(); private readonly RenderCache cache; private readonly Action<string> warn; private readonly bool external; private InventoryGrid grid; private Inventory inventory; private Player player; private VisualSettings settings; private PatternRasterSettings rasterSettings; private string settingsKey; private bool maskWarned; private int generation; internal GridRenderer(Action<string> warn, RenderCache cache, bool external = false) { this.warn = warn; this.cache = cache; this.external = external; elementsField = typeof(InventoryGrid).GetField("m_elements", BindingFlags.Instance | BindingFlags.NonPublic); if (elementsField == null || elementsField.FieldType != typeof(List<InventoryElement>)) { throw new NotSupportedException("Unsupported native inventory cell collection."); } } internal void Configure(VisualSettings value) { if (!PatternRaster.SupportsMode(value.Mode)) { throw new NotSupportedException("Unsupported pattern " + value.Mode.ToString() + "."); } if (value.Gravity || value.MaterialAuto || value.IconShadow || (value.IconOutline && value.SeparationMode != SeparationMode.Cutout)) { throw new NotSupportedException("Selected preset requests unsupported gravity, material assignment, shadow or black outline."); } settings = value; rasterSettings = PatternRasterSettings.FromVisual(value); settingsKey = RasterCacheKey.Settings(rasterSettings); cache.Shapes.DropQueuedExcept(settingsKey); generation++; } internal void Refresh() { //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: 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_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)localPlayer) || !InventoryGui.IsVisible()) { Clear(); return; } InventoryGrid val = CurrentGrid(instance, localPlayer); if (!Object.op_Implicit((Object)(object)val)) { Clear(); return; } Inventory val2 = val.GetInventory(); if (val2 == null) { Clear(); return; } if ((Object)(object)grid != (Object)(object)val || (Object)(object)player != (Object)(object)localPlayer || inventory != val2) { Clear(); grid = val; inventory = val2; player = localPlayer; } List<InventoryElement> list = elementsField.GetValue(grid) as List<InventoryElement>; int num = list?.Count ?? 0; if (list == null || num != (long)inventory.GetWidth() * (long)inventory.GetHeight() || num > 256) { throw new NotSupportedException("Player grid is inconsistent or exceeds " + 256 + " cells."); } weights.RefreshBackpackRegistry(); string text = weights.TakeNotice(); if (text != null) { warn(text); } foreach (Cell value2 in cells.Values) { value2.Seen = false; } ordered.Clear(); foreach (InventoryElement item in list) { if (!Object.op_Implicit((Object)(object)item)) { continue; } cells.TryGetValue(item, out var value); if (value != null) { value.Seen = true; } ItemData val3 = CurrentItem(item); double? num2 = weights.Read(val3); if (!num2.HasValue || num2.Value <= 0.0 || !((Component)item).gameObject.activeInHierarchy || !Object.op_Implicit((Object)(object)item.m_icon) || !((Behaviour)item.m_icon).enabled) { value?.Hide(); if (value != null) { value.Pending = false; value.Item = null; } continue; } Transform transform = ((Component)item).transform; RectTransform val4 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (Object.op_Implicit((Object)(object)val4)) { Rect rect = val4.rect; if (!(((Rect)(ref rect)).width <= 0f)) { rect = val4.rect; if (!(((Rect)(ref rect)).height <= 0f) && !((Object)(object)((Component)item.m_icon).transform.parent != (Object)(object)((Component)item).transform)) { if (value == null) { value = new Cell(item); cells.Add(item, value); } ordered.Add(value); value.PlaceBackground(); value.Seen = true; Matrix4x4 val5 = ((Transform)((Graphic)item.m_icon).rectTransform).worldToLocalMatrix * ((Transform)val4).localToWorldMatrix; Rect pixelAdjustedRect = ((Graphic)item.m_icon).GetPixelAdjustedRect(); string text2 = ""; if (NeedsMask()) { try { text2 = cache.MaskKey(item.m_icon, val5, pixelAdjustedRect, val4.rect); } catch (Exception ex) { if (!maskWarned) { maskWarned = true; warn("Icon cutout unavailable: " + ex.Message); } } } bool flag = (Object)(object)value.Sprite != (Object)(object)item.m_icon.sprite || value.IconMatrix != val5 || value.IconRect != pixelAdjustedRect || value.CellRect != val4.rect || value.PreserveAspect != item.m_icon.preserveAspect || value.MaskKey != text2; if (flag) { value.ReleaseMask(); value.MaskAttempted = false; } bool flag2 = value.Item != val3; bool flag3 = value.Weight != num2.Value; bool num3 = flag || flag2 || flag3 || value.Generation != generation || (Object)(object)value.Texture == (Object)null; value.Sprite = item.m_icon.sprite; value.IconMatrix = val5; value.IconRect = pixelAdjustedRect; value.CellRect = val4.rect; value.PreserveAspect = item.m_icon.preserveAspect; value.MaskKey = text2; value.Item = val3; value.Weight = num2.Value; value.Generation = generation; if (num3) { value.Pending = true; value.KeepVisible = !flag && !flag2 && !flag3 && Object.op_Implicit((Object)(object)value.Texture); if (!value.KeepVisible) { value.Hide(); } } UpdateLabel(value); continue; } } } throw new NotSupportedException("Native icon hierarchy cannot be safely underlaid."); } retired.Clear(); foreach (KeyValuePair<InventoryElement, Cell> cell in cells) { if (!cell.Value.Seen || !Object.op_Implicit((Object)(object)cell.Key)) { retired.Add(cell.Key); } } foreach (InventoryElement item2 in retired) { cells[item2].Dispose(); cells.Remove(item2); } } internal int Tick(int maximum) { //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)grid)) { return 0; } InventoryGui instance = InventoryGui.instance; if (!Object.op_Implicit((Object)(object)instance) || !InventoryGui.IsVisible() || (Object)(object)Player.m_localPlayer != (Object)(object)player || (Object)(object)CurrentGrid(instance, player) != (Object)(object)grid || grid.GetInventory() != inventory) { Clear(); return 0; } int num = Math.Max(0, maximum); int num2 = 0; int count = ordered.Count; int num3 = cursor.Start(count); for (int i = 0; i < count; i++) { int num4 = num3; num3 = (num3 + 1) % count; Cell cell = ordered[num4]; if (cell.Item == null || !Object.op_Implicit((Object)(object)cell.Native) || !((Component)cell.Native).gameObject.activeInHierarchy || CurrentItem(cell.Native) != cell.Item) { cell.Hide(); } else { if (!cell.Pending) { continue; } bool flag = false; if (NeedsMask() && cell.Mask == null && !cell.MaskAttempted && cell.MaskKey.Length > 0) { cell.MaskLease = cache.FindMask(cell.MaskKey); if (cell.MaskLease == null) { if (num == 0) { continue; } num--; num2++; flag = true; cell.MaskAttempted = true; try { cell.MaskLease = cache.ReadMask(cell.MaskKey, cell.Native.m_icon, (RectTransform)((Component)cell.Native).transform); } catch (Exception ex) { if (!maskWarned) { maskWarned = true; warn("Icon cutout unavailable; backgrounds continue without cutout: " + ex.Message); } } } } double num5 = PatternRaster.CacheWeight(cell.Weight, rasterSettings); (string, long, long) key = RasterCacheKey.Pattern(settingsKey, num5, cell.MaskLease?.Id ?? 0); BoundedLeaseCache<(string, long, long), Texture2D>.Lease lease = cache.FindPattern(key); if (lease == null) { bool flag2 = PatternRaster.IsShapeMode(rasterSettings.Mode) && num5 > 0.0 && cache.ShapeAsync; if (flag2 && !cache.Shapes.IsReady(key)) { cache.RequestShape(key, cell.Weight, rasterSettings, cell.Mask); continue; } if (!flag && num == 0) { continue; } if (!flag) { num--; num2++; } lease = (flag2 ? cache.TakeShape(key, raster, cell.Weight, rasterSettings, cell.Mask) : cache.Render(key, raster, cell.Weight, rasterSettings, cell.Mask)); if (lease == null) { continue; } } cell.Attach(lease); cell.Pending = false; cell.KeepVisible = false; cursor.After(num4, count); Reveal(cell); } } foreach (Cell item in ordered) { if (item.Item != null && Object.op_Implicit((Object)(object)item.Native) && ((Component)item.Native).gameObject.activeInHierarchy && CurrentItem(item.Native) == item.Item) { Reveal(item); } } return num2; } private bool NeedsMask() { if (!settings.IconOutline) { return PatternRaster.IsShapeMode(settings.Mode); } return true; } private InventoryGrid CurrentGrid(InventoryGui gui, Player local) { if (!Object.op_Implicit((Object)(object)gui) || !Object.op_Implicit((Object)(object)local)) { return null; } if (!external) { InventoryGrid playerGrid = gui.m_playerGrid; if (!Object.op_Implicit((Object)(object)playerGrid) || !((Behaviour)playerGrid).isActiveAndEnabled || !((Component)playerGrid).gameObject.activeInHierarchy || playerGrid.GetInventory() != ((Humanoid)local).GetInventory()) { return null; } return playerGrid; } if (!gui.IsContainerOpen() || !Object.op_Implicit((Object)(object)gui.m_container) || !((Component)gui.m_container).gameObject.activeInHierarchy) { return null; } InventoryGrid containerGrid = gui.ContainerGrid; if (!Object.op_Implicit((Object)(object)containerGrid) || !((Behaviour)containerGrid).isActiveAndEnabled || !((Component)containerGrid).gameObject.activeInHierarchy || containerGrid.GetInventory() == null || containerGrid.GetInventory() == ((Humanoid)local).GetInventory()) { return null; } return containerGrid; } private ItemData CurrentItem(InventoryElement native) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)native) || !native.m_used || inventory == null) { return null; } Vector2i position = native.Position; if (position.x < 0 || position.y < 0 || position.x >= inventory.GetWidth() || position.y >= inventory.GetHeight()) { return null; } return inventory.GetItemAt(position.x, position.y); } private bool Focused(InventoryElement native) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)grid.m_uiGroup) || !grid.m_uiGroup.IsActive) { return false; } if (ZInput.IsExclusiveGamepadActive() || ZInput.IsTouchActive()) { if (Object.op_Implicit((Object)(object)native.m_selected)) { return native.m_selected.activeInHierarchy; } return false; } RectTransform elementRectTransform = native.GetElementRectTransform(); if (Object.op_Implicit((Object)(object)elementRectTransform)) { Rect rect = elementRectTransform.rect; return ((Rect)(ref rect)).Contains(((Transform)elementRectTransform).InverseTransformPoint(ZInput.pointerPosition)); } return false; } private void Reveal(Cell cell) { bool flag = Focused(cell.Native); if (Object.op_Implicit((Object)(object)cell.Background)) { cell.Background.SetActive((!cell.Pending || cell.KeepVisible) && (!settings.RevealPattern || flag)); } if (Object.op_Implicit((Object)(object)cell.Label)) { cell.Label.SetActive(settings.Numbers && (!settings.RevealLabels || flag)); } } private void UpdateLabel(Cell cell) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) if (!settings.Numbers) { if (Object.op_Implicit((Object)(object)cell.Label)) { cell.Label.SetActive(false); } return; } InventoryElement native = cell.Native; if (Object.op_Implicit((Object)(object)native.m_amount) && Object.op_Implicit((Object)(object)native.m_amount.font)) { cell.EnsureLabel(); TextMeshProUGUI text = cell.Text; ((TMP_Text)text).font = native.m_amount.font; ((TMP_Text)text).fontSharedMaterial = native.m_amount.fontSharedMaterial; RectTransform val = (RectTransform)((Component)native).transform; Rect rect = val.rect; float width = ((Rect)(ref rect)).width; rect = val.rect; float height = ((Rect)(ref rect)).height; ((TMP_Text)text).fontSize = Mathf.Max(12f, width * 0.18f) * (float)settings.LabelSize; ((TMP_Text)text).alignment = (TextAlignmentOptions)513; ((TMP_Text)text).margin = Vector4.zero; bool flag = settings.LabelStyle == LabelStyle.Icon; ((TMP_Text)text).text = cell.Weight.ToString("0.#", CultureInfo.InvariantCulture) + (flag ? "" : " wt"); Vector2 preferredValues = ((TMP_Text)text).GetPreferredValues(((TMP_Text)text).text); if (!VisualSettings.Finite(preferredValues.x) || !VisualSettings.Finite(preferredValues.y) || preferredValues.x <= 0f || preferredValues.y <= 0f) { throw new NotSupportedException("Weight label font returned invalid measurement."); } float num = Mathf.Max(2f, width * 0.035f); float num2 = (flag ? ((TMP_Text)text).fontSize : 0f); float num3 = (flag ? num : 0f); float num4 = preferredValues.x + num2 + num3 + 2f * num; float num5 = Mathf.Max(preferredValues.y, num2) + 2f * num; float num6 = Mathf.Min(1f, Mathf.Min(width * 0.94f / num4, height * 0.45f / num5)); ((TMP_Text)text).fontSize = ((TMP_Text)text).fontSize * num6; num *= num6; num2 *= num6; num3 *= num6; preferredValues *= num6; num4 *= num6; num5 *= num6; BadgeRect badgeRect = BadgeLayout.Place(width, height, num4, num5, settings.LabelCorner, NativeCountBounds(native.m_amount, val)); RectTransform val2 = (RectTransform)cell.Label.transform; Vector2 val3 = (val2.pivot = Vector2.zero); Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; val2.anchoredPosition = new Vector2((float)badgeRect.X, (float)badgeRect.Y); val2.sizeDelta = new Vector2((float)badgeRect.Width, (float)badgeRect.Height); RectTransform rectTransform = ((TMP_Text)text).rectTransform; val3 = (rectTransform.pivot = Vector2.zero); anchorMin = (rectTransform.anchorMax = val3); rectTransform.anchorMin = anchorMin; rectTransform.anchoredPosition = new Vector2(num + num2 + num3, num); rectTransform.sizeDelta = new Vector2(preferredValues.x, num5 - 2f * num); if (flag) { cell.EnsureBadge(); } if (Object.op_Implicit((Object)(object)cell.Badge)) { ((Component)cell.Badge).gameObject.SetActive(flag); ((Graphic)cell.Badge).rectTransform.sizeDelta = new Vector2(num2, num2); ((Graphic)cell.Badge).rectTransform.anchoredPosition = new Vector2(num, 0f); } Reveal(cell); } } private BadgeRect NativeCountBounds(TMP_Text count, RectTransform cell) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00f6: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)count) || !((Behaviour)count).isActiveAndEnabled || !((Component)count).gameObject.activeInHierarchy || string.IsNullOrEmpty(count.text)) { return default(BadgeRect); } Bounds textBounds = count.textBounds; if (((Bounds)(ref textBounds)).size.x <= 0f || ((Bounds)(ref textBounds)).size.y <= 0f) { return default(BadgeRect); } Matrix4x4 val = ((Transform)cell).worldToLocalMatrix * count.transform.localToWorldMatrix; Vector3 val2 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(((Bounds)(ref textBounds)).min); Vector3 val3 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(((Bounds)(ref textBounds)).max); float num = Mathf.Min(val2.x, val3.x); Rect rect = cell.rect; float num2 = num - ((Rect)(ref rect)).xMin; float num3 = Mathf.Min(val2.y, val3.y); rect = cell.rect; float num4 = num3 - ((Rect)(ref rect)).yMin; return new BadgeRect(num2 - 1f, num4 - 1f, Mathf.Abs(val3.x - val2.x) + 2f, Mathf.Abs(val3.y - val2.y) + 2f); } private void Clear() { Exception ex = null; foreach (Cell value in cells.Values) { try { value.Dispose(); } catch (Exception ex2) { if (ex == null) { ex = ex2; } } } cells.Clear(); ordered.Clear(); cursor.Reset(); retired.Clear(); grid = null; inventory = null; player = null; if (ex != null) { throw ex; } } public void Dispose() { Clear(); } } internal static class IconSilhouette { internal static byte[] Read(Image icon, RectTransform cell) { //IL_001d: 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_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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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) //IL_01fc: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) Sprite sprite = icon.sprite; if (!Object.op_Implicit((Object)(object)sprite) || !Object.op_Implicit((Object)(object)sprite.texture) || (int)icon.type != 0 || (sprite.packed && (int)sprite.packingRotation != 0)) { throw new NotSupportedException("Icon cutout requires an unrotated Simple sprite."); } Texture2D texture = sprite.texture; Rect textureRect = sprite.textureRect; Vector2 textureRectOffset = sprite.textureRectOffset; Rect rect = sprite.rect; Rect pixelAdjustedRect = ((Graphic)icon).GetPixelAdjustedRect(); if (!(((Rect)(ref rect)).width <= 0f) && !(((Rect)(ref rect)).height <= 0f) && !(((Rect)(ref pixelAdjustedRect)).width <= 0f) && !(((Rect)(ref pixelAdjustedRect)).height <= 0f)) { Rect rect2 = cell.rect; if (!(((Rect)(ref rect2)).width <= 0f)) { rect2 = cell.rect; if (!(((Rect)(ref rect2)).height <= 0f)) { if (icon.preserveAspect) { float num = ((Rect)(ref rect)).width / ((Rect)(ref rect)).height; if (num > ((Rect)(ref pixelAdjustedRect)).width / ((Rect)(ref pixelAdjustedRect)).height) { float num2 = ((Rect)(ref pixelAdjustedRect)).width / num; ((Rect)(ref pixelAdjustedRect)).y = ((Rect)(ref pixelAdjustedRect)).y + (((Rect)(ref pixelAdjustedRect)).height - num2) * ((Graphic)icon).rectTransform.pivot.y; ((Rect)(ref pixelAdjustedRect)).height = num2; } else { float num3 = ((Rect)(ref pixelAdjustedRect)).height * num; ((Rect)(ref pixelAdjustedRect)).x = ((Rect)(ref pixelAdjustedRect)).x + (((Rect)(ref pixelAdjustedRect)).width - num3) * ((Graphic)icon).rectTransform.pivot.x; ((Rect)(ref pixelAdjustedRect)).width = num3; } } RenderTexture val = null; Texture2D val2 = null; RenderTexture active = RenderTexture.active; try { val = RenderTexture.GetTemporary(127, 127, 0, (RenderTextureFormat)0); Graphics.Blit((Texture)(object)texture, val, new Vector2(((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height), new Vector2(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height)); RenderTexture.active = val; val2 = new Texture2D(127, 127, (TextureFormat)4, false); val2.ReadPixels(new Rect(0f, 0f, 127f, 127f), 0, 0, false); Color32[] pixels = val2.GetPixels32(); byte[] array = new byte[16129]; Matrix4x4 val3 = ((Transform)((Graphic)icon).rectTransform).worldToLocalMatrix * ((Transform)cell).localToWorldMatrix; Rect rect3 = cell.rect; for (int i = 0; i < 127; i++) { for (int j = 0; j < 127; j++) { Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(new Vector3(((Rect)(ref rect3)).x + ((float)j + 0.5f) / 127f * ((Rect)(ref rect3)).width, ((Rect)(ref rect3)).y + ((float)(127 - i) - 0.5f) / 127f * ((Rect)(ref rect3)).height, 0f)); float num4 = (val4.x - ((Rect)(ref pixelAdjustedRect)).x) / ((Rect)(ref pixelAdjustedRect)).width * ((Rect)(ref rect)).width - textureRectOffset.x; float num5 = (val4.y - ((Rect)(ref pixelAdjustedRect)).y) / ((Rect)(ref pixelAdjustedRect)).height * ((Rect)(ref rect)).height - textureRectOffset.y; if (!(num4 < 0f) && !(num5 < 0f) && !(num4 >= ((Rect)(ref textureRect)).width) && !(num5 >= ((Rect)(ref textureRect)).height)) { int num6 = Math.Min(126, (int)(num4 / ((Rect)(ref textureRect)).width * 127f)); int num7 = Math.Min(126, (int)(num5 / ((Rect)(ref textureRect)).height * 127f)); array[i * 127 + j] = pixels[num7 * 127 + num6].a; } } } return array; } finally { RenderTexture.active = active; if (Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)val2); } if (Object.op_Implicit((Object)(object)val)) { RenderTexture.ReleaseTemporary(val); } } } } } throw new NotSupportedException("Icon cutout requires positive layout dimensions."); } } internal sealed class LiveEditor : IDisposable { internal sealed class DraftState { internal readonly string Path; internal readonly string Selected; internal readonly string Name; internal readonly JObject Basis; internal readonly VisualSettings Draft; internal DraftState(string path, string selected, string name, JObject basis, VisualSettings draft) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Path = path; Selected = selected; Name = name; Basis = (JObject)((JToken)basis).DeepClone(); Draft = draft.Validated(); } } private readonly BrowserPresetLibrary presets; private readonly PresetThumbnails thumbnails; private readonly Action<VisualSettings> preview; private readonly string localPath; private JObject basis; private VisualSettings draft; private Rect window; private Vector2 scroll; private float scale; private int uiScalePercent; private bool uiScalePending; private float uiScaleSaveAt; private Texture2D background; private Texture2D buttonFill; private Texture2D buttonHover; private Texture2D selectedFill; private GUISkin ownedSkin; private GUIStyle titleStyle; private GUIStyle headingStyle; private GUIStyle hintStyle; private GUIStyle headerStatusStyle; private GUIStyle valueStyle; private GUIStyle activeButtonStyle; private GUIStyle quietButtonStyle; private GUIStyle statusStyle; private string name = ""; private string status = ""; private string requestedPreset; private bool requestedFromBar; private bool showAdvanced; private bool confirmingOriginal; private bool open; private bool dirty; private bool pending; private bool placed; private bool ownsKeyboard; private bool previousKeyboard; private bool clearFocusPending; private float previewAt; private int side; private bool noRoom; private bool noRoomNoticeShown; private Action deferredOption; private GameObject inputShield; private RectTransform shieldRect; private const int WindowId = 9202603; internal bool IsOpen => open; internal bool IsEditingName { get; private set; } internal bool IsDirty => dirty; internal Action<int> ConfirmOriginalSelection { private get; set; } internal VisualSettings Draft => draft; internal string Selected => presets.Selected; internal string RecoveryMessage => presets.RecoveryMessage; internal LiveEditor(string originals, string localPath, string defaultName, VisualSettings[] configuredOriginals, Action<VisualSettings> preview, RenderCache cache = null) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown this.localPath = localPath; presets = new BrowserPresetLibrary(originals, localPath, defaultName, configuredOriginals, LoadBundledPresets("Finn.WeightUi.TopRowPresets.json"), LoadBundledPresets("Finn.WeightUi.ShapePresets.json")); thumbnails = new PresetThumbnails(presets, cache); this.preview = preview; basis = (JObject)presets.Entry(presets.Selected)["settings"]; draft = presets.Visual(presets.Selected); name = presets.DisplayName(presets.Selected); status = presets.RecoveryMessage; uiScalePercent = presets.UiScalePercent; } private static string LoadBundledPresets(string resource) { using Stream stream = typeof(LiveEditor).Assembly.GetManifestResourceStream(resource); if (stream == null) { return null; } using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } internal DraftState CaptureDraft() { if (!dirty) { return null; } return new DraftState(localPath, presets.Selected, name, basis, draft); } internal bool RestoreDraft(DraftState saved) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown if (saved == null || saved.Path != localPath || !presets.Names.Contains(saved.Selected)) { return false; } if (presets.Selected != saved.Selected) { status = "Unsaved edits for " + presets.DisplayName(saved.Selected) + " are held for this session. Select that look before restoring them."; return false; } JObject val = (JObject)((JToken)saved.Basis).DeepClone(); VisualSettings value = saved.Draft.Validated(); BrowserPresetLibrary.WithVisual(val, value); basis = val; draft = value; name = saved.Name; dirty = true; pending = false; status = "Unsaved edits restored for this game session. Save as new or update selected to keep them."; return true; } internal void Toggle() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) open = !open; if (open) { noRoomNoticeShown = false; showAdvanced = false; scroll = Vector2.zero; } if (!open) { requestedPreset = null; requestedFromBar = false; deferredOption = null; StopTyping(); DestroyShield(); } } internal int TickPreviews(int maximum) { if (!open || noRoom) { return 0; } return thumbnails.Tick(maximum); } internal void Tick(float now) { if (uiScalePending && now >= uiScaleSaveAt) { uiScalePending = false; Safe(delegate { presets.SetUiScalePercent(uiScalePercent); }); } if (pending && now >= previewAt) { pending = false; preview(draft.Validated()); } } internal void GuardNativeInput() { if (!open || !IsEditingName) { StopTyping(); return; } if (!ownsKeyboard) { previousKeyboard = ZInput.VirtualKeyboardOpen; ZInput.VirtualKeyboardOpen = true; ownsKeyboard = true; } ZInput.ResetButtonStatus("Inventory"); ZInput.ResetButtonStatus("Use"); ZInput.ResetButtonStatus("JoyButtonB"); ZInput.ResetButtonStatus("JoyButtonY"); } internal void SuspendInput() { deferredOption = null; StopTyping(); DestroyShield(); } internal bool Select(string presetName) { return RequestSelection(presetName, fromBar: false); } private bool RequestSelection(string presetName, bool fromBar) { if (presetName == presets.Selected) { return true; } if (dirty && !confirmingOriginal) { requestedPreset = presetName; requestedFromBar = fromBar; open = true; showAdvanced = false; StopTyping(); return false; } LoadPreset(presetName); return true; } private void LoadPreset(string presetName) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown VisualSettings obj = presets.Visual(presetName); JObject val = (JObject)presets.Entry(presetName)["settings"]; presets.Select(presetName); draft = obj; basis = val; name = presets.DisplayName(presetName); dirty = (pending = false); deferredOption = null; requestedPreset = null; requestedFromBar = false; status = "Loaded " + presets.DisplayName(presetName); preview(obj); } internal bool SelectOriginal(int index) { if (index < 1 || index > 3) { throw new ArgumentOutOfRangeException("index"); } return RequestSelection(presets.Names.ElementAt(index - 1), fromBar: true); } private void SelectGalleryLook(string presetName) { if (presetName == presets.Selected) { return; } if (presets.IsOriginal(presetName) && ConfirmOriginalSelection != null) { int num = Array.IndexOf(presets.Names.Take(3).ToArray(), presetName) + 1; if (num < 1) { throw new ArgumentException("Original look is no longer available."); } ConfirmOriginalSelection(num); } else { Select(presetName); } } internal void ReportSelectionError(string message) { status = "Preset switch failed: " + message + ". Your edits are still available."; } internal void ReportRecoveryDeferred(string message) { status = message; } internal bool RecoverFailedSwitch(string previousLook, DraftState previousDraft) { if (previousLook == null) { return false; } if (presets.Selected != previousLook) { LoadPreset(previousLook); } if (previousDraft != null) { return RestoreDraft(previousDraft); } return true; } internal void Draw(InventoryGui gui) { //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_0151: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Invalid comparison between Unknown and I4 if (!open || !PresetBar.CanInteract(gui)) { StopTyping(); DestroyShield(); return; } if (!PlaceBesideInventory(gui)) { NotifyNoRoom(); StopTyping(); DestroyShield(); return; } noRoomNoticeShown = false; PlaceShield(gui); int depth = GUI.depth; Matrix4x4 matrix = GUI.matrix; GUISkin skin = GUI.skin; Color contentColor = GUI.contentColor; try { EnsureAppearance(skin); GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, 1f)); GUI.skin = ownedSkin; GUI.contentColor = new Color(0.95f, 0.95f, 0.91f, 1f); GUI.depth = -50; if (clearFocusPending) { GUI.FocusControl(""); clearFocusPending = false; } if (deferredOption != null && Event.current != null && (int)Event.current.type == 8) { Action action = deferredOption; deferredOption = null; action(); Changed(); } window = GUILayout.Window(9202603, window, new WindowFunction(DrawWindow), "", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(((Rect)(ref window)).width), GUILayout.Height(((Rect)(ref window)).height) }); if (!open) { StopTyping(); DestroyShield(); return; } ClampWindow(gui); PlaceShield(gui); IsEditingName = GUI.GetNameOfFocusedControl() == "Finn.WeightUi.PresetName"; if (!IsEditingName) { StopTyping(); } } finally { GUI.contentColor = contentColor; GUI.skin = skin; GUI.matrix = matrix; GUI.depth = depth; } } private void EnsureAppearance(GUISkin source) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Expected O, but got Unknown //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Expected O, but got Unknown //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Expected O, but got Unknown //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Expected O, but got Unknown //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Expected O, but got Unknown //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Expected O, but got Unknown //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Expected O, but got Unknown //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)background)) { background = Solid(new Color32((byte)22, (byte)25, (byte)30, byte.MaxValue)); buttonFill = Solid(new Color32((byte)43, (byte)46, (byte)49, byte.MaxValue)); buttonHover = Solid(new Color32((byte)58, (byte)61, (byte)63, byte.MaxValue)); selectedFill = Solid(new Color32((byte)223, (byte)173, (byte)91, byte.MaxValue)); } if (!Object.op_Implicit((Object)(object)ownedSkin)) { ownedSkin = ScriptableObject.CreateInstance<GUISkin>(); ownedSkin.font = source.font; ownedSkin.box = new GUIStyle(source.box); ownedSkin.label = new GUIStyle(source.label); ownedSkin.button = new GUIStyle(source.button); ownedSkin.toggle = new GUIStyle(source.toggle); ownedSkin.textField = new GUIStyle(source.textField); ownedSkin.textArea = new GUIStyle(source.textArea); ownedSkin.window = new GUIStyle(source.window); ownedSkin.scrollView = new GUIStyle(source.scrollView); ownedSkin.horizontalSlider = new GUIStyle(source.horizontalSlider); ownedSkin.horizontalSliderThumb = new GUIStyle(source.horizontalSliderThumb); ownedSkin.verticalSlider = new GUIStyle(source.verticalSlider); ownedSkin.verticalSliderThumb = new GUIStyle(source.verticalSliderThumb); ownedSkin.horizontalScrollbar = new GUIStyle(source.horizontalScrollbar); ownedSkin.horizontalScrollbarThumb = new GUIStyle(source.horizontalScrollbarThumb); ownedSkin.horizontalScrollbarLeftButton = new GUIStyle(source.horizontalScrollbarLeftButton); ownedSkin.horizontalScrollbarRightButton = new GUIStyle(source.horizontalScrollbarRightButton); ownedSkin.verticalScrollbar = new GUIStyle(source.verticalScrollbar); ownedSkin.verticalScrollbarThumb = new GUIStyle(source.verticalScrollbarThumb); ownedSkin.verticalScrollbarUpButton = new GUIStyle(source.verticalScrollbarUpButton); ownedSkin.verticalScrollbarDownButton = new GUIStyle(source.verticalScrollbarDownButton); GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[5] { ownedSkin.label, ownedSkin.button, ownedSkin.toggle, ownedSkin.textField, ownedSkin.textArea }; foreach (GUIStyle obj in array) { obj.fontSize = 14; obj.normal.textColor = new Color(0.95f, 0.95f, 0.91f, 1f); obj.hover.textColor = Color.white; obj.active.textColor = Color.white; obj.focused.textColor = Color.white; } ownedSkin.button.padding = new RectOffset(8, 8, 5, 5); ownedSkin.button.alignment = (TextAnchor)4; ownedSkin.button.wordWrap = true; ownedSkin.button.normal.background = buttonFill; ownedSkin.button.hover.background = buttonHover; ownedSkin.button.active.background = buttonHover; ownedSkin.textField.padding = new RectOffset(8, 8, 5, 5); titleStyle = new GUIStyle(ownedSkin.label) { fontSize = 17, fontStyle = (FontStyle)1 }; titleStyle.normal.textColor = new Color(0.95f, 0.77f, 0.47f, 1f); headingStyle = new GUIStyle(ownedSkin.label) { fontSize = 14, fontStyle = (FontStyle)1 }; headingStyle.normal.textColor = new Color(0.91f, 0.74f, 0.46f, 1f); hintStyle = new GUIStyle(ownedSkin.label) { fontSize = 12, wordWrap = true }; hintStyle.normal.textColor = new Color(0.72f, 0.73f, 0.69f, 1f); headerStatusStyle = new GUIStyle(hintStyle) { wordWrap = false, clipping = (TextClipping)1 }; valueStyle = new GUIStyle(ownedSkin.label) { alignment = (TextAnchor)5, fontStyle = (FontStyle)1 }; valueStyle.normal.textColor = new Color(0.96f, 0.8f, 0.52f, 1f); activeButtonStyle = new GUIStyle(ownedSkin.button); activeButtonStyle.normal.background = selectedFill; activeButtonStyle.normal.textColor = new Color(0.13f, 0.11f, 0.08f, 1f); activeButtonStyle.hover.background = selectedFill; activeButtonStyle.hover.textColor = new Color(0.08f, 0.07f, 0.05f, 1f); activeButtonStyle.active.background = selectedFill; activeButtonStyle.active.textColor = activeButtonStyle.normal.textColor; quietButtonStyle = new GUIStyle(ownedSkin.button) { fontSize = 12 }; statusStyle = new GUIStyle(hintStyle) { fontSize = 12 }; } } private static Texture2D Solid(Color32 color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, Color32.op_Implicit(color)); val.Apply(false, true); return val; } private void DrawWindow(int id) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_0299: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref window)).width, ((Rect)(ref window)).height), (Texture)(object)background, (ScaleMode)0, false); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("OOF", titleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label(showAdvanced ? "SETTINGS" : "PRESET GALLERY", headingStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)(showAdvanced ? 90 : 145)) }); if (GUILayout.Button("×", quietButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) })) { Close(); } GUILayout.EndHorizontal(); if (noRoom) { GUILayout.Label("No room for the editor. Close the chest or lower game UI scale, then reopen Oof.", hintStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); return; } string text = presets.DisplayName(presets.Selected); GUILayout.Label(new GUIContent(((text.Length > 29) ? (text.Substring(0, 28) + "…") : text) + (dirty ? " • Unsaved" : " • Saved"), text), headerStatusStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(19f) }); if (requestedPreset != null) { DrawSwitchConfirmation(); } else { scroll = GUILayout.BeginScrollView(scroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(Mathf.Max(45f, ((Rect)(ref window)).height - 112f)) }); if (showAdvanced) { DrawSavedLooks(); DrawMainControls(); DrawAdvancedControls(); DrawActions(); } else { DrawGallery(); } GUILayout.EndScrollView(); if (GUILayout.Button(showAdvanced ? "‹ Back to gallery" : "Advanced settings ▾", quietButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { showAdvanced = !showAdvanced; scroll = Vector2.zero; StopTyping(); } if (!showAdvanced && !string.IsNullOrEmpty(status)) { GUILayout.Label(status, statusStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) }); } } GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref window)).width - 34f, 23f)); } private void DrawGallery() { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Choose a look · preview shows its pattern at 100 wt, without an item icon.", hintStyle, Array.Empty<GUILayoutOption>()); string[] names = thumbnails.Names; int num = 0; while (num < names.Length) { int num2 = presets.GalleryGroup(names[num]); int i; for (i = num; i < names.Length && presets.GalleryGroup(names[i]) == num2; i++) { } Heading(num2 switch { 2 => "Shape-aware", 0 => "Designer's picks", _ => "Featured looks", }); if (num2 == 2) { GUILayout.Label("Patterns that follow the item's own outline. Previews use a stand-in shape.", hintStyle, Array.Empty<GUILayoutOption>()); } for (int j = num; j < i; j += 3) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int k = 0; k < 3; k++) { int num3 = j + k; Rect rect = GUILayoutUtility.GetRect(84f, 135f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(135f) }); if (num3 < i) { DrawGalleryCard(rect, names[num3]); } if (k < 2) { GUILayout.Space(5f); } } GUILayout.EndHorizontal(); GUILayout.Space(6f); } num = i; } } private void DrawGalleryCard(Rect card, string presetName) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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) bool flag = presetName == presets.Selected; if ((int)Event.current.type == 7) { Color color = GUI.color; GUI.color = (flag ? new Color(0.71f, 0.51f, 0.26f, 1f) : new Color(0.23f, 0.24f, 0.24f, 1f)); GUI.DrawTexture(card, (Texture)(object)Texture2D.whiteTexture); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref card)).x + 6f, ((Rect)(ref card)).y + 6f, ((Rect)(ref card)).width - 12f, 73f); GUI.color = new Color(0.08f, 0.1f, 0.11f, 1f); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture); Texture2D val2 = thumbnails.TextureFor(presetName); if (Object.op_Implicit((Object)(object)val2)) { GUI.color = Color.white; GUI.DrawTexture(val, (Texture)(object)val2, (ScaleMode)2, true); } GUI.color = color; } if (!Object.op_Implicit((Object)(object)thumbnails.TextureFor(presetName))) { GUI.Label(new Rect(((Rect)(ref card)).x + 9f, ((Rect)(ref card)).y + 26f, ((Rect)(ref card)).width - 18f, 32f), thumbnails.Failed(presetName) ? "Preview unavailable" : "Loading…", hintStyle); } GUI.Label(new Rect(((Rect)(ref card)).x + 5f, ((Rect)(ref card)).y + 83f, ((Rect)(ref card)).width - 10f, 34f), presets.DisplayName(presetName), hintStyle); GUI.Label(new Rect(((Rect)(ref card)).x + 5f, ((Rect)(ref card)).y + 118f, ((Rect)(ref card)).width - 10f, 15f), "100 wt · pattern", hintStyle); if (GUI.Button(card, GUIContent.none, GUIStyle.none)) { Safe(delegate { SelectGalleryLook(presetName); }); } } private void DrawMainControls() { Heading("Pattern appearance"); GUILayout.Label("Choose a motif, then tune its presence on the item grid.", hintStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Option("Waves", draft.Mode == PatternKind.Water, delegate { draft.Mode = PatternKind.Water; }); Option("Deep", draft.Mode == PatternKind.DeepWater, delegate { draft.Mode = PatternKind.DeepWater; }); Option("Dots", draft.Mode == PatternKind.Dots, delegate { draft.Mode = PatternKind.Dots; }); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Option("Cross", draft.Mode == PatternKind.Cross, delegate { draft.Mode = PatternKind.Cross; }); Option("Lattice", draft.Mode == PatternKind.Lattice, delegate { draft.Mode = PatternKind.Lattice; }); Option("Hatch", draft.Mode == PatternKind.Hatch, delegate { draft.Mode = PatternKind.Hatch; }); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Option("Wash", draft.Mode == PatternKind.Wash, delegate { draft.Mode = PatternKind.Wash; }); Option("Rings", draft.Mode == PatternKind.Rings, delegate { draft.Mode = PatternKind.Rings; }); Option("Strata", draft.Mode == PatternKind.Strata, delegate { draft.Mode = PatternKind.Strata; }); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Option("Sink", draft.Mode == PatternKind.Sink, delegate { draft.Mode = PatternKind.Sink; }); Option("Contour", draft.Mode == PatternKind.Contour, delegate { draft.Mode = PatternKind.Contour; }); GUILayout.EndHorizontal(); GUILayout.Label(MotifDescription(draft.Mode), hintStyle, Array.Empty<GUILayoutOption>()); if (PatternRaster.IsShapeMode(draft.Mode)) { GUILayout.Label("Shape-aware looks take lines, depth, gap, colour ramp, core whitening and their weight range from the lab look. Those channels are kept when you save; here you can tune overall opacity, labels and the icon gap.", hintStyle, Array.Empty<GUILayoutOption>()); Heading("Pattern strength"); Range("Opacity", draft.Strength, 0.05, 1.0, 0.01, delegate(double v) { draft.Strength = v; }); Heading("On the item"); Toggle("Show weight labels", draft.Numbers, delegate(bool v) { draft.Numbers = v; }); Toggle("Clear space around icon", draft.IconOutline, delegate(bool v) { draft.IconOutline = v; }); GUILayout.Label("Changes appear in your open inventory after a short pause.", hintStyle, Array.Empty<GUILayoutOption>()); return; } DrawMotifPreview(); Heading("Colour"); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Option("Amber", draft.Palette == PaletteKind.Amber, delegate { draft.Palette = PaletteKind.Amber; }); Option("Chalk", draft.Palette == PaletteKind.Chalk, delegate { draft.Palette = PaletteKind.Chalk; }); Option("Copper", draft.Palette == PaletteKind.Copper, delegate { draft.Palette = PaletteKind.Copper; }); GUILayout.EndHorizontal(); Heading("Pattern strength"); GUILayout.Label("Faint / solid sketches. Sets the maximum, or the fixed amount when weight response is off.", hintStyle, Array.Empty<GUILayoutOption>()); DrawComparisonPreview(density: false); Range("Opacity", draft.Strength, 0.05, 1.0, 0.01, delegate(double v) { draft.Strength = v; }); Toggle("Vary opacity with weight", draft.OpacityByWeight, delegate(bool v) { draft.OpacityByWeight = v; }); Heading("Pattern detail"); GUILayout.Label((draft.Mode == PatternKind.Wash) ? "Wash is a continuous colour field; density has no visible effect." : "Sparse / dense sketches. This percentage controls pattern detail, not a literal line count.", hintStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label(draft.DensityByWeight ? "Density is the maximum at full response to weight." : "Density is fixed at this level for visible items.", hintStyle, Array.Empty<GUILayoutOption>()); if (draft.Mode != PatternKind.Wash) { DrawComparisonPreview(density: true); Range("Density", draft.PatternDensity, 0.25, 2.5, 0.01, delegate(double v) { draft.PatternDensity = v; }); Toggle("Vary density with weight", draft.DensityByWeight, delegate(bool v) { draft.DensityByWeight = v; }); } Heading("On the item"); Toggle("Show weight labels", draft.Numbers, delegate(bool v) { draft.Numbers = v; }); Toggle("Clear space around icon", draft.IconOutline, delegate(bool v) { draft.IconOutline = v; }); GUILayout.Label("Changes appear in your open inventory after a short pause.", hintStyle, Array.Empty<GUILayoutOption>()); } private void DrawAdvancedControls() { GUILayout.Space(10f); if (PatternRaster.IsShapeMode(draft.Mode)) { DrawLabelAndPanelControls(); return; } Heading("Response to item weight"); GUILayout.Label("When weight response is on, the main sliders set the maximum. Below, choose when the effect begins and reaches that amount.", hintStyle, Array.Empty<GUILayoutOption>()); Range("Weight scale (wt)", draft.Scale, 1.0, 420.0, 1.0, delegate(double v) { draft.Scale = v; }); Toggle("Perceptual weight scale", draft.Perceptual, delegate(bool v) { draft.Perceptual = v; }); Range("Minimum visible weight (wt)", draft.MinimumWeight, 0.0, 420.0, 1.0, delegate(double v) { draft.MinimumWeight = v; }); Range("Pattern cutoff (wt)", draft.DensityMinWeight, 0.0, 420.0, 1.0, delegate(double v) { draft.DensityMinWeight = v; }); GUILayout.Label("The pattern cutoff hides lighter line and dot patterns, even at fixed density. Wash uses the minimum visible weight instead.", hintStyle, Array.Empty<GUILayoutOption>()); if (draft.OpacityByWeight) { Heading("Opacity ramp"); Range("Minimum opacity", draft.MinimumVisibility, 0.0, 1.0, 0.01, delegate(double v) { draft.MinimumVisibility = v; }); Range("Start weight (wt)", draft.HeavyThreshold, 0.0, 420.0, 1.0, delegate(double v) { draft.HeavyThreshold = Math.Min(v, draft.FadeEnd); }); Range("Full opacity at (wt)", draft.FadeEnd, 0.0, 420.0, 1.0, delegate(double v) { draft.FadeEnd = Math.Max(v, draft.HeavyThreshold); }); } if (draft.DensityByWeight) { Heading("Density ramp"); Range("Minimum density", draft.DensityFloor, 0.0, 1.0, 0.01, delegate(double v) { draft.DensityFloor = v; }); Range("Start weight (wt)", draft.DensityStart, 0.0, 420.0, 1.0, delegate(double v) { draft.DensityStart = Math.Min(v, draft.DensityEnd); }); Range("Full density at (wt)", draft.DensityEnd, 0.0, 420.0, 1.0, delegate(double v) { draft.DensityEnd = Math.Max(v, draft.DensityStart); }); } if (draft.Mode != PatternKind.Wash) { Heading("Line thickness"); Range("Thickness", draft.PatternThickness, 0.25, 2.5, 0.01, delegate(double v) { draft.PatternThickness = v; }); Toggle("Vary thickness with weight", draft.ThicknessByWeight, delegate(bool v) { draft.ThicknessByWeight = v; }); if (draft.ThicknessByWeight) { Range("Minimum thickness", draft.ThicknessMin, 0.0, 1.0, 0.01, delegate(double v) { draft.ThicknessMin = v; }); Range("Start weight (wt)", draft.ThicknessStart, 0.0, 420.0, 1.0, delegate(double v) { draft.ThicknessStart = Math.Min(v, draft.ThicknessEnd); }); Range("Full thickness at (wt)", draft.ThicknessEnd, 0.0, 420.0, 1.0, delegate(double v) { draft.ThicknessEnd = Math.Max(v, draft.ThicknessStart); }); } } if (draft.Mode == PatternKind.DeepWater) { Heading("Deep wave curve"); Range("Curve depth", draft.WaterCurveDepth, 0.0, 2.0, 0.01, delegate(double v) { draft.WaterCurveDepth = v; }); Toggle("Vary curve with weight", draft.CurveByWeight, delegate(bool v) { draft.CurveByWeight = v; }); if (draft.CurveByWeight) { Range("Minimum curve", draft.CurveMin, 0.0, 1.0, 0.01, delegate(double v) { draft.CurveMin = v; }); Range("Start weight (wt)", draft.CurveStart, 0.0, 420.0, 1.0, delegate(double v) { draft.CurveStart = Math.Min(v, draft.CurveEnd); }); Range("Full curve at (wt)", draft.CurveEnd, 0.0, 420.0, 1.0, delegate(double v) { draft.CurveEnd = Math.Max(v, draft.CurveStart); }); } } Heading("Icon clearance"); if (draft.IconOutline) { Range("Gap width (px)", draft.OutlinePixels, 1.0, 20.0, 1.0, delegate(double v) { draft.OutlinePixels = (int)v; }); Range("Inner transparency", draft.SeparationInner, 0.0, 1.0, 0.01, delegate(double v) { draft.SeparationInner = v; }); Range("Outer transparency", draft.SeparationOuter, 0.0, 1.0, 0.01, delegate(double v) { draft.SeparationOuter = v; }); } DrawLabelAndPanelControls(); } private void DrawLabelAndPanelControls() { Heading("Weight labels"); if (draft.Numbers) { Range("Label size", draft.LabelSize, 0.5, 2.0, 0.01, delegate(double v) { draft.LabelSize = v; }); Choice("Corner", draft.LabelCorner.ToString(), delegate { draft.LabelCorner = (LabelCorner)((int)(draft.LabelCorner + 1) % 4); }); Choice("Style", draft.LabelStyle.ToString(), delegate { draft.LabelStyle = (LabelStyle)((int)(draft.LabelStyle + 1) % 3); }); Toggle("Reveal labels on hover", draft.RevealLabels, delegate(bool v) { draft.RevealLabels = v; }); } Toggle("Reveal pattern on hover", draft.RevealPattern, delegate(bool v) { draft.RevealPattern = v; }); Heading("Editor size"); Range("Panel size (%)", uiScalePercent, 75.0, 200.0, 1.0, delegate(double v) { uiScalePercent = (int)v; uiScalePending = true; uiScaleSaveAt = Time.unscaledTime + 0.35f; }, enabled: true, affectsLook: false); GUILayout.Label("The panel size is saved separately from your look.", hintStyle, Array.Empty<GUILayoutOption>()); } private void DrawSavedLooks() { Heading("Saved looks"); string[] array = presets.Names.ToArray(); foreach (string presetName in array) { bool flag = presetName == presets.Selected; string text = (presets.IsOriginal(presetName) ? " • Designer pick" : ((!presets.CanUpdate(presetName)) ? " • Featured" : "")); if (GUILayout.Button((flag ? "● " : "○ ") + presets.DisplayName(presetName) + text, flag ? activeButtonStyle : quietButtonStyle, Array.Empty<GUILayoutOption>())) { Safe(delegate { Select(presetName); }); } } } private void DrawActions() { GUILayout.Space(5f); GUILayout.Label("SAVE YOUR LOOK", headingStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Name", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(43f) }); GUI.SetNextControlName("Finn.WeightUi.PresetName"); name = GUILayout.TextField(name, 50, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Save as new", activeButtonStyle, Array.Empty<GUILayoutOption>())) { Safe(delegate { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown JObject settings = Current(); FlushPreview(); string text = ((!presets.CanUpdate(presets.Selected) && name == presets.DisplayName(presets.Selected)) ? CopyName(name) : name); presets.SaveAsNew(text, settings); thumbnails.Refresh(presets.Selected); basis = (JObject)presets.Entry(presets.Selected)["settings"]; name = presets.DisplayName(presets.Selected); dirty = false; status = "Saved " + presets.Selected; }); } bool enabled = GUI.enabled; GUI.enabled = enabled && presets.CanUpdate(presets.Selected) && dirty; if (GUILayout.Button("Update selected", Array.Empty<GUILayoutOption>())) { Safe(delegate { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown JObject settings = Current(); FlushPreview(); presets.Update(presets.Selected, settings); thumbnails.Refresh(presets.Selected); basis = (JObject)presets.Entry(presets.Selected)["settings"]; dirty = false; status = "Updated " + presets.Selected; }); } GUI.enabled = enabled; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Export selected", quietButtonStyle, Array.Empty<GUILayoutOption>())) { Safe(delegate { Export(all: false); }); } if (GUILayout.Button("Export all", quietButtonStyle, Array.Empty<GUILayoutOption>())) { Safe(delegate { Export(all: true); }); } GUILayout.EndHorizontal(); if (!presets.CanUpdate(presets.Selected)) { GUILayout.Label(presets.IsOriginal(presets.Selected) ? "Designer picks stay intact. Save a copy to keep edits." : "Featured looks stay intact. Save a copy to keep edits.", hintStyle, Array.Empty<GUILayoutOption>()); } if (dirty) { GUILayout.Label("Export includes saved looks plus this unsaved draft separately. Save first to share it as a named look.", hintStyle, Array.Empty<GUILayoutOption>()); } GUILayout.Label(status, statusStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }); } private void DrawSwitchConfirmation() { GUILayout.Space(24f); GUILayout.Label("Unsaved changes", titleStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Loading " + presets.DisplayName(requestedPreset) + " will discard the edits to " + presets.DisplayName(presets.Selected) + ". Save this look first, or keep editing.", hintStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(12f); if (GUILayout.Button("Keep editing", Array.Empty<GUILayoutOption>())) { requestedPreset = null; } if (GUILayout.Button("Discard edits and load", Array.Empty<GUILayoutOption>())) { Safe(delegate { string text = requestedPreset; if (requestedFromBar) { int num = Array.IndexOf(presets.Names.Take(3).ToArray(), text); if (num < 0) { throw new ArgumentException("Original look is no longer available."); } if (ConfirmOriginalSelection != null) { confirmingOriginal = true; try { ConfirmOriginalSelection(num + 1); return; } finally { confirmingOriginal = false; } } status = "Original preset switch is unavailable; edits are still here."; } else { LoadPreset(text); } }); } if (!string.IsNullOrEmpty(status)) { GUILayout.Label(status, statusStyle, Array.Empty<GUILayoutOption>()); } } private void Close() { open = false; requestedPreset = null; requestedFromBar = false; StopTyping(); DestroyShield(); } private void Heading(string title) { GUILayout.Space(11f); GUILayout.Label(title.ToUpperInvariant(), headingStyle, Array.Empty<GUILayoutOption>()); } private void Option(string title, bool selected, Action apply) { if (GUILayout.Button(title, selected ? activeButtonStyle : quietButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }) && !selected) { deferredOption = apply; } } private static string MotifDescription(PatternKind mode) { return mode switch { PatternKind.Water => "Waves: flowing horizontal lines.", PatternKind.DeepWater => "Deep waves: layered, curved water lines.", PatternKind.Dots => "Dots: scattered points behind the icon.", PatternKind.Cross => "Cross: open diagonal X marks.", PatternKind.Lattice => "Lattice: a repeating diamond mesh.", PatternKind.Hatch => "Hatch: parallel slanted strokes.", PatternKind.Wash => "Wash: a soft, continuous colour field.", PatternKind.Rings => "Rings: nested circular contours.", PatternKind.Strata => "Strata: stacked, jagged horizontal layers.", PatternKind.Sink => "Sink: lines pressed down under the item's real shape.", PatternKind.Contour => "Contour: rings that follow the item's real outline.", _ => "This motif has no editor sketch.", }; } private void DrawMotifPreview() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Pattern sketch · inventory is the live preview", hintStyle, Array.Empty<GUILayoutOption>()); Rect rect = GUILayoutUtility.GetRect(10f, 28f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if ((int)Event.current.type == 7) { DrawSample(rect, 1f, 0.8f); } } private void DrawComparisonPreview(bool density) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Invalid comparison between Unknown and I4 //IL_00bb: 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) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(density ? "SPARSE" : "FAINT", hintStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label(density ? "DENSE" : "SOLID", hintStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndHorizontal(); Rect rect = GUILayoutUtility.GetRect(10f, 37f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if ((int)Event.current.type == 7) { float num = 8f; float num2 = (((Rect)(ref rect)).width - num) * 0.5f; DrawSample(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, num2, ((Rect)(ref rect)).height), density ? 0.45f : 1f, density ? 0.76f : 0.22f); DrawSample(new Rect(((Rect)(ref rect)).x + num2 + num, ((Rect)(ref rect)).y, num2, ((Rect)(ref rect)).height), density ? 1.8f : 1f, density ? 0.76f : 0.88f); } } private void DrawSample(Rect rect, float density, float opacity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_08a8: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = new Color(0.12f, 0.14f, 0.15f, 1f); GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); Color val = (GUI.color = ((draft.Palette == PaletteKind.Chalk) ? new Color(0.93f, 0.91f, 0.84f, opacity) : ((draft.Palette == PaletteKind.Copper) ? new Color(0.76f, 0.45f, 0.32f, opacity) : new Color(0.92f, 0.72f, 0.42f, opacity)))); int num = Mathf.Clamp(Mathf.RoundToInt(3f * density), 1, 7); if (draft.Mode == PatternKind.Dots) { int num2 = Mathf.Clamp(Mathf.RoundToInt(8f * density), 2, 18); for (int i = 0; i < num; i++) { for (int j = 0; j < num2; j++) { GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 7f + (((Rect)(ref rect)).width - 15f) * ((float)j + 0.5f) / (float)num2, ((Rect)(ref rect)).y + 4f + (((Rect)(ref rect)).height - 9f) * ((float)i + 0.5f) / (float)num, 2f, 2f), (Texture)(object)Texture2D.whiteTexture); } } } else if (draft.Mode == PatternKind.Cross) { int num3 = Mathf.Clamp(Mathf.RoundToInt(6f * density), 2, 12); for (int k = 0; k < num; k++) { for (int l = 0; l < num3; l++) { float num4 = ((Rect)(ref rect)).x + 6f + (((Rect)(ref rect)).width - 12f) * ((float)l + 0.5f) / (float)num3; float num5 = ((Rect)(ref rect)).y + 4f + (((Rect)(ref rect)).height - 8f) * ((float)k + 0.5f) / (float)num; float num6 = Mathf.Min(3.2f, (((Rect)(ref rect)).height - 8f) / ((float)num * 3f)); SketchLine(num4 - num6, num5 - num6, num4 + num6, num5 + num6, 1.3f); SketchLine(num4 + num6, num5 - num6, num4 - num6, num5 + num6, 1.3f); } } } else if (draft.Mode == PatternKind.Lattice) { int num7 = Mathf.Clamp(Mathf.RoundToInt(5f * density), 2, 10); for (int m = 0; m < num; m++) { for (int n = 0; n < num7; n++) { float num8 = ((Rect)(ref rect)).x + 6f + (((Rect)(ref rect)).width - 12f) * ((float)n + 0.5f) / (float)num7; float num9 = ((Rect)(ref rect)).y + 4f + (((Rect)(ref rect)).height - 8f) * ((float)m + 0.5f) / (float)num; float num10 = (((Rect)(ref rect)).width - 12f) / ((float)num7 * 2.2f); float num11 = (((Rect)(ref rect)).height - 8f) / ((float)num * 2.2f); SketchLine(num8, num9 - num11, num8 + num10, num9, 1.2f); SketchLine(num8 + num10, num9, num8, num9 + num11, 1.2f); SketchLine(num8, num9 + num11, num8 - num10, num9, 1.2f); SketchLine(num8 - num10, num9, num8, num9 - num11, 1.2f); } } } else if (draft.Mode == PatternKind.Hatch) { int num12 = Mathf.Clamp(Mathf.RoundToInt(9f * density), 3, 18); for (int num13 = 0; num13 < num12; num13++) { float num14 = ((Rect)(ref rect)).x + 8f + (((Rect)(ref rect)).width - 16f) * ((float)num13 + 0.5f) / (float)num12; SketchLine(num14 - 5f, ((Rect)(ref rect)).y + ((Rect)(ref rect)).height - 6f, num14 + 5f, ((Rect)(ref rect)).y + 6f, 1.5f); } } else if (draft.Mode == PatternKind.Wash) { GUI.color = new Color(val.r, val.g, val.b, opacity * 0.32f); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 6f, ((Rect)(ref rect)).y + 5f, ((Rect)(ref rect)).width - 12f, ((Rect)(ref rect)).height - 10f), (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(val.r, val.g, val.b, opacity * 0.22f); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + ((Rect)(ref rect)).width * 0.18f, ((Rect)(ref rect)).y + 8f, ((Rect)(ref rect)).width * 0.64f, ((Rect)(ref rect)).height - 16f), (Texture)(object)Texture2D.whiteTexture); } else if (draft.Mode == PatternKind.Rings) { int num15 = Mathf.Clamp(Mathf.RoundToInt(3f * density), 1, 5); float num16 = ((Rect)(ref rect)).y + ((Rect)(ref rect)).height * 0.5f; for (int num17 = 0; num17 < 3; num17++) { float num18 = ((Rect)(ref rect)).x + ((Rect)(ref rect)).width * ((float)num17 + 0.5f) / 3f; for (int num19 = 1; num19 <= num15; num19++) { float num20 = Mathf.Min((((Rect)(ref rect)).height - 10f) * 0.44f, (((Rect)(ref rect)).width / 3f - 10f) * 0.44f) * (float)num19 / (float)num15; for (int num21 = 0; num21 < 24; num21++) { float num22 = (float)num21 * MathF.PI * 2f / 24f; float num23 = (float)(num21 + 1) * MathF.PI * 2f / 24f; SketchLine(num18 + Mathf.Cos(num22) * num20, num16 + Mathf.Sin(num22) * num20, num18 + Mathf.Cos(num23) * num20, num16 + Mathf.Sin(num23) * num20, 1.2f); } } } } else if (draft.Mode == PatternKind.Strata) { for (int num24 = 0; num24 < num; num24++) { float num25 = ((Rect)(ref rect)).y + 5f + (((Rect)(ref rect)).height - 10f) * ((float)num24 + 0.5f) / (float)num; float num26 = Mathf.Min(2.5f, (((Rect)(ref rect)).height - 10f) / ((float)num * 3f)); float num27 = ((Rect)(ref rect)).x + 6f; float num28 = ((Rect)(ref rect)).width - 12f; float[] array = new float[6] { 0f, 0f - num26, num26, (0f - num26) * 0.5f, num26 * 1.2f, 0f }; for (int num29 = 0; num29 < 5; num29++) { SketchLine(num27 + num28 * (float)num29 / 5f, num25 + array[num29], num27 + num28 * (float)(num29 + 1) / 5f, num25 + array[num29 + 1], 1.8f); } } } else if (draft.Mode == PatternKind.Water || draft.Mode == PatternKind.DeepWater) { for (int num30 = 0; num30 < num; num30++) { float num31 = ((Rect)(ref rect)).y + 5f + (((Rect)(ref rect)).height - 11f) * ((float)num30 + 0.5f) / (float)num; for (int num32 = 0; num32 < 12; num32++) { float num33 = ((Rect)(ref rect)).x + 6f + (((Rect)(ref rect)).width - 12f) * (float)num32 / 12f; float num34 = Mathf.Sin((float)num32 * 0.7f + (float)num30 * ((draft.Mode == PatternKind.DeepWater) ? 1f : 0.55f)) * ((draft.Mode == PatternKind.DeepWater) ? 2.4f : 1.3f); GUI.DrawTexture(new Rect(num33, num31 + num34, (((Rect)(ref rect)).width - 13f) / 12f + 1f, 1.5f), (Texture)(object)Texture2D.whiteTexture); } } } GUI.color = color; } private static void SketchLine(float x0, float y0, float x1, float y1, float width) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(Mathf.CeilTo