diff --git a/AGENTS.md b/AGENTS.md index ddbd9ef..52e9bc4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,6 +38,7 @@ - `PatchImpl.Enable(true)` must remain fail-soft: log, unpatch, and leave the patch unset if Harmony application fails so config delegate chains remain consistent. - Overlay UI state must converge from actual game state on periodic updates, not depend only on one-shot event or patch callbacks. Treat replacement of a planet transport as a lifecycle boundary and clear its dependent overlays once. Station IDs are reusable indices, and a stable planet ID or factory reference does not imply stable transport ownership. Cloned controls must reset runtime state while retaining source styles; use `UXAssist.UI.Util.GetPreferredWidth` for dynamic text and `ResetButton` for cloned buttons. Preserve the source tip settings when resetting cloned help buttons so the game's native tips work; do not replace them with separate dialogs. Shared button sizing must use anchor-relative child positions so text and icons remain aligned after a button pivot changes. - Logistics station overlays must refresh through the native UI lifecycle, independently of typing guards. Reconcile cached tips against live station/entity identities and recycle local tips when stations are removed. +- Planet vein utilization counters belong before resource labels, not beside native icons or highlight controls. Restore original label layout when rows are reused or the feature is disabled. - UI-only options must preserve native progression, statistics, and event delivery. Suppress presentation handlers rather than bypassing authoritative game-state setters. - LiveStreamAssist browser overlays must use single-flight polling and discard stale work after connection changes. Compound queries must reject mixed session IDs; cache only positive production indices so newly tracked items remain discoverable. - LiveStreamAssist production reads must schedule the native extra-info calculator for queried factories independently of the statistics UI. Deduplicate and throttle refreshes, let active native batches finish, and clear pending factory indices and deadlines at session boundaries. diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index c019685..16f9c75 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -4,6 +4,7 @@ ## Changlog * 1.6.1 + * `Planet vein utilization`: Move vein-group counts to the left of resource names to avoid overlapping the game's new buttons. * `Settings help`: Restore the game's native tips on question-mark buttons. * `Auto-cruise`: Align the settings sliders and reduce spacing between their tracks and values. * `Real-time logistic stations info panel`: Fix lingering panels after dismantling stations or initializing a planet, and keep panels updating while typing. @@ -420,6 +421,7 @@ ## 更新日志 * 1.6.1 + * `宇宙视图行星/星系矿脉数量显示`:将矿脉数量移至矿物名称左侧,避免与游戏新版按钮重叠。 * `设置提示`:修复问号按钮的游戏内提示不显示的问题。 * `自动巡航`:统一设置滑条的起始位置,并缩小滑条与数值之间的间距。 * `物流站实时信息面板`:修复拆除物流站或初始化本行星后面板残留的问题,输入文字时也会保持刷新。 diff --git a/UXAssist/Patches/UIPatch.cs b/UXAssist/Patches/UIPatch.cs index 9dafafb..00fed28 100644 --- a/UXAssist/Patches/UIPatch.cs +++ b/UXAssist/Patches/UIPatch.cs @@ -37,6 +37,8 @@ public class UIPatch : PatchImpl private class PlanetVeinUtilization : PatchImpl { + private const float CountLabelGap = 4f; + private const float MinCountWidth = 36f; private static VeinTypeInfo[] planetVeinCount = null; private static VeinTypeInfo[] starVeinCount = null; private static readonly Dictionary tmpGroups = []; @@ -47,6 +49,7 @@ public class UIPatch : PatchImpl { foreach (VeinTypeInfo vti in planetVeinCount) { + vti.Reset(); if (vti.textCtrl != null) { Object.Destroy(vti.textCtrl.gameObject); @@ -58,6 +61,7 @@ public class UIPatch : PatchImpl { foreach (VeinTypeInfo vti in starVeinCount) { + vti.Reset(); if (vti.textCtrl != null) { Object.Destroy(vti.textCtrl.gameObject); @@ -153,12 +157,18 @@ public class UIPatch : PatchImpl tmpGroups.Clear(); } - private static void FormatResource(int refId, UIResAmountEntry uiresAmountEntry, VeinTypeInfo vt) + private static void FormatResource(UIResAmountEntry uiresAmountEntry, VeinTypeInfo vt) { + RectTransform labelRect = uiresAmountEntry.labelText.rectTransform; + if (vt.labelRect != labelRect) + { + vt.RestoreLabel(); + vt.labelRect = labelRect; + vt.labelOffsetMinX = labelRect.offsetMin.x; + } if (vt.textCtrl == null) { - var parent = uiresAmountEntry.labelText.transform.parent; - vt.textCtrl = Object.Instantiate(uiresAmountEntry.valueText, parent); + vt.textCtrl = Object.Instantiate(uiresAmountEntry.valueText, labelRect.parent); vt.textCtrl.font = uiresAmountEntry.labelText.font; vt.textCtrl.text = ""; vt.textCtrl.color = uiresAmountEntry.normalColor; @@ -166,22 +176,22 @@ public class UIPatch : PatchImpl vt.textCtrl.fontStyle = FontStyle.Normal; vt.textCtrl.horizontalOverflow = HorizontalWrapMode.Overflow; vt.textCtrl.verticalOverflow = VerticalWrapMode.Overflow; - RectTransform trans = vt.textCtrl.rectTransform; - var pos = uiresAmountEntry.rectTrans.localPosition; - pos.x = pos.x + uiresAmountEntry.iconImage.rectTransform.localPosition.x - 25f; - trans.localPosition = pos; - Vector2 size = trans.sizeDelta; - size.x = 40f; - trans.sizeDelta = size; - } - else - { - RectTransform trans = vt.textCtrl.rectTransform; - Vector3 pos = trans.localPosition; - pos.y = uiresAmountEntry.rectTrans.localPosition.y; - trans.localPosition = pos; + vt.textCtrl.resizeTextForBestFit = false; + vt.textCtrl.raycastTarget = false; } vt.textCtrl.text = $"{vt.numVeinGroupsWithCollector}/{vt.numVeinGroups}"; + float countWidth = Mathf.Max(MinCountWidth, Mathf.Ceil(UI.Util.GetPreferredWidth(vt.textCtrl))); + RectTransform countRect = vt.textCtrl.rectTransform; + if (countRect.parent != labelRect.parent) + { + countRect.SetParent(labelRect.parent, false); + } + countRect.anchorMin = labelRect.anchorMin; + countRect.anchorMax = new Vector2(labelRect.anchorMin.x, labelRect.anchorMax.y); + countRect.pivot = new Vector2(0f, labelRect.pivot.y); + countRect.offsetMin = new Vector2(vt.labelOffsetMinX, labelRect.offsetMin.y); + countRect.offsetMax = new Vector2(vt.labelOffsetMinX + countWidth, labelRect.offsetMax.y); + labelRect.offsetMin = new Vector2(vt.labelOffsetMinX + countWidth + CountLabelGap, labelRect.offsetMin.y); } private static void InitializeVeinCountArray(VeinTypeInfo[] veinCountArray) @@ -236,7 +246,6 @@ public class UIPatch : PatchImpl } // update each resource to show the following vein group info: - // Iron: / foreach (UIResAmountEntry uiresAmountEntry in __instance.entries) { int refId = uiresAmountEntry.refId; @@ -245,11 +254,11 @@ public class UIPatch : PatchImpl var vt = planetVeinCount[refId]; if (vt.numVeinGroups > 0) { - FormatResource(refId, uiresAmountEntry, vt); + FormatResource(uiresAmountEntry, vt); } - else if (vt.textCtrl != null) + else { - vt.textCtrl.text = ""; + vt.Reset(); } } } @@ -296,7 +305,6 @@ public class UIPatch : PatchImpl } } // update each resource to show the following vein group info: - // Iron: / foreach (UIResAmountEntry uiresAmountEntry in __instance.entries) { int refId = uiresAmountEntry.refId; @@ -305,11 +313,11 @@ public class UIPatch : PatchImpl var vt = starVeinCount[refId]; if (vt.numVeinGroups > 0) { - FormatResource(refId, uiresAmountEntry, vt); + FormatResource(uiresAmountEntry, vt); } - else if (vt.textCtrl != null) + else { - vt.textCtrl.text = ""; + vt.Reset(); } } } @@ -322,11 +330,23 @@ public class UIPatch : PatchImpl public int numVeinGroups; public int numVeinGroupsWithCollector; public Text textCtrl; + public RectTransform labelRect; + public float labelOffsetMinX; + + public void RestoreLabel() + { + if (labelRect != null) + { + labelRect.offsetMin = new Vector2(labelOffsetMinX, labelRect.offsetMin.y); + } + labelRect = null; + } public void Reset() { numVeinGroups = 0; numVeinGroupsWithCollector = 0; + RestoreLabel(); if (textCtrl != null) { textCtrl.text = "";