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 MoreUIPanel v0.2.0
plugins/MoreUIPanel.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MoreUIPanel")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MoreUIPanel")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("61df5c61-4524-4ad1-bcae-08468af2cb03")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace MoreUIPanel; [BepInPlugin("cn_xc.MoreUIPanel", "MoreUIPanel", "0.2.0")] public class Plugin : BaseUnityPlugin { private sealed class Line { public string Key; public Func<string> Provider; public int FontSize; public float OffsetX; public float OffsetY; public bool Visible = true; public string Cache = string.Empty; } private static readonly List<Line> _lines = new List<Line>(); private static readonly Dictionary<string, Line> _index = new Dictionary<string, Line>(); private static Plugin _inst; private static string _posFile; private static GUIStyle _style; private static Font _font; private static int _styleFontSize = -1; private static StringBuilder _sb = new StringBuilder(512); private static float _baseX = 10f; private static float _baseY = -1f; private static bool _editMode; private static bool _dragging; private static Line _dragLine; private static Vector2 _dragOffset; private Vector2 _dragStartMouse; private Vector2 _dragStartOffset; private ConfigEntry<bool> _enabled; private ConfigEntry<int> _fontSize; private ConfigEntry<int> _opacityPercent; private ConfigEntry<float> _refreshInterval; private ConfigEntry<string> _dragKey; private float _timer; public static bool Visible { get; set; } = true; private void Awake() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown _inst = this; _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("常规", "启用面板", true, "是否显示左下角信息面板。"); _fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("常规", "字号", 20, new ConfigDescription("全局文字大小(10~28);单个模组可用 API 单独指定。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 28), Array.Empty<object>())); _opacityPercent = ((BaseUnityPlugin)this).Config.Bind<int>("常规", "透明度百分比", 70, new ConfigDescription("文字透明度(1~100)。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _refreshInterval = ((BaseUnityPlugin)this).Config.Bind<float>("常规", "刷新间隔秒", 0.5f, new ConfigDescription("面板内容刷新间隔(0.1~10 秒)。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); _dragKey = ((BaseUnityPlugin)this).Config.Bind<string>("常规", "拖动模式快捷键", "F2", "按一下进入拖动模式:可整体拖动面板,也可单独拖动某一行;再按一次保存。"); _posFile = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? ".", "panel.pos"); LoadPos(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("MoreUIPanel 0.2.0 已加载(按行独立渲染,刷新 " + _refreshInterval.Value + "s)")); } public static void RegisterLine(string key, Func<string> textProvider) { RegisterLine(key, textProvider, 0); } public static void RegisterLine(string key, Func<string> textProvider, int fontSize, float offsetX = 0f, float offsetY = 0f) { if (string.IsNullOrEmpty(key) || textProvider == null) { return; } lock (_lines) { if (_index.TryGetValue(key, out var value)) { value.Provider = textProvider; value.FontSize = fontSize; value.OffsetX = offsetX; value.OffsetY = offsetY; return; } Line line = new Line { Key = key, Provider = textProvider, FontSize = fontSize, OffsetX = offsetX, OffsetY = offsetY }; _lines.Add(line); _index[key] = line; } } public static void UnregisterLine(string key) { if (string.IsNullOrEmpty(key)) { return; } lock (_lines) { if (_index.TryGetValue(key, out var value)) { _lines.Remove(value); _index.Remove(key); } } } public static void SetLineVisible(string key, bool visible) { if (string.IsNullOrEmpty(key)) { return; } lock (_lines) { if (_index.TryGetValue(key, out var value)) { value.Visible = visible; } } } public static void SetLineOffset(string key, float offsetX, float offsetY) { if (string.IsNullOrEmpty(key)) { return; } lock (_lines) { if (_index.TryGetValue(key, out var value)) { value.OffsetX = offsetX; value.OffsetY = offsetY; } } } private void Update() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (_enabled == null || !_enabled.Value) { return; } if (_dragKey != null && Enum.TryParse<KeyCode>(_dragKey.Value, ignoreCase: true, out KeyCode result) && Input.GetKeyDown(result)) { _editMode = !_editMode; ((BaseUnityPlugin)this).Logger.LogInfo((object)(_editMode ? "拖动模式:开(可拖动整体/单行,再按一次保存)" : "拖动模式:关(位置已保存)")); if (!_editMode) { SavePos(); } } _timer += Time.unscaledDeltaTime; if (_timer >= Mathf.Max(0.05f, _refreshInterval.Value)) { _timer = 0f; RefreshText(); } } private void RefreshText() { lock (_lines) { foreach (Line line in _lines) { try { _sb.Clear(); line.Cache = ((line.Provider != null) ? (line.Provider() ?? string.Empty) : string.Empty); } catch { line.Cache = string.Empty; } } } } private GUIStyle GetStyle(int fontSize, float alpha) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) int num = ((fontSize > 0) ? fontSize : Mathf.Clamp(_fontSize.Value, 10, 28)); if (_style == null || _styleFontSize != num) { _style = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)0, alignment = (TextAnchor)0, wordWrap = false, richText = true }; try { _font = Font.CreateDynamicFontFromOSFont(new string[5] { "Microsoft YaHei", "Microsoft YaHei UI", "SimHei", "Segoe UI", "Arial Unicode MS" }, num); } catch { } if ((Object)(object)_font != (Object)null) { _style.font = _font; } _style.fontSize = num; _styleFontSize = num; } _style.normal.textColor = new Color(1f, 1f, 1f, alpha); return _style; } private void OnGUI() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00cb: 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_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Expected O, but got Unknown //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Expected O, but got Unknown //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) if (_enabled == null || !_enabled.Value || !Visible) { return; } try { float alpha = (float)Mathf.Clamp(_opacityPercent.Value, 1, 100) / 100f; List<KeyValuePair<Line, Rect>> list = new List<KeyValuePair<Line, Rect>>(); lock (_lines) { foreach (Line line in _lines) { if (line.Visible && !string.IsNullOrEmpty(line.Cache)) { GUIStyle style = GetStyle(line.FontSize, alpha); float num = style.CalcHeight(new GUIContent(line.Cache), 1400f); float num2 = Mathf.Min(1600f, Mathf.Max(200f, style.CalcSize(new GUIContent(line.Cache)).x + 8f)); float num3 = ((_baseY < 0f) ? ((float)Screen.height - 12f) : _baseY) + line.OffsetY; list.Add(new KeyValuePair<Line, Rect>(line, new Rect(_baseX + line.OffsetX, num3, num2, num))); } } } list.Sort(delegate(KeyValuePair<Line, Rect> a, KeyValuePair<Line, Rect> b) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Rect value3 = a.Value; float y = ((Rect)(ref value3)).y; value3 = b.Value; return y.CompareTo(((Rect)(ref value3)).y); }); float num4 = float.NegativeInfinity; List<Rect> list2 = new List<Rect>(); for (int num5 = 0; num5 < list.Count; num5++) { Line key = list[num5].Key; Rect val = list[num5].Value; if (num5 > 0) { ((Rect)(ref val)).y = Mathf.Max(((Rect)(ref val)).y, num4); } val = ClampToScreen(val); list2.Add(val); num4 = ((Rect)(ref val)).yMax + 2f; list[num5] = new KeyValuePair<Line, Rect>(key, val); } if (list2.Count > 0) { float num6 = 0f; foreach (Rect item in list2) { Rect current2 = item; num6 = Mathf.Max(num6, ((Rect)(ref current2)).yMax); } float num7 = num6 - (float)Screen.height + 4f; if (num7 > 0f) { for (int num8 = 0; num8 < list.Count; num8++) { Rect value = list[num8].Value; ((Rect)(ref value)).y = Mathf.Max(0f, ((Rect)(ref value)).y - num7); list[num8] = new KeyValuePair<Line, Rect>(list[num8].Key, value); } } } foreach (KeyValuePair<Line, Rect> item2 in list) { Line key2 = item2.Key; Rect value2 = item2.Value; GUIStyle style2 = GetStyle(key2.FontSize, alpha); if (_editMode) { DrawEditBox(value2, key2); } GUI.Label(value2, key2.Cache, style2); } if (_editMode) { GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 22, alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; if ((Object)(object)_font != (Object)null) { val2.font = _font; } val2.normal.textColor = new Color(0.02f, 0.85f, 0.91f, 0.95f); float num9 = Mathf.Min((float)Screen.width * 0.8f, 720f); GUI.Label(new Rect(((float)Screen.width - num9) * 0.5f, (float)Screen.height * 0.45f, num9, 40f), "拖动模式:拖空白移动整体 / 拖某行只移动该行", val2); GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 18, alignment = (TextAnchor)4 }; if ((Object)(object)_font != (Object)null) { val3.font = _font; } val3.normal.textColor = new Color(1f, 0.93f, 0.04f, 0.95f); GUI.Label(new Rect(((float)Screen.width - num9) * 0.5f, (float)Screen.height * 0.45f + 42f, num9, 30f), "按 " + ((_dragKey != null) ? _dragKey.Value : "F2") + " 保存并退出", val3); } } catch { } } private void DrawEditBox(Rect rect, Line line) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_0110: 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_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Invalid comparison between Unknown and I4 //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Invalid comparison between Unknown and I4 //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) try { Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.35f); GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(0.02f, 0.85f, 0.91f, 0.9f); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; Event current = Event.current; if (current == null) { return; } if ((int)current.type == 0 && ((Rect)(ref rect)).Contains(current.mousePosition)) { _dragging = true; _dragLine = line; _dragStartMouse = current.mousePosition; _dragStartOffset = new Vector2(line.OffsetX, line.OffsetY); current.Use(); } else if (_dragging && (int)current.type == 3) { if (_dragLine != null) { Vector2 val = current.mousePosition - _dragStartMouse; float offsetX = Mathf.Clamp(_dragStartOffset.x + val.x, 0f - _baseX, (float)Screen.width - _baseX - 40f); float offsetY = Mathf.Clamp(_dragStartOffset.y + val.y, (float)(-Screen.height), (float)Screen.height); _dragLine.OffsetX = offsetX; _dragLine.OffsetY = offsetY; } current.Use(); } else if ((int)current.type == 1 && _dragging) { _dragging = false; _dragLine = null; SavePos(); current.Use(); } } catch { } } private static Rect ClampToScreen(Rect r) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, (float)Screen.width - ((Rect)(ref r)).width); float num2 = Mathf.Max(0f, (float)Screen.height - ((Rect)(ref r)).height); ((Rect)(ref r)).x = Mathf.Clamp(((Rect)(ref r)).x, 0f, num); ((Rect)(ref r)).y = Mathf.Clamp(((Rect)(ref r)).y, 0f, num2); return r; } private static void LoadPos() { try { if (!File.Exists(_posFile)) { return; } string[] array = File.ReadAllLines(_posFile); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ',' }); Line value; float result3; float result4; if (array2.Length >= 3 && array2[0] == "base" && float.TryParse(array2[1], out var result) && float.TryParse(array2[2], out var result2)) { _baseX = result; _baseY = result2; } else if (array2.Length >= 3 && _index.TryGetValue(array2[0], out value) && float.TryParse(array2[1], out result3) && float.TryParse(array2[2], out result4)) { if (Mathf.Abs(result3) > (float)Screen.width || Mathf.Abs(result4) > (float)Screen.height) { result3 = 0f; result4 = 0f; } value.OffsetX = result3; value.OffsetY = result4; } } } catch { } } private static void SavePos() { try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("base," + _baseX.ToString("F1") + "," + _baseY.ToString("F1")); lock (_lines) { foreach (Line line in _lines) { if (Math.Abs(line.OffsetX) > 0.01f || Math.Abs(line.OffsetY) > 0.01f) { stringBuilder.AppendLine(line.Key + "," + line.OffsetX.ToString("F1") + "," + line.OffsetY.ToString("F1")); } } } File.WriteAllText(_posFile, stringBuilder.ToString()); } catch { } } }