Migrate and refine the trade window in Lua
## Outcome Replace the main native-presented Trade window with an XML/Lua package and refine its default presentation toward the supplied original-client reference while preserving the existing native trade rules, lifecycle, validation, and convenience features. ## Scope - Cover player trades, shops that buy and sell, and sell-only shops rendered by `TradeController`/`TradePresenter`. - Let Lua own the shared window composition, mode-specific sections, item grids/shop list, sizing policy, labels, totals, status indicators, and visual spacing. - Keep `ClientTradeState`, pricing/totals, affordability checks, server messages, confirmation flow, decline/close behavior, cash settlement/echo handling, inventory drops, item inspection/tooltips, and authoritative action validation native. - Use the existing Core Window, icon-grid, Table, preference, secure-action, diagnostics, and Lua window-service patterns rather than building parallel UI infrastructure. - Preserve shop grid/list mode, sorting/auto-arrange semantics, persisted window state, resizability, UI scaling, and Native AOT support. - Remove the superseded Trade XML/native layout and sizing implementation once the scripted route is complete. ## Visual target - Open at the compact three-column width shown in the original-client screenshot rather than the current six-column layout. - Use the supplied reference as the baseline for the taller shop shelf, one-row bought/sold sections, compact centered credits rows, section spacing, scrollbar placement, and bottom controls, while retaining PRK's resizable/list-mode enhancements. - Reuse existing GUI assets and standard shared window chrome; do not copy reverse-engineered code or identifiers. ## Known defect included Resolve `prk/spiritech-known-issues#132` / intake `prk/player-bug-intake#771`: the local player's offered credits must display thousands separators when not actively being edited, while editing/parsing remains stable, accepts grouped pasted text safely, caps at available cash, and preserves settle/echo behavior. ## Acceptance criteria - All three main Trade modes render and transition correctly through the Lua package with compact reference-aligned defaults. - Buying, returning, offering/removing items, drops, tooltips/inspection, acceptance/confirmation, decline/close/Escape, affordability refusal, partner lock status, unknown/non-credit totals, and shop sorting/list mode retain current behavior. - Lua receives bounded presentation data and scoped references; direct or stale script calls cannot execute trade commands, and authoritative state is revalidated natively. - Outgoing player-trade credits show grouped values outside active editing without caret corruption, parsing regressions, premature sends, or loss of cash caps. - Unchanged snapshots avoid unnecessary Lua work; package failure remains diagnosable and closable without trapping an open server trade. - Targeted unit/Lua tests, Native AOT acceptance, client build, and asset-backed render checks pass. ## Boundary This task covers the main Trade window shown in the screenshots. `NpcChatTrade.xml`, the separate NPC conversation hand-over panel, remains with the future Lua migration of NPC conversations and is excluded from this work. ## Verified outcome Implemented on `feature/migrate-trade-window-to-lua`. The main player/shop Trade window now uses the shipped XML/Lua package with compact three-column defaults, responsive grid/list layouts, secure scoped actions, legacy geometry migration, native drops/tooltips/inspection, and grouped inactive credit display. Superseded native layout/sizing code is removed. Validation passed on the final patch: 4,134 client tests passed with 185 environment-dependent skips; native Lua normal and sanitizer suites passed; Lua API self-test and both Native AOT suites passed; asset-backed player, shop, and sell-only renders passed; `git diff --check` passed. Review findings covering reference collisions, combat reconciliation, scripted close provenance, and restored geometry were fixed and regression-tested. The final follow-up review returned no verified findings, with one static correctness reviewer timing out. Pull request: #2860 — https://git.project-rk.com/prk/engines/pulls/2860 (`feature/migrate-trade-window-to-lua` → `develop`). Post-merge verification: user confirmed the change was merged and fully verified on all supported platforms.
Checklist
6 of 6 complete- Define bounded Trade Lua contracts and a native presentation/action adapter with generation-scoped references, icon/tooltips, pricing facts, and authoritative current-state validation.
- Build the Trade XML/Lua package from shared Core Window, icon-grid, Table, preference, and security components for player, shop, and sell-only modes.
- Match the compact three-column reference defaults and section/control geometry while retaining responsive resizing, list mode, sorting, scaling, and persisted state.
- Integrate the scripted component with TradeController lifecycle, drops, tooltips/inspection, confirmation, close/Escape decline, failure handling, and remove superseded native presentation/layout code.
- Fix offered-credit presentation so inactive/confirmed values are grouped while active editing, sanitization, cash caps, settle timing, and server-echo behavior remain correct.
- Add focused behavior/security/layout tests, Native AOT acceptance, and asset-backed renders for all Trade modes; run targeted Lua/client validation and build.
- Area
- Project Rubi-Ka
- Project
- engines
- Kind
- Feature
- Priority
- Medium
- Task ID
tsk_nvc9xzmb2d- Updated