From 51af1430bc77dee57a8a59f3d2f4e1ad87c90e80 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Wed, 4 Nov 2026 22:57:23 +0800 Subject: [PATCH] fix(uxassist): anchor blueprint options and use native popup controls Follow the Auto-fill entry after native layout and scrolling, flip or constrain placement at canvas edges, and close detached or hidden popups. Use the native close-X artwork with an isolated callback, compact settings, and one footer Generate action. Keep dropdown choices above the action and preserve native blueprint layout and production calculations. --- UXAssist/CHANGELOG.md | 4 +- UXAssist/Common/I18NKeys.cs | 2 + UXAssist/Patches/BlueprintDescriptionPatch.cs | 198 ++++++++++++++---- UXAssist/README.md | 6 +- .../docs/BlueprintDescriptionValidation.md | 53 +++-- UXAssist/docs/ProductionArchitecture.md | 12 +- 6 files changed, 209 insertions(+), 66 deletions(-) diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index 2d34c15..4488d16 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -4,7 +4,7 @@ ## Changlog * 1.6.4 - * `Blueprint descriptions`: Fix the misplaced production-basis selector and incorrectly sized dropdown when opening Auto-fill options or changing the language. + * `Blueprint descriptions`: Open generation options next to the `Auto-fill` entry and keep them attached while scrolling, with placement adjusted at screen edges. Use a titled panel with a native close button, compact options, and one `Generate` action at the bottom. The production-basis dropdown has correctly sized rows and expands the panel above the action. Close with the X, an outside click, or Esc; Esc first closes an expanded dropdown. Preserve the native inspector layout and fix selector sizing when reopening options or changing language. * `Hide battle-related techs in Peace mode`: Fix an array index error when opening the tech tree after switching from a Peace-mode save to a Combat-mode save in the same game process, including when disabling the option after loading another Peace-mode save. * 1.6.3 * `Quick build Mining Machines`: @@ -448,7 +448,7 @@ ## 更新日志 * 1.6.4 - * `蓝图说明`:修复打开自动填写说明选项或切换语言时,「产量基准」选择框错位、下拉列表宽度异常的问题。 + * `蓝图说明`:生成选项在「自动填写」入口旁打开,滚动时跟随入口,并根据屏幕边缘调整位置。面板包含标题、原生关闭按钮、紧凑排列的选项和底部单个「生成说明」按钮;产量基准下拉列表使用正确的行尺寸,展开时面板增高,操作按钮随之下移。可通过叉号、点击外部或 Esc 关闭;下拉列表展开时,Esc 先收起列表。保留原生检查面板布局,并修复重新打开选项或切换语言时的选择框尺寸问题。 * `在和平模式下隐藏战斗相关科技`:修复在同一次游戏运行中从和平模式存档切换到战斗模式存档后打开科技树时的数组越界,以及再次加载和平模式存档后关闭选项时的同类问题。 * 1.6.3 * `快速铺设采矿机`: diff --git a/UXAssist/Common/I18NKeys.cs b/UXAssist/Common/I18NKeys.cs index a7fe8a8..c4736f0 100644 --- a/UXAssist/Common/I18NKeys.cs +++ b/UXAssist/Common/I18NKeys.cs @@ -6,6 +6,7 @@ public static class I18NKeys { public const string Unknown = "Unknown"; public const string BlueprintAutoFillDescription = "UXAssist Blueprint Auto-fill description"; + public const string BlueprintGenerateDescription = "UXAssist Blueprint Generate Description"; public const string BlueprintDescriptionOptions = "UXAssist Blueprint Description Options"; public const string BlueprintDescriptionOptionsTip = "UXAssist Blueprint Description Options Tip"; public const string BlueprintProliferation = "UXAssist Blueprint Proliferation"; @@ -244,6 +245,7 @@ public static class I18NKeys { I18N.Add(Unknown, "Unknown", "未知"); I18N.Add(BlueprintAutoFillDescription, "Auto-fill description", "自动填写说明"); + I18N.Add(BlueprintGenerateDescription, "Generate", "生成说明"); I18N.Add(BlueprintDescriptionOptions, "Auto-fill…", "自动填写…"); I18N.Add(BlueprintDescriptionOptionsTip, "Choose production basis and proliferation, then fill the blueprint description.", diff --git a/UXAssist/Patches/BlueprintDescriptionPatch.cs b/UXAssist/Patches/BlueprintDescriptionPatch.cs index 54b61d5..85e6fc1 100644 --- a/UXAssist/Patches/BlueprintDescriptionPatch.cs +++ b/UXAssist/Patches/BlueprintDescriptionPatch.cs @@ -70,6 +70,12 @@ public class BlueprintDescriptionPatch : PatchImpl } } + [HarmonyPostfix, HarmonyPatch(typeof(UIBlueprintInspector), nameof(UIBlueprintInspector._OnUpdate))] + private static void OnUpdate(UIBlueprintInspector __instance) + { + if (Inspectors.TryGetValue(__instance, out var controls)) controls.HandleInput(); + } + [HarmonyPostfix, HarmonyPatch(typeof(UIBlueprintInspector), nameof(UIBlueprintInspector.OnLanguageChanged))] private static void OnLanguageChanged(UIBlueprintInspector __instance) { @@ -103,7 +109,7 @@ public class BlueprintDescriptionPatch : PatchImpl private sealed class InspectorControls { private const float Left = 12f; - private const float ControlsGap = 12f; + private const float ControlsGap = 10f; private readonly UIBlueprintInspector _inspector; private RectTransform _panel; @@ -111,8 +117,12 @@ public class BlueprintDescriptionPatch : PatchImpl private Text _entryText; private UIButton _button; private Text _buttonText; - private UIButton _cancelButton; - private Text _cancelText; + private UIButton _closeButton; + private Text _title; + private readonly Vector3[] _corners = new Vector3[4]; + private readonly Canvas _canvas; + private readonly RectTransform _viewport; + private bool _optionsOpen; private MyCheckBox _checkbox; private MyCornerComboBox _basisCombo; private Text _basisLabel; @@ -123,6 +133,8 @@ public class BlueprintDescriptionPatch : PatchImpl public InspectorControls(UIBlueprintInspector inspector) { _inspector = inspector; + _canvas = inspector.rectTrans.GetComponentInParent().rootCanvas; + _viewport = inspector.descGroupTrans.GetComponentInParent()?.viewport; try { // The native description has a 22px title row above its editable text. @@ -143,24 +155,28 @@ public class BlueprintDescriptionPatch : PatchImpl child.SetActive(false); UnityEngine.Object.Destroy(child); } - _panel.anchorMin = new Vector2(0, 1); - _panel.anchorMax = Vector2.one; + _panel.anchorMin = _panel.anchorMax = new Vector2(0, 1); _panel.pivot = new Vector2(0, 1); - _panel.anchoredPosition = new Vector2(Left, -Left); - _panel.sizeDelta = new Vector2(-Left * 2, 152); - _button = LayoutHelper.AddButton(Left, 12, _panel, - I18NKeys.BlueprintAutoFillDescription, 15, "blueprint-auto-fill-description", Generate); + _panel.GetComponent().raycastTarget = true; + _title = LayoutHelper.AddText(Left, 10, _panel, I18NKeys.BlueprintAutoFillDescription, 16); + _title.color = _entryText.color; + var closeSource = UIRoot.instance.uiGame.inserterWindow.transform + .Find("panel-bg/btn-box/close-wnd-btn").GetComponent(); + _closeButton = UnityEngine.Object.Instantiate(closeSource, _panel); + Util.ResetButton(_closeButton); + // The source's persistent callback closes the original inserter window. + _closeButton.button.onClick = new Button.ButtonClickedEvent(); + _closeButton.button.onClick.AddListener(CloseOptions); + Util.NormalizeRectWithTopRight(_closeButton, 0, 0, _panel); + _button = LayoutHelper.AddButton(0, 0, _panel, + I18NKeys.BlueprintGenerateDescription, 15, "blueprint-auto-fill-description", Generate); _buttonText = _button.transform.Find("button-text").GetComponent(); - _cancelButton = LayoutHelper.AddButton(0, 0, _panel, - I18NKeys.Cancel, 14, "blueprint-description-cancel", CloseOptions); - _cancelText = _cancelButton.transform.Find("button-text").GetComponent(); - Util.NormalizeRectWithTopRight(_cancelButton, Left, 14, _panel); - _checkbox = MyCheckBox.CreateCheckBox(Left, 52, _panel, false, - I18NKeys.BlueprintProliferation.Translate(), 15).WithSmallerBox(22f); + _checkbox = MyCheckBox.CreateCheckBox(Left, 42, _panel, false, + I18NKeys.BlueprintProliferation.Translate(), 15).WithSmallerBox(20f); _checkbox.gameObject.name = "blueprint-proliferation"; _checkbox.OnChecked += OnProliferationChecked; - _basisLabel = LayoutHelper.AddText(Left, 80, _panel, I18NKeys.BlueprintProductionBasis, 14); - _basisCombo = MyCornerComboBox.CreateComboBox(Left, 108, _panel).WithFontSize(14); + _basisLabel = LayoutHelper.AddText(Left, 68, _panel, I18NKeys.BlueprintProductionBasis, 14); + _basisCombo = MyCornerComboBox.CreateComboBox(0, 68, _panel).WithFontSize(14); // The star-panel localizer would replace the stretched width on every enable or language change. var localizer = _basisCombo.GetComponent(); if (localizer) @@ -171,15 +187,11 @@ public class BlueprintDescriptionPatch : PatchImpl var combo = _basisCombo.GetComponent(); combo.CanInput = false; combo.autoWidth = false; - var comboRect = (RectTransform)_basisCombo.transform; - comboRect.anchorMax = Vector2.one; - comboRect.sizeDelta = new Vector2(-Left * 2, 28); + combo.ItemHeight = 24; Util.NormalizeRectWithMargin(_basisCombo.transform.Find("Main Button"), 0, 0, 0, 0); combo.m_Text.alignment = TextAnchor.MiddleLeft; combo.m_ListItemRes.GetComponentInChildren().alignment = TextAnchor.MiddleLeft; - _basisCombo.SetItems(I18NKeys.BlueprintFinalProducts, I18NKeys.BlueprintBottleneckIntermediate); - _basisCombo.SetIndex(0); - _basisHelp = LayoutHelper.AddTipsButton(Left, 80, _panel, + _basisHelp = LayoutHelper.AddTipsButton(Left, 68, _panel, I18NKeys.BlueprintProductionBasis.Translate(), I18NKeys.BlueprintProductionBasisTip.Translate(), ""); UpdateLabels(); _panel.gameObject.SetActive(false); @@ -210,11 +222,107 @@ public class BlueprintDescriptionPatch : PatchImpl private void ToggleOptions() { + if (_optionsOpen) + { + CloseOptions(); + return; + } + _optionsOpen = true; _panel.SetAsLastSibling(); - _panel.gameObject.SetActive(!_panel.gameObject.activeSelf); + _panel.gameObject.SetActive(true); + PositionOptions(); + if (_optionsOpen) Canvas.willRenderCanvases += PositionOptions; } - private void CloseOptions() => _panel.gameObject.SetActive(false); + private void CloseOptions() + { + Canvas.willRenderCanvases -= PositionOptions; + _optionsOpen = false; + if (_panel) _panel.gameObject.SetActive(false); + } + + public void HandleInput() + { + if (!_optionsOpen) return; + var combo = _basisCombo.GetComponent(); + if (VFInput.escape) + { + if (combo.isDroppedDown) + { + combo.isDroppedDown = false; + combo.m_DropDownList.gameObject.SetActive(false); + } + else CloseOptions(); + VFInput.UseEscape(); + return; + } + if (!Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2)) return; + var mouse = (Vector2)Input.mousePosition; + if (RectTransformUtility.RectangleContainsScreenPoint(_panel, mouse, _canvas.worldCamera) || + RectTransformUtility.RectangleContainsScreenPoint((RectTransform)_entry.transform, mouse, _canvas.worldCamera) || + combo.isDroppedDown && RectTransformUtility.RectangleContainsScreenPoint(combo.m_DropDownList, mouse, _canvas.worldCamera)) + return; + CloseOptions(); + } + + private Rect BoundsInPopupParent(RectTransform rect) + { + rect.GetWorldCorners(_corners); + var min = new Vector2(float.PositiveInfinity, float.PositiveInfinity); + var max = new Vector2(float.NegativeInfinity, float.NegativeInfinity); + foreach (var corner in _corners) + { + var point = _panel.parent.InverseTransformPoint(corner); + min = Vector2.Min(min, point); + max = Vector2.Max(max, point); + } + return Rect.MinMaxRect(min.x, min.y, max.x, max.y); + } + + private void PositionOptions() + { + if (!_optionsOpen) return; + if (!_entry || !_entry.gameObject.activeInHierarchy) + { + CloseOptions(); + return; + } + var anchor = BoundsInPopupParent((RectTransform)_entry.transform); + var screen = BoundsInPopupParent((RectTransform)_canvas.transform); + if (!anchor.Overlaps(screen) || _viewport && !anchor.Overlaps(BoundsInPopupParent(_viewport))) + { + CloseOptions(); + return; + } + var combo = _basisCombo.GetComponent(); + var extra = combo.isDroppedDown ? combo.DropDownCount * combo.ItemHeight + 2 * combo.ItemPadding + 2 : 0; + var footerTop = 112 + extra; + _panel.sizeDelta = new Vector2(_panel.sizeDelta.x, footerTop + 30 + Left); + Util.NormalizeRectWithTopRight(_button, Left, footerTop, _panel); + if (!TryGetPopupPosition(anchor, screen, _panel.sizeDelta, out var position)) + { + CloseOptions(); + return; + } + var parent = (RectTransform)_panel.parent; + _panel.anchoredPosition = position - new Vector2(parent.rect.xMin, parent.rect.yMax); + } + + private static bool TryGetPopupPosition(Rect anchor, Rect screen, Vector2 size, out Vector2 position) + { + const float gap = 6; + const float margin = 8; + position = default; + if (size.x > screen.width - margin * 2 || size.y > screen.height - margin * 2) return false; + var left = Math.Max(screen.xMin + margin, + Math.Min(anchor.xMax - size.x, screen.xMax - margin - size.x)); + var top = anchor.yMin - gap; + if (top - size.y < screen.yMin + margin) + top = anchor.yMax + gap + size.y; + top = Math.Min(screen.yMax - margin, Math.Max(screen.yMin + margin + size.y, top)); + position = new Vector2(left, top); + return true; + } public void UpdateLabels() { @@ -224,29 +332,43 @@ public class BlueprintDescriptionPatch : PatchImpl _entry.tips.tipTitle = I18NKeys.BlueprintAutoFillDescription.Translate(); _entry.tips.tipText = I18NKeys.BlueprintDescriptionOptionsTip.Translate(); _entry.UpdateTip(); - _buttonText.text = I18NKeys.BlueprintAutoFillDescription.Translate(); - _cancelText.text = I18NKeys.Cancel.Translate(); - ((RectTransform)_cancelButton.transform).sizeDelta = - new Vector2(Util.GetPreferredWidth(_cancelText) + 20, 24); + _title.text = I18NKeys.BlueprintAutoFillDescription.Translate(); + _buttonText.text = I18NKeys.BlueprintGenerateDescription.Translate(); _checkbox.SetLabelText(I18NKeys.BlueprintProliferation.Translate()); _basisLabel.text = I18NKeys.BlueprintProductionBasis.Translate(); var combo = _basisCombo.GetComponent(); - var index = combo.itemIndex; + var index = Math.Max(0, combo.itemIndex); _basisCombo.SetItems(I18NKeys.BlueprintFinalProducts, I18NKeys.BlueprintBottleneckIntermediate); - _basisCombo.SetIndex(index); _basisHelp.tips.tipTitle = I18NKeys.BlueprintProductionBasis.Translate(); _basisHelp.tips.tipText = I18NKeys.BlueprintProductionBasisTip.Translate(); _basisHelp.UpdateTip(); - var width = Math.Max(160f, Util.GetPreferredWidth(_buttonText) + 26f); - _button.transform.GetComponent().sizeDelta = - new Vector2(width, _button.transform.GetComponent().sizeDelta.y); + var width = Math.Max(90f, Util.GetPreferredWidth(_buttonText) + 20f); + ((RectTransform)_button.transform).sizeDelta = new Vector2(width, 30); var labelWidth = Util.GetPreferredWidth(_basisLabel); - _basisLabel.rectTransform.sizeDelta = new Vector2(labelWidth, _basisLabel.rectTransform.sizeDelta.y); - Util.NormalizeRectWithTopLeft(_basisHelp, Left + labelWidth + ControlsGap, 80, _panel); + _basisLabel.rectTransform.sizeDelta = new Vector2(labelWidth, 28); + var helpRect = (RectTransform)_basisHelp.transform; + Util.NormalizeRectWithTopLeft(_basisHelp, Left + labelWidth + ControlsGap, + 68 + (28 - helpRect.rect.height) / 2, _panel); + var comboLeft = Left + labelWidth + ControlsGap + helpRect.rect.width + ControlsGap; + var comboWidth = 180f; + foreach (var key in new[] { I18NKeys.BlueprintFinalProducts, I18NKeys.BlueprintBottleneckIntermediate }) + { + combo.m_Text.text = key.Translate(); + comboWidth = Math.Max(comboWidth, Util.GetPreferredWidth(combo.m_Text) + 40); + } + _basisCombo.SetIndex(index); + Util.NormalizeRectWithTopLeft(_basisCombo, comboLeft, 68, _panel); + _basisCombo.SetSize(comboWidth, 28); + var popupWidth = Math.Max(320, Math.Max(comboLeft + comboWidth + Left, + Util.GetPreferredWidth(_title) + Left * 2 + 50)); + _panel.sizeDelta = new Vector2(popupWidth, _panel.sizeDelta.y); + _title.rectTransform.sizeDelta = new Vector2(popupWidth - Left * 2 - 50, 24); + PositionOptions(); } public void Destroy() { + CloseOptions(); if (_entry) { _entry.button.onClick.RemoveListener(ToggleOptions); @@ -254,8 +376,8 @@ public class BlueprintDescriptionPatch : PatchImpl } if (_button) _button.button.onClick.RemoveListener(Generate); - if (_cancelButton) - _cancelButton.button.onClick.RemoveListener(CloseOptions); + if (_closeButton) + _closeButton.button.onClick.RemoveListener(CloseOptions); if (_checkbox) _checkbox.OnChecked -= OnProliferationChecked; if (!_panel) return; diff --git a/UXAssist/README.md b/UXAssist/README.md index 5e7397f..6323920 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -17,7 +17,8 @@ * Strict hotkey dectection for build menu, thus building hotkeys(0~9, F1~F10, X, U) are not triggered while holding Ctrl/Alt/Shift. * Fix a bug that warning popup on `Veins Utilization` upgraded to level 8000+ * Sort blueprint structures before saving, to reduce generated blueprint data size a little - * Add an `Auto-fill` entry to the description header in the blueprint browser, copy, and paste inspectors. Click it to open generation options without moving or resizing native fields or covering the file list + * Add an `Auto-fill` entry to the description header in the blueprint browser, copy, and paste inspectors. Click it to open options beside the entry without moving or resizing native fields; the popup follows the entry while scrolling and adjusts its position at screen edges + * The popup has an `Auto-fill description` title, a native X close button, proliferation and production-basis options, and one `Generate` button at the bottom. Opening the dropdown expands the background and moves the action below its rows. Close with the X, an outside click, or Esc; when the dropdown is open, Esc closes it first. Successful generation closes the popup. * `Production basis` defaults to `Final-product output` each time the inspector opens, retaining rated final outputs and showing intermediate shortages and excess. Choose `Lowest intermediate throughput` to scale the final-product mix together to the bottleneck, using recipe ratios and shared intermediate demand. Complete, balanceable chains then have no internal shortages; unused intermediate capacity appears as excess. External inputs and final outputs use the same basis. * `Proliferation` defaults to on when the blueprint contains a Spray Coater; it can be changed manually. Power demand still estimates all selected buildings at full load in either production basis. * Replaces the main description with material flows per minute and writes power demand to a `Power` custom field, preserving other custom fields. If the bottleneck basis cannot be determined, the existing description is kept; check missing building settings and chain outputs, or select `Final-product output`. Save the blueprint manually to keep generated changes. @@ -225,7 +226,8 @@ * 更严格的建造菜单热键检测,因此在按住Ctrl/Alt/Shift时不再会触发建造热键(0~9, F1~F10, X, U) * 修复了`矿物利用`升级到8000级以上时弹出警告的bug * 保存蓝图前对建筑进行排序,以减少生成的蓝图数据大小 - * 在蓝图浏览、复制和粘贴检查面板的说明标题行增加「自动填写」入口,点击展开生成选项,不移动或缩放原生字段,也不遮挡文件列表 + * 在蓝图浏览、复制和粘贴检查面板的说明标题行增加「自动填写」入口,点击后在入口旁打开生成选项,不移动或缩放原生字段;滚动时弹出面板跟随入口,并在屏幕边缘调整位置 + * 面板包含「自动填写说明」标题、原生叉号关闭按钮、增产和产量基准选项,以及底部单个「生成说明」按钮。展开下拉列表时,背景增高,操作按钮移至列表下方。可通过叉号、点击外部或 Esc 关闭;下拉列表展开时,Esc 先收起列表。生成成功后关闭面板。 * 每次打开检查面板时,「产量基准」默认为「最终产物产量」,保留最终产物的额定产量,并显示中间产物的缺口和余量。选择「最低产量中间产物」后,按配方比例和共享中间物料的需求换算瓶颈,等比例缩放各最终产物。数据完整且可平衡的生产链没有内部缺口,未使用的中间产能列为「多余」;外部输入和最终输出采用同一基准。 * 蓝图含喷涂机时默认勾选「增产」,也可手动修改。两种产量基准均按所选全部建筑满载估算耗电。 * 用每分钟的物料流量替换原说明,将耗电写入「耗电」自定义字段,保留其他自定义字段。无法确定瓶颈基准时保留原说明;可检查缺失的建筑参数和生产链输出,或改选「最终产物产量」。填写后需手动保存蓝图。 diff --git a/UXAssist/docs/BlueprintDescriptionValidation.md b/UXAssist/docs/BlueprintDescriptionValidation.md index b8523d6..5628681 100644 --- a/UXAssist/docs/BlueprintDescriptionValidation.md +++ b/UXAssist/docs/BlueprintDescriptionValidation.md @@ -22,36 +22,47 @@ The relevant original methods can be reproduced by decompiling the following typ | `UIBlueprintInspector.OnCustomFieldEndEdit(string str)` and `CollectExternalFields(int excludeTargetId = -1)` | Collect, escape, and validate pending custom-field edits through the native path. | | `UIBlueprintInspector.OnCopyClick()`, `OnSaveChangesClick()`, and `OnSaveClick()` | Serialize or save the current blueprint with the game's native workflow. | -The native `descGroupTrans` in all three inspectors contains a description label at the top and an input beginning 22 pixels below it. The compact UXAssist entry occupies the right side of this existing title row; it does not move the title, input, groups, or scroll content. Options appear only on request inside the inspector and close after successful generation or inspector closure. The browser's file grid remains outside the UXAssist controls. Following the separate native settings panel is unnecessary, and no per-frame positioning patch is used. +The native `descGroupTrans` in all three inspectors contains a description label at the top and an input beginning 22 pixels below it. The compact UXAssist entry occupies the right side of this existing title row. Options open next to the actual entry and follow it after layout and scrolling; only owned popup transforms are positioned. Native labels, inputs, groups, scroll content, and the separate settings panel retain their native layout. `UIBlueprintInspector.Refresh(forModify: true)` does not reload `descTextInput`. Successful generation must assign both the blueprint description and its input before using the native modification refresh. Pending custom fields must first pass through the native field collection and escaping rules. Native copy and save handlers serialize the current blueprint, so they remain the actions used to share or persist a generated description. Decompiled methods and extracted rectangle data are development artifacts under `UXAssist/obj/native-inspector/`. Reinspect the installed original assembly and assets after a game update; the publicized compile-time references omit method bodies. -## Options layout correction on 2026-11-04 +## Anchored options and native conventions -The reported screenshot shows the production-basis selector displaced to the right and its expanded list wider than the options panel. The correction applies to this selector in the existing on-demand options. +The original DLL and `level0` hashes and installed version above were rechecked on 2026-11-04. The supplied screenshot shows why a fixed position at the inspector's top loses its connection to the entry after several custom fields. The options now use the entry's world corners, transformed into the popup parent's coordinates, and actual root-canvas bounds. Placement prefers below the entry with a 6-pixel gap and aligned right edges, flips above when needed, and clamps against an 8-pixel canvas inset. A panel too large for that area is closed. `Canvas.willRenderCanvases` reconciles placement after native layout only while open. An inactive or fully clipped entry closes its popup. -The selector is cloned from `UIRoot.instance.uiGame.starDetail.displayCombo`. Its root inherits a `Localizer` with `wParamKey = "恒星信息面板组合框宽度"`, `sizeApplyTrans = null`, and `def_w = 0`. Original `Localizer.OnEnable()` subscribes to language changes and immediately calls `Refresh()`; `OnLanguageChange()` also calls `Refresh()`. With no separate size target, `Refresh()` writes the translated positive width to the combo root's `sizeDelta.x`. The blueprint selector uses horizontal stretch with an intended width delta of `-24`, so this source-specific width assignment expands the root beyond its parent. Reopening the options re-enables the inherited component, explaining why an initial size assignment alone does not hold. +The panel has an `Auto-fill description` title and native X, then a 20-pixel proliferation row and a 28-pixel production-basis row with help. A single 30-pixel `Generate` action sits at the lower right. Localized preferred widths determine panel and selector width. The closed-list panel is 154 pixels high; two 24-pixel dropdown rows, 4 pixels of padding, and a 2-pixel gap add 54 pixels when expanded. The background grows to 208 pixels and the footer moves below the list. -The original DLL and `level0` hashes and the installed version above were rechecked on 2026-11-04. The native locale parameter is 200 in `Locale/1033/parameters.txt` and 90 in `Locale/2052/parameters.txt`, both at line 28. With the original 392- and 394-pixel inspector variants, the inherited assignment produces combo widths of 568/570 in English or 458/460 in Simplified Chinese. The corrected stretched root is 344/346 pixels wide, and the main button, list, content, row template, and selection share its horizontal bounds. +The X comes from `inserterWindow/panel-bg/btn-box/close-wnd-btn`: a 40-by-30 native button with a centered 16-by-16 icon and a transparent 30-by-19 raycast child. Its original serialized `Button.onClick` targets the original inserter window's `_Close`. The owned clone replaces the entire `Button.ButtonClickedEvent` before adding its popup callback; removing runtime listeners alone would leave that persistent callback active. -The original combo also has a right-anchored, right-pivoted main button with its own fixed width and right-aligned selected and item-template text. The correction disables and removes only the owned clone root's `Localizer` before setting its geometry, disables `autoWidth` before setting items or index, stretches the main button to its owned root, and left-aligns the selected and template text. Source dropdown, content, template, and selection rectangles already use horizontal stretch with zero width delta and are retained. Original `UIComboBox.SetState()` adjusts list and content heights and row positions, preserving their width deltas; it does not repair a source-specific root width. +The source production-basis combo also carries source-specific behavior. Its root `Localizer` uses `wParamKey = "恒星信息面板组合框宽度"`, `sizeApplyTrans = null`, and `def_w = 0`. `OnEnable()` and `OnLanguageChange()` call `Refresh()`, which writes the root's width. Native locale parameters are 200 in `Locale/1033/parameters.txt` and 90 in `Locale/2052/parameters.txt`, both at line 28. The owned clone disables and removes this component before assigning dimensions, and disables `autoWidth` before setting items and index. Its main button fills the owned root, with selected and row-template text aligned left. Correct native horizontal anchors are retained. Native combo row `PointerDown` first selects the item, then closes the list; no extra submit-close callback is added. -The popup remains 152 pixels high, with a 28-pixel selector starting 108 pixels below its top. Native dropdown placement adds a 2-pixel gap and uses two 18-pixel rows with 4 pixels of total padding. The expanded list therefore reaches 178 pixels below the popup top, extending 26 pixels below the background as a native dropdown overlay. Check this overlay in-game at the target UI scale. +| Original source | Behavior used by the popup | +| --- | --- | +| `UIRoot._OnUpdate()` and `EscapeInputLogic()` | Give native message boxes Escape priority before the game UI updates. | +| `UIGame._OnUpdate()` | Updates blueprint inspectors before later native picker and function-window Escape handlers. The owned inspector postfix consumes Escape after closing an expanded dropdown or its popup. | +| `UIItemPicker._OnUpdate()` | Tests left, right, and middle clicks outside a screen rectangle using the overlay canvas camera. The owned test also accepts the entry and an open dropdown. | +| `UIPopupMenu.SetState()` | Constrains popup placement to game UI bounds and brings it to the front. | +| Native blueprint settings, color-palette input rows, and inspector footer | Supply 20-pixel checkbox, 28-pixel input-row, and 30-pixel primary-action conventions. | +| Native inserter close-button subtree and combo row event routing | Supply the actual X artwork/hit area and the select-then-close event order. | -The persistent task evidence bundle `2026-11-04-UXAssist-BlueprintDescriptionLayout` retains `reported-layout.png`, the native combo and background JSON captures, focused `Localizer` and `UIComboBox` decompilations, `inspect_native_layout.py`, `reproduce_geometry.py`, and `geometry-lifecycle-replay.json`. Rectangle calculations or schematic previews derived from these files are evidence of geometry, not screenshots of a repaired running game. +The persistent task evidence bundle `2026-11-04-UXAssist-BlueprintDescriptionLayout/anchored-options/` retains the current reported screenshot, `native-recommendations.md`, `native-inserter-close-button.json`, `native-combo-row-routing.json`, focused original decompilations, asset captures, and extraction scripts. `layout-preview.png` is a marked schematic using the exported native X artwork; its fonts and background are representative. Calculated geometry, a test harness, and this preview must be distinguished from screenshots of a running game. These checks do not execute Unity event dispatch, measure native font rendering, or establish third-party mod compatibility. -Recorded checks for this correction: +## Recorded placement checks + +The temporary placement harness extracts the actual private `TryGetPopupPosition` method body from `BlueprintDescriptionPatch.cs` and compiles it with data-only `Rect` and `Vector2` substitutes. It does not mirror the placement algorithm in a second implementation. Sources and results are preserved under `anchored-options/actual-placement-check/` and `actual-placement-check.json`. + +The harness passed 8 exact placement cases, 3 oversized-panel rejection cases, and 1,920 native-parent fixtures, totaling 20,191 assertions. Fixtures cover the 392- and 394-pixel native inspector frames, translated and scaled parent coordinates, scales 0.75/1/1.25/1.5, scrolling, below/above placement, canvas edges, and 154/208-pixel panel heights. Widths of 320/360/440/520 pixels are supplied test inputs, rather than measured English or Chinese font widths. The expanded-list checks also verify the 16-pixel gap before the moved footer. This is analytical geometry validation; it does not run Unity layout or input events. + +Final development checks on 2026-11-04: | Check | Result | | --- | --- | | Normal Release build, using the command below | Passed with 0 warnings and 0 errors. | | `ProductionCheck` | 569 checks passed. | -| Original-asset geometry replay | 64 analytical combinations passed: inspector widths 392/394, English/Simplified Chinese, first opening/two reopenings/language change, and scales 0.75/1/1.25/1.5. | -| Focused UI code review and `git diff --check` | Passed. | - -The geometry replay calculates rectangle bounds from captured assets and the original `Localizer` rules. It does not execute Unity enable or language-change events, measure font rendering or preferred text width, or test mouse interaction. The evidence bundle's `test-build/UXAssist.dll` has SHA-256 `3645ebfe03fb5ed7bc50459f25e0e6557d903db852624d640eafbd588e735ef5`. +| Actual-source placement harness | All cases and assertions above passed on the final source. | +| Whole-diff code review and `git diff --check` | Passed. | ## Managed production checks @@ -69,10 +80,12 @@ The production-basis cases check an undersupplied chain, recipe-ratio conversion No in-game, Unity event-loop, or third-party mod integration test has been performed for this change. Repeat these checks at the target profile's resolutions and UI scales, with each installed blueprint UI mod. The header entry avoids native layout writes but another mod may use the same extension space. -1. Open all three inspectors in English and Simplified Chinese. Confirm the header entry is readable without covering the title or editable description. Open, close, and reopen its options, and switch languages while they are open. The production-basis selector and both dropdown rows must retain matching widths inside the inspector, with readable left-aligned labels. Generate and close the inspector; options must not remain over the file grid or survive an inspector close. -2. Scroll the native description and custom fields and expand native foundation, fill-only, and reform settings. All native fields must retain their positions and sizes, and scrolling must reach every field. -3. Reopen each inspector and repeatedly refresh or change the blueprint selection. Confirm there is one entry, options are initially closed, the production basis resets to final-product output on opening, Spray Coaters set the automatic proliferation default, and a manual checkbox choice survives content refreshes in the current session. -4. Generate both production bases for an unbalanced chain. Final-product output should retain rated final capacity and show the missing intermediate; lowest intermediate throughput should reduce the common final-output mix, use correspondingly reduced external inputs, and show no internal shortage when the chain is complete and balanceable. Power should remain the same full-load estimate. Check necessary coproduct output separately from unused intermediate capacity. -5. Edit the description and unrelated custom fields before generating. Generate twice, including with 20 custom fields and with existing English or Chinese power fields. Confirm unrelated edits survive, duplicate power fields are consolidated, and failed generation leaves the prior description and fields intact. Include missing building settings, an unavailable bottleneck basis, and the native description length limit. -6. Save, copy the share code, and reopen or paste the blueprint through the native buttons. Confirm the generated main description, power field, and unrelated fields persist correctly. With a research-mode lab, confirm net produced matrices appear under Research without fabricated matrix imports or research speed. -7. Restart the test profile without UXAssist, then restore it and restart again. Confirm the entry and options are absent without UXAssist, native fields keep their normal layout in both cases, and repeated opening and generation work with the installed blueprint mods. `OnDisable` and inspector-destruction cleanup are code-review checks unless a development harness exercises them; a supported user-facing hot-disable workflow is not assumed. +1. Open each inspector in English and Simplified Chinese with different custom-field counts. Click its header entry. Confirm the popup opens beside that actual entry, with a title, native X, compact options, and a single footer action. At screen edges, confirm it flips or shifts into available canvas space. +2. Scroll while the popup is open. Confirm it follows the entry after native layout and closes when the entry is fully clipped. Expand native foundation, fill-only, and reform settings; all native fields must retain their positions and sizes, and scrolling must reach every field. +3. Open the production-basis list. Confirm both readable, left-aligned rows fit within the expanded background above the footer. Select each item and confirm it closes the list without generating text. Reopen the popup and change language; selector dimensions and footer spacing must remain valid. +4. Close the popup with its X; the inspector and an open inserter window must remain open. Reopen and click outside with the left, right, and middle mouse buttons: the popup should close, and the clicked native control or world target should retain its normal behavior. Press Esc with the list expanded: only the list should close. Press Esc again: the popup should close while the inspector stays open. With a native message box present, its Escape handler must retain priority. +5. Reopen each inspector and repeatedly refresh or change the blueprint selection. Confirm there is one entry, options are initially closed, the production basis resets to final-product output on opening, Spray Coaters set the automatic proliferation default, and a manual checkbox choice survives content refreshes in the current session. Successful generation, a replacement blueprint, and inspector closure must dismiss the popup. +6. Generate both production bases for an unbalanced chain. Final-product output should retain rated final capacity and show the missing intermediate; lowest intermediate throughput should reduce the common final-output mix, use correspondingly reduced external inputs, and show no internal shortage when the chain is complete and balanceable. Power should remain the same full-load estimate. Check necessary coproduct output separately from unused intermediate capacity. +7. Edit the description and unrelated custom fields before generating. Generate twice, including with 20 custom fields and with existing English or Chinese power fields. Confirm unrelated edits survive, duplicate power fields are consolidated, and failed generation leaves the prior description and fields intact. Include missing building settings, an unavailable bottleneck basis, and the native description length limit. +8. Save, copy the share code, and reopen or paste the blueprint through the native buttons. Confirm the generated main description, power field, and unrelated fields persist correctly. With a research-mode lab, confirm net produced matrices appear under Research without fabricated matrix imports or research speed. +9. Restart the test profile without UXAssist, then restore it and restart again. Confirm the entry and options are absent without UXAssist, native fields keep their normal layout in both cases, and repeated opening and generation work with the installed blueprint mods. `OnDisable` and inspector-destruction cleanup are code-review checks unless a development harness exercises them; a supported user-facing hot-disable workflow is not assumed. diff --git a/UXAssist/docs/ProductionArchitecture.md b/UXAssist/docs/ProductionArchitecture.md index 25c72ce..8c98920 100644 --- a/UXAssist/docs/ProductionArchitecture.md +++ b/UXAssist/docs/ProductionArchitecture.md @@ -70,11 +70,15 @@ Native research uses the current lab technology's matrix point requirements, wit ## Blueprint descriptions -The shared `UIBlueprintInspector` in browser, copy, and paste modes adds a compact `Auto-fill` entry to the existing description header. Its options open on demand within the inspector, rather than occupying the browser file grid. Only UXAssist-owned transforms are positioned: native fields, groups, anchors, and scroll height remain owned by the game. No per-frame layout patch or native-settings tracking is needed. Disable and destruction remove only the UXAssist controls. +The shared `UIBlueprintInspector` in browser, copy, and paste modes adds a compact `Auto-fill` entry to the existing description header. Its options panel is an owned child of `inspector.rectTrans`, outside the scroll mask. On opening, actual entry corners and root-canvas bounds are converted into that parent's coordinates. The private placement method in `InspectorControls` prefers a position below the entry with their right edges aligned, flips above when needed, and clamps against canvas bounds; a panel too large for those bounds is closed. A `Canvas.willRenderCanvases` subscription follows the entry after native layout and scrolling only while the options are open; hiding the entry or scrolling it completely outside its viewport closes the popup. Native fields, groups, anchors, and scroll height remain owned by the game. Closing, disabling, and destruction unsubscribe the positioning callback and remove only owned controls as appropriate. -The production-basis selector clones the star-detail combo. Disable and remove the clone root's inherited `Localizer` before applying its horizontal stretch: that source component writes a star-panel-specific width on enable and language changes. Turn off the clone's `UIComboBox.autoWidth` before populating items, stretch its main button within the owned root, and align its selected and template text to the left. Preserve the native dropdown, content, item-template, and selection anchors; native `UIComboBox.SetState` already controls row heights. These adjustments belong to this selector rather than the shared combo helper. The expanded list keeps the native overlay behavior and may extend below the options background while remaining within the inspector. +The options use a title and the actual native X subtree, then a 20-pixel proliferation checkbox row, a 28-pixel production-basis row with help, and one 30-pixel `Generate` action at the lower right. Width is measured from the localized labels and choices. The normal 154-pixel panel gains 54 pixels when the two 24-pixel dropdown rows open, moving the footer below the list. The cloned X must receive a new `Button.ButtonClickedEvent`: its source has a persistent callback to the original inserter window that `RemoveAllListeners` does not remove. -The options contain `Auto-fill description`, `Proliferation`, and a `Production basis` selector with a localized help tip. Each inspector open resets the basis to `Final-product output`, retaining existing calculation behavior; selecting `Lowest intermediate throughput` opts into `BottleneckIntermediate` for generation. The checkbox initially reflects the blueprint's Spray Coater prefab capability and tracks content changes until manually changed in the current editing session; changing it does not modify the blueprint. Generation captures only `blueprint.buildings` with `BlueprintSelectionReader.FromBlueprint` on the game thread, then runs `FactoryBlackBoxAnalyzer` against the captured catalog. A successful bottleneck solve supplies classification and steady-state balances directly; the original classifier runs only in final-product mode or after an unavailable bottleneck result. The maximum supported proliferation level applies while each building keeps its acceleration or extra-products mode. Input coating is assumed to be supplied externally; no spray routing or spray consumption is inferred from the Spray Coater. +The production-basis selector clones the star-detail combo. Disable and remove the clone root's inherited `Localizer` before assigning owned dimensions: that source component writes a star-panel-specific width on enable and language changes. Turn off the clone's `UIComboBox.autoWidth` before populating items, stretch its main button within the owned root, and align its selected and template text to the left. Preserve the native dropdown, content, item-template, and selection anchors; native `UIComboBox.SetState` controls row heights and the native row event selects an item before closing the list. These adjustments belong to this selector rather than the shared combo helper. + +Handle dismissal in the owning inspector's `_OnUpdate` postfix. Processed `VFInput.escape` respects an earlier native message-box handler; close an expanded dropdown first, otherwise close the popup, then consume Escape before later native window-closing handlers run. Left, right, or middle clicks outside the popup, entry, and open dropdown close the options while preserving the clicked native target's normal behavior. Successful generation, blueprint replacement, and inspector closure also close the options. + +Each inspector open resets the basis to `Final-product output`, retaining existing calculation behavior; selecting `Lowest intermediate throughput` opts into `BottleneckIntermediate` for generation. The checkbox initially reflects the blueprint's Spray Coater prefab capability and tracks content changes until manually changed in the current editing session; changing it does not modify the blueprint. Generation captures only `blueprint.buildings` with `BlueprintSelectionReader.FromBlueprint` on the game thread, then runs `FactoryBlackBoxAnalyzer` against the captured catalog. A successful bottleneck solve supplies classification and steady-state balances directly; the original classifier runs only in final-product mode or after an unavailable bottleneck result. The maximum supported proliferation level applies while each building keeps its acceleration or extra-products mode. Input coating is assumed to be supplied externally; no spray routing or spray consumption is inferred from the Spray Coater. `BlueprintDescriptionFormatter` builds replacement multiline `blueprint.desc` text in this order: optional `Missing:` and `Excess:` lines for intermediate shortages and excess classified by the selected production basis; `Input:` for external inputs capped by downstream demand; `Output:` for ordinary final products and necessary coproduct surplus; and `Research:` for positive net matrix production accepted by a selected research-mode lab. Each warning category has one label followed by comma-separated items; warnings do not repeat in Input, and a matrix on Research does not repeat in Output. It uses `SteadyStateExternalSupply` for complete and independently known partial inputs, labeling partial values as known portions. The assumed lab adds no numerical matrix consumption or external input; other buildings' known matrix demand is subtracted from the Research rate. Omit each empty line, including Research when no produced matrix remains. A single optional `Power` custom field separates factory and configured logistics consumption, omitting categories with no demand and removing the field altogether if neither consumes power; a present but unknown category displays `Unknown` rather than zero. Material rates remain items per minute even though the description labels omit the unit. Rates are rounded only for display. Large displayed rates use the largest exact K/M/G suffix with at most one decimal place (for example, 1,234,000 becomes 1,234K); if no suffix preserves that display precision, keep the ordinary number. Numbers with four or more integer digits use comma thousands separators, including coefficients before material or power units. Rates are ordered by item ID within each category, and use native item icon/name tags with comma-separated entries inside each description line. Uncertain final-product, overbuild, or coproduct conclusions are omitted. Veins and other scene objects are not blueprint entries or requested parameters. @@ -131,7 +135,7 @@ Use a test game for the following manual checks. Compare full-load rates only wi - Select miners at different machine speeds, including one with a backed-up output, a gas collector, and renewable generators. Check native miner power scaling, full-load miner output regardless of the output backlog, per-minute gas output without added grid demand, and ideal rated renewable power rather than local conditions. - Select ray receivers in both modes, fuel generators, ejectors, and silos. Toggle proliferation and compare working power, generation, accumulator exchange, and Dyson demand as separate quantities. In a sandbox game, capture boosted artificial stars and launchers, and confirm that blueprint analysis of boosted buildings requires `BoostEnabled`. - Remove an upstream producer from a mixed production selection. Confirm that downstream capacity is unchanged and the missing material appears as required external supply. Add one producer more than downstream demand needs, and confirm that only that whole building's output is reported as excess. -- In browser, copy, and paste inspectors, check the localized description-header entry and options, Spray Coater defaults and manual overrides, and native item tags in the generated description and `Power` field. Confirm options close after successful generation or inspector closure, the file grid stays usable, and native settings and description fields retain their positions. Generate twice and at the 20-field limit; verify that pending manual edits, unrelated fields, save/copy behavior, and ordinary blueprint sharing remain intact. +- In browser, copy, and paste inspectors, check that the localized options follow their header entry when scrolling and use the available canvas space. Verify the native X, outside-click dismissal, and Escape priority, including an expanded dropdown and a native message box. Confirm both dropdown rows fit above the footer, options close after successful generation or inspector closure, and native settings and description fields retain their positions. Check Spray Coater defaults and manual overrides, generate twice and at the 20-field limit, and verify pending edits, unrelated fields, native item tags, and save/copy behavior. - Compare both production bases on an undersupplied chain, uneven recipe ratios, shared intermediate branches, and a joint-product chain. Final-product mode must retain rated final outputs and expose intermediate shortages. Bottleneck mode must scale final outputs together, update raw inputs to the same throughput, and leave no internal shortage for a complete, balanceable chain. Confirm unused intermediate capacity and necessary coproduct output remain distinct, and that power stays at the same full-load estimate. Test a chain without internal intermediates, missing building settings, and a cycle without a final outlet; an unavailable bottleneck basis must preserve existing description and fields. - Place one research-mode lab alongside one or all six matrix production chains. Confirm the matrices' positive net production appears only in the Research line, other final products stay in Output, and known in-blueprint matrix consumption reduces the Research rate. Do not fabricate lab matrix imports, excess, or an estimated lab consumption rate; change current technology, add more labs, and toggle proliferation to check matrix routing stays independent while full working power updates. Without the lab, normal matrix output and overbuild rules resume. - Combine planner targets with shared coproducts, explicit raw-material boundaries, and alternate selected recipes. Confirm material conservation, shared surplus reuse, and no introduction of unselected recipes.