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.
This commit is contained in:
soarqin committed 2026-11-04 22:57:23 +08:00
1 parent 8fd449d991
commit 51af1430bc
6 files changed
+209 -66

No files matched your search

+33 -20
View File
@@ -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.