This repository was archived by the owner on Sep 20, 2026. It is now read-only.
fix(tooltips): handle unreferenced aura upgrade values - #218
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes upgrade-preview tooltip value fusion for certain Aura .mod tokens where the game’s native tooltip rendering path omits the ITooltipComponent argument when ReferencedAttribute == null, preventing BazaarPlusPlus’s upgrade value projection from recomputing the upgraded value (e.g., Guzheng 15 → 30).
Changes:
- Add a thread-local render scope around
CardTooltipData.RenderTooltipand capture “unreferenced but styled” Aura components immediately afterTooltipComponentAura.Resolve(). - Extend
UpgradePreviewValueRegistryto provide a per-render fallbackITooltipComponentwhen the native formatter passesnull. - Add a Guzheng-shaped regression scenario to the upgrade preview tooltip tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/UpgradePreviewTooltip.Tests/Program.cs | Adds a regression scenario modeling Guzheng’s player-attribute × card-attribute multiplier structure. |
| src/BazaarPlusPlus/Patches/Tooltips/UpgradePreviewValuePatch.cs | Introduces Harmony patches to establish a render scope and capture Aura components for fallback projection. |
| src/BazaarPlusPlus/Game/Tooltips/UpgradePreviewValueRegistry.cs | Implements thread-local render depth + fallback component storage/consumption to recover missing projection context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+192
to
+201
| AssertTrue( | ||
| guzhengProjection.TryResolve(guzhengToken, out var upgradedGuzhengMultiplier), | ||
| "Projected Guzheng aura token should resolve." | ||
| ); | ||
| AssertFloatEqual( | ||
| 30f, | ||
| upgradedGuzhengMultiplier, | ||
| "Guzheng Damage and Shield per Tempo should upgrade from 15 to 30." | ||
| ); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
古筝从金色升级到钻石时,Shift 升级预览仍显示“每层 Tempo 造成 15 伤害并获得 15 护盾”,没有展示应有的
15 → 30。根因是这两个值来自
{aura.*.mod}:Aura 外层引用玩家 Tempo,倍率内层才引用物品的Custom_0。游戏原生RenderTooltip对这类ReferencedAttribute == null、但带属性样式的 token 调用格式化函数时,没有传入 tooltip component,导致现有升级投影补丁缺少重算上下文。协作过程
sequenceDiagram participant U as 用户 participant C as Codex participant G as 游戏原生 Tooltip participant P as 升级投影 U->>C: 提供古筝升级预览无数值变化的截图 C->>G: 对照实时模板数据与反编译渲染路径 Note over C,G: 确认金色 Custom_0=15、钻石 Custom_0=30,且原生无 ReferencedAttribute 分支漏传 component C->>P: 复刻古筝的玩家属性 × 物品属性倍率结构 P-->>C: 投影可正确计算 15 → 30 C->>G: 在同步渲染作用域内交接 Aura token 上下文 C-->>U: 完成修复并加入回归测试方案讨论
考虑过修改投影算法和直接改写原生
RenderTooltip。投影算法本身在获得 Aura token 后能够正确计算 30,因此没有扩大其职责;直接 transpile 原生方法则依赖 IL 结构,游戏更新后更脆弱。最终采用范围受限的上下文交接:仅在
CardTooltipData.RenderTooltip同步调用期间捕获ReferencedAttribute == null的可着色 Aura token,并在原生省略 component 的格式化调用中消费。线程本地状态在渲染结束时清理,避免跨 tooltip 泄漏。最终方案
Resolve()后捕获原生遗漏的 component 上下文。ReferencedAttribute的.modtoken 从 15 投影为 30。验证情况
dotnet run --project tests/UpgradePreviewTooltip.Tests/UpgradePreviewTooltip.Tests.csproj -p:ManagedPath=".../Managed"dotnet build src/BazaarPlusPlus/BazaarPlusPlus.csproj -c Release --no-restore -p:ManagedPath=".../Managed" -p:BPPInstallerSourcePath=".../resources" -p:BuildProductionPackage=false(0 warnings / 0 errors)./run.sh format-checkgit diff --check已知局限 / 后续工作