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 Empress UIEditor v1.0.0
EmpressAIO.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+31d33a1e262fb9cd936a8fd3f583fdd7bc996e5a")] [assembly: AssemblyProduct("EmpressAIO")] [assembly: AssemblyTitle("EmpressAIO")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Empress.AllInOneUIEditor { [BepInPlugin("Empress.AllInOneUIEditor", "AllInOneUIEditor", "1.4.1")] public class AllInOneUIEditor : BaseUnityPlugin { [HarmonyPatch(typeof(SemiUI), "UpdatePositionLogic")] private static class Patch_SemiUI_UpdatePositionLogic { private static void Postfix(SemiUI __instance) { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_00d1: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Instance) || !Object.op_Implicit((Object)(object)HUDCanvas.instance)) { return; } if (!Instance.layoutInitialized) { Instance.LoadLayout(); } Transform val = (Object.op_Implicit((Object)(object)__instance.textRectTransform) ? __instance.textRectTransform : ((Component)__instance).transform); if (!Object.op_Implicit((Object)(object)val)) { return; } string path = Instance.GetPath(val); if (!Instance.elements.TryGetValue(path, out EditableElement value)) { value = new EditableElement { key = path, transform = val }; if (Instance.layout.TryGetValue(path, out var value2)) { value.offset = value2.offset; value.scaleMultiplier = ((value2.scale <= 0f) ? 1f : value2.scale); } Instance.elements[path] = value; } value.lastGamePos = val.localPosition; value.lastGameScale = val.localScale; val.localPosition = value.lastGamePos + Vector2.op_Implicit(value.offset); val.localScale = value.lastGameScale * value.scaleMultiplier; } } private struct LayoutEntry { public string key; public Vector2 offset; public float scale; } private class EditableElement { public string key; public Transform transform; public Vector2 offset = Vector2.zero; public float scaleMultiplier = 1f; public Vector3 lastGamePos; public Vector3 lastGameScale; } private ConfigEntry<KeyCode> ToggleKey = null; private ConfigEntry<float> WheelSensitivity = null; private ConfigEntry<float> DragSensitivity = null; private bool editMode; private bool dragging; private Vector2 dragStartMouse; private Vector2 dragStartOffset; private EditableElement selected; private readonly Dictionary<string, EditableElement> elements = new Dictionary<string, EditableElement>(); private readonly Dictionary<string, LayoutEntry> layout = new Dictionary<string, LayoutEntry>(); private string savePath = Path.Combine(Paths.ConfigPath, "Empress.AllInOneUIEditor.layout"); private GUIStyle labelStyle = null; private GUIStyle smallStyle = null; private bool layoutInitialized; private Vector2 scrollPosition; internal static AllInOneUIEditor Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b1: Expected O, but got Unknown //IL_00b7: Expected O, but got Unknown //IL_00be: 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_00d1: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)289, (ConfigDescription)null); WheelSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WheelSensitivity", 0.1f, (ConfigDescription)null); DragSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DragSensitivity", 1f, (ConfigDescription)null); labelStyle = new GUIStyle { fontSize = 16, normal = new GUIStyleState { textColor = Color.white } }; smallStyle = new GUIStyle(labelStyle) { fontSize = 14 }; Patch(); LoadLayout(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } private void Start() { ((MonoBehaviour)this).InvokeRepeating("RefreshElements", 0.75f, 2f); } private void RefreshElements() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) SemiUI[] array = Object.FindObjectsOfType<SemiUI>(true); SemiUI[] array2 = array; foreach (SemiUI val in array2) { Transform val2 = (Object.op_Implicit((Object)(object)val.textRectTransform) ? val.textRectTransform : ((Component)val).transform); if (!Object.op_Implicit((Object)(object)val2)) { continue; } string path = GetPath(val2); if (!elements.ContainsKey(path)) { EditableElement editableElement = new EditableElement { key = path, transform = val2 }; if (layout.TryGetValue(path, out var value)) { editableElement.offset = value.offset; editableElement.scaleMultiplier = ((value.scale <= 0f) ? 1f : value.scale); } elements[path] = editableElement; } else { elements[path].transform = val2; } } } private void Update() { //IL_0007: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(ToggleKey.Value)) { editMode = !editMode; dragging = false; selected = null; if (!editMode) { SaveLayout(); } } if (!editMode) { return; } if (Object.op_Implicit((Object)(object)InputManager.instance)) { InputManager.instance.DisableMovement(); InputManager.instance.DisableAiming(); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (Object.op_Implicit((Object)(object)MenuCursor.instance)) { MenuCursor.instance.Show(); } Vector2 val = SemiFunc.UIMousePosToUIPos(); if (selected != null) { if (Input.mouseScrollDelta.y != 0f) { selected.scaleMultiplier = Mathf.Max(0.1f, selected.scaleMultiplier + Input.mouseScrollDelta.y * WheelSensitivity.Value); } if (Input.GetKeyDown((KeyCode)114)) { selected.offset = Vector2.zero; selected.scaleMultiplier = 1f; } if (Input.GetKeyDown((KeyCode)99)) { selected.offset = -Vector2.op_Implicit(selected.lastGamePos); } if (Input.GetMouseButtonDown(0) && Input.mousePosition.x > 430f) { dragging = true; dragStartMouse = val; dragStartOffset = selected.offset; } } if (dragging && selected != null) { if (Input.GetMouseButton(0)) { Vector2 val2 = (val - dragStartMouse) * DragSensitivity.Value; selected.offset = dragStartOffset + val2; } if (Input.GetMouseButtonUp(0)) { dragging = false; } } } private void OnGUI() { //IL_0027: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //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_02f2: 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_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) if (!editMode) { return; } GUI.color = new Color(0f, 0f, 0f, 0.6f); GUI.DrawTexture(new Rect(0f, 0f, 420f, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; GUI.Label(new Rect(10f, 4f, 600f, 30f), "ALL-IN-ONE UI EDITOR", labelStyle); GUI.Label(new Rect(10f, 32f, 800f, 24f), "Click list → Drag in game → Scroll scale → R reset → C center", smallStyle); scrollPosition = GUI.BeginScrollView(new Rect(10f, 60f, 400f, (float)(Screen.height - 110)), scrollPosition, new Rect(0f, 0f, 380f, (float)(elements.Count * 26))); float num = 0f; List<EditableElement> list = new List<EditableElement>(elements.Values); list.Sort((EditableElement a, EditableElement b) => string.Compare(a.key, b.key, StringComparison.Ordinal)); foreach (EditableElement item in list) { string text = (item.key.Contains("/") ? item.key.Substring(item.key.LastIndexOf('/') + 1) : item.key); string text2 = string.Format("{0} [{1:F0}, {2:F0}] x{3:0.00}{4}", text, item.offset.x, item.offset.y, item.scaleMultiplier, (selected == item) ? " ← SELECTED" : ""); if (GUI.Button(new Rect(5f, num, 370f, 24f), text2, (selected == item) ? labelStyle : smallStyle)) { selected = item; } num += 26f; } GUI.EndScrollView(); if (selected != null) { Vector2 val = UIToScreen(Vector2.op_Implicit(selected.lastGamePos) + selected.offset); GUI.color = Color.red; GUI.DrawTexture(new Rect(val.x - 12f, val.y - 12f, 24f, 24f), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; GUI.Label(new Rect(val.x + 15f, val.y - 10f, 1200f, 20f), selected.key, labelStyle); Vector2 val2 = UIToScreen(Vector2.op_Implicit(selected.lastGamePos)); GUI.color = Color.green; GUI.DrawTexture(new Rect(val2.x - 20f, val2.y - 20f, 40f, 40f), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; } string text3 = string.Format("Elements: {0} │ Selected: {1} │ Scale: {2}", elements.Count, selected?.key ?? "None", (selected != null) ? selected.scaleMultiplier.ToString("0.00") : "-"); GUI.Label(new Rect(430f, (float)(Screen.height - 32), 1400f, 30f), text3, labelStyle); } private Vector2 UIToScreen(Vector2 uiPos) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0057: 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_0075: 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_00be: 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_00c7: Unknown result type (might be due to invalid IL or missing references) float num = HUDCanvas.instance.rect.sizeDelta.x / HUDCanvas.instance.rect.sizeDelta.y; float num2 = HUDCanvas.instance.rect.sizeDelta.x * num / HUDCanvas.instance.rect.sizeDelta.y; float num3 = uiPos.x / (HUDCanvas.instance.rect.sizeDelta.x * num2); float num4 = uiPos.y / (HUDCanvas.instance.rect.sizeDelta.y * num); num3 *= (float)Screen.width; num4 *= (float)Screen.height; num3 /= 1.015f; num4 /= 1.015f; return new Vector2(num3, (float)Screen.height - num4); } private string GetPath(Transform t) { List<string> list = new List<string>(); Transform val = t; while ((Object)(object)val != (Object)null) { list.Add(((Object)val).name); if ((Object)(object)val.parent == (Object)null) { break; } val = val.parent; if (list.Count > 64) { break; } } list.Reverse(); return string.Join("/", list); } private void LoadLayout() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) layoutInitialized = true; layout.Clear(); if (!File.Exists(savePath)) { return; } try { string[] array = File.ReadAllLines(savePath); string[] array2 = array; foreach (string text in array2) { if (!string.IsNullOrWhiteSpace(text)) { string[] array3 = text.Split('|'); if (array3.Length == 4) { string key = array3[0]; float num = float.Parse(array3[1], CultureInfo.InvariantCulture); float num2 = float.Parse(array3[2], CultureInfo.InvariantCulture); float num3 = float.Parse(array3[3], CultureInfo.InvariantCulture); layout[key] = new LayoutEntry { key = key, offset = new Vector2(num, num2), scale = ((num3 <= 0f) ? 1f : num3) }; } } } } catch { } } private void SaveLayout() { try { List<string> list = new List<string>(); foreach (EditableElement value in elements.Values) { if (Object.op_Implicit((Object)(object)value.transform)) { list.Add(value.key + "|" + value.offset.x.ToString(CultureInfo.InvariantCulture) + "|" + value.offset.y.ToString(CultureInfo.InvariantCulture) + "|" + value.scaleMultiplier.ToString(CultureInfo.InvariantCulture)); } } File.WriteAllLines(savePath, list.ToArray()); } catch { } } } }