mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-11-25 06:26:29 +08:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
defbd639e1 | ||
|
|
d61b4b2526 | ||
|
|
98116bef7b |
@@ -20,7 +20,7 @@ The entire Skill invocation must remain read-only:
|
|||||||
- Do not fix findings, advance phase, or update tasks, state, verification reports, or review records.
|
- Do not fix findings, advance phase, or update tasks, state, verification reports, or review records.
|
||||||
- Do not call this review a Verify pass or treat “no findings” as proof that tests passed.
|
- Do not call this review a Verify pass or treat “no findings” as proof that tests passed.
|
||||||
|
|
||||||
Only run commands needed to read files, query state, and inspect Git diffs. Checks that might execute project code, install dependencies, or produce files are outside this entry's scope.
|
Only run commands needed to read files, query state, and inspect Git diffs, plus the focused browser check in the [battle UI review checklist](../../../docs/reviews/mengsan-battle-ui.md). Run that check without screenshot output unless a temporary directory outside the repository has been designated for review evidence. All other checks that execute project code, install dependencies, or produce files are outside this entry's scope.
|
||||||
|
|
||||||
## 1. Locate the project and current change
|
## 1. Locate the project and current change
|
||||||
|
|
||||||
@@ -80,6 +80,8 @@ If the available evidence still cannot establish a reliable, verifiable baseline
|
|||||||
|
|
||||||
## 4. Perform the review
|
## 4. Perform the review
|
||||||
|
|
||||||
|
Apply the battle UI review checklist and record the results by scenario name in the evidence status. Reuse evidence bound to the current changes when available.
|
||||||
|
|
||||||
Review the requirements, tasks, and current diff, focusing only on:
|
Review the requirements, tasks, and current diff, focusing only on:
|
||||||
|
|
||||||
- Implementation correctness and clear logic errors.
|
- Implementation correctness and clear logic errors.
|
||||||
@@ -110,7 +112,7 @@ Evidence: The specific relationship to the diff, task, spec, or verification rec
|
|||||||
Then include:
|
Then include:
|
||||||
|
|
||||||
- `Review scope`: workflow, change, phase, baseline, included diffs, and any scope limitations.
|
- `Review scope`: workflow, change, phase, baseline, included diffs, and any scope limitations.
|
||||||
- `Evidence status`: the test, build, and verification records inspected and whether they still apply to the current changes. Do not rerun tests.
|
- `Evidence status`: report each battle UI scenario by its name in the checklist, together with the other test, build, and verification records inspected and whether they still apply to the current changes.
|
||||||
- `Open questions`: only questions that actually prevent a judgment.
|
- `Open questions`: only questions that actually prevent a judgment.
|
||||||
- `Conclusion`: the finding count, or an explicit “No concrete findings.”
|
- `Conclusion`: the finding count, or an explicit “No concrete findings.”
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ tools/*.mjs
|
|||||||
!/tools/test_mengsan_zip_install.mjs
|
!/tools/test_mengsan_zip_install.mjs
|
||||||
!/mengsan/tools/test-hud-status.cjs
|
!/mengsan/tools/test-hud-status.cjs
|
||||||
!/mengsan/tools/test-battle-hud.cjs
|
!/mengsan/tools/test-battle-hud.cjs
|
||||||
|
!/mengsan/tools/test-journey-ui-zoom.cjs
|
||||||
!/mengsan/tools/import-status-icons.cjs
|
!/mengsan/tools/import-status-icons.cjs
|
||||||
|
|
||||||
/.update_tmp/
|
/.update_tmp/
|
||||||
|
|||||||
@@ -63,3 +63,7 @@ gives you structural context (callers, dependents, test coverage) that file sear
|
|||||||
3. Use `get_affected_flows_tool` to understand impact.
|
3. Use `get_affected_flows_tool` to understand impact.
|
||||||
4. Use `query_graph_tool` pattern="tests_for" to check coverage.
|
4. Use `query_graph_tool` pattern="tests_for" to check coverage.
|
||||||
<!-- /code-review-graph MCP tools -->
|
<!-- /code-review-graph MCP tools -->
|
||||||
|
|
||||||
|
## 梦三战斗 UI 审查
|
||||||
|
|
||||||
|
每次 review 都按 [梦三战斗 UI 回归清单](docs/reviews/mengsan-battle-ui.md) 逐项核验,并记录结果和验证环境。涉及战斗 UI 的改动须附本轮渲染截图,并单独记录 Android 实机验证状态。
|
||||||
|
|||||||
Vendored
+392
-497
File diff suppressed because it is too large
Load Diff
Vendored
+698
-1548
File diff suppressed because it is too large
Load Diff
Vendored
+1
-84
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "2.0.2.3-rc.9",
|
"version": "2.0.2.3-rc.3",
|
||||||
"module_id": "mengsan",
|
"module_id": "mengsan",
|
||||||
"snapshot": "legacy",
|
"snapshot": "legacy",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -249,7 +249,6 @@
|
|||||||
"mengsan/assets/portraits/bygone-effigy-original.png",
|
"mengsan/assets/portraits/bygone-effigy-original.png",
|
||||||
"mengsan/assets/portraits/byrdonis-forest-portrait.png",
|
"mengsan/assets/portraits/byrdonis-forest-portrait.png",
|
||||||
"mengsan/assets/portraits/byrdonis-original.png",
|
"mengsan/assets/portraits/byrdonis-original.png",
|
||||||
"mengsan/assets/portraits/caocao-portrait.jpg",
|
|
||||||
"mengsan/assets/portraits/ceremonial-beast-forest-portrait.png",
|
"mengsan/assets/portraits/ceremonial-beast-forest-portrait.png",
|
||||||
"mengsan/assets/portraits/ceremonial-beast-original.png",
|
"mengsan/assets/portraits/ceremonial-beast-original.png",
|
||||||
"mengsan/assets/portraits/cubex-construct-forest-portrait.png",
|
"mengsan/assets/portraits/cubex-construct-forest-portrait.png",
|
||||||
@@ -291,7 +290,6 @@
|
|||||||
"mengsan/assets/portraits/slithering-strangler-original.png",
|
"mengsan/assets/portraits/slithering-strangler-original.png",
|
||||||
"mengsan/assets/portraits/snapping-jaxfruit-forest-portrait.png",
|
"mengsan/assets/portraits/snapping-jaxfruit-forest-portrait.png",
|
||||||
"mengsan/assets/portraits/snapping-jaxfruit-original.png",
|
"mengsan/assets/portraits/snapping-jaxfruit-original.png",
|
||||||
"mengsan/assets/portraits/sunquan-portrait.jpg",
|
|
||||||
"mengsan/assets/portraits/sushuang-zhangshiping.png",
|
"mengsan/assets/portraits/sushuang-zhangshiping.png",
|
||||||
"mengsan/assets/portraits/twig-slime-m-forest-portrait.png",
|
"mengsan/assets/portraits/twig-slime-m-forest-portrait.png",
|
||||||
"mengsan/assets/portraits/twig-slime-m-original.png",
|
"mengsan/assets/portraits/twig-slime-m-original.png",
|
||||||
@@ -603,68 +601,6 @@
|
|||||||
"mengsan/assets/relics/wongo_customer_appreciation_badge.png",
|
"mengsan/assets/relics/wongo_customer_appreciation_badge.png",
|
||||||
"mengsan/assets/relics/wongos_mystery_ticket.png",
|
"mengsan/assets/relics/wongos_mystery_ticket.png",
|
||||||
"mengsan/assets/relics/yummy_cookie.png",
|
"mengsan/assets/relics/yummy_cookie.png",
|
||||||
"mengsan/assets/scenes/pinefire-camp.webp",
|
|
||||||
"mengsan/assets/status/aggression_power.png",
|
|
||||||
"mengsan/assets/status/artifact_power.png",
|
|
||||||
"mengsan/assets/status/automation_power.png",
|
|
||||||
"mengsan/assets/status/barricade_power.png",
|
|
||||||
"mengsan/assets/status/beacon_of_hope_power.png",
|
|
||||||
"mengsan/assets/status/block_next_turn_power.png",
|
|
||||||
"mengsan/assets/status/calamity_power.png",
|
|
||||||
"mengsan/assets/status/colossus_power.png",
|
|
||||||
"mengsan/assets/status/constrict_power.png",
|
|
||||||
"mengsan/assets/status/corruption_power.png",
|
|
||||||
"mengsan/assets/status/crimson_mantle_power.png",
|
|
||||||
"mengsan/assets/status/curious_power.png",
|
|
||||||
"mengsan/assets/status/dark_embrace_power.png",
|
|
||||||
"mengsan/assets/status/demesne_power.png",
|
|
||||||
"mengsan/assets/status/demon_form_power.png",
|
|
||||||
"mengsan/assets/status/dexterity_power.png",
|
|
||||||
"mengsan/assets/status/draw_cards_next_turn_power.png",
|
|
||||||
"mengsan/assets/status/energy_next_turn_power.png",
|
|
||||||
"mengsan/assets/status/entropy_power.png",
|
|
||||||
"mengsan/assets/status/fasten_power.png",
|
|
||||||
"mengsan/assets/status/feel_no_pain_power.png",
|
|
||||||
"mengsan/assets/status/flame_barrier_power.png",
|
|
||||||
"mengsan/assets/status/frail_power.png",
|
|
||||||
"mengsan/assets/status/free_attack_power.png",
|
|
||||||
"mengsan/assets/status/hellraiser_power.png",
|
|
||||||
"mengsan/assets/status/inferno_power.png",
|
|
||||||
"mengsan/assets/status/infested_power.png",
|
|
||||||
"mengsan/assets/status/intangible_power.png",
|
|
||||||
"mengsan/assets/status/juggernaut_power.png",
|
|
||||||
"mengsan/assets/status/juggling_power.png",
|
|
||||||
"mengsan/assets/status/manifest.json",
|
|
||||||
"mengsan/assets/status/mayhem_power.png",
|
|
||||||
"mengsan/assets/status/no_block_power.png",
|
|
||||||
"mengsan/assets/status/no_draw_power.png",
|
|
||||||
"mengsan/assets/status/no_energy_gain_power.png",
|
|
||||||
"mengsan/assets/status/nostalgia_power.png",
|
|
||||||
"mengsan/assets/status/one_two_punch_power.png",
|
|
||||||
"mengsan/assets/status/panache_power.png",
|
|
||||||
"mengsan/assets/status/plating_power.png",
|
|
||||||
"mengsan/assets/status/plow_power.png",
|
|
||||||
"mengsan/assets/status/prep_time_power.png",
|
|
||||||
"mengsan/assets/status/rage_power.png",
|
|
||||||
"mengsan/assets/status/retain_hand_power.png",
|
|
||||||
"mengsan/assets/status/ringing_power.png",
|
|
||||||
"mengsan/assets/status/rolling_boulder_power.png",
|
|
||||||
"mengsan/assets/status/rupture_power.png",
|
|
||||||
"mengsan/assets/status/shrink_power.png",
|
|
||||||
"mengsan/assets/status/slippery_power.png",
|
|
||||||
"mengsan/assets/status/slow_power.png",
|
|
||||||
"mengsan/assets/status/stampede_power.png",
|
|
||||||
"mengsan/assets/status/strength_power.png",
|
|
||||||
"mengsan/assets/status/tangled_power.png",
|
|
||||||
"mengsan/assets/status/tank_power.png",
|
|
||||||
"mengsan/assets/status/territorial_power.png",
|
|
||||||
"mengsan/assets/status/the_bomb_power.png",
|
|
||||||
"mengsan/assets/status/the_gambit_power.png",
|
|
||||||
"mengsan/assets/status/unmovable_power.png",
|
|
||||||
"mengsan/assets/status/vicious_power.png",
|
|
||||||
"mengsan/assets/status/vigor_power.png",
|
|
||||||
"mengsan/assets/status/vulnerable_power.png",
|
|
||||||
"mengsan/assets/status/weak_power.png",
|
|
||||||
"mengsan/assets/sushuang-zhangshiping.png",
|
"mengsan/assets/sushuang-zhangshiping.png",
|
||||||
"mengsan/battle/battle-director.js",
|
"mengsan/battle/battle-director.js",
|
||||||
"mengsan/battle/battle-flow.js",
|
"mengsan/battle/battle-flow.js",
|
||||||
@@ -679,7 +615,6 @@
|
|||||||
"mengsan/battle/intent-damage.js",
|
"mengsan/battle/intent-damage.js",
|
||||||
"mengsan/battle/intent-effects.js",
|
"mengsan/battle/intent-effects.js",
|
||||||
"mengsan/battle/skill-teardown.js",
|
"mengsan/battle/skill-teardown.js",
|
||||||
"mengsan/battle/status-sources.js",
|
|
||||||
"mengsan/battle/stun-intent.js",
|
"mengsan/battle/stun-intent.js",
|
||||||
"mengsan/bonds/battle.js",
|
"mengsan/bonds/battle.js",
|
||||||
"mengsan/bonds/definitions.js",
|
"mengsan/bonds/definitions.js",
|
||||||
@@ -807,14 +742,10 @@
|
|||||||
"mengsan/monsters/vantom-intent.js",
|
"mengsan/monsters/vantom-intent.js",
|
||||||
"mengsan/monsters/vine-intent.js",
|
"mengsan/monsters/vine-intent.js",
|
||||||
"mengsan/monsters/vine-tangled.js",
|
"mengsan/monsters/vine-tangled.js",
|
||||||
"mengsan/potions/battle.js",
|
|
||||||
"mengsan/potions/presentation.js",
|
|
||||||
"mengsan/potions/state.js",
|
|
||||||
"mengsan/progression/dialogue-choice.js",
|
"mengsan/progression/dialogue-choice.js",
|
||||||
"mengsan/progression/encounter-progress.js",
|
"mengsan/progression/encounter-progress.js",
|
||||||
"mengsan/progression/map-checkpoint.js",
|
"mengsan/progression/map-checkpoint.js",
|
||||||
"mengsan/progression/mode-storage.js",
|
"mengsan/progression/mode-storage.js",
|
||||||
"mengsan/progression/random-event.js",
|
|
||||||
"mengsan/progression/reward-package.js",
|
"mengsan/progression/reward-package.js",
|
||||||
"mengsan/progression/reward.js",
|
"mengsan/progression/reward.js",
|
||||||
"mengsan/progression/state.js",
|
"mengsan/progression/state.js",
|
||||||
@@ -856,10 +787,7 @@
|
|||||||
"mengsan/state.js",
|
"mengsan/state.js",
|
||||||
"mengsan/style.css",
|
"mengsan/style.css",
|
||||||
"mengsan/ui/bonds.js",
|
"mengsan/ui/bonds.js",
|
||||||
"mengsan/ui/card-choice-names.js",
|
|
||||||
"mengsan/ui/card-library.js",
|
"mengsan/ui/card-library.js",
|
||||||
"mengsan/ui/character-select.css",
|
|
||||||
"mengsan/ui/character-select.js",
|
|
||||||
"mengsan/ui/dialogue.js",
|
"mengsan/ui/dialogue.js",
|
||||||
"mengsan/ui/energy-display.js",
|
"mengsan/ui/energy-display.js",
|
||||||
"mengsan/ui/flow-ui.js",
|
"mengsan/ui/flow-ui.js",
|
||||||
@@ -871,25 +799,14 @@
|
|||||||
"mengsan/ui/hand/input.js",
|
"mengsan/ui/hand/input.js",
|
||||||
"mengsan/ui/hand/overlays.js",
|
"mengsan/ui/hand/overlays.js",
|
||||||
"mengsan/ui/hand/style.css",
|
"mengsan/ui/hand/style.css",
|
||||||
"mengsan/ui/hud/index.js",
|
|
||||||
"mengsan/ui/hud/overlays.js",
|
|
||||||
"mengsan/ui/hud/status-model.js",
|
|
||||||
"mengsan/ui/hud/style.css",
|
|
||||||
"mengsan/ui/intent-display.js",
|
"mengsan/ui/intent-display.js",
|
||||||
"mengsan/ui/map/index.js",
|
"mengsan/ui/map/index.js",
|
||||||
"mengsan/ui/map/renderer.js",
|
"mengsan/ui/map/renderer.js",
|
||||||
"mengsan/ui/navigation.js",
|
"mengsan/ui/navigation.js",
|
||||||
"mengsan/ui/potions.css",
|
|
||||||
"mengsan/ui/potions.js",
|
|
||||||
"mengsan/ui/relic-icon.js",
|
"mengsan/ui/relic-icon.js",
|
||||||
"mengsan/ui/relic-strip.js",
|
|
||||||
"mengsan/ui/relics.js",
|
"mengsan/ui/relics.js",
|
||||||
"mengsan/ui/rest-ui.js",
|
|
||||||
"mengsan/ui/rest.css",
|
|
||||||
"mengsan/ui/reward-package.js",
|
"mengsan/ui/reward-package.js",
|
||||||
"mengsan/ui/reward-ui.js",
|
"mengsan/ui/reward-ui.js",
|
||||||
"mengsan/ui/shop-ui.js",
|
|
||||||
"mengsan/ui/shop.css",
|
|
||||||
"mengsan/ui/style.css",
|
"mengsan/ui/style.css",
|
||||||
"mengsan/ui/virtual-card-grid.js"
|
"mengsan/ui/virtual-card-grid.js"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# 梦三战斗 UI 回归清单
|
||||||
|
|
||||||
|
每次 review 核验下表各项。在报告中逐项写明通过、失败或未验,并记录证据对应的代码版本、皮肤、尺寸和缩放。涉及战斗 UI 的改动,附受影响场景的渲染截图。
|
||||||
|
|
||||||
|
| 场景 | 操作与通过标准 |
|
||||||
|
| --- | --- |
|
||||||
|
| 触屏拖牌与目标连线 | 从手牌拖出一张【杀】并移动到可选敌人。线起点贴在拖动牌上缘中央,终点跟随触点,两端误差各不超过 2 CSS px。取消手势后线立即消失。对合法目标松手后拖线立即消失,原生提交只触发一次。完整对局中再检查提交后的出牌特效能指向实际目标。 |
|
||||||
|
| 普通出牌布局与缩放 | 在主动出牌阶段检查手牌扇面、提示语和「确定/回合结束」按钮组。三者共用战场中线,误差不超过 2 CSS px。改变界面缩放后重新检查对齐和拖牌线两端。 |
|
||||||
|
| 出牌响应布局与按钮交互 | 敌人出【杀】,选择【闪】,观察场上出牌副本、响应文字与「确定/取消」两键的整体边界。三者从上到下共用战场中线,横向中心误差不超过 2 CSS px,牌面、提示、按钮和选中手牌之间有可见间距。确认和取消分别可点击,响应结束后场上的牌恢复原生位置。 |
|
||||||
|
| 弃牌时技能栏稳定 | 启用十周年 UI,进入需弃置两张手牌的场景并点选第一张。技能栏在重建的首帧起就不出现重复的药水按钮,普通技能仍可见,弃牌计数正常更新。 |
|
||||||
|
| 战斗药水槽与计数信息 | 持有药水进入战斗。药水槽位于左上区域,可贴近轮数、时间及牌堆数量控件,各自的可见区域互不重叠。点按药水可打开详情,并能在可用阶段正常使用。 |
|
||||||
|
|
||||||
|
## 浏览器回归
|
||||||
|
|
||||||
|
从无名游戏目录内的术樱包根目录执行。脚本使用本地引擎、十周年 UI 样式、Playwright 和 Microsoft Edge。Playwright 安装在其他目录时,可将 `CODEX_NODE_MODULES` 指向包含它的 `node_modules`。
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:HUD_REVIEW = '1'
|
||||||
|
node mengsan/tools/test-battle-hud.cjs
|
||||||
|
```
|
||||||
|
|
||||||
|
需要截图时,将 `HUD_ARTIFACTS` 指向已建立的临时目录。完整矩阵覆盖原生 UI、十周年 UI 的手杀、十周年和新杀风格,以及 1080×486、812×375、667×375,含非整数像素比。1080×486 使用无名杀「新版」布局,从 65% 缩放基线切换到 50%、85%、100% 和 120%,核验普通出牌位置和拖牌线。出牌后的默认及金龙连线均检查端点,完整金龙贴图需在客户端核验。
|
||||||
|
|
||||||
|
## Android 实机复核
|
||||||
|
|
||||||
|
在本轮改动对应的 Android 客户端启用十周年 UI,使用该客户端当前启用的皮肤复核各场景,并记录十周年 UI 版本和皮肤。拖牌时分别观察松手前的拖线和松手后的出牌特效。响应用两次事件分别检查确认和取消。弃牌时观察点牌瞬间,检查原生计数面板与药水槽能同时看清并各自操作。实机结果单独记录,实机不可用时写明未验。
|
||||||
|
|
||||||
|
涉及地图、剧情、奖励、牌库、遗物或其他公共弹窗时,一并使用[梦三界面缩放回归清单](mengsan-ui-zoom.md)。
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# 梦三界面缩放回归清单
|
||||||
|
|
||||||
|
无名杀原生 UI 底层以 `transform: scale()` 缩放,十周年 UI 以 `body.zoom` 缩放。检查通用界面时覆盖两条入口,并记录界面缩放、窗口尺寸、UI 版本和实际使用的风格。
|
||||||
|
|
||||||
|
## 实施方案
|
||||||
|
|
||||||
|
- 地图用实际渲染尺寸换算鼠标位移,保证地图和指针同速移动。窄小布局允许行军菜单和顶部栏在各自区域滚动。
|
||||||
|
- 选将和事件面板的高度随剩余空间调整,内容在面板内滚动,打开和关闭时恢复焦点也保持页面位置。
|
||||||
|
- 剧情将文本和分支选项放进同一滚动容器,跳过和菜单留在顶部。较高倍率下可滚动查看并点按选项。
|
||||||
|
- 牌库、牌堆、遗物、战斗状态、菜单确认和调试管理器沿用奖励与药水的原生对话框挂载方式,以可视窗口约束弹窗尺寸。打开、选择与关闭仍通过各自原有入口执行。
|
||||||
|
- 战场右侧的牌堆和遗物入口随可用高度调整。战斗状态平时放在头像上方,上方空间不足时移到头像侧面。
|
||||||
|
|
||||||
|
## 验收项
|
||||||
|
|
||||||
|
| 范围 | 操作与通过标准 |
|
||||||
|
| --- | --- |
|
||||||
|
| 选将、事件、商店、休息处 | 能看到主操作,点按后返回正确选择或退出。 |
|
||||||
|
| 地图和行军菜单 | 相同屏幕位移下,地图拖动与鼠标位移差不超过 2 CSS px。触屏能滚动,能点开菜单、查看行囊、返回和关闭,能选中可前往节点。 |
|
||||||
|
| 剧情 | 文本和分支选项可浏览,点按分支写入正确剧情状态,跳过和继续均可用。 |
|
||||||
|
| 奖励和战后结算 | 选牌、跳过和结算选项可到达,确认后继续流程。 |
|
||||||
|
| 牌库、牌堆、遗物、药水和战斗状态 | 能通过实际入口打开,弹窗在可视区域内,详情和关闭可点按。内容较长时能滚动。 |
|
||||||
|
| 菜单确认和调试管理器 | 对话框在可视区域内,所选操作返回正确结果,关闭后回到原界面。 |
|
||||||
|
|
||||||
|
## 浏览器复核
|
||||||
|
|
||||||
|
从术樱包根目录执行。脚本使用本地无名杀、十周年 UI、Playwright 和 Microsoft Edge。需要时将 `CODEX_NODE_MODULES` 指向包含 Playwright 的 `node_modules`,将 `HUD_ARTIFACTS` 指向已建立的截图目录。
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:UI_ZOOM_REVIEW = '1'
|
||||||
|
node mengsan/tools/test-battle-hud.cjs
|
||||||
|
```
|
||||||
|
|
||||||
|
自动回归覆盖 16 个界面与交互。以 812×375 横屏为基线,十周年 UI 检查 50%、65%、100%、150%、200%、300%,原生 UI 检查 150% 和 300%。两条缩放入口均检查界面打开后从 65% 切到 200%。另检查 420×360 窄屏、390×720 竖屏和 1280×720 桌面。
|
||||||
|
|
||||||
|
脚本通过渲染出的按钮执行代表性操作,检查界面边界、返回值和关闭结果。鼠标地图拖动单独检查像素误差。完整战斗 HUD 和出牌响应按[战斗回归清单](mengsan-battle-ui.md)复核。
|
||||||
|
|
||||||
|
## Android 实机复核
|
||||||
|
|
||||||
|
用 Android 客户端实际启用的十周年 UI 风格,在常用倍率和一个较高倍率下复核受影响的操作。优先确认触屏地图滚动、剧情分支点按、较长内容滑动和弹窗关闭。报告逐项标注通过、失败或未验。
|
||||||
@@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
**接口** `build_archives(root: Path, output: Path, tag: str) -> list[Path]` 使用 `root/dist/modules/mengsan.json`,生成 `mengsan-<tag>-part-001.zip` 等附件。条目名为 `mengsan/…`,与模块清单路径逐字一致。
|
**接口** `build_archives(root: Path, output: Path, tag: str) -> list[Path]` 使用 `root/dist/modules/mengsan.json`,生成 `mengsan-<tag>-part-001.zip` 等附件。条目名为 `mengsan/…`,与模块清单路径逐字一致。
|
||||||
|
|
||||||
- [ ] 在 `tools/test_mengsan_archives.py` 写 `test_parts_cover_packable_files_once` 和 `test_reject_inconsistent_release`。用临时目录验证 `Counter(written_paths) == Counter(packable_paths)`、条目 SHA-256 与清单一致、超出 5 MiB 的单文件不入包。对清单版本不匹配、源文件变化和单个分包成品超过 6 MiB 分别断言生成失败。
|
- [ ] 在 `tools/test_mengsan_archives.py` 写 `test_parts_cover_packable_files_once` 和 `test_reject_inconsistent_release`。用临时目录验证 `Counter(written_paths) == Counter(packable_paths)`、条目 SHA-256 与清单一致、超出 10 MiB 的单文件不入包。对清单版本不匹配、源文件变化和单个分包成品超过 11 MiB 分别断言生成失败。
|
||||||
- [ ] 运行 `python -m unittest discover -s tools -p test_mengsan_archives.py`,确认因生成器尚缺而失败。
|
- [ ] 运行 `python -m unittest discover -s tools -p test_mengsan_archives.py`,确认因生成器尚缺而失败。
|
||||||
- [ ] 实现生成器及 CLI `python tools/build_mengsan_archives.py --root <snapshot> --out-dir <output> --tag <tag>`。按清单路径排序,依次填入每包合计最多 5 MiB 的未压缩文件。使用 `ZIP_DEFLATED`、压缩级别 6。关闭 ZIP 后检查成品不超过 6 MiB,逐项校验路径、大小和 SHA-256,并检查各包合计覆盖所有可打包条目。两个上限是实测起点,调整时同步客户端和测试。
|
- [ ] 实现生成器及 CLI `python tools/build_mengsan_archives.py --root <snapshot> --out-dir <output> --tag <tag>`。按清单路径排序,依次填入每包合计最多 10 MiB 的未压缩文件。使用 `ZIP_DEFLATED`、压缩级别 6。关闭 ZIP 后检查成品不超过 11 MiB,逐项校验路径、大小和 SHA-256,并检查各包合计覆盖所有可打包条目。调整上限时同步客户端和测试。
|
||||||
- [ ] 重跑 Python 测试并确认通过。以当前分支生成的清单和导出快照运行 CLI,检查实际分包数、最大包大小和完整覆盖。使用发布工作流同样的标签快照校验命令 `python tools/verify_manifest.py --root <snapshot> --version <version>`。
|
- [ ] 重跑 Python 测试并确认通过。以当前分支生成的清单和导出快照运行 CLI,检查实际分包数、最大包大小和完整覆盖。使用发布工作流同样的标签快照校验命令 `python tools/verify_manifest.py --root <snapshot> --version <version>`。
|
||||||
|
|
||||||
## 任务二 · 接入两个发布工作流
|
## 任务二 · 接入两个发布工作流
|
||||||
@@ -57,14 +57,14 @@
|
|||||||
|
|
||||||
- [ ] 在 `tools/test_mengsan_zip_install.mjs` 用 `node:test` 从正常菜单入口 `manageMengsanModule` 触发安装。`fresh install stages from selected release` 对两个源分别断言附件查询标签正确、成功分包文件无 raw 请求、所有文件备齐前无正式路径写入。`falls back for missing or unusable release parts` 覆盖 Release 404、草稿、标签不匹配、超限响应、损坏 ZIP、越界条目和错误 SHA-256,断言 `rawRequests` 恰好等于未成功暂存文件。`retries the failed ZIP once` 覆盖单包下载异常后成功。`staging write errors preserve recovery` 断言写入失败后无后续 raw 请求。`installed updates and legacy repairs stay on raw` 从 `checkVersion`、`repairMissingFiles` 和旧修复记录分别验证无 Release 请求。至少一个解析用例使用宿主实际捆绑的 JSZip 2.7 和脚本生成的 ZIP。
|
- [ ] 在 `tools/test_mengsan_zip_install.mjs` 用 `node:test` 从正常菜单入口 `manageMengsanModule` 触发安装。`fresh install stages from selected release` 对两个源分别断言附件查询标签正确、成功分包文件无 raw 请求、所有文件备齐前无正式路径写入。`falls back for missing or unusable release parts` 覆盖 Release 404、草稿、标签不匹配、超限响应、损坏 ZIP、越界条目和错误 SHA-256,断言 `rawRequests` 恰好等于未成功暂存文件。`retries the failed ZIP once` 覆盖单包下载异常后成功。`staging write errors preserve recovery` 断言写入失败后无后续 raw 请求。`installed updates and legacy repairs stay on raw` 从 `checkVersion`、`repairMissingFiles` 和旧修复记录分别验证无 Release 请求。至少一个解析用例使用宿主实际捆绑的 JSZip 2.7 和脚本生成的 ZIP。
|
||||||
- [ ] 运行 `node --experimental-vm-modules --test tools/test_mengsan_zip_install.mjs` 并确认新增 ZIP 场景因当前只请求 raw 文件而失败。可通过 `vm.SourceTextModule` 和测试用 `SyntheticModule` 为 `../../noname.js` 注入宿主 API,无需从产品代码导出测试接口。
|
- [ ] 运行 `node --experimental-vm-modules --test tools/test_mengsan_zip_install.mjs` 并确认新增 ZIP 场景因当前只请求 raw 文件而失败。可通过 `vm.SourceTextModule` 和测试用 `SyntheticModule` 为 `../../noname.js` 注入宿主 API,无需从产品代码导出测试接口。
|
||||||
- [ ] 在 `update.js` 实现附件查询和下载。两源均请求所选 `<repoApi>/releases/tags/<tag>`,要求 `tag_name` 匹配且 `draft` 为 `false`。仅接收与版本文件名匹配、`size` 为正整数且不超过 6 MiB 的附件。使用该源的 HTTPS `browser_download_url`。GitHub 现有附件链接与 CDN 实测缺少浏览器跨域响应头,因此 Electron 使用支持 HTTPS 重定向的原生请求,Cordova 使用 `FileTransfer` 下载到本次操作目录,校验文件大小后读取并清理。网页 Fetch 用尽该附件的网络重试后回退同源逐文件下载。
|
- [ ] 在 `update.js` 实现附件查询和下载。两源均请求所选 `<repoApi>/releases/tags/<tag>`,要求 `tag_name` 匹配且 `draft` 为 `false`。仅接收与版本文件名匹配、`size` 为正整数且不超过 11 MiB 的附件。使用该源的 HTTPS `browser_download_url`。GitHub 现有附件链接与 CDN 实测缺少浏览器跨域响应头,因此 Electron 使用支持 HTTPS 重定向的原生请求,Cordova 使用 `FileTransfer` 下载到本次操作目录,校验文件大小后读取并清理。网页 Fetch 用尽该附件的网络重试后回退同源逐文件下载。
|
||||||
- [ ] 使用 `get.zip` 获取 JSZip,逐包调用 `load` 读取目录和压缩字节。解包前检查文件名、清单归属、单条目声明大小和包内合计上限。用 `DecompressionStream("deflate-raw")` 解压到按清单大小分配的缓冲区并限制实际输出,随后调用 `verifyFile` 和 `stageVerified`。缺少流式解压能力的客户端直接逐文件下载。异常 ZIP 至多重新取一次再回退。校验、网络和解包错误记录包名及原因。写盘错误从暂存阶段直接抛出。
|
- [ ] 使用 `get.zip` 获取 JSZip,逐包调用 `load` 读取目录和压缩字节。解包前检查文件名、清单归属、单条目声明大小和包内合计上限。用 `DecompressionStream("deflate-raw")` 解压到按清单大小分配的缓冲区并限制实际输出,随后调用 `verifyFile` 和 `stageVerified`。缺少流式解压能力的客户端直接逐文件下载。异常 ZIP 至多重新取一次再回退。校验、网络和解包错误记录包名及原因。写盘错误从暂存阶段直接抛出。
|
||||||
- [ ] 在 `manageMengsanModule` 判定首次安装。无既有安装,或已明确清空的卸载记录进入全新安装;旧待修复记录按原路径。操作记录只在已知首次安装进入 `installing` 时标记 `freshInstall: true`,失败后该标记用于重新发起完整下载。通过 `installMengsanFiles` 把这个选择传给 `updateAllFiles` 的暂存阶段;本次已完成的文件更新原进度和清理集合,原文件池仅处理剩余项。将 ZIP 网络进度与已验证文件字节分开,避免回退时重复计数。保留现有正式路径落盘前复核及安装记录提交逻辑。
|
- [ ] 在 `manageMengsanModule` 判定首次安装。无既有安装,或已明确清空的卸载记录进入全新安装;旧待修复记录按原路径。操作记录只在已知首次安装进入 `installing` 时标记 `freshInstall: true`,失败后该标记用于重新发起完整下载。通过 `installMengsanFiles` 把这个选择传给 `updateAllFiles` 的暂存阶段;本次已完成的文件更新原进度和清理集合,原文件池仅处理剩余项。将 ZIP 网络进度与已验证文件字节分开,避免回退时重复计数。保留现有正式路径落盘前复核及安装记录提交逻辑。
|
||||||
- [ ] 运行 `node --check update.js` 和 Node 测试,确认通过。分别用清单对比正常 ZIP 和逐文件回退的最终目录及安装记录,确认每个新文件大小和 SHA-256 一致。
|
- [ ] 运行 `node --check update.js` 和 Node 测试,确认通过。分别用清单对比正常 ZIP 和逐文件回退的最终目录及安装记录,确认每个新文件大小和 SHA-256 一致。
|
||||||
|
|
||||||
## 任务四 · 实机验收和默认启用
|
## 任务四 · 实机验收和默认启用
|
||||||
|
|
||||||
- [ ] 在同一台受支持手机上,用同一客户端版本、梦三标签、下载源和网络条件,对逐文件和分包的干净安装各测三次。每次从确认安装计时到校验完成。通过网络记录统计资源请求数,从应用及其 WebView 进程记录内存峰值,报告原始样本和中位数。先测 5 MiB 展开、6 MiB 下载上限,再按实测调整。
|
- [ ] 在同一台受支持手机上,用同一客户端版本、梦三标签、下载源和网络条件,对逐文件和分包的干净安装各测三次。每次从确认安装计时到校验完成。通过网络记录统计资源请求数,从应用及其 WebView 进程记录内存峰值,报告原始样本和中位数。先测 10 MiB 展开、11 MiB 下载上限,再按实测调整。
|
||||||
- [ ] 在客户端真实窗口验证 GitHub 与 Gitea Release 的匿名下载、重定向和跨域行为,并分别验证 ZIP 不可用时回退到当前源的同标签文件。测试手机端强制退出后再点击安装。通过安装记录、清单校验和重启后进入梦三确认结果。另跑桌面端首次安装及差量更新一次。
|
- [ ] 在客户端真实窗口验证 GitHub 与 Gitea Release 的匿名下载、重定向和跨域行为,并分别验证 ZIP 不可用时回退到当前源的同标签文件。测试手机端强制退出后再点击安装。通过安装记录、清单校验和重启后进入梦三确认结果。另跑桌面端首次安装及差量更新一次。
|
||||||
- [ ] 对照同环境逐文件基线检验收益。建议启用条件为手机端资源请求数和总耗时中位数下降,内存峰值无可重复的上升,两个源与回退均通过。记录采用的包大小、测试设备和结果,再启用默认 ZIP 路径。
|
- [ ] 对照同环境逐文件基线检验收益。建议启用条件为手机端资源请求数和总耗时中位数下降,内存峰值无可重复的上升,两个源与回退均通过。记录采用的包大小、测试设备和结果,再启用默认 ZIP 路径。
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import { configureDiagnostics } from "./diagnostics/index.js";
|
|||||||
|
|
||||||
export const type = "extension";
|
export const type = "extension";
|
||||||
export let shuYing = new Object();
|
export let shuYing = new Object();
|
||||||
const shuYingLocalVersion = "2.0.2.3-rc.9";
|
const shuYingLocalVersion = "2.0.2.3-rc.12";
|
||||||
|
|
||||||
shuYing.name = "术樱包";
|
shuYing.name = "术樱包";
|
||||||
shuYing.editable = false;
|
shuYing.editable = false;
|
||||||
|
|||||||
@@ -20,13 +20,15 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
// Detached nodes: engine get.position recognises these IDs; no duplicate document IDs.
|
// Detached nodes: engine get.position recognises these IDs; no duplicate document IDs.
|
||||||
draw.id = "cardPile"; discard.id = "discardPile";
|
draw.id = "cardPile"; discard.id = "discardPile";
|
||||||
const owned = new Set(), topPlaying = new Set(), restores = [];
|
const owned = new Set(), topPlaying = new Set(), restores = [];
|
||||||
|
const pileNodes = { drawPile: draw, discardPile: discard };
|
||||||
|
const viewKeys = new WeakMap(), exhaustSources = new WeakMap();
|
||||||
const strict = env.strict !== false;
|
const strict = env.strict !== false;
|
||||||
let released = false, forcedOwner = false, forcedPublic = false, exhaustTotal = 0;
|
let released = false, forcedOwner = false, forcedPublic = false, exhaustTotal = 0;
|
||||||
function recordExhaust(card) {
|
function recordExhaust(card) {
|
||||||
if (card.storage?.mengsanExhausted_shuying) return false;
|
if (card.storage?.mengsanExhausted_shuying) return false;
|
||||||
card.storage.mengsanExhausted_shuying = true;
|
card.storage.mengsanExhausted_shuying = true;
|
||||||
battle.exhaustPile.push(snapshot(card)); exhaustTotal++;
|
battle.exhaustPile.push(snapshotExhausted(card)); exhaustTotal++;
|
||||||
queueIroncladExhaust(owner, card); queueRelicExhaust(owner, card); refresh(); return true;
|
queueIroncladExhaust(owner, card); queueRelicExhaust(owner, card); refresh("exhaustPile"); return true;
|
||||||
}
|
}
|
||||||
const personal = () => {
|
const personal = () => {
|
||||||
if (released || forcedPublic) return false;
|
if (released || forcedPublic) return false;
|
||||||
@@ -42,7 +44,7 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
}
|
}
|
||||||
return false; // Never infer ownership from whose turn it is.
|
return false; // Never infer ownership from whose turn it is.
|
||||||
};
|
};
|
||||||
const refresh = () => { if (!released) env.refresh(); };
|
const refresh = (...piles) => { if (!released) env.refresh(...piles); };
|
||||||
const canReceiveTransfer = (card, sourceSession) => !released && session.active && sourceSession===session &&
|
const canReceiveTransfer = (card, sourceSession) => !released && session.active && sourceSession===session &&
|
||||||
owner.isAlive() && !owned.has(card) && typeof card?.storage?.mengsanCard_shuying?.id==="string" &&
|
owner.isAlive() && !owned.has(card) && typeof card?.storage?.mengsanCard_shuying?.id==="string" &&
|
||||||
![...owned].some(c=>c.storage?.mengsanCard_shuying?.id===card.storage.mengsanCard_shuying.id);
|
![...owned].some(c=>c.storage?.mengsanCard_shuying?.id===card.storage.mengsanCard_shuying.id);
|
||||||
@@ -95,6 +97,19 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
return { ...data, ...snapshotRampage(card), ...ironcladHooks(owner)?.snapshotCard(card), ...sharedHooks(owner)?.snapshotCard?.(card), name: card.name, suit: card.suit, number: card.number,
|
return { ...data, ...snapshotRampage(card), ...ironcladHooks(owner)?.snapshotCard(card), ...sharedHooks(owner)?.snapshotCard?.(card), name: card.name, suit: card.suit, number: card.number,
|
||||||
nature: card.nature || null, affixes: data.affixes?.slice() || [], upgrade: data.upgrade || 0 };
|
nature: card.nature || null, affixes: data.affixes?.slice() || [], upgrade: data.upgrade || 0 };
|
||||||
}
|
}
|
||||||
|
function viewKey(card) {
|
||||||
|
if (!viewKeys.has(card)) viewKeys.set(card, Symbol());
|
||||||
|
return viewKeys.get(card);
|
||||||
|
}
|
||||||
|
function snapshotExhausted(card) {
|
||||||
|
const data = snapshot(card);
|
||||||
|
exhaustSources.set(data, card);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
function removeExhaustSnapshot(card) {
|
||||||
|
const index = battle.exhaustPile.findIndex(data => exhaustSources.get(data) === card);
|
||||||
|
if (index >= 0) battle.exhaustPile.splice(index, 1);
|
||||||
|
}
|
||||||
for (const data of battle.drawPile) {
|
for (const data of battle.drawPile) {
|
||||||
if (data.name === "muniu") continue;
|
if (data.name === "muniu") continue;
|
||||||
const card = game.createCard(data.name, data.suit, data.number, data.nature);
|
const card = game.createCard(data.name, data.suit, data.number, data.nature);
|
||||||
@@ -111,16 +126,28 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
if (Object.getOwnPropertyDescriptor(ui, key)?.get === read) Object.defineProperty(ui, key, descriptor.get ? descriptor : { ...descriptor, value: publicNode });
|
if (Object.getOwnPropertyDescriptor(ui, key)?.get === read) Object.defineProperty(ui, key, descriptor.get ? descriptor : { ...descriptor, value: publicNode });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (const [key, node] of [["drawPile", draw], ["discardPile", discard]]) {
|
for (const [key, node] of Object.entries(pileNodes)) {
|
||||||
Object.defineProperty(battle, key, { configurable: true, enumerable: true,
|
Object.defineProperty(battle, key, { configurable: true, enumerable: true,
|
||||||
get: () => Array.from(node.childNodes, snapshot) });
|
get: () => Array.from(node.childNodes, snapshot) });
|
||||||
}
|
}
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(records => {
|
||||||
if (released) return;
|
if (released) return;
|
||||||
|
const changed = new Set(records.map(record => record.target));
|
||||||
// A card from our deck can be discarded during an enemy-owned event.
|
// A card from our deck can be discarded during an enemy-owned event.
|
||||||
for (const card of Array.from(publicDiscard.childNodes)) if (owned.has(card)) discard.appendChild(card);
|
if (changed.has(publicDiscard)) {
|
||||||
for (const node of [draw, discard]) for (const card of node.childNodes) adopt(card);
|
for (const card of Array.from(publicDiscard.childNodes)) {
|
||||||
refresh();
|
if (!owned.has(card)) continue;
|
||||||
|
discard.appendChild(card);
|
||||||
|
changed.add(discard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const piles = [];
|
||||||
|
for (const [key, node] of Object.entries(pileNodes)) {
|
||||||
|
if (!changed.has(node)) continue;
|
||||||
|
for (const card of node.childNodes) adopt(card);
|
||||||
|
piles.push(key);
|
||||||
|
}
|
||||||
|
if (piles.length) refresh(...piles);
|
||||||
});
|
});
|
||||||
for (const node of [draw, discard, publicDiscard]) observer.observe(node, { childList: true });
|
for (const node of [draw, discard, publicDiscard]) observer.observe(node, { childList: true });
|
||||||
function wash() {
|
function wash() {
|
||||||
@@ -129,7 +156,7 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
shuffle(run, cards);
|
shuffle(run, cards);
|
||||||
queueRelicShuffle(owner);
|
queueRelicShuffle(owner);
|
||||||
for (const card of cards) { card.fix?.(); draw.appendChild(card); }
|
for (const card of cards) { card.fix?.(); draw.appendChild(card); }
|
||||||
refresh();
|
refresh("drawPile", "discardPile");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function take(number = 1, putBack = false, bottom = false) {
|
function take(number = 1, putBack = false, bottom = false) {
|
||||||
@@ -147,7 +174,7 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
if (putBack) for (let i = cards.length - 1; i >= 0; i--) {
|
if (putBack) for (let i = cards.length - 1; i >= 0; i--) {
|
||||||
if (bottom) draw.appendChild(cards[i]); else draw.insertBefore(cards[i], draw.firstChild);
|
if (bottom) draw.appendChild(cards[i]); else draw.insertBefore(cards[i], draw.firstChild);
|
||||||
}
|
}
|
||||||
refresh(); return cards;
|
refresh("drawPile"); return cards;
|
||||||
}
|
}
|
||||||
function wrap(object, key, replacement, shouldReplace = personal) {
|
function wrap(object, key, replacement, shouldReplace = personal) {
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(object, key), original = object[key];
|
const descriptor = Object.getOwnPropertyDescriptor(object, key), original = object[key];
|
||||||
@@ -177,6 +204,17 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
owned.clear(); topPlaying.clear(); draw.remove(); discard.remove(); exhausted.remove();
|
owned.clear(); topPlaying.clear(); draw.remove(); discard.remove(); exhausted.remove();
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
pileView: {
|
||||||
|
count(key) {
|
||||||
|
return pileNodes[key]?.childNodes.length ?? battle.exhaustPile.length;
|
||||||
|
},
|
||||||
|
records(key) {
|
||||||
|
const node = pileNodes[key];
|
||||||
|
return node
|
||||||
|
? Array.from(node.childNodes, card => ({ card: snapshot(card), key: viewKey(card) }))
|
||||||
|
: battle.exhaustPile.map(card => ({ card, key: viewKey(exhaustSources.get(card) ?? card) }));
|
||||||
|
},
|
||||||
|
},
|
||||||
take,
|
take,
|
||||||
canReceiveTransfer,
|
canReceiveTransfer,
|
||||||
receiveTransfer(card,sourceSession) {
|
receiveTransfer(card,sourceSession) {
|
||||||
@@ -259,13 +297,12 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
exhaustTotal() { return exhaustTotal; },
|
exhaustTotal() { return exhaustTotal; },
|
||||||
exhaustedCards() { return [...owned].filter(card => card.storage?.mengsanExhausted_shuying); },
|
exhaustedCards() { return [...owned].filter(card => card.storage?.mengsanExhausted_shuying); },
|
||||||
syncExhaustSnapshots() {
|
syncExhaustSnapshots() {
|
||||||
if(released || !session.active)return;
|
if (released || !session.active) return;
|
||||||
const current=new Map([...owned].filter(card=>card.storage?.mengsanExhausted_shuying)
|
for (let index = 0; index < battle.exhaustPile.length; index++) {
|
||||||
.map(card=>[card.storage.mengsanCard_shuying?.id,card]));
|
const card = exhaustSources.get(battle.exhaustPile[index]);
|
||||||
for(let index=0;index<battle.exhaustPile.length;index++){
|
if (card?.storage?.mengsanExhausted_shuying) battle.exhaustPile[index] = snapshotExhausted(card);
|
||||||
const card=current.get(battle.exhaustPile[index].id);
|
|
||||||
if(card)battle.exhaustPile[index]=snapshot(card);
|
|
||||||
}
|
}
|
||||||
|
// Whole-deck upgrades also mutate draw and discard cards in place.
|
||||||
refresh();
|
refresh();
|
||||||
},
|
},
|
||||||
// 自动打出不会触发抽牌、洗牌或堆顶牌不足的失败规则。
|
// 自动打出不会触发抽牌、洗牌或堆顶牌不足的失败规则。
|
||||||
@@ -273,9 +310,7 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
if (released || !session.active || !owned.has(card)) return false;
|
if (released || !session.active || !owned.has(card)) return false;
|
||||||
if (fromExhaust) {
|
if (fromExhaust) {
|
||||||
if (!card.storage?.mengsanExhausted_shuying) return false;
|
if (!card.storage?.mengsanExhausted_shuying) return false;
|
||||||
const id = card.storage?.mengsanCard_shuying?.id;
|
removeExhaustSnapshot(card);
|
||||||
const index = battle.exhaustPile.findIndex(data => data.id === id);
|
|
||||||
if (index >= 0) battle.exhaustPile.splice(index,1);
|
|
||||||
delete card.storage.mengsanExhausted_shuying;
|
delete card.storage.mengsanExhausted_shuying;
|
||||||
delete card._selfDestroyed;
|
delete card._selfDestroyed;
|
||||||
} else if (card.parentNode !== draw && card.parentNode !== discard) return false;
|
} else if (card.parentNode !== draw && card.parentNode !== discard) return false;
|
||||||
@@ -315,9 +350,7 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
if(released || !session.active || !owner.isAlive() || !owned.has(card))return false;
|
if(released || !session.active || !owner.isAlive() || !owned.has(card))return false;
|
||||||
if(owner.getCards("h").includes(card))return true;
|
if(owner.getCards("h").includes(card))return true;
|
||||||
if(card.storage?.mengsanExhausted_shuying){
|
if(card.storage?.mengsanExhausted_shuying){
|
||||||
const id=card.storage.mengsanCard_shuying?.id;
|
removeExhaustSnapshot(card);
|
||||||
const index=battle.exhaustPile.findIndex(data=>data.id===id);
|
|
||||||
if(index>=0)battle.exhaustPile.splice(index,1);
|
|
||||||
delete card.storage.mengsanExhausted_shuying;delete card._selfDestroyed;
|
delete card.storage.mengsanExhausted_shuying;delete card._selfDestroyed;
|
||||||
}
|
}
|
||||||
delete card.storage.mengsanConsumed_shuying;
|
delete card.storage.mengsanConsumed_shuying;
|
||||||
@@ -356,7 +389,7 @@ export function installPersonalPiles(session, owner, battle, run, resources, env
|
|||||||
const card = game.createCard(data.name, data.suit, data.number, data.nature);
|
const card = game.createCard(data.name, data.suit, data.number, data.nature);
|
||||||
adopt(card, data);
|
adopt(card, data);
|
||||||
discard.appendChild(card);
|
discard.appendChild(card);
|
||||||
refresh();
|
refresh("discardPile");
|
||||||
return card;
|
return card;
|
||||||
},
|
},
|
||||||
async addToHand(data) {
|
async addToHand(data) {
|
||||||
|
|||||||
+2
-2
@@ -703,7 +703,7 @@ const prepareBattle = async (run, node, encounter, session, resources) => {
|
|||||||
|
|
||||||
activeBattle.personalPiles = installPersonalPiles(session, me, _status.mengsanBattle_shuying, run, resources, {
|
activeBattle.personalPiles = installPersonalPiles(session, me, _status.mengsanBattle_shuying, run, resources, {
|
||||||
game, ui, get, lib, _status, document, MutationObserver, shuffle: shuffleBattlePile,
|
game, ui, get, lib, _status, document, MutationObserver, shuffle: shuffleBattlePile,
|
||||||
refresh: () => activeBattle?.session === session && activeBattle.pilesUI?.refresh(),
|
refresh: (...piles) => activeBattle?.session === session && activeBattle.pilesUI?.refresh(...piles),
|
||||||
});
|
});
|
||||||
activeBattle.personalPiles.withOwner(() => me.init(run.player.character));
|
activeBattle.personalPiles.withOwner(() => me.init(run.player.character));
|
||||||
me.storage.mengsanUnitId_shuying = "player";
|
me.storage.mengsanUnitId_shuying = "player";
|
||||||
@@ -799,7 +799,7 @@ const prepareBattle = async (run, node, encounter, session, resources) => {
|
|||||||
session.ownResource({}, () => game.removeGlobalSkill(skill));
|
session.ownResource({}, () => game.removeGlobalSkill(skill));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activeBattle.pilesUI = mountBattlePiles(session, _status.mengsanBattle_shuying);
|
activeBattle.pilesUI = mountBattlePiles(session, _status.mengsanBattle_shuying, activeBattle.personalPiles.pileView);
|
||||||
currentBattle.owner = me;
|
currentBattle.owner = me;
|
||||||
currentBattle.run = run;
|
currentBattle.run = run;
|
||||||
potionSkillIds.forEach(skill => me.addSkill(skill));
|
potionSkillIds.forEach(skill => me.addSkill(skill));
|
||||||
|
|||||||
@@ -4,9 +4,12 @@ const http = require('node:http');
|
|||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const app = path.resolve(__dirname, '../../../..');
|
const app = path.resolve(__dirname, '../../../..');
|
||||||
const packages = process.env.CODEX_NODE_MODULES || 'C:/Users/Diuse/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules';
|
const packages = process.env.CODEX_NODE_MODULES;
|
||||||
const { chromium } = require(path.join(packages, 'playwright'));
|
const { chromium } = require(packages ? path.join(packages, 'playwright') : 'playwright');
|
||||||
const prefix = '/extension/' + encodeURIComponent('术樱包') + '/mengsan';
|
const prefix = '/extension/' + encodeURIComponent('术樱包') + '/mengsan';
|
||||||
|
const decadePrefix = '/extension/' + encodeURIComponent('十周年UI');
|
||||||
|
const reviewOnly = process.env.HUD_REVIEW === '1';
|
||||||
|
const journeyReview = process.env.UI_ZOOM_REVIEW === '1';
|
||||||
const holdStatus = async (page, locator, pointerType = 'mouse') => {
|
const holdStatus = async (page, locator, pointerType = 'mouse') => {
|
||||||
const box = await locator.boundingBox();
|
const box = await locator.boundingBox();
|
||||||
const point = {x:box.x + box.width / 2,y:box.y + box.height / 2};
|
const point = {x:box.x + box.width / 2,y:box.y + box.height / 2};
|
||||||
@@ -31,10 +34,389 @@ const exposedTarget = (page,index) => page.evaluate(index => {
|
|||||||
}
|
}
|
||||||
throw new Error('Native target has no exposed drag point: '+index);
|
throw new Error('Native target has no exposed drag point: '+index);
|
||||||
},index);
|
},index);
|
||||||
|
async function checkMobileTargetLine(page, artifact) {
|
||||||
|
const touch = await page.context().newCDPSession(page);
|
||||||
|
const handCard = page.locator('.handcards>.card').first();
|
||||||
|
const target = await exposedTarget(page, 1);
|
||||||
|
const end = {x:target.x, y:target.y};
|
||||||
|
const aim = page.locator('.mengsan-hand-aim-shuying');
|
||||||
|
async function drag() {
|
||||||
|
const start = await handCard.boundingBox();
|
||||||
|
const source = {x:start.x + start.width / 2,y:start.y + start.height / 2};
|
||||||
|
await touch.send('Input.dispatchTouchEvent', {type:'touchStart',touchPoints:[source]});
|
||||||
|
await touch.send('Input.dispatchTouchEvent', {type:'touchMove',touchPoints:[end]});
|
||||||
|
await aim.waitFor({state:'visible',timeout:2500});
|
||||||
|
}
|
||||||
|
// Exercise a WebView-style mismatch between the SVG matrix and its painted bounds.
|
||||||
|
await page.evaluate(() => {
|
||||||
|
const create = document.createElementNS.bind(document);
|
||||||
|
document.createElementNS = (namespace,tag) => {
|
||||||
|
const node = create(namespace,tag);
|
||||||
|
if (tag === 'svg') {
|
||||||
|
const screenMatrix = node.getScreenCTM.bind(node);
|
||||||
|
node.getScreenCTM = () => screenMatrix()?.translate(-120,45);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
await drag();
|
||||||
|
const geometry = await aim.evaluate((overlay, pointer) => {
|
||||||
|
const card = window.card.getBoundingClientRect();
|
||||||
|
const origin = {x:card.left + card.width / 2, y:card.top};
|
||||||
|
const line = overlay.querySelector('line');
|
||||||
|
if (line) {
|
||||||
|
const matrix = line.getScreenCTM();
|
||||||
|
return {origin,pointer,from:new DOMPoint(line.x1.baseVal.value,line.y1.baseVal.value).matrixTransform(matrix).toJSON(),
|
||||||
|
to:new DOMPoint(line.x2.baseVal.value,line.y2.baseVal.value).matrixTransform(matrix).toJSON(),bounds:line.getBoundingClientRect().toJSON()};
|
||||||
|
}
|
||||||
|
const bounds = overlay.getBoundingClientRect();
|
||||||
|
const left = origin.x <= pointer.x, up = origin.y <= pointer.y;
|
||||||
|
return {origin,pointer,from:{x:left?bounds.left:bounds.right,y:up?bounds.top:bounds.bottom},
|
||||||
|
to:{x:left?bounds.right:bounds.left,y:up?bounds.bottom:bounds.top}};
|
||||||
|
},end);
|
||||||
|
await page.evaluate(() => { delete document.createElementNS; });
|
||||||
|
if (artifact) await page.screenshot({path:artifact});
|
||||||
|
await touch.send('Input.dispatchTouchEvent', {type:'touchCancel',touchPoints:[]});
|
||||||
|
assert.equal(await aim.count(),0,'the target line disappears on touch cancellation');
|
||||||
|
assert.ok(Math.hypot(geometry.from.x-geometry.origin.x,geometry.from.y-geometry.origin.y)<=2,
|
||||||
|
'A012 target line starts at the selected card’s top center: '+JSON.stringify(geometry));
|
||||||
|
assert.ok(Math.hypot(geometry.to.x-end.x,geometry.to.y-end.y)<=2,
|
||||||
|
'A012 target line ends at the current touch: '+JSON.stringify(geometry));
|
||||||
|
assert.ok(geometry.bounds && Math.abs(geometry.bounds.bottom-geometry.origin.y)<=2 &&
|
||||||
|
Math.abs(geometry.bounds.top-end.y)<=2,'A012 the rendered line reaches both endpoint heights');
|
||||||
|
await page.waitForTimeout(180);
|
||||||
|
await drag();
|
||||||
|
const before = await page.evaluate(()=>game.isSubmitted());
|
||||||
|
await touch.send('Input.dispatchTouchEvent', {type:'touchEnd',touchPoints:[]});
|
||||||
|
assert.equal(await aim.count(),0,'the target line disappears on touch release');
|
||||||
|
assert.equal(await page.evaluate(()=>game.isSubmitted()),before+1,'touch release still submits the valid target once');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkOrdinaryPlayCenter(page, skin, artifact) {
|
||||||
|
const geometry = await page.evaluate(async skin => {
|
||||||
|
const {arena,control,me} = ui;
|
||||||
|
const prompt = document.createElement('div');
|
||||||
|
prompt.className = skin === 'native' ? 'dialog' : 'hand-tip';
|
||||||
|
prompt.textContent = '请选择要使用的牌';
|
||||||
|
arena.append(prompt);
|
||||||
|
ui.dialog = prompt;
|
||||||
|
hudEventState.event.dialog = prompt;
|
||||||
|
hud.refresh();
|
||||||
|
await new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)));
|
||||||
|
const bounds = node => node.getBoundingClientRect().toJSON();
|
||||||
|
const result = {arena:bounds(arena),hand:bounds(me),card:bounds(card),prompt:bounds(prompt),
|
||||||
|
buttons:[...control.firstElementChild.children].map(bounds)};
|
||||||
|
if (!window.card.isConnected) throw new Error('The original hand card must remain connected');
|
||||||
|
return result;
|
||||||
|
},skin);
|
||||||
|
if (artifact) await page.screenshot({path:artifact});
|
||||||
|
await page.evaluate(()=>{ui.dialog.remove();delete ui.dialog;delete hudEventState.event.dialog;hud.refresh();});
|
||||||
|
const {arena,hand,card,prompt,buttons} = geometry;
|
||||||
|
const center = box => (box.left+box.right)/2;
|
||||||
|
const actions = {left:Math.min(...buttons.map(box=>box.left)),right:Math.max(...buttons.map(box=>box.right))};
|
||||||
|
assert.ok([hand,card,prompt,actions].every(box=>Math.abs(center(box)-center(arena))<=2),
|
||||||
|
'ordinary play fan, prompt and action buttons share the arena center: '+JSON.stringify(geometry));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setBattleZoom(page, zoom) {
|
||||||
|
await page.evaluate(zoom => {
|
||||||
|
const {style} = document.body;
|
||||||
|
style.zoom = zoom;
|
||||||
|
style.width = style.height = '100%';
|
||||||
|
},zoom);
|
||||||
|
// Let the native hand transform and the resize observers settle after a zoom change.
|
||||||
|
await page.waitForFunction(() => {
|
||||||
|
const arena = ui.arena.getBoundingClientRect(), hand = card.getBoundingClientRect();
|
||||||
|
return Math.abs(arena.width-innerWidth)<=2 &&
|
||||||
|
Math.abs((arena.left+arena.right-hand.left-hand.right)/2)<=2;
|
||||||
|
},null,{timeout:2500});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkCommittedLine(page, skin) {
|
||||||
|
const geometry = await page.evaluate(async ({skin,decadePrefix}) => {
|
||||||
|
const engine = await import('/noname.js');
|
||||||
|
const {Player} = await import('/noname/library/element/player.js');
|
||||||
|
const {arena,me:hand} = window.ui;
|
||||||
|
const [actor,target] = window.game.players;
|
||||||
|
// Use the shipped line producers and renderer, with only the game lifecycle isolated.
|
||||||
|
engine.lib.config ??= {};
|
||||||
|
engine.setUI({arena,create:{div:selector => {
|
||||||
|
const node = document.createElement('div');
|
||||||
|
if (selector) node.className = 'linexy hidden';
|
||||||
|
node.show = () => node.classList.remove('hidden');
|
||||||
|
node.listenTransition = () => {};
|
||||||
|
node.setBackgroundImage = path => {node.style.backgroundImage = `url(${path})`;};
|
||||||
|
return node;
|
||||||
|
}},refresh:node=>node.getBoundingClientRect()});
|
||||||
|
const get = engine.get;
|
||||||
|
engine.setGet({itemtype:()=> 'player',objtype:get.objtype.bind(get),xyDistance:get.xyDistance.bind(get)});
|
||||||
|
engine.setGame({me:actor,broadcast(){},addVideo(){},linexy:engine.Game.prototype.linexy});
|
||||||
|
actor.getLeft = target.getLeft = function() { return this.offsetLeft; };
|
||||||
|
actor.getTop = target.getTop = function() { return this.offsetTop; };
|
||||||
|
let line = Player.prototype.line;
|
||||||
|
if (skin !== 'native') {
|
||||||
|
const {playerLine} = await import(decadePrefix+'/src/overrides/player/animations.js');
|
||||||
|
const {BoundsCache} = await import(decadePrefix+'/src/utils/bounds.js');
|
||||||
|
window.decadeUI ??= {boundsCaches:{hand:new BoundsCache(hand)}};
|
||||||
|
actor.checkBoundsCache = target.checkBoundsCache = function() {
|
||||||
|
this.cacheLeft = this.offsetLeft;
|
||||||
|
this.cacheTop = this.offsetTop;
|
||||||
|
this.cacheWidth = this.offsetWidth;
|
||||||
|
this.cacheHeight = this.offsetHeight;
|
||||||
|
};
|
||||||
|
line = playerLine;
|
||||||
|
}
|
||||||
|
line.call(actor,target,{duration:120});
|
||||||
|
const effect = arena.querySelector('.linexy');
|
||||||
|
if (!effect) return null;
|
||||||
|
await new Promise(resolve=>setTimeout(resolve,150));
|
||||||
|
const matrix = new DOMMatrix(getComputedStyle(effect).transform);
|
||||||
|
const x1 = parseFloat(effect.style.left), y1 = parseFloat(effect.style.top);
|
||||||
|
const length = parseFloat(effect.style.height);
|
||||||
|
const expectedStart = skin === 'native'
|
||||||
|
? {x:actor.offsetLeft+actor.offsetWidth/2,y:actor.offsetTop+actor.offsetHeight/2}
|
||||||
|
: {x:arena.offsetWidth/2,y:hand.offsetTop};
|
||||||
|
const result = {x1,y1,x2:x1+matrix.c*length,y2:y1+matrix.d*length,expectedStart,
|
||||||
|
expectedEnd:{x:target.offsetLeft+target.offsetWidth/2,y:target.offsetTop+target.offsetHeight/2}};
|
||||||
|
effect.remove();
|
||||||
|
// Run the configured renderer as well as the default one. Its art may be provided by the Android package.
|
||||||
|
Object.assign(engine.game,{
|
||||||
|
linexy:engine.Game.prototype.zsJinlongLineXy,
|
||||||
|
zsPlayLineAnimationByName:engine.Game.prototype.zsPlayLineAnimationByName,
|
||||||
|
zsPlayLineAnimation:engine.Game.prototype.zsPlayLineAnimation,
|
||||||
|
jianqiLineAnim:new engine.Game().jianqiLineAnim,
|
||||||
|
});
|
||||||
|
line.call(actor,target,{duration:120});
|
||||||
|
const dragon = arena.lastElementChild;
|
||||||
|
const {left,top,width,transform,backgroundImage} = dragon.style;
|
||||||
|
const degrees = Number(transform.match(/rotate\(([-.\d]+)deg\)/)?.[1]);
|
||||||
|
const radians = degrees*Math.PI/180;
|
||||||
|
const distance = parseFloat(width)-2;
|
||||||
|
const start = {x:parseFloat(left),y:parseFloat(top)+10};
|
||||||
|
result.dragon = {start,end:{x:start.x+distance*Math.cos(radians),y:start.y+distance*Math.sin(radians)},backgroundImage};
|
||||||
|
return result;
|
||||||
|
},{skin,decadePrefix});
|
||||||
|
assert.ok(geometry && Math.hypot(geometry.x1-geometry.expectedStart.x,geometry.y1-geometry.expectedStart.y)<=2 &&
|
||||||
|
Math.hypot(geometry.x2-geometry.expectedEnd.x,geometry.y2-geometry.expectedEnd.y)<=2,
|
||||||
|
'A012 the committed card effect retains its native origin and reaches the target: '+JSON.stringify(geometry));
|
||||||
|
assert.ok(geometry.dragon.backgroundImage.includes('jinlonglinexy') &&
|
||||||
|
Math.hypot(geometry.dragon.start.x-geometry.expectedStart.x,geometry.dragon.start.y-geometry.expectedStart.y)<=2 &&
|
||||||
|
Math.hypot(geometry.dragon.end.x-geometry.expectedEnd.x,geometry.dragon.end.y-geometry.expectedEnd.y)<=2,
|
||||||
|
'the configured Jinlong effect retains its origin and reaches the target: '+JSON.stringify(geometry));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkBattlePotionSlots(page, skin, artifact) {
|
||||||
|
await page.evaluate(async ({prefix,skin}) => {
|
||||||
|
const {mountPotionSlots} = await import(prefix+'/ui/potions.js');
|
||||||
|
const {ui,battle,hud} = window;
|
||||||
|
const counter = document.createElement('div');
|
||||||
|
counter.className = 'cardRoundNumber';
|
||||||
|
counter.innerHTML = '<div class="cardPileNumber"><span>23</span></div><div class="roundNumber">第3轮</div><div class="time">03:00</div>';
|
||||||
|
if (skin === 'native') counter.style.cssText = 'left:18px;top:4px;width:140px;height:40px';
|
||||||
|
(skin === 'shousha' ? document.body : ui.arena).append(counter);
|
||||||
|
ui.cardRoundTime = counter;
|
||||||
|
window.reviewCounter = counter;
|
||||||
|
window.potionActionCalls = 0;
|
||||||
|
battle.potionUI = mountPotionSlots(ui.arena,{potions:['ENERGY_POTION',null,'FIRE_POTION']},{
|
||||||
|
canUse:()=>true,use:()=>{ window.potionActionCalls++; },
|
||||||
|
});
|
||||||
|
hud.refresh();
|
||||||
|
},{prefix,skin});
|
||||||
|
const geometry = await page.evaluate(() => {
|
||||||
|
const box = node => node.getBoundingClientRect().toJSON();
|
||||||
|
return {arena:box(ui.arena),strip:box(document.querySelector('.mengsan-battle-potions')),
|
||||||
|
counters:[reviewCounter,...reviewCounter.querySelectorAll('div,span')].map(box)};
|
||||||
|
});
|
||||||
|
const {arena,strip,counters} = geometry;
|
||||||
|
assert.ok(strip.left>=arena.left && strip.right<=arena.left+arena.width/2 && strip.top>=arena.top &&
|
||||||
|
strip.bottom<=arena.top+140,'battle potions stay at the upper left: '+JSON.stringify(geometry));
|
||||||
|
assert.ok(counters.every(box=>!box.width||!box.height||strip.right<=box.left||strip.left>=box.right||
|
||||||
|
strip.bottom<=box.top||strip.top>=box.bottom),'battle potion slots clear the round, time and pile counters');
|
||||||
|
if (artifact) await page.screenshot({path:artifact});
|
||||||
|
await page.getByRole('button',{name:'能量药水',exact:true}).tap();
|
||||||
|
await page.getByRole('button',{name:'使用',exact:true}).tap();
|
||||||
|
assert.equal(await page.evaluate(()=>potionActionCalls),1,'the relocated potion button opens details and submits once');
|
||||||
|
const fallback = await page.evaluate(() => {
|
||||||
|
reviewCounter.className = '';
|
||||||
|
reviewCounter.replaceChildren();
|
||||||
|
reviewCounter.style.cssText = 'position:absolute;left:0;top:0;width:46%;height:46px;transition:none';
|
||||||
|
hud.refresh();
|
||||||
|
const panel = reviewCounter.getBoundingClientRect(), arena = ui.arena.getBoundingClientRect();
|
||||||
|
const slots = ui.arena.querySelector('.mengsan-battle-potions').getBoundingClientRect();
|
||||||
|
return slots.top>panel.bottom && slots.left>=arena.left && slots.right<=arena.left+arena.width/2;
|
||||||
|
});
|
||||||
|
assert.ok(fallback,'the potion strip drops below a counter that leaves no room beside it');
|
||||||
|
await page.evaluate(()=>{battle.potionUI.dispose();delete battle.potionUI;reviewCounter.remove();delete ui.cardRoundTime;});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkPotionSkillsDuringDiscard(page, skin, artifact) {
|
||||||
|
const [factory,filename] = {shousha:['createShoushaSkillPlugin','shousha'],
|
||||||
|
shizhounian:['createShizhounianSkillPlugin','shizhounian'],xinsha:['createXinshaSkillPlugin','xinsha']}[skin];
|
||||||
|
await page.evaluate(async ({prefix,decadePrefix,filename,factory}) => {
|
||||||
|
const [engine,{Click},{Check},skinModule,{createBaseLbtnPlugin},potions] = await Promise.all([
|
||||||
|
import('/noname.js'),import('/noname/ui/click/index.js'),import('/noname/game/check.js'),
|
||||||
|
import(decadePrefix+`/ui/skill/skins/${filename}.js`),import(decadePrefix+'/ui/lbtn/skins/base.js'),import(prefix+'/potions/battle.js'),
|
||||||
|
]);
|
||||||
|
const {ui,game,card,hud,hudEventState:status} = window;
|
||||||
|
const me = game.me;
|
||||||
|
const passive = 'mengsan_taoyuan_bond_shuying';
|
||||||
|
const names = {...potions.potionSkillTranslations,[passive]:'桃园羁绊'};
|
||||||
|
const skill = {...potions.createPotionSkills(()=>null,game),[passive]:{locked:true,mark:true}};
|
||||||
|
const config = {touchscreen:true,phonelayout:true,extension_十周年UI_rightLayout:'on'};
|
||||||
|
const lib = {config,skill};
|
||||||
|
const get = {info:id=>skill[id],translation:id=>names[id]||id,
|
||||||
|
is:{locked:id=>id===passive,zhuanhuanji:()=>false,phoneLayout:()=>true}};
|
||||||
|
const app = {listen(){},reWriteFunction(){},get:{skillInfo(id) {
|
||||||
|
return {id,name:id,info:skill[id],translation:names[id],type:skill[id].enable?'enable':'trigger'};
|
||||||
|
}}};
|
||||||
|
Array.prototype.addArray ??= function(items){for(const item of items)if(!this.includes(item))this.push(item);return this;};
|
||||||
|
Array.prototype.add ??= function(item){if(!this.includes(item))this.push(item);return this;};
|
||||||
|
Array.prototype.remove ??= function(item){const i=this.indexOf(item);if(i!==-1)this.splice(i,1);return this;};
|
||||||
|
ui.controls = [ui.control.firstElementChild];
|
||||||
|
ui.updatec = ()=>{};
|
||||||
|
ui.create = {div(selector,parent,label) {
|
||||||
|
const node = document.createElement('div');
|
||||||
|
if(selector) node.className = selector.split('.').filter(Boolean).join(' ');
|
||||||
|
if(label) node.textContent=label;
|
||||||
|
parent?.appendChild(node);
|
||||||
|
return node;
|
||||||
|
},control:()=>ui.control.firstElementChild};
|
||||||
|
engine.lib.config = config;
|
||||||
|
engine.lib.device = 'android';
|
||||||
|
engine.setUI(ui);engine.setGame(game);engine.setGet(get);engine.setStatus(status);
|
||||||
|
Object.assign(status.event,{name:'chooseToDiscard',selectCard:[2,2],position:'h'});
|
||||||
|
delete status.event.respondTo;
|
||||||
|
window.reviewResponse.card.remove();
|
||||||
|
ui.thrown = [];
|
||||||
|
const prompt = window.reviewResponse.prompt;
|
||||||
|
const count = document.createElement('span');
|
||||||
|
count.textContent = '0/2';
|
||||||
|
prompt.replaceChildren('请弃置两张手牌',document.createElement('br'),count);
|
||||||
|
status.event.custom = {add:{card() {count.textContent = `${ui.selected.cards.length}/2`;}}};
|
||||||
|
Object.assign(me,{getSkills:type=>type==='e'?[]:Object.keys(skill),invisibleSkills:[],awakenedSkills:[],
|
||||||
|
getStorage:(key,fallback=[])=>me.storage[key]??fallback,isTempBanned:()=>false});
|
||||||
|
Object.assign(game,{expandSkills:skills=>skills,addVideo(){},countChoose(){},check:()=>Check.prototype.confirm(status.event,'')});
|
||||||
|
const plugin = skinModule[factory](lib,game,ui,get,{},status,app);
|
||||||
|
if (filename === 'xinsha') {
|
||||||
|
plugin.initCreateFunctions();
|
||||||
|
plugin.initUpdateFunctions();
|
||||||
|
} else {
|
||||||
|
plugin._extendUICreate();
|
||||||
|
plugin._extendUI();
|
||||||
|
}
|
||||||
|
plugin.updateSkillMarks=()=>{};
|
||||||
|
createBaseLbtnPlugin(lib,game,ui,get,{},status,app).initConfirmRewrite();
|
||||||
|
ui.confirm = null;
|
||||||
|
ui.create.confirm('');
|
||||||
|
card.classList.remove('selected');
|
||||||
|
card.updateTransform=()=>{};
|
||||||
|
card.addEventListener('touchend',()=>{
|
||||||
|
status.clicked=false;
|
||||||
|
Click.prototype.card.call(card);
|
||||||
|
});
|
||||||
|
hud.refresh();
|
||||||
|
const visiblePotionButtons = () => [...ui.skillControl.querySelectorAll('[data-id]')].filter(node=>
|
||||||
|
node.getClientRects().length && potions.potionSkillIds.includes(node.dataset.id)).map(node=>node.dataset.id);
|
||||||
|
window.discardSkillCheck = {frames:[],visiblePotionButtons,passive,
|
||||||
|
initialPotionButton:ui.skillControl.querySelector(`[data-id="${potions.potionSkillIds[0]}"]`)};
|
||||||
|
const capture = event => {
|
||||||
|
if (event.target.closest('.card')!==card) return;
|
||||||
|
// Listen after the real card handler, before any scheduled HUD refresh.
|
||||||
|
discardSkillCheck.frames.push(visiblePotionButtons());
|
||||||
|
requestAnimationFrame(()=>discardSkillCheck.frames.push(visiblePotionButtons()));
|
||||||
|
};
|
||||||
|
window.addEventListener('touchend',capture,{once:true});
|
||||||
|
},{prefix,decadePrefix,factory,filename});
|
||||||
|
await page.locator('.handcards>.card').first().tap();
|
||||||
|
const result = await page.evaluate(async () => {
|
||||||
|
await new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)));
|
||||||
|
const {frames,passive,initialPotionButton,visiblePotionButtons} = discardSkillCheck;
|
||||||
|
return {frames,visible:visiblePotionButtons(),rebuilt:initialPotionButton && !initialPotionButton.isConnected,
|
||||||
|
selected:ui.selected.cards.length,count:ui.dialog.textContent,passiveVisible:Boolean(ui.skillControl.querySelector(`[data-id="${passive}"]`)?.getClientRects().length)};
|
||||||
|
});
|
||||||
|
if (artifact) await page.screenshot({path:artifact});
|
||||||
|
assert.equal(result.rebuilt,true,'ten-year UI rebuilt the skill row on tap');
|
||||||
|
assert.ok(result.selected===1 && result.count.endsWith('1/2'),'the original touch selects one discard card and updates the count');
|
||||||
|
assert.ok(result.passiveVisible,'normal skills remain visible');
|
||||||
|
assert.equal(result.frames.length,2,'both touch and first animation frame were sampled');
|
||||||
|
assert.deepEqual([...result.frames.flat(),...result.visible],[],'potion skill duplicates are hidden from the first frame');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkMobileResponseLayout(page, skin, artifact) {
|
||||||
|
await page.evaluate(({skin,decadePrefix}) => {
|
||||||
|
const {arena,control} = ui;
|
||||||
|
const card = document.createElement('div');
|
||||||
|
const scale = Math.min(arena.clientHeight * .18 / 156,1);
|
||||||
|
card.className = 'card thrown';
|
||||||
|
card.style.cssText = `left:calc(50% - 56px);top:calc(50% - 78px);width:112px;height:156px;transform:scale(${scale});`;
|
||||||
|
card.style.background = `center/100% 100% url("${decadePrefix}/image/card-skins/decade/sha.png")`;
|
||||||
|
arena.appendChild(card);
|
||||||
|
ui.thrown = [card];
|
||||||
|
const prompt = document.createElement('div');
|
||||||
|
prompt.className = skin === 'native' ? 'dialog' : 'hand-tip';
|
||||||
|
prompt.innerHTML = skin === 'native'
|
||||||
|
? '<div class="content-container"><div class="content"><div class="caption">请使用一张闪响应杀</div></div></div>'
|
||||||
|
: '<span>请使用一张闪响应杀</span>';
|
||||||
|
arena.appendChild(prompt);
|
||||||
|
ui.dialog = prompt;
|
||||||
|
const event = hudEventState.event;
|
||||||
|
event.name = 'chooseToUse';
|
||||||
|
event.respondTo = [game.players[1],{name:'sha'}];
|
||||||
|
event.dialog = prompt;
|
||||||
|
window.reviewResponses = [];
|
||||||
|
const confirm = control.firstElementChild;
|
||||||
|
confirm.classList.remove('stayleft');
|
||||||
|
ui.confirm = confirm;
|
||||||
|
if (skin !== 'native') confirm.classList.add('combo-control','lbtn-confirm');
|
||||||
|
const [ok,cancel] = confirm.children;
|
||||||
|
confirm.node = {ok,cancel};
|
||||||
|
[ok,cancel].forEach((node,index) => {
|
||||||
|
node.dataset.response = index ? 'cancel' : 'ok';
|
||||||
|
if (skin !== 'native') node.classList.add('control');
|
||||||
|
if (skin === 'shousha') {
|
||||||
|
(node.firstElementChild || node).textContent = '';
|
||||||
|
if (index) node.innerHTML = '<img src="/extension/十周年UI/ui/assets/lbtn/uibutton/QX.png" alt="取消">';
|
||||||
|
} else (node.firstElementChild || node).textContent = index ? '取消' : '确定';
|
||||||
|
node.addEventListener('click',()=>reviewResponses.push(node.dataset.response));
|
||||||
|
});
|
||||||
|
window.reviewResponse = {card,prompt};
|
||||||
|
window.card.classList.add('selected');
|
||||||
|
window.card.style.backgroundImage = `url("${decadePrefix}/image/card-skins/decade/shan.png")`;
|
||||||
|
window.card.textContent = '';
|
||||||
|
hud.refresh();
|
||||||
|
},{skin,decadePrefix});
|
||||||
|
await page.waitForTimeout(550);
|
||||||
|
const geometry = await page.evaluate(() => {
|
||||||
|
const box = node => node.getBoundingClientRect().toJSON();
|
||||||
|
return {arena:box(ui.arena), card:box(reviewResponse.card), prompt:box(reviewResponse.prompt),
|
||||||
|
ok:box(document.querySelector('[data-response="ok"]')),cancel:box(document.querySelector('[data-response="cancel"]')),
|
||||||
|
hand:box(card)};
|
||||||
|
});
|
||||||
|
if (artifact) await page.screenshot({path:artifact});
|
||||||
|
const {arena, card, prompt, ok, cancel, hand} = geometry;
|
||||||
|
const center = ({left,right}) => (left + right) / 2;
|
||||||
|
assert.ok([card,prompt,{left:ok.left,right:cancel.right}].every(box=>Math.abs(center(box)-center(arena))<=2),
|
||||||
|
'A013 played card, response prompt and action group share the arena center: '+JSON.stringify(geometry));
|
||||||
|
const gap = 4;
|
||||||
|
assert.ok(card.top >= arena.top+2 && card.bottom+gap <= prompt.top && prompt.bottom+gap <= Math.min(ok.top,cancel.top) &&
|
||||||
|
Math.max(ok.bottom,cancel.bottom)+gap <= hand.top && ok.right <= cancel.left,
|
||||||
|
'A013 played card, prompt, actions and selected hand card do not overlap: '+JSON.stringify(geometry));
|
||||||
|
await page.locator('[data-response="ok"]').tap();
|
||||||
|
await page.locator('[data-response="cancel"]').tap();
|
||||||
|
assert.deepEqual(await page.evaluate(()=>reviewResponses),['ok','cancel'],'both original response callbacks are reachable');
|
||||||
|
const restored = await page.evaluate(() => {
|
||||||
|
delete hudEventState.event.respondTo;
|
||||||
|
hud.refresh();
|
||||||
|
const verticalShift = Number.parseFloat(ui.control.style.translate.split(/\s+/)[1]) || 0;
|
||||||
|
return verticalShift === 0 && reviewResponse.card.style.translate === '';
|
||||||
|
});
|
||||||
|
assert.ok(restored,'response spacing is released when the original event ends');
|
||||||
|
}
|
||||||
const fixture = `<!doctype html><meta charset="utf-8"><link rel="stylesheet" href="/layout/default/layout.css"><div id="window"><div id="arena"><div id="mebg"></div><div id="me" class="mengsan-hand-root-shuying"><div id="handcards1" class="mengsan-hand-scroll-shuying"><div class="handcards mengsan-hand-zone-shuying mengsan-hand-layout-shuying"></div></div><div id="handcards2"><div class="handcards"></div></div></div><div id="control"><div class="control"><div>测试技能</div><div>结束出牌</div></div></div></div></div><style>html,body,#window{margin:0;width:100%;height:100%;position:absolute}#arena{inset:0;width:100%;height:100%;position:absolute}#arena>.player{position:absolute;width:100px;height:130px;background:#345;color:#fff}#arena>.player .avatar{height:100%;width:100%;background:linear-gradient(#334f4b,#172d29)}#arena>.player .name{position:absolute;top:4px;left:4px}#me{position:absolute;bottom:0;width:100%;height:160px}#handcards1,#handcards2{position:absolute;width:100%;height:100%}.handcards{height:100%}.card{background:#e8d7b2;color:#263b35;position:absolute}.mengsan-intent-shuying{position:absolute}</style>`;
|
const fixture = `<!doctype html><meta charset="utf-8"><link rel="stylesheet" href="/layout/default/layout.css"><div id="window"><div id="arena"><div id="mebg"></div><div id="me" class="mengsan-hand-root-shuying"><div id="handcards1" class="mengsan-hand-scroll-shuying"><div class="handcards mengsan-hand-zone-shuying mengsan-hand-layout-shuying"></div></div><div id="handcards2"><div class="handcards"></div></div></div><div id="control"><div class="control"><div>测试技能</div><div>结束出牌</div></div></div></div></div><style>html,body,#window{margin:0;width:100%;height:100%;position:absolute}#arena{inset:0;width:100%;height:100%;position:absolute}#arena>.player{position:absolute;width:100px;height:130px;background:#345;color:#fff}#arena>.player .avatar{height:100%;width:100%;background:linear-gradient(#334f4b,#172d29)}#arena>.player .name{position:absolute;top:4px;left:4px}#me{position:absolute;bottom:0;width:100%;height:160px}#handcards1,#handcards2{position:absolute;width:100%;height:100%}.handcards{height:100%}.card{background:#e8d7b2;color:#263b35;position:absolute}.mengsan-intent-shuying{position:absolute}</style>`;
|
||||||
|
const importMap = reviewOnly || journeyReview ? fs.readFileSync(path.join(app,'index.html'),'utf8').match(/<script type="importmap">.*?<\/script>/s)[0] : '';
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
if (req.url === '/fixture') { res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fixture);return; }
|
if (req.url === '/fixture') { res.setHeader('Content-Type','text/html;charset=utf-8');res.end(fixture.replace('<meta charset="utf-8">','<meta charset="utf-8">'+importMap));return; }
|
||||||
if(req.url==='/noname.js'){res.setHeader('Content-Type','text/javascript');res.end('export const _status={};');return;}
|
if(!reviewOnly && !journeyReview && req.url==='/noname.js'){res.setHeader('Content-Type','text/javascript');res.end('export const _status={};');return;}
|
||||||
if(decodeURIComponent(new URL(req.url,'http://localhost').pathname)==='/extension/术樱包/diagnostics/index.js') {
|
if(decodeURIComponent(new URL(req.url,'http://localhost').pathname)==='/extension/术樱包/diagnostics/index.js') {
|
||||||
res.setHeader('Content-Type','text/javascript');res.end('export const getDiagnostics=()=>({status:()=>({enabled:false}),scope:()=>({info(){},error(){}})});');return;
|
res.setHeader('Content-Type','text/javascript');res.end('export const getDiagnostics=()=>({status:()=>({enabled:false}),scope:()=>({info(){},error(){}})});');return;
|
||||||
}
|
}
|
||||||
@@ -48,20 +430,32 @@ const server = http.createServer((req, res) => {
|
|||||||
const origin = 'http://127.0.0.1:' + server.address().port;
|
const origin = 'http://127.0.0.1:' + server.address().port;
|
||||||
const browser = await chromium.launch({channel:'msedge',headless:true});
|
const browser = await chromium.launch({channel:'msedge',headless:true});
|
||||||
let checks = 0;
|
let checks = 0;
|
||||||
|
const reviewFailures = [];
|
||||||
|
const viewports = reviewOnly ? [{width:1080,height:486},{width:812,height:375},{width:667,height:375}]
|
||||||
|
: [{width:1280,height:720},{width:1234,height:920},{width:812,height:600},{width:812,height:375},{width:667,height:375},{width:375,height:500},{width:540,height:900}];
|
||||||
try {
|
try {
|
||||||
|
if (journeyReview) {
|
||||||
|
await require('./test-journey-ui-zoom.cjs').testJourneyZoom(browser,origin,prefix);
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (const skin of process.env.HUD_TEST_SKIN?[process.env.HUD_TEST_SKIN]:['native','shousha','shizhounian','xinsha']) {
|
for (const skin of process.env.HUD_TEST_SKIN?[process.env.HUD_TEST_SKIN]:['native','shousha','shizhounian','xinsha']) {
|
||||||
for (const viewport of [{width:1280,height:720},{width:1234,height:920},{width:812,height:600},{width:812,height:375},{width:667,height:375},{width:375,height:500},{width:540,height:900}]) {
|
for (const viewport of viewports) {
|
||||||
const page = await browser.newPage({viewport,hasTouch:true});
|
const page = await browser.newPage({viewport,hasTouch:true,deviceScaleFactor:reviewOnly?2.625:1});
|
||||||
await page.goto(origin+'/fixture');
|
await page.goto(origin+'/fixture');
|
||||||
|
if (reviewOnly && viewport.width===1080) {
|
||||||
|
await page.addStyleTag({url:origin+'/layout/nova/layout.css'});
|
||||||
|
await page.addStyleTag({content:'body{zoom:.65;width:100%;height:100%}'});
|
||||||
|
}
|
||||||
await page.addStyleTag({content:'body{background:#161e29 url("/image/background/lanting_bg.jpg") center/cover no-repeat}'});
|
await page.addStyleTag({content:'body{background:#161e29 url("/image/background/lanting_bg.jpg") center/cover no-repeat}'});
|
||||||
await page.addStyleTag({url:origin+prefix+'/ui/style.css'});
|
await page.addStyleTag({url:origin+prefix+'/ui/style.css'});
|
||||||
|
if(reviewOnly) await page.addStyleTag({url:origin+prefix+'/ui/potions.css'});
|
||||||
if(skin!=='native') {
|
if(skin!=='native') {
|
||||||
for(const css of ['/extension/'+encodeURIComponent('十周年UI')+'/src/styles/layout.css','/extension/'+encodeURIComponent('十周年UI')+'/ui/styles/base.css','/extension/'+encodeURIComponent('十周年UI')+'/ui/styles/skill/'+skin+'.css','/extension/'+encodeURIComponent('十周年UI')+'/ui/styles/lbtn/'+skin+'.css'])await page.addStyleTag({url:origin+css});
|
for(const css of ['/extension/'+encodeURIComponent('十周年UI')+'/src/styles/layout.css','/extension/'+encodeURIComponent('十周年UI')+'/ui/styles/base.css','/extension/'+encodeURIComponent('十周年UI')+'/ui/styles/skill/'+skin+'.css','/extension/'+encodeURIComponent('十周年UI')+'/ui/styles/lbtn/'+skin+'.css'])await page.addStyleTag({url:origin+css});
|
||||||
await page.addStyleTag({url:origin+'/extension/'+encodeURIComponent('十周年UI')+'/src/styles/player'+({shousha:2,shizhounian:1,xinsha:3}[skin])+'.css'});
|
await page.addStyleTag({url:origin+'/extension/'+encodeURIComponent('十周年UI')+'/src/styles/player'+({shousha:2,shizhounian:1,xinsha:3}[skin])+'.css'});
|
||||||
await page.addStyleTag({url:origin+'/extension/'+encodeURIComponent('十周年UI')+'/src/styles/equip.css'});
|
await page.addStyleTag({url:origin+'/extension/'+encodeURIComponent('十周年UI')+'/src/styles/equip.css'});
|
||||||
}
|
}
|
||||||
await page.addStyleTag({url:origin+prefix+'/ui/hand/style.css'});
|
await page.addStyleTag({url:origin+prefix+'/ui/hand/style.css'});
|
||||||
const initial = await page.evaluate(async ({prefix,skin}) => {
|
const initial = await page.evaluate(async ({prefix,skin,reviewOnly,decadePrefix}) => {
|
||||||
const mod = await import(prefix+'/ui/hud/index.js').catch(error=>({error:String(error)}));
|
const mod = await import(prefix+'/ui/hud/index.js').catch(error=>({error:String(error)}));
|
||||||
if(typeof mod.mountBattleHUD!=='function')return {module:false,error:mod.error};
|
if(typeof mod.mountBattleHUD!=='function')return {module:false,error:mod.error};
|
||||||
const releases=[];window.session={id:'hud-test',active:true,ownResource:(_,f)=>releases.push(f)};
|
const releases=[];window.session={id:'hud-test',active:true,ownResource:(_,f)=>releases.push(f)};
|
||||||
@@ -82,12 +476,16 @@ const server = http.createServer((req, res) => {
|
|||||||
node.addEventListener('click',()=>{window.nativeActionClicks=(window.nativeActionClicks||0)+1;});
|
node.addEventListener('click',()=>{window.nativeActionClicks=(window.nativeActionClicks||0)+1;});
|
||||||
});
|
});
|
||||||
const players=[];
|
const players=[];
|
||||||
for(let i=0;i<8;i++) {
|
for(let i=0;i<(reviewOnly?2:8);i++) {
|
||||||
const player=document.createElement('div');player.className='player';player.dataset.position=String(i);player.playerid=String(i);player.name=i?'enemy'+i:'liubei';player.hp=40;player.maxHp=60;player.hujia=8;
|
const player=document.createElement('div');player.className='player';player.dataset.position=String(i);player.playerid=String(i);player.name=i?'enemy'+i:'liubei';player.hp=40;player.maxHp=60;player.hujia=8;
|
||||||
player.storage={mengsanCamp_shuying:i?'enemy':'ally',mengsanStrength_shuying:i===1?3:0,mengsanVulnerable_shuying:i===2?2:0,mengsanEnergy_shuying:3,mengsanMaxEnergy_shuying:3};
|
player.storage={mengsanCamp_shuying:i?'enemy':'ally',mengsanStrength_shuying:i===1?3:0,mengsanVulnerable_shuying:i===2?2:0,mengsanEnergy_shuying:3,mengsanMaxEnergy_shuying:3};
|
||||||
player.innerHTML=skin==='native' ? '<div class="avatar"></div><div class="name">'+(i?'敌人'+i:'刘备')+'</div><div class="hp">40/60</div><div class="marks"></div>' : '<div class="primary-avatar has-outcrop"><div class="action">回合开始</div></div><div class="framebg"></div><div class="identity">汉</div><div class="camp-wrap"><div class="camp-border"></div><div class="avatar-name">'+(i?'敌人'+i:'刘备')+'</div></div><div class="hp-wrap"><div class="hp">40/60</div></div><div class="card-count">8</div><div class="dui-marks"></div>';
|
player.innerHTML=skin==='native' ? '<div class="avatar"></div><div class="name">'+(i?'敌人'+i:'刘备')+'</div><div class="hp">40/60</div><div class="marks"></div>' : '<div class="primary-avatar has-outcrop"><div class="action">回合开始</div></div><div class="framebg"></div><div class="identity">汉</div><div class="camp-wrap"><div class="camp-border"></div><div class="avatar-name">'+(i?'敌人'+i:'刘备')+'</div></div><div class="hp-wrap"><div class="hp">40/60</div></div><div class="card-count">8</div><div class="dui-marks"></div>';
|
||||||
if(i)player.insertAdjacentHTML('beforeend','<div class="mengsan-intent-shuying">攻击 8×2</div>');
|
if(i)player.insertAdjacentHTML('beforeend','<div class="mengsan-intent-shuying">攻击 8×2</div>');
|
||||||
player.node={avatar:player.querySelector('.avatar,.primary-avatar'),hp:player.querySelector('.hp'),hpWrap:player.querySelector('.hp-wrap'),campWrap:player.querySelector('.camp-wrap'),name:player.querySelector('.name,.avatar-name'),identity:player.querySelector('.identity'),framebg:player.querySelector('.framebg'),count:player.querySelector('.card-count'),marks:player.querySelector('.marks,.dui-marks')};
|
player.node={avatar:player.querySelector('.avatar,.primary-avatar'),hp:player.querySelector('.hp'),hpWrap:player.querySelector('.hp-wrap'),campWrap:player.querySelector('.camp-wrap'),name:player.querySelector('.name,.avatar-name'),identity:player.querySelector('.identity'),framebg:player.querySelector('.framebg'),count:player.querySelector('.card-count'),marks:player.querySelector('.marks,.dui-marks')};
|
||||||
|
if (reviewOnly && i && window.innerWidth>=1000) {
|
||||||
|
player.style.cssText='left:50%!important;right:auto!important;top:12px!important;bottom:auto!important;transform:translateX(-50%)!important;';
|
||||||
|
}
|
||||||
|
if (reviewOnly && !i) player.node.avatar.style.backgroundImage=`url(${prefix}/assets/portraits/liubei-portrait.jpg)`;
|
||||||
player.node.avatar.style.backgroundImage='url("/image/character/'+(i?'caocao':'liubei')+'.jpg")';
|
player.node.avatar.style.backgroundImage='url("/image/character/'+(i?'caocao':'liubei')+'.jpg")';
|
||||||
if(i){player.style.cssText=`left:${(i-1)%4*21+5}%;top:${68+Math.floor((i-1)/4)*96}px;width:68px;height:82px;transform:none`;}
|
if(i){player.style.cssText=`left:${(i-1)%4*21+5}%;top:${68+Math.floor((i-1)/4)*96}px;width:68px;height:82px;transform:none`;}
|
||||||
const equips=document.createElement('div');equips.className='equips';player.node.equips=equips;player.appendChild(equips);
|
const equips=document.createElement('div');equips.className='equips';player.node.equips=equips;player.appendChild(equips);
|
||||||
@@ -119,6 +517,10 @@ const server = http.createServer((req, res) => {
|
|||||||
me.node.handcards1=ui.handcards1Container.firstElementChild;me.node.handcards2=ui.handcards2Container.firstElementChild;
|
me.node.handcards1=ui.handcards1Container.firstElementChild;me.node.handcards2=ui.handcards2Container.firstElementChild;
|
||||||
const get={translation:value=>value==='liubei'?'刘备':String(value).replace(/^enemy/,'敌人'),select:value=>value};
|
const get={translation:value=>value==='liubei'?'刘备':String(value).replace(/^enemy/,'敌人'),select:value=>value};
|
||||||
const card=document.createElement('div');card.className='card selectable';card.textContent='杀';card.name='sha';me.node.handcards1.appendChild(card);window.card=card;
|
const card=document.createElement('div');card.className='card selectable';card.textContent='杀';card.name='sha';me.node.handcards1.appendChild(card);window.card=card;
|
||||||
|
if (reviewOnly) {
|
||||||
|
card.style.background=`center/100% 100% url("${decadePrefix}/image/card-skins/decade/sha.png")`;
|
||||||
|
card.textContent='';
|
||||||
|
}
|
||||||
card.addEventListener('contextmenu',event=>{
|
card.addEventListener('contextmenu',event=>{
|
||||||
event.preventDefault();window.introOpens=(window.introOpens||0)+1;
|
event.preventDefault();window.introOpens=(window.introOpens||0)+1;
|
||||||
const tip=document.createElement('div');tip.className='dialog popped static';
|
const tip=document.createElement('div');tip.className='dialog popped static';
|
||||||
@@ -148,10 +550,50 @@ const server = http.createServer((req, res) => {
|
|||||||
window.testHandUI=await mountHandUI(me,session,{ui,game,get,lib:{card:{},translate:{}},_status:hudEventState,document,window,isActiveCardUse:()=>true,canPayCard:()=>true,cardCost:()=>1,styleURL:prefix+'/ui/hand/style.css'});
|
window.testHandUI=await mountHandUI(me,session,{ui,game,get,lib:{card:{},translate:{}},_status:hudEventState,document,window,isActiveCardUse:()=>true,canPayCard:()=>true,cardCost:()=>1,styleURL:prefix+'/ui/hand/style.css'});
|
||||||
window.testInput={owns:()=>false};hud.refresh();window.testFan={sync:()=>testHandUI.refresh()};
|
window.testInput={owns:()=>false};hud.refresh();window.testFan={sync:()=>testHandUI.refresh()};
|
||||||
return {module:true,parentKept:hand.parentNode===oldParents.hand&&control.parentNode===oldParents.control&&card.parentNode===oldParents.card,skin};
|
return {module:true,parentKept:hand.parentNode===oldParents.hand&&control.parentNode===oldParents.control&&card.parentNode===oldParents.card,skin};
|
||||||
},{prefix,skin});
|
},{prefix,skin,reviewOnly,decadePrefix});
|
||||||
assert.equal(initial.module,true,initial.error||'HUD mount module must exist');checks++;
|
assert.equal(initial.module,true,initial.error||'HUD mount module must exist');checks++;
|
||||||
assert.equal(initial.parentKept,true);checks++;
|
assert.equal(initial.parentKept,true);checks++;
|
||||||
await page.waitForTimeout(70);
|
await page.waitForTimeout(70);
|
||||||
|
if (reviewOnly) {
|
||||||
|
const scenario = `${skin}-${viewport.width}x${viewport.height}`;
|
||||||
|
const artifact = name => process.env.HUD_ARTIFACTS && path.join(process.env.HUD_ARTIFACTS,`${name}-${scenario}.png`);
|
||||||
|
try { await checkMobileTargetLine(page,artifact('A012')); await checkCommittedLine(page,skin); checks+=8; }
|
||||||
|
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
|
||||||
|
try { await checkOrdinaryPlayCenter(page,skin,artifact('ordinary-play-center')); checks++; }
|
||||||
|
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
|
||||||
|
if (viewport.width===1080) {
|
||||||
|
for (const zoom of [.5,.85,1,1.2]) {
|
||||||
|
try {
|
||||||
|
await setBattleZoom(page,zoom);
|
||||||
|
await checkOrdinaryPlayCenter(page,skin);
|
||||||
|
await checkMobileTargetLine(page);
|
||||||
|
await checkCommittedLine(page,skin);
|
||||||
|
checks+=9;
|
||||||
|
} catch (error) { reviewFailures.push(`${scenario} zoom ${zoom} ${error.message}`); }
|
||||||
|
}
|
||||||
|
await setBattleZoom(page,.65);
|
||||||
|
}
|
||||||
|
try { await checkBattlePotionSlots(page,skin,artifact('battle-potion-slots')); checks+=4; }
|
||||||
|
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
|
||||||
|
try { await checkMobileResponseLayout(page,skin,artifact('A013')); checks+=4; }
|
||||||
|
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
|
||||||
|
if (skin!=='native') {
|
||||||
|
try { await checkPotionSkillsDuringDiscard(page,skin,artifact('discard-skill-controls')); checks+=5; }
|
||||||
|
catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
|
||||||
|
try {
|
||||||
|
assert.equal(await page.evaluate(()=>{
|
||||||
|
const bounds = window.decadeUI.boundsCaches.hand;
|
||||||
|
bounds.check();
|
||||||
|
hud.dispose();
|
||||||
|
return bounds.updated;
|
||||||
|
}),false,'the skin will read restored hand geometry after the HUD exits');
|
||||||
|
checks++;
|
||||||
|
} catch (error) { reviewFailures.push(`${scenario} ${error.message}`); }
|
||||||
|
}
|
||||||
|
if (!reviewFailures.some(failure => failure.startsWith(`${scenario} `))) console.log(`${scenario} battle UI review passed`);
|
||||||
|
await page.close();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const releasedControls = await page.evaluate(() => {
|
const releasedControls = await page.evaluate(() => {
|
||||||
const control = document.createElement('div');
|
const control = document.createElement('div');
|
||||||
control.className = 'control';
|
control.className = 'control';
|
||||||
@@ -444,6 +886,7 @@ const server = http.createServer((req, res) => {
|
|||||||
await page.close();
|
await page.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (reviewFailures.length) throw new Error(reviewFailures.join('\n'));
|
||||||
console.log('HUD browser checks: '+checks);
|
console.log('HUD browser checks: '+checks);
|
||||||
} finally {await browser.close();await new Promise(resolve=>server.close(resolve));}
|
} finally {await browser.close();await new Promise(resolve=>server.close(resolve));}
|
||||||
})().catch(error=>{console.error(error);server.close();process.exitCode=1;});
|
})().catch(error=>{console.error(error);server.close();process.exitCode=1;});
|
||||||
|
|||||||
@@ -0,0 +1,368 @@
|
|||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const path = require('node:path');
|
||||||
|
|
||||||
|
const surfaces = [
|
||||||
|
['选将', '.mengsan-character-overlay-shuying', '确认出征', 'mengsan_liubei_shuying'],
|
||||||
|
['地图', '.mengsan-map-overlay-shuying', /可前往$/, 'route'],
|
||||||
|
['事件选项', '.mengsan-flow-overlay-shuying', '继续', 'go'],
|
||||||
|
['商店', '.mengsan-shop-overlay-shuying', '离开商店', 'leave'],
|
||||||
|
['休息处', '.mengsan-rest-overlay-shuying', '离开休息处', 'done'],
|
||||||
|
['剧情', '.mengsan-dialogue-overlay-shuying', /跳过对话/, null],
|
||||||
|
['剧情分支', '.mengsan-dialogue-overlay-shuying', /剧情文本/, 'pledge'],
|
||||||
|
['奖励选牌', '.mengsan-card-choice-dialog-shuying', '跳过', null],
|
||||||
|
['战后选择', '.mengsan-victory-dialog-shuying', /领取战利品/, 'claim'],
|
||||||
|
['牌库', '.mengsan-deck-dialog-shuying', '关闭', null],
|
||||||
|
['牌堆', '.mengsan-deck-dialog-shuying', '关闭', null],
|
||||||
|
['遗物', '.mengsan-relic-dialog-shuying', '关闭', null],
|
||||||
|
['药水详情', '.mengsan-potion-dialog', '关闭', null],
|
||||||
|
['菜单确认', '.mengsan-menu-dialog-shuying', '保留', 'keep'],
|
||||||
|
['调试管理器', '.mengsan-gm-dialog-shuying', '关闭', null],
|
||||||
|
['战斗状态', '.mengsan-hud-dialog-shuying', '关闭', null],
|
||||||
|
];
|
||||||
|
|
||||||
|
async function mountSurface(page, origin, prefix, settings, surface) {
|
||||||
|
await page.goto(origin+'/fixture');
|
||||||
|
await page.addStyleTag({content:'#window,#arena{transition:none}'});
|
||||||
|
for (const file of ['style','shop','rest','potions','character-select']) {
|
||||||
|
await page.addStyleTag({url:origin+prefix+`/ui/${file}.css`});
|
||||||
|
}
|
||||||
|
await page.evaluate(async ({prefix,settings,surface}) => {
|
||||||
|
const engine = await import('/noname.js');
|
||||||
|
const imported = await import(prefix+'/progression/state.js');
|
||||||
|
const updateZoom = settings.transform ? engine.UI.prototype.updatez.bind(engine.ui) :
|
||||||
|
(await import('/extension/'+encodeURIComponent('十周年UI')+'/src/overrides/ui/update.js')).uiUpdatez;
|
||||||
|
window.zoomReviewSetScale = zoom => {
|
||||||
|
engine.game.documentZoom = zoom;
|
||||||
|
updateZoom();
|
||||||
|
};
|
||||||
|
window.zoomReviewSetScale(settings.zoom);
|
||||||
|
const ui = {window:document.getElementById('window'),arena:document.getElementById('arena'),create:{}};
|
||||||
|
ui.create.div = (selector,...args) => {
|
||||||
|
const element = document.createElement('div');
|
||||||
|
element.className = selector.split('.').filter(Boolean).join(' ');
|
||||||
|
element.setBackground = (name,type) => {element.style.backgroundImage=`url(/image/${type}/${name}.jpg)`;};
|
||||||
|
for (const arg of args) {
|
||||||
|
if (arg instanceof Node) arg.append(element);
|
||||||
|
else if (typeof arg === 'string') element.textContent = arg;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
};
|
||||||
|
engine.lib.config ??= {};
|
||||||
|
engine.lib.assetURL = '/';
|
||||||
|
engine.lib.card.sha ??= {type:'basic'};
|
||||||
|
engine.lib.translate.sha = '杀';
|
||||||
|
engine.lib.translate.sha_info = '对一名其他角色造成伤害。';
|
||||||
|
engine.lib.translate.mengsan_liubei_shuying = '刘备';
|
||||||
|
engine.setUI(ui);
|
||||||
|
const run = imported.createRun('mengsan_liubei_shuying');
|
||||||
|
Object.assign(run.player,{gold:99,hp:25,maxHp:50,potions:['ENERGY_POTION']});
|
||||||
|
window.zoomReviewResult = null;
|
||||||
|
function settled(value) {window.zoomReviewResult = value;}
|
||||||
|
const modules = name => import(prefix+`/ui/${name}.js`);
|
||||||
|
const choices = [{id:'go',name:'继续'},{id:'leave',name:'离开'}];
|
||||||
|
if (surface==='选将') {
|
||||||
|
const {chooseCharacterCards} = await modules('character-select');
|
||||||
|
chooseCharacterCards([{id:run.player.character,name:'刘备',description:'出征武将'}],prefix,'返回').then(settled);
|
||||||
|
} else if (surface==='地图') {
|
||||||
|
const {showMap} = await modules('map/renderer');
|
||||||
|
showMap(run).then(()=>settled('route'));
|
||||||
|
} else if (surface==='事件选项') {
|
||||||
|
const {chooseButtons} = await modules('flow-ui');
|
||||||
|
chooseButtons('地图事件',choices,'选择一项继续前进').then(settled);
|
||||||
|
} else if (surface==='商店') {
|
||||||
|
const {chooseShop} = await modules('shop-ui');
|
||||||
|
chooseShop(run.player,[{id:'supply:heal',name:'补给',description:'获得补给',price:30}]).then(settled);
|
||||||
|
} else if (surface==='休息处') {
|
||||||
|
const {chooseRest} = await modules('rest-ui');
|
||||||
|
chooseRest([{id:'heal',name:'休息',description:'恢复生命'}],{tent:true}).then(settled);
|
||||||
|
} else if (surface==='剧情' || surface==='剧情分支') {
|
||||||
|
const {playDialogue} = await modules('dialogue');
|
||||||
|
const branch = surface==='剧情分支';
|
||||||
|
const lines = branch ? [{type:'choice',text:'如何回答?',speed:0,flag:'story.zoom',
|
||||||
|
choices:[{id:'pledge',text:'结伴前行'},{id:'leave',text:'独自出发'}]}] :
|
||||||
|
[{type:'narrator',text:'整备完毕,今日继续向前。',speed:0}];
|
||||||
|
playDialogue(lines,{run}).then(()=>settled(branch ? run.storyFlags['story.zoom'] : null));
|
||||||
|
} else if (surface==='奖励选牌') {
|
||||||
|
const {chooseCardDialog} = await modules('reward-ui');
|
||||||
|
chooseCardDialog([{id:'sha',card:{name:'sha'}}]).then(settled);
|
||||||
|
} else if (surface==='战后选择') {
|
||||||
|
const {chooseVictoryOptions} = await modules('reward-ui');
|
||||||
|
chooseVictoryOptions([{id:'claim',label:'领取战利品'}]).then(settled);
|
||||||
|
} else if (surface==='牌库') {
|
||||||
|
const {openCardLibrary} = await modules('card-library');
|
||||||
|
run.player.deck = Array.from({length:48},()=>({name:'sha',suit:'heart',number:5}));
|
||||||
|
openCardLibrary(run);
|
||||||
|
} else if (surface==='牌堆') {
|
||||||
|
const {mountBattlePiles} = await modules('card-library');
|
||||||
|
const battle = {drawPile:run.player.deck,discardPile:[],exhaustPile:[]};
|
||||||
|
window.pileReview = {
|
||||||
|
battle,
|
||||||
|
control: mountBattlePiles({active:true,ownResource(){}},battle),
|
||||||
|
};
|
||||||
|
} else if (surface==='遗物') {
|
||||||
|
const {mountRelics} = await modules('relics');
|
||||||
|
mountRelics({active:true,ownResource(){}},run,{status(){},counter:()=>({value:null,label:null})},{stripRoot:ui.arena});
|
||||||
|
} else if (surface==='药水详情') {
|
||||||
|
const {mountPotionSlots} = await modules('potions');
|
||||||
|
const slots = mountPotionSlots(ui.arena,run.player,{use(){},canUse:()=>true});
|
||||||
|
slots.layoutBattleSlots(ui);
|
||||||
|
} else if (surface==='菜单确认') {
|
||||||
|
const {askMenu} = await modules('navigation');
|
||||||
|
askMenu('结束征程?','保留进度后可以继续。',[{id:'keep',name:'保留'}]).then(settled);
|
||||||
|
} else if (surface==='调试管理器') {
|
||||||
|
const {mountGMManager} = await modules('gm-manager');
|
||||||
|
const game = {};
|
||||||
|
mountGMManager({active:true,ownResource(){}},{getCards:()=>[]},{},{},
|
||||||
|
{field:(target,key,value)=>{target[key]=value;}},game);
|
||||||
|
game.mengsanGM_shuying();
|
||||||
|
} else if (surface==='战斗状态') {
|
||||||
|
const {mountBattleHUD} = await modules('hud/index');
|
||||||
|
ui.me = document.getElementById('me');
|
||||||
|
ui.control = document.getElementById('control');
|
||||||
|
const player = ui.create.div('.player',ui.arena);
|
||||||
|
Object.assign(player,{name:run.player.character,hp:25,maxHp:50,storage:{mengsanStrength_shuying:2},node:{}});
|
||||||
|
mountBattleHUD(player,{session:{active:true,ownResource(){}}},{ui,get:engine.get,_status:engine._status,document,window,assetBase:prefix});
|
||||||
|
}
|
||||||
|
},{prefix,settings,surface});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkMapDrag(page) {
|
||||||
|
const viewport = page.locator('.mengsan-map-viewport-shuying');
|
||||||
|
const scroll = await viewport.evaluate(element => {
|
||||||
|
element.scrollTop = (element.scrollHeight-element.clientHeight)/2;
|
||||||
|
const box = element.getBoundingClientRect();
|
||||||
|
const y = Math.min(box.bottom-4,innerHeight-4);
|
||||||
|
return {top:element.scrollTop,scale:box.height/element.offsetHeight,x:box.left+box.width/2,y,
|
||||||
|
distance:Math.min(32,Math.floor((y-Math.max(0,box.top))/2))};
|
||||||
|
});
|
||||||
|
assert.ok(scroll.distance>=8,`the map still provides a draggable viewport: ${JSON.stringify(scroll)}`);
|
||||||
|
await page.mouse.move(scroll.x,scroll.y);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(scroll.x,scroll.y-scroll.distance,{steps:4});
|
||||||
|
await page.mouse.up();
|
||||||
|
const moved = await viewport.evaluate(element=>element.scrollTop)-scroll.top;
|
||||||
|
assert.ok(Math.abs(moved*scroll.scale-scroll.distance)<=2,`map drag follows the pointer: ${JSON.stringify({...scroll,moved})}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkSurface(page, surface, settings, origin, prefix) {
|
||||||
|
const [name,selector,buttonName,result] = surface;
|
||||||
|
await mountSurface(page,origin,prefix,settings,name);
|
||||||
|
const launcher = {'牌堆':'.mengsan-battle-piles-button-shuying','遗物':'.mengsan-battle-relics-button-shuying',
|
||||||
|
'药水详情':'button.mengsan-potion-slot','战斗状态':'.mengsan-hud-status-shuying'}[name];
|
||||||
|
if (launcher) await page.locator(launcher).first().tap({timeout:1800});
|
||||||
|
const root = page.locator(selector);
|
||||||
|
await root.waitFor({state:'visible',timeout:1800});
|
||||||
|
if (settings.switchTo) {
|
||||||
|
await page.evaluate(zoom => window.zoomReviewSetScale(zoom), settings.switchTo);
|
||||||
|
}
|
||||||
|
const box = await root.boundingBox();
|
||||||
|
const viewport = page.viewportSize();
|
||||||
|
assert.ok(box.x>=-2 && box.y>=-2 && box.x+box.width<=viewport.width+2 && box.y+box.height<=viewport.height+2,
|
||||||
|
`surface within viewport: ${JSON.stringify({box,viewport})}`);
|
||||||
|
if (name==='地图') {
|
||||||
|
await checkMapDrag(page);
|
||||||
|
await root.getByRole('button',{name:'菜单',exact:true}).tap({timeout:1800});
|
||||||
|
const drawer = root.locator('.mengsan-map-menu-sheet-shuying');
|
||||||
|
await drawer.getByRole('button',{name:/行囊/}).tap({timeout:1800});
|
||||||
|
await drawer.getByRole('button',{name:'返回菜单',exact:true}).tap({timeout:1800});
|
||||||
|
await drawer.getByRole('button',{name:'关闭菜单',exact:true}).tap({timeout:1800});
|
||||||
|
}
|
||||||
|
if (process.env.HUD_ARTIFACTS && settings.zoom===1.5 && !settings.transform && !settings.viewport) {
|
||||||
|
await page.screenshot({path:path.join(process.env.HUD_ARTIFACTS,`zoom-${name}.png`)});
|
||||||
|
}
|
||||||
|
if (name==='剧情分支') await root.getByRole('button',{name:'结伴前行',exact:true}).tap({timeout:1800});
|
||||||
|
const action = root.getByRole('button',{name:buttonName}).first();
|
||||||
|
if(name==='牌库') {
|
||||||
|
const card = root.locator('.ms-deck-card').first();
|
||||||
|
await card.tap({timeout:1800});
|
||||||
|
assert.ok(await root.locator('.ms-deck-detail').isVisible(),'a card opens its details');
|
||||||
|
}
|
||||||
|
await action.tap({timeout:1800});
|
||||||
|
assert.equal(await root.count(),0,'the original action closes the surface');
|
||||||
|
if (result!==null) assert.equal(await page.evaluate(()=>zoomReviewResult),result,'the original action returns the choice');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkLivePiles(page, origin, prefix) {
|
||||||
|
await mountSurface(page,origin,prefix,{zoom:1},'牌堆');
|
||||||
|
await page.evaluate(async prefix => {
|
||||||
|
const {battle,control} = window.pileReview;
|
||||||
|
control.dispose();
|
||||||
|
const engine = await import('/noname.js');
|
||||||
|
const {mountBattlePiles} = await import(prefix+'/ui/card-library.js');
|
||||||
|
const {installPersonalPiles} = await import(prefix+'/cards/personal-piles.js');
|
||||||
|
const {DAZED_NAME,dazedDefinition,createDazedData} = await import(prefix+'/cards/status-cards.js');
|
||||||
|
battle.drawPile = Array.from({length:48},(_,index) => ({id:`card-${index}`,name:'sha',suit:'heart',number:index%13+1}));
|
||||||
|
engine.lib.card[DAZED_NAME] = dazedDefinition;
|
||||||
|
engine.lib.translate[DAZED_NAME] = '晕眩';
|
||||||
|
const hand = document.createElement('div');
|
||||||
|
const owner = {playerid:'pile-review',isAlive:()=>true,getCards:()=>Array.from(hand.childNodes),
|
||||||
|
lose(card,pile) { pile.appendChild(card); return {}; }};
|
||||||
|
const session = {active:true,ownResource(){}};
|
||||||
|
const publicDiscard = document.createElement('div');
|
||||||
|
const ui = {cardPile:document.createElement('div'),discardPile:publicDiscard};
|
||||||
|
const game = {createCard(name,suit,number,nature) {
|
||||||
|
return Object.assign(document.createElement('div'),{name,suit,number,nature,gaintag:new Set(),
|
||||||
|
addGaintag(tag) { this.gaintag.add(tag); }});
|
||||||
|
}};
|
||||||
|
let dialogControl;
|
||||||
|
const piles = installPersonalPiles(session,owner,battle,{}, {card(){}}, {
|
||||||
|
game,ui,get:{},lib:engine.lib,_status:{},document,MutationObserver,shuffle:(_,cards)=>cards.reverse(),
|
||||||
|
refresh: (...keys) => dialogControl?.refresh(...keys),
|
||||||
|
});
|
||||||
|
const reads = {count:0,records:0};
|
||||||
|
dialogControl = mountBattlePiles(session,battle,{
|
||||||
|
count(key) { reads.count++; return piles.pileView.count(key); },
|
||||||
|
records(key) { reads.records++; return piles.pileView.records(key); },
|
||||||
|
});
|
||||||
|
window.pileReview = {piles,control:dialogControl,draw:piles.withOwner(()=>ui.cardPile),publicDiscard,createDazedData,reads,
|
||||||
|
makeNative(suit,number) { return hand.appendChild(game.createCard('sha',suit,number)); }};
|
||||||
|
},prefix);
|
||||||
|
await page.locator('.mengsan-battle-piles-button-shuying').tap();
|
||||||
|
const result = await page.evaluate(async () => {
|
||||||
|
const {piles,draw,publicDiscard,createDazedData,reads,makeNative} = window.pileReview;
|
||||||
|
const dialog = document.querySelector('.mengsan-deck-dialog-shuying');
|
||||||
|
const [drawTab,discardTab,exhaustTab] = dialog.querySelectorAll('.ms-deck-tabs button:not([hidden])');
|
||||||
|
const grid = dialog.querySelector('.ms-library-grid');
|
||||||
|
const body = dialog.querySelector('.ms-deck-body');
|
||||||
|
const frame = async () => {
|
||||||
|
// Let native pile mutations notify the dialog before waiting for its next paint.
|
||||||
|
await Promise.resolve();
|
||||||
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
||||||
|
};
|
||||||
|
const cardAt = index => grid.querySelector(`[data-card-index="${index}"]`);
|
||||||
|
const first = cardAt(0);
|
||||||
|
reads.count = reads.records = 0;
|
||||||
|
publicDiscard.appendChild(document.createElement('div'));
|
||||||
|
await frame();
|
||||||
|
const unrelatedReads = {...reads};
|
||||||
|
let countUpdates = 0;
|
||||||
|
const observer = new MutationObserver(records => { countUpdates += records.length; });
|
||||||
|
observer.observe(discardTab,{childList:true});
|
||||||
|
for (let index=0;index<3;index++) {
|
||||||
|
piles.addToDiscard(createDazedData(`status-${index}`));
|
||||||
|
}
|
||||||
|
const beforeFrame = discardTab.textContent;
|
||||||
|
await frame();
|
||||||
|
observer.disconnect();
|
||||||
|
const afterBatch = {beforeFrame,countUpdates,discard:discardTab.textContent,sameCard:first===cardAt(0),reads:{...reads}};
|
||||||
|
|
||||||
|
first.click();
|
||||||
|
const heading = dialog.querySelector('.ms-deck-detail h3');
|
||||||
|
const back = dialog.querySelector('.ms-deck-detail button');
|
||||||
|
const [seen] = piles.take(1);
|
||||||
|
await frame();
|
||||||
|
const detail = {stillOpen:heading.isConnected && !heading.closest('section').hidden,focused:document.activeElement===back,draw:drawTab.textContent};
|
||||||
|
if (!detail.stillOpen) return {afterBatch,detail};
|
||||||
|
back.click();
|
||||||
|
const afterBack = {top:body.scrollTop,number:cardAt(0).querySelector('.ms-deck-corner').textContent,
|
||||||
|
focused:document.activeElement===drawTab};
|
||||||
|
|
||||||
|
const start = 12;
|
||||||
|
const original = cardAt(start);
|
||||||
|
body.scrollTop = original.getBoundingClientRect().top - body.getBoundingClientRect().top - 5;
|
||||||
|
await frame();
|
||||||
|
const topBefore = cardAt(start).getBoundingClientRect().top - body.getBoundingClientRect().top;
|
||||||
|
cardAt(start).focus({preventScroll:true});
|
||||||
|
draw.prepend(seen,...Array.from(draw.childNodes).slice(25,33));
|
||||||
|
await frame();
|
||||||
|
const moved = cardAt(start+9);
|
||||||
|
const reorder = {topBefore,topAfter:moved?.getBoundingClientRect().top-body.getBoundingClientRect().top,
|
||||||
|
focused:document.activeElement===moved,order:moved?.querySelector('.ms-deck-order').textContent};
|
||||||
|
|
||||||
|
const upgraded = draw.childNodes[start+9];
|
||||||
|
upgraded.storage.mengsanCard_shuying.upgrade = 1;
|
||||||
|
piles.syncExhaustSnapshots();
|
||||||
|
await frame();
|
||||||
|
const upgrade = {tag:cardAt(start+9).querySelector('.ms-deck-tags')?.textContent,focused:document.activeElement===cardAt(start+9)};
|
||||||
|
|
||||||
|
body.style.maxHeight = '32px';
|
||||||
|
draw.replaceChildren();
|
||||||
|
await frame();
|
||||||
|
const empty = {visible:!!grid.querySelector('.ms-deck-empty'),top:body.scrollTop,focused:document.activeElement===drawTab};
|
||||||
|
body.scrollTop = body.scrollHeight;
|
||||||
|
piles.take(1);
|
||||||
|
await frame();
|
||||||
|
const wash = {draw:drawTab.textContent,discard:discardTab.textContent,top:body.scrollTop,
|
||||||
|
first:cardAt(0).querySelector('.ms-deck-name').textContent};
|
||||||
|
body.style.maxHeight = '';
|
||||||
|
|
||||||
|
publicDiscard.appendChild(seen);
|
||||||
|
await frame();
|
||||||
|
const reclaimed = {stillPublic:publicDiscard.contains(seen),discard:discardTab.textContent};
|
||||||
|
piles.addToDiscard(createDazedData('status-4'));
|
||||||
|
discardTab.click();
|
||||||
|
const switched = {discard:discardTab.textContent,visible:cardAt(1).querySelector('.ms-deck-name').textContent};
|
||||||
|
cardAt(1).click();
|
||||||
|
piles.addToDiscard(createDazedData('status-5'));
|
||||||
|
await frame();
|
||||||
|
const discardDetail = {visible:!dialog.querySelector('.ms-deck-detail').hidden,
|
||||||
|
summary:dialog.querySelector('.ms-deck-summary').textContent};
|
||||||
|
|
||||||
|
const nativeFirst = makeNative('club',7), nativeSecond = makeNative('diamond',8);
|
||||||
|
await piles.exhaustFromHand(nativeFirst);
|
||||||
|
await piles.exhaustFromHand(nativeSecond);
|
||||||
|
exhaustTab.click();
|
||||||
|
cardAt(0).focus({preventScroll:true});
|
||||||
|
piles.syncExhaustSnapshots();
|
||||||
|
await frame();
|
||||||
|
const corners = () => Array.from(grid.querySelectorAll('.ms-deck-corner'),card => card.textContent);
|
||||||
|
const exhaust = {cards:corners(),focused:document.activeElement===cardAt(0)};
|
||||||
|
piles.beginAutoPlay(nativeSecond,true);
|
||||||
|
await frame();
|
||||||
|
exhaust.remaining = corners();
|
||||||
|
discardTab.click();
|
||||||
|
return {unrelatedReads,afterBatch,detail,afterBack,reorder,upgrade,empty,wash,reclaimed,switched,discardDetail,exhaust};
|
||||||
|
});
|
||||||
|
assert.deepEqual(result.unrelatedReads,{count:0,records:0});
|
||||||
|
assert.deepEqual(result.afterBatch,{beforeFrame:'弃牌堆 · 0',countUpdates:1,discard:'弃牌堆 · 3',sameCard:true,
|
||||||
|
reads:{count:1,records:0}});
|
||||||
|
assert.deepEqual(result.detail,{stillOpen:true,focused:true,draw:'剩余牌堆 · 47'});
|
||||||
|
assert.deepEqual(result.afterBack,{top:0,number:'♥ 红桃 2',focused:true});
|
||||||
|
assert.ok(Math.abs(result.reorder.topAfter-result.reorder.topBefore)<=2,JSON.stringify(result.reorder));
|
||||||
|
assert.equal(result.reorder.focused,true);
|
||||||
|
assert.equal(result.reorder.order,'22');
|
||||||
|
assert.deepEqual(result.upgrade,{tag:'+1',focused:true});
|
||||||
|
assert.deepEqual(result.empty,{visible:true,top:0,focused:true});
|
||||||
|
assert.deepEqual(result.wash,{draw:'剩余牌堆 · 2',discard:'弃牌堆 · 0',top:0,first:'晕眩'});
|
||||||
|
assert.deepEqual(result.reclaimed,{stillPublic:false,discard:'弃牌堆 · 1'});
|
||||||
|
assert.deepEqual(result.switched,{discard:'弃牌堆 · 2',visible:'晕眩'});
|
||||||
|
assert.deepEqual(result.discardDetail,{visible:true,summary:'弃牌堆 · 共 3 张'});
|
||||||
|
assert.deepEqual(result.exhaust,{cards:['♣ 梅花 7','♦ 方块 8'],focused:true,remaining:['♣ 梅花 7']});
|
||||||
|
if (process.env.HUD_ARTIFACTS) {
|
||||||
|
await page.screenshot({path:path.join(process.env.HUD_ARTIFACTS,'battle-piles-live.png')});
|
||||||
|
}
|
||||||
|
const readsAfterClose = await page.evaluate(async () => {
|
||||||
|
const {control,reads} = window.pileReview;
|
||||||
|
reads.count = reads.records = 0;
|
||||||
|
control.refresh();
|
||||||
|
document.querySelector('.ms-deck-header button').click();
|
||||||
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
||||||
|
return {...reads};
|
||||||
|
});
|
||||||
|
assert.deepEqual(readsAfterClose,{count:0,records:0});
|
||||||
|
assert.equal(await page.locator('.mengsan-deck-dialog-shuying').count(),0);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.testJourneyZoom = async function testJourneyZoom(browser,origin,prefix) {
|
||||||
|
const pilePage = await browser.newPage({viewport:{width:812,height:375},hasTouch:true});
|
||||||
|
try { await checkLivePiles(pilePage,origin,prefix); }
|
||||||
|
finally { await pilePage.close(); }
|
||||||
|
console.log('Live battle piles: passed');
|
||||||
|
if (process.env.PILE_REFRESH_REVIEW === '1') return;
|
||||||
|
const failures = [];
|
||||||
|
let checks = 0;
|
||||||
|
const scenarios = [{zoom:.5},{zoom:.65},{zoom:1},{zoom:1.5},{zoom:2},{zoom:3},{zoom:1.5,transform:true},
|
||||||
|
{zoom:1.5,viewport:{width:420,height:360}}, {zoom:.65,transform:true,viewport:{width:390,height:720}},
|
||||||
|
{zoom:1,transform:true,viewport:{width:1280,height:720}}, {zoom:3,transform:true},
|
||||||
|
{zoom:.65,switchTo:2}, {zoom:.65,switchTo:2,transform:true}];
|
||||||
|
for (const settings of scenarios) {
|
||||||
|
const page = await browser.newPage({viewport:settings.viewport??{width:812,height:375},hasTouch:true});
|
||||||
|
for (const surface of surfaces) {
|
||||||
|
try { await checkSurface(page,surface,settings,origin,prefix); checks++; }
|
||||||
|
catch (error) { failures.push(`${surface[0]} ${JSON.stringify(settings)} ${error.message}`); }
|
||||||
|
}
|
||||||
|
await page.close();
|
||||||
|
}
|
||||||
|
if (failures.length) throw new Error(`${checks} passed\n${failures.join('\n')}`);
|
||||||
|
console.log(`Journey UI zoom: ${checks} passed`);
|
||||||
|
};
|
||||||
+118
-46
@@ -115,6 +115,7 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
if (existing) { existing.focus(); return () => {}; }
|
if (existing) { existing.focus(); return () => {}; }
|
||||||
const previousFocus = document.activeElement;
|
const previousFocus = document.activeElement;
|
||||||
const selection = options.selection;
|
const selection = options.selection;
|
||||||
|
const sections = options.sections;
|
||||||
const dialog = element("dialog", "mengsan-deck-dialog-shuying", null);
|
const dialog = element("dialog", "mengsan-deck-dialog-shuying", null);
|
||||||
dialog.setAttribute("aria-label", options.title || "卡牌库");
|
dialog.setAttribute("aria-label", options.title || "卡牌库");
|
||||||
const header = element("header", "ms-deck-header", null, dialog);
|
const header = element("header", "ms-deck-header", null, dialog);
|
||||||
@@ -122,10 +123,13 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
element("span", "ms-deck-eyebrow", options.eyebrow || "梦三 · 行囊", title);
|
element("span", "ms-deck-eyebrow", options.eyebrow || "梦三 · 行囊", title);
|
||||||
element("h2", "ms-deck-title", options.title || "卡牌库", title);
|
element("h2", "ms-deck-title", options.title || "卡牌库", title);
|
||||||
let closed = false, sizeObserver = null, virtualGrid = null, searchTimer = 0;
|
let closed = false, sizeObserver = null, virtualGrid = null, searchTimer = 0;
|
||||||
|
let refreshFrame = 0;
|
||||||
|
const pendingPiles = new Set();
|
||||||
const close = () => {
|
const close = () => {
|
||||||
if (closed) return;
|
if (closed) return;
|
||||||
closed = true;
|
closed = true;
|
||||||
clearTimeout(searchTimer);
|
clearTimeout(searchTimer);
|
||||||
|
cancelPileRefresh();
|
||||||
virtualGrid?.dispose();
|
virtualGrid?.dispose();
|
||||||
sizeObserver?.disconnect();
|
sizeObserver?.disconnect();
|
||||||
if (typeof window !== "undefined") window.removeEventListener?.("resize", fitCards);
|
if (typeof window !== "undefined") window.removeEventListener?.("resize", fitCards);
|
||||||
@@ -134,7 +138,7 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
list.replaceChildren(); detailPanel.replaceChildren(); body.replaceChildren();
|
list.replaceChildren(); detailPanel.replaceChildren(); body.replaceChildren();
|
||||||
dialog.replaceChildren();
|
dialog.replaceChildren();
|
||||||
catalogRecords = null; descriptionCache = new WeakMap();
|
catalogRecords = null; descriptionCache = new WeakMap();
|
||||||
selectedButton = null; current = [];
|
selectedButton = null; current = []; sectionRecords = []; detailListPosition = null;
|
||||||
virtualGrid = null; sizeObserver = null;
|
virtualGrid = null; sizeObserver = null;
|
||||||
if (previousFocus?.isConnected) previousFocus.focus();
|
if (previousFocus?.isConnected) previousFocus.focus();
|
||||||
const onClose = options.onClose;
|
const onClose = options.onClose;
|
||||||
@@ -142,16 +146,16 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
onClose?.(close);
|
onClose?.(close);
|
||||||
};
|
};
|
||||||
button("关闭", header, close);
|
button("关闭", header, close);
|
||||||
let view = selection || (!options.sections && options.view === "catalog")
|
let view = selection || (!sections && options.view === "catalog")
|
||||||
? "catalog" : "deck";
|
? "catalog" : "deck";
|
||||||
const navigation = element("nav", "ms-deck-tabs", null, dialog);
|
const navigation = element("nav", "ms-deck-tabs", null, dialog);
|
||||||
navigation.setAttribute("aria-label", "卡牌列表视图");
|
navigation.setAttribute("aria-label", "卡牌列表视图");
|
||||||
const deckTab = button("持有牌", navigation, () => { view = "deck"; render(); });
|
const deckTab = button("持有牌", navigation, () => { view = "deck"; render(); });
|
||||||
const catalogTab = button("图鉴", navigation, () => { view = "catalog"; render(); });
|
const catalogTab = button("图鉴", navigation, () => { view = "catalog"; render(); });
|
||||||
deckTab.hidden = catalogTab.hidden = Boolean(options.sections || selection);
|
deckTab.hidden = catalogTab.hidden = Boolean(sections || selection);
|
||||||
let sectionIndex = 0;
|
let sectionIndex = 0;
|
||||||
const sectionTabs = options.sections ? options.sections().map((section, index) =>
|
const sectionTabs = sections?.map((section, index) =>
|
||||||
button(section.title, navigation, () => { sectionIndex = index; render(); })) : [];
|
button(section.title, navigation, () => { sectionIndex = index; render(); }));
|
||||||
const filters = element("div", "ms-catalog-filters", null, dialog);
|
const filters = element("div", "ms-catalog-filters", null, dialog);
|
||||||
function field(label) {
|
function field(label) {
|
||||||
const wrapper = element("label", "ms-catalog-field", null, filters);
|
const wrapper = element("label", "ms-catalog-field", null, filters);
|
||||||
@@ -192,6 +196,7 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
const footer = element("p", "ms-deck-footer", "点击卡牌查看完整介绍 · 仅供查看,不改变牌组或抽牌顺序", dialog);
|
const footer = element("p", "ms-deck-footer", "点击卡牌查看完整介绍 · 仅供查看,不改变牌组或抽牌顺序", dialog);
|
||||||
let current = Array.isArray(run?.player?.deck) ? run.player.deck : [];
|
let current = Array.isArray(run?.player?.deck) ? run.player.deck : [];
|
||||||
let detail = false, selectedButton = null, scrollTop = 0, orderedView = false;
|
let detail = false, selectedButton = null, scrollTop = 0, orderedView = false;
|
||||||
|
let sectionRecords = [], displayedSection = -1, detailListPosition = null;
|
||||||
const list = element("div", "ms-deck-grid ms-library-grid", null, body);
|
const list = element("div", "ms-deck-grid ms-library-grid", null, body);
|
||||||
const detailPanel = element("section", "ms-deck-detail", null, body);
|
const detailPanel = element("section", "ms-deck-detail", null, body);
|
||||||
detailPanel.hidden = true;
|
detailPanel.hidden = true;
|
||||||
@@ -199,7 +204,15 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
virtualGrid = createVirtualCardGrid(body, list, createTile);
|
virtualGrid = createVirtualCardGrid(body, list, createTile);
|
||||||
function back() {
|
function back() {
|
||||||
detail = false; detailPanel.hidden = true; list.hidden = false;
|
detail = false; detailPanel.hidden = true; list.hidden = false;
|
||||||
detailPanel.replaceChildren(); body.scrollTop = scrollTop; fitCards();
|
detailPanel.replaceChildren();
|
||||||
|
if (sections) {
|
||||||
|
cancelPileRefresh();
|
||||||
|
updateSectionTabs();
|
||||||
|
renderSection({ position: detailListPosition });
|
||||||
|
detailListPosition = null; selectedButton = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
body.scrollTop = scrollTop; fitCards();
|
||||||
virtualGrid?.resume();
|
virtualGrid?.resume();
|
||||||
if (selectedButton?.isConnected) selectedButton.focus({ preventScroll: true });
|
if (selectedButton?.isConnected) selectedButton.focus({ preventScroll: true });
|
||||||
else if (virtualGrid && selectedButton) virtualGrid.focus(Number(selectedButton.dataset.cardIndex));
|
else if (virtualGrid && selectedButton) virtualGrid.focus(Number(selectedButton.dataset.cardIndex));
|
||||||
@@ -207,6 +220,7 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
function showDetail(card, details, owner, catalog = false) {
|
function showDetail(card, details, owner, catalog = false) {
|
||||||
clearTimeout(searchTimer);
|
clearTimeout(searchTimer);
|
||||||
selectedButton = owner; scrollTop = body.scrollTop;
|
selectedButton = owner; scrollTop = body.scrollTop;
|
||||||
|
if (sections) detailListPosition = captureListPosition(owner);
|
||||||
detail = true; list.hidden = true; detailPanel.hidden = false;
|
detail = true; list.hidden = true; detailPanel.hidden = false;
|
||||||
detailPanel.replaceChildren();
|
detailPanel.replaceChildren();
|
||||||
const backButton = button(catalog ? "返回图鉴" : "返回牌库", detailPanel, back);
|
const backButton = button(catalog ? "返回图鉴" : "返回牌库", detailPanel, back);
|
||||||
@@ -242,7 +256,8 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
}
|
}
|
||||||
body.scrollTop = 0; backButton.focus();
|
body.scrollTop = 0; backButton.focus();
|
||||||
}
|
}
|
||||||
function fitCards() {
|
function fitCards() { layoutCards(); }
|
||||||
|
function layoutCards(position = null) {
|
||||||
if (closed || !body.clientHeight) return;
|
if (closed || !body.clientHeight) return;
|
||||||
const padding = getComputedStyle(body);
|
const padding = getComputedStyle(body);
|
||||||
const available = body.clientHeight - parseFloat(padding.paddingTop) - parseFloat(padding.paddingBottom);
|
const available = body.clientHeight - parseFloat(padding.paddingTop) - parseFloat(padding.paddingBottom);
|
||||||
@@ -250,7 +265,7 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
const height = Math.max(128, Math.min(218, Math.floor((available - (rows - 1) * 8) / rows)));
|
const height = Math.max(128, Math.min(218, Math.floor((available - (rows - 1) * 8) / rows)));
|
||||||
dialog.style.setProperty("--ms-card-height", String(height) + "px");
|
dialog.style.setProperty("--ms-card-height", String(height) + "px");
|
||||||
dialog.style.setProperty("--ms-card-art-width", String(Math.max(8, Math.min(98, Math.floor((height - (orderedView ? 104 : 80)) * 5 / 7)))) + "px");
|
dialog.style.setProperty("--ms-card-art-width", String(Math.max(8, Math.min(98, Math.floor((height - (orderedView ? 104 : 80)) * 5 / 7)))) + "px");
|
||||||
virtualGrid?.layout(height);
|
virtualGrid?.layout(height, position);
|
||||||
}
|
}
|
||||||
function createTile(record, index) {
|
function createTile(record, index) {
|
||||||
const { card, catalog = false, ordered = false } = record;
|
const { card, catalog = false, ordered = false } = record;
|
||||||
@@ -266,33 +281,95 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
element("span", "ms-deck-excerpt", details.description, tile);
|
element("span", "ms-deck-excerpt", details.description, tile);
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
function captureListPosition(focused = document.activeElement) {
|
||||||
|
const scrollTop = sectionRecords.length ? body.scrollTop : 0;
|
||||||
|
const anchors = scrollTop > 0 ? virtualGrid.visiblePositions().map(({ index, offset }) =>
|
||||||
|
({ key: sectionRecords[index].key, offset })) : [];
|
||||||
|
const focusKey = list.contains(focused) ? sectionRecords[Number(focused.dataset.cardIndex)]?.key : undefined;
|
||||||
|
return { scrollTop, anchors, focusKey };
|
||||||
|
}
|
||||||
|
function restoreListPosition(position) {
|
||||||
|
if (!position) { fitCards(); return; }
|
||||||
|
const indices = new Map(sectionRecords.map(({ key }, index) => [key, index]));
|
||||||
|
const anchor = position.anchors.find(({ key }) => indices.has(key));
|
||||||
|
layoutCards({ index: anchor ? indices.get(anchor.key) : -1, offset: anchor?.offset,
|
||||||
|
scrollTop: sectionRecords.length ? position.scrollTop : 0 });
|
||||||
|
if (position.focusKey === undefined) return;
|
||||||
|
const index = indices.get(position.focusKey);
|
||||||
|
if (index === undefined) sectionTabs[sectionIndex].focus({ preventScroll: true });
|
||||||
|
else virtualGrid.focus(index, { scroll: false });
|
||||||
|
}
|
||||||
|
function updateSectionTabs(piles = null) {
|
||||||
|
sections.forEach(({ title, key, ordered }, index) => {
|
||||||
|
if (piles && !piles.has(key)) return;
|
||||||
|
const tab = sectionTabs[index];
|
||||||
|
const count = options.pileView.count(key);
|
||||||
|
const label = `${title} · ${count}`;
|
||||||
|
if (tab.textContent !== label) tab.textContent = label;
|
||||||
|
if (!piles) tab.setAttribute("aria-pressed", String(index === sectionIndex));
|
||||||
|
if (index !== sectionIndex) return;
|
||||||
|
const summaryLabel = ordered ? "剩余牌堆按从左到右、从上到下的顺序摸取;第 1 张为下一张。" :
|
||||||
|
`${title} · 共 ${count} 张`;
|
||||||
|
if (summary.textContent !== summaryLabel) summary.textContent = summaryLabel;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function renderSection({ position = null, preserve = false } = {}) {
|
||||||
|
const { key, ordered } = sections[sectionIndex];
|
||||||
|
const records = options.pileView.records(key).map(({ card, key }) =>
|
||||||
|
({ card, key, ordered, signature: JSON.stringify(card) }));
|
||||||
|
if (displayedSection === sectionIndex && records.length === sectionRecords.length &&
|
||||||
|
records.every(({ key, signature }, index) => key === sectionRecords[index].key && signature === sectionRecords[index].signature)) {
|
||||||
|
if (position) restoreListPosition(position);
|
||||||
|
else if (!preserve) virtualGrid.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (preserve) position = captureListPosition();
|
||||||
|
displayedSection = sectionIndex; sectionRecords = records; orderedView = ordered;
|
||||||
|
descriptionCache = new WeakMap();
|
||||||
|
virtualGrid.setRecords(records);
|
||||||
|
if (!records.length) {
|
||||||
|
const emptyMessage = ordered ? "剩余牌堆为空;下一次摸牌需按规则洗切弃牌堆,洗切后的顺序尚未确定。" : "此处暂无卡牌。";
|
||||||
|
element("p", "ms-deck-empty", emptyMessage, list);
|
||||||
|
}
|
||||||
|
restoreListPosition(position);
|
||||||
|
}
|
||||||
|
function cancelPileRefresh() {
|
||||||
|
if (refreshFrame) cancelAnimationFrame(refreshFrame);
|
||||||
|
refreshFrame = 0;
|
||||||
|
pendingPiles.clear();
|
||||||
|
}
|
||||||
|
function schedulePileRefresh(...piles) {
|
||||||
|
if (closed) return;
|
||||||
|
for (const key of piles.length ? piles : sections.map(section => section.key)) pendingPiles.add(key);
|
||||||
|
if (refreshFrame) return;
|
||||||
|
refreshFrame = requestAnimationFrame(() => {
|
||||||
|
refreshFrame = 0;
|
||||||
|
updateSectionTabs(pendingPiles);
|
||||||
|
const updateList = !detail && pendingPiles.has(sections[sectionIndex].key);
|
||||||
|
pendingPiles.clear();
|
||||||
|
if (updateList) renderSection({ preserve: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
function render() {
|
function render() {
|
||||||
clearTimeout(searchTimer);
|
clearTimeout(searchTimer);
|
||||||
detail = false; list.hidden = false; detailPanel.hidden = true;
|
detail = false; list.hidden = false; detailPanel.hidden = true;
|
||||||
detailPanel.replaceChildren();
|
detailPanel.replaceChildren();
|
||||||
body.scrollTop = 0;
|
body.scrollTop = 0;
|
||||||
selectedButton = null;
|
selectedButton = null;
|
||||||
const catalog = !options.sections && view === "catalog";
|
const catalog = !sections && view === "catalog";
|
||||||
filters.hidden = !catalog;
|
filters.hidden = !catalog;
|
||||||
deckTab.setAttribute("aria-pressed", String(!catalog));
|
deckTab.setAttribute("aria-pressed", String(!catalog));
|
||||||
catalogTab.setAttribute("aria-pressed", String(catalog));
|
catalogTab.setAttribute("aria-pressed", String(catalog));
|
||||||
list.classList.toggle("ms-catalog-grid", catalog);
|
list.classList.toggle("ms-catalog-grid", catalog);
|
||||||
let records = [], emptyMessage = "此处暂无卡牌。";
|
if (sections) {
|
||||||
orderedView = false;
|
cancelPileRefresh();
|
||||||
if (options.sections) {
|
detailListPosition = null;
|
||||||
const sections = options.sections();
|
updateSectionTabs();
|
||||||
const section = sections[sectionIndex];
|
renderSection();
|
||||||
orderedView = Boolean(section?.ordered);
|
return;
|
||||||
if (section?.ordered) emptyMessage = "剩余牌堆为空;下一次摸牌需按规则洗切弃牌堆,洗切后的顺序尚未确定。";
|
}
|
||||||
sectionTabs.forEach((tab, index) => {
|
let records = [];
|
||||||
tab.textContent = `${sections[index].title} · ${sections[index].cards.length}`;
|
if (catalog) {
|
||||||
tab.setAttribute("aria-pressed", String(index === sectionIndex));
|
|
||||||
});
|
|
||||||
records = (section?.cards || []).map(card => ({ card, ordered: section.ordered }));
|
|
||||||
summary.textContent = section?.ordered
|
|
||||||
? "剩余牌堆按从左到右、从上到下的顺序摸取;第 1 张为下一张。"
|
|
||||||
: `${section?.title || "牌堆"} · 共 ${records.length} 张`;
|
|
||||||
} else if (catalog) {
|
|
||||||
const query = search.value.trim().toLocaleLowerCase();
|
const query = search.value.trim().toLocaleLowerCase();
|
||||||
catalogRecords ||= getCardCatalog().map(card => {
|
catalogRecords ||= getCardCatalog().map(card => {
|
||||||
const details = describeCatalogCard(card);
|
const details = describeCatalogCard(card);
|
||||||
@@ -311,15 +388,14 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
details.cost !== null && details.cost === Number(costFilter.value))));
|
details.cost !== null && details.cost === Number(costFilter.value))));
|
||||||
summary.textContent = `卡牌图鉴 · 共 ${total} 种 · 当前显示 ${records.length} 种`;
|
summary.textContent = `卡牌图鉴 · 共 ${total} 种 · 当前显示 ${records.length} 种`;
|
||||||
} else {
|
} else {
|
||||||
summary.textContent = options.sections ? "剩余牌堆按从左到右、从上到下的顺序摸取;第 1 张为下一张。" :
|
summary.textContent = `本次征程实际携带 · 共 ${current.length} 张 · 同名不同花色、点数分别展示`;
|
||||||
`本次征程实际携带 · 共 ${current.length} 张 · 同名不同花色、点数分别展示`;
|
|
||||||
}
|
}
|
||||||
if (catalog && selection) footer.textContent = selection.description;
|
if (catalog && selection) footer.textContent = selection.description;
|
||||||
else footer.textContent = catalog ? "图鉴仅供查阅,不会获得卡牌或改变征程牌组 · 点击卡牌查看完整介绍" :
|
else footer.textContent = catalog ? "图鉴仅供查阅,不会获得卡牌或改变征程牌组 · 点击卡牌查看完整介绍" :
|
||||||
"点击卡牌查看完整介绍 · 仅供查看,不改变牌组或抽牌顺序";
|
"点击卡牌查看完整介绍 · 仅供查看,不改变牌组或抽牌顺序";
|
||||||
virtualGrid.setRecords(catalog || options.sections ? records : current.map(card => ({ card })));
|
virtualGrid.setRecords(catalog ? records : current.map(card => ({ card })));
|
||||||
if (!(catalog || options.sections ? records : current).length) {
|
if (!(catalog ? records : current).length) {
|
||||||
element("p", "ms-deck-empty", catalog ? "没有符合筛选的卡牌,可清空筛选后查看全部图鉴。" : emptyMessage, list);
|
element("p", "ms-deck-empty", catalog ? "没有符合筛选的卡牌,可清空筛选后查看全部图鉴。" : "此处暂无卡牌。", list);
|
||||||
}
|
}
|
||||||
fitCards();
|
fitCards();
|
||||||
}
|
}
|
||||||
@@ -328,7 +404,7 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
// Prevent the map's Escape/Tab handler from acting behind this modal.
|
// Prevent the map's Escape/Tab handler from acting behind this modal.
|
||||||
dialog.addEventListener("keydown", event => event.stopPropagation());
|
dialog.addEventListener("keydown", event => event.stopPropagation());
|
||||||
render();
|
render();
|
||||||
document.body.appendChild(dialog);
|
document.documentElement.appendChild(dialog);
|
||||||
try { dialog.showModal(); } catch (error) { close(); throw error; }
|
try { dialog.showModal(); } catch (error) { close(); throw error; }
|
||||||
fitCards();
|
fitCards();
|
||||||
if (typeof ResizeObserver !== "undefined") {
|
if (typeof ResizeObserver !== "undefined") {
|
||||||
@@ -338,20 +414,12 @@ export function openCardLibrary(run, options = {}) {
|
|||||||
window.addEventListener?.("resize", fitCards);
|
window.addEventListener?.("resize", fitCards);
|
||||||
}
|
}
|
||||||
header.querySelector("button").focus();
|
header.querySelector("button").focus();
|
||||||
close.refresh = () => {
|
if (sections) close.refresh = schedulePileRefresh;
|
||||||
if (closed) return;
|
|
||||||
// Rebuild from live arrays after a pile mutation, including while viewing details.
|
|
||||||
const wasDetail = detail, offset = body.scrollTop;
|
|
||||||
catalogRecords = null; descriptionCache = new WeakMap();
|
|
||||||
render(); body.scrollTop = offset;
|
|
||||||
virtualGrid?.resume();
|
|
||||||
if (wasDetail) header.querySelector("button").focus();
|
|
||||||
};
|
|
||||||
return close;
|
return close;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The battle view exposes only this player's own piles, including consumed cards.
|
// The battle view exposes only this player's own piles, including consumed cards.
|
||||||
export function mountBattlePiles(session, battle) {
|
export function mountBattlePiles(session, battle, pileView) {
|
||||||
let closeDialog = null, disposed = false;
|
let closeDialog = null, disposed = false;
|
||||||
const control = button("牌堆", ui.window, () => {
|
const control = button("牌堆", ui.window, () => {
|
||||||
if (disposed || !session.active || battle.resolving) return;
|
if (disposed || !session.active || battle.resolving) return;
|
||||||
@@ -359,10 +427,14 @@ export function mountBattlePiles(session, battle) {
|
|||||||
closeDialog = openCardLibrary(null, {
|
closeDialog = openCardLibrary(null, {
|
||||||
title: "战斗牌堆", eyebrow: "梦三 · 个人牌堆",
|
title: "战斗牌堆", eyebrow: "梦三 · 个人牌堆",
|
||||||
onClose(handle) { if (closeDialog === handle) closeDialog = null; },
|
onClose(handle) { if (closeDialog === handle) closeDialog = null; },
|
||||||
sections: () => [
|
pileView: pileView ?? {
|
||||||
{ title: "剩余牌堆", cards: battle.drawPile, ordered: true },
|
count: key => battle[key].length,
|
||||||
{ title: "弃牌堆", cards: battle.discardPile, ordered: false },
|
records: key => battle[key].map(card => ({ card, key: card.id ?? card })),
|
||||||
{ title: "消耗牌堆", cards: battle.exhaustPile, ordered: false },
|
},
|
||||||
|
sections: [
|
||||||
|
{ title: "剩余牌堆", key: "drawPile", ordered: true },
|
||||||
|
{ title: "弃牌堆", key: "discardPile", ordered: false },
|
||||||
|
{ title: "消耗牌堆", key: "exhaustPile", ordered: false },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}, "mengsan-battle-piles-button-shuying");
|
}, "mengsan-battle-piles-button-shuying");
|
||||||
@@ -372,5 +444,5 @@ export function mountBattlePiles(session, battle) {
|
|||||||
disposed = true; closeDialog?.(); closeDialog = null; control.remove();
|
disposed = true; closeDialog?.(); closeDialog = null; control.remove();
|
||||||
};
|
};
|
||||||
session.ownResource(control, dispose);
|
session.ownResource(control, dispose);
|
||||||
return { dispose, refresh() { if (!disposed) closeDialog?.refresh?.(); } };
|
return { dispose, refresh(...piles) { if (!disposed && session.active) closeDialog?.refresh?.(...piles); } };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,21 +29,22 @@ export const playDialogue = (lines, options = {}) => new Promise(resolve => {
|
|||||||
|
|
||||||
const overlay = ui.create.div(".mengsan-dialogue-overlay-shuying", ui.window);
|
const overlay = ui.create.div(".mengsan-dialogue-overlay-shuying", ui.window);
|
||||||
const stage = ui.create.div(".mengsan-dialogue-stage-shuying", overlay);
|
const stage = ui.create.div(".mengsan-dialogue-stage-shuying", overlay);
|
||||||
ui.create.div(".mengsan-dialogue-chapter-shuying", options.title || "剧情", stage);
|
ui.create.div(".mengsan-dialogue-chapter-shuying", options.title || "剧情", overlay);
|
||||||
const textBox = ui.create.div(".mengsan-dialogue-box-shuying", stage);
|
const content = ui.create.div(".mengsan-dialogue-content-shuying", stage);
|
||||||
|
const choices = ui.create.div(".mengsan-dialogue-choices-shuying", content);
|
||||||
|
const textBox = ui.create.div(".mengsan-dialogue-box-shuying", content);
|
||||||
const portraitFrame = ui.create.div(
|
const portraitFrame = ui.create.div(
|
||||||
".mengsan-dialogue-portrait-frame-shuying", textBox);
|
".mengsan-dialogue-portrait-frame-shuying", textBox);
|
||||||
const speaker = ui.create.div(".mengsan-dialogue-speaker-shuying", textBox);
|
const speaker = ui.create.div(".mengsan-dialogue-speaker-shuying", textBox);
|
||||||
const text = ui.create.div(".mengsan-dialogue-text-shuying", textBox);
|
const text = ui.create.div(".mengsan-dialogue-text-shuying", textBox);
|
||||||
const progress = ui.create.div(".mengsan-dialogue-progress-shuying", textBox);
|
const progress = ui.create.div(".mengsan-dialogue-progress-shuying", textBox);
|
||||||
const indicator = ui.create.div(".mengsan-dialogue-indicator-shuying", "◆", textBox);
|
const indicator = ui.create.div(".mengsan-dialogue-indicator-shuying", "◆", textBox);
|
||||||
const choices = ui.create.div(".mengsan-dialogue-choices-shuying", stage);
|
|
||||||
const skipButton = document.createElement("button");
|
const skipButton = document.createElement("button");
|
||||||
skipButton.type = "button";
|
skipButton.type = "button";
|
||||||
skipButton.className = "mengsan-dialogue-skip-shuying";
|
skipButton.className = "mengsan-dialogue-skip-shuying";
|
||||||
skipButton.textContent = "跳过对话";
|
skipButton.textContent = "跳过对话";
|
||||||
skipButton.setAttribute("aria-label", "跳过对话,未选择的发言使用默认选项");
|
skipButton.setAttribute("aria-label", "跳过对话,未选择的发言使用默认选项");
|
||||||
stage.appendChild(skipButton);
|
overlay.appendChild(skipButton);
|
||||||
|
|
||||||
let lineIndex = -1;
|
let lineIndex = -1;
|
||||||
let timer = null;
|
let timer = null;
|
||||||
@@ -189,5 +190,5 @@ export const playDialogue = (lines, options = {}) => new Promise(resolve => {
|
|||||||
const help = ui.create.div(".mengsan-dialogue-help-shuying", stage);
|
const help = ui.create.div(".mengsan-dialogue-help-shuying", stage);
|
||||||
help.textContent = "点击补全文字 · 再次点击继续 · Enter / 空格";
|
help.textContent = "点击补全文字 · 再次点击继续 · Enter / 空格";
|
||||||
showNextLine();
|
showNextLine();
|
||||||
textBox.focus();
|
if (!awaitingChoice || typing) textBox.focus({ preventScroll: true });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const chooseFlow = (title, render, { back } = {}) => new Promise(resolve
|
|||||||
if (overlay.dataset.resolved) return;
|
if (overlay.dataset.resolved) return;
|
||||||
overlay.dataset.resolved = "true";
|
overlay.dataset.resolved = "true";
|
||||||
overlay.remove();
|
overlay.remove();
|
||||||
if (previousFocus?.isConnected) previousFocus.focus();
|
if (previousFocus?.isConnected) previousFocus.focus({ preventScroll: true });
|
||||||
resolve(id);
|
resolve(id);
|
||||||
};
|
};
|
||||||
const initialFocus = render(overlay, finish);
|
const initialFocus = render(overlay, finish);
|
||||||
@@ -26,7 +26,7 @@ export const chooseFlow = (title, render, { back } = {}) => new Promise(resolve
|
|||||||
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
|
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
|
||||||
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
|
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
|
||||||
});
|
});
|
||||||
initialFocus?.focus();
|
initialFocus?.focus({ preventScroll: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
export const chooseButtons = (title, choices, description = "", options = {}) => chooseFlow(title, (overlay, finish) => {
|
export const chooseButtons = (title, choices, description = "", options = {}) => chooseFlow(title, (overlay, finish) => {
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export function mountGMManager(session, owner, piles, battle, resources, game) {
|
|||||||
const created = dialog;
|
const created = dialog;
|
||||||
dialog.addEventListener("close", () => { if (dialog === created) close(); });
|
dialog.addEventListener("close", () => { if (dialog === created) close(); });
|
||||||
dialog.addEventListener("keydown", event => event.stopPropagation());
|
dialog.addEventListener("keydown", event => event.stopPropagation());
|
||||||
document.body.appendChild(dialog);
|
document.documentElement.appendChild(dialog);
|
||||||
try { dialog.showModal(); } catch (error) { close(); throw error; }
|
try { dialog.showModal(); } catch (error) { close(); throw error; }
|
||||||
render();
|
render();
|
||||||
dialog.querySelector(".ms-deck-header button").focus();
|
dialog.querySelector(".ms-deck-header button").focus();
|
||||||
|
|||||||
@@ -79,22 +79,30 @@ export function createHandInput(player, session, adapter, fan, env, refresh, log
|
|||||||
function removeAim() { aim?.remove(); aim = null; }
|
function removeAim() { aim?.remove(); aim = null; }
|
||||||
function showAim(card, point) {
|
function showAim(card, point) {
|
||||||
const rect = card.getBoundingClientRect();
|
const rect = card.getBoundingClientRect();
|
||||||
const x = rect.left + rect.width / 2, y = rect.top + Math.min(12, rect.height / 2);
|
const x = rect.left + rect.width / 2, y = rect.top;
|
||||||
const dx = point.x - x, dy = point.y - y;
|
if (!(rect.width > 0 && rect.height > 0 && Number.isFinite(point.x) && Number.isFinite(point.y))) {
|
||||||
const length = Math.hypot(dx, dy);
|
|
||||||
if (!(rect.width > 0 && rect.height > 0 && length > 0 && Number.isFinite(length))) {
|
|
||||||
removeAim();
|
removeAim();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!aim) {
|
if (!aim) {
|
||||||
aim = document.createElement("div");
|
const svg = "http://www.w3.org/2000/svg";
|
||||||
|
aim = document.createElementNS(svg, "svg");
|
||||||
aim.classList.add("mengsan-hand-aim-shuying");
|
aim.classList.add("mengsan-hand-aim-shuying");
|
||||||
aim.setAttribute("aria-hidden", "true");
|
aim.setAttribute("aria-hidden", "true");
|
||||||
// 无名杀缩放 body,牌面矩形和指针事件都使用视口坐标。
|
aim.setAttribute("preserveAspectRatio", "none");
|
||||||
|
aim.appendChild(document.createElementNS(svg, "line"));
|
||||||
document.documentElement.appendChild(aim);
|
document.documentElement.appendChild(aim);
|
||||||
}
|
}
|
||||||
aim.style.width = `${length}px`;
|
// Use the painted overlay bounds so card, touch and line share viewport CSS pixels.
|
||||||
aim.style.transform = `translate(${x}px, ${y}px) rotate(${Math.atan2(dy, dx)}rad) translateY(-50%)`;
|
const overlay = aim.getBoundingClientRect();
|
||||||
|
if (!(overlay.width > 0 && overlay.height > 0)) { removeAim(); return; }
|
||||||
|
const viewBox = `0 0 ${overlay.width} ${overlay.height}`;
|
||||||
|
if (aim.getAttribute("viewBox") !== viewBox) aim.setAttribute("viewBox", viewBox);
|
||||||
|
const line = aim.firstElementChild;
|
||||||
|
line.setAttribute("x1", x - overlay.left);
|
||||||
|
line.setAttribute("y1", y - overlay.top);
|
||||||
|
line.setAttribute("x2", point.x - overlay.left);
|
||||||
|
line.setAttribute("y2", point.y - overlay.top);
|
||||||
}
|
}
|
||||||
function clearSelection(state) {
|
function clearSelection(state) {
|
||||||
if (!live(state) || !state.selected) return;
|
if (!live(state) || !state.selected) return;
|
||||||
|
|||||||
@@ -78,16 +78,18 @@
|
|||||||
}
|
}
|
||||||
.mengsan-hand-aim-shuying {
|
.mengsan-hand-aim-shuying {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
inset: 0;
|
||||||
left: 0;
|
width: 100%;
|
||||||
height: 2.6px;
|
height: 100%;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
transform-origin: 0 0;
|
}
|
||||||
transition: none;
|
.mengsan-hand-aim-shuying > line {
|
||||||
border-radius: 2px;
|
stroke: rgb(250, 220, 140);
|
||||||
background: rgb(250, 220, 140);
|
stroke-width: 2.6px;
|
||||||
box-shadow: 0 0 2px #f5d25b;
|
stroke-linecap: round;
|
||||||
|
vector-effect: non-scaling-stroke;
|
||||||
|
filter: drop-shadow(0 0 2px #f5d25b);
|
||||||
}
|
}
|
||||||
/* 只在梦三手牌挂载期间隐藏十周年阶段、等待响应和对方思考图片。 */
|
/* 只在梦三手牌挂载期间隐藏十周年阶段、等待响应和对方思考图片。 */
|
||||||
body.mengsan-hand-ui-shuying [style*="extension/十周年UI/ui/assets/lbtn/tips/"]:is(
|
body.mengsan-hand-ui-shuying [style*="extension/十周年UI/ui/assets/lbtn/tips/"]:is(
|
||||||
|
|||||||
+45
-14
@@ -108,7 +108,7 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
const openDetails = (target, id = null) => {
|
const openDetails = (target, id = null) => {
|
||||||
if (disposed || frozen || !battle.session.active) return;
|
if (disposed || frozen || !battle.session.active) return;
|
||||||
closeDialog(); previousFocus = document.activeElement;
|
closeDialog(); previousFocus = document.activeElement;
|
||||||
dialog = create('dialog', 'mengsan-hud-dialog-shuying mengsan-deck-dialog-shuying mengsan-relic-dialog-shuying', document.body);
|
dialog = create('dialog', 'mengsan-hud-dialog-shuying mengsan-deck-dialog-shuying mengsan-relic-dialog-shuying', document.documentElement);
|
||||||
const current = dialog;
|
const current = dialog;
|
||||||
const header = create('header', 'ms-deck-header', dialog);
|
const header = create('header', 'ms-deck-header', dialog);
|
||||||
create('h2', '', header, `${nameOf(target)} · 当前状态`);
|
create('h2', '', header, `${nameOf(target)} · 当前状态`);
|
||||||
@@ -247,8 +247,13 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
for (const mark of hiddenMarks) if (!wanted.has(mark)) { mark.classList.remove('mengsan-hud-represented-mark-shuying'); hiddenMarks.delete(mark); }
|
for (const mark of hiddenMarks) if (!wanted.has(mark)) { mark.classList.remove('mengsan-hud-represented-mark-shuying'); hiddenMarks.delete(mark); }
|
||||||
for (const mark of wanted) if (!mark.classList.contains('mengsan-hud-represented-mark-shuying')) { mark.classList.add('mengsan-hud-represented-mark-shuying'); hiddenMarks.add(mark); }
|
for (const mark of wanted) if (!mark.classList.contains('mengsan-hud-represented-mark-shuying')) { mark.classList.add('mengsan-hud-represented-mark-shuying'); hiddenMarks.add(mark); }
|
||||||
}
|
}
|
||||||
let layout = null;
|
let layout = null, handGeometry;
|
||||||
const hudHeightFor = () => layout === 'short' ? 188 : layout === 'narrow' ? 288 : 274;
|
const hudHeightFor = () => layout === 'short' ? 188 : layout === 'narrow' ? 288 : 274;
|
||||||
|
function invalidateHandBounds() {
|
||||||
|
// Decade uses this cache to place the origin of committed card effects.
|
||||||
|
const bounds = window.decadeUI?.boundsCaches?.hand;
|
||||||
|
if (bounds) bounds.updated = false;
|
||||||
|
}
|
||||||
const oldLayout = arena.getAttribute('data-mengsan-hud-layout');
|
const oldLayout = arena.getAttribute('data-mengsan-hud-layout');
|
||||||
restores.push(() => {
|
restores.push(() => {
|
||||||
if (arena.getAttribute('data-mengsan-hud-layout') !== layout) return;
|
if (arena.getAttribute('data-mengsan-hud-layout') !== layout) return;
|
||||||
@@ -272,20 +277,41 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
const hudHeight = hudHeightFor();
|
const hudHeight = hudHeightFor();
|
||||||
style(arena, '--mengsan-hud-height', `${hudHeight}px`);
|
style(arena, '--mengsan-hud-height', `${hudHeight}px`);
|
||||||
const large = width >= 1000;
|
const large = width >= 1000;
|
||||||
style(arena, '--mengsan-hud-left', short ? '216px' : narrow ? '116px' : large ? '352px' : '292px');
|
const left = short ? 216 : narrow ? 116 : large ? 352 : 292;
|
||||||
style(arena, '--mengsan-hud-right', short ? '132px' : narrow ? '116px' : '184px');
|
const right = short ? 132 : narrow ? 116 : 184;
|
||||||
|
style(arena, '--mengsan-hud-left', `${left}px`);
|
||||||
|
style(arena, '--mengsan-hud-right', `${right}px`);
|
||||||
|
// Nova sets important geometry on #me and #handcards1. The HUD owns these positions for this battle.
|
||||||
|
const handInset = Math.min(Math.max(left,right),Math.max(0,(width-114)/2));
|
||||||
|
for (const [key,value] of Object.entries({left:`${handInset}px`,right:`${handInset}px`,
|
||||||
|
width:'auto',bottom:short?'64px':'68px'})) style(handRoot,key,value);
|
||||||
|
const firstHand = ui.handcards1Container;
|
||||||
|
if (firstHand && handRoot.contains(firstHand)) {
|
||||||
|
style(firstHand,'left','0px');
|
||||||
|
style(firstHand,'width','100%');
|
||||||
|
}
|
||||||
|
const geometry = [handRoot.offsetLeft, handRoot.offsetTop, handRoot.offsetWidth, handRoot.offsetHeight].join(',');
|
||||||
|
if (geometry !== handGeometry) {
|
||||||
|
handGeometry = geometry;
|
||||||
|
invalidateHandBounds();
|
||||||
|
}
|
||||||
style(arena, '--mengsan-profile-info-left', short ? '108px' : narrow ? '22px' : large ? '200px' : '160px');
|
style(arena, '--mengsan-profile-info-left', short ? '108px' : narrow ? '22px' : large ? '200px' : '160px');
|
||||||
style(arena, '--mengsan-profile-width', short ? '172px' : narrow ? '76px' : large ? '200px' : '130px');
|
style(arena, '--mengsan-profile-width', short ? '172px' : narrow ? '76px' : large ? '200px' : '130px');
|
||||||
skinActor(player);
|
skinActor(player);
|
||||||
// Inline important dimensions also beat skins with #arena > .player !important rules.
|
// Inline important dimensions also beat skins with #arena > .player !important rules.
|
||||||
|
const selfLeft = short ? 24 : narrow ? 22 : 40;
|
||||||
|
const selfWidth = short || narrow ? 76 : large ? 144 : 104;
|
||||||
const selfBottom = narrow ? 180 : 24;
|
const selfBottom = narrow ? 180 : 24;
|
||||||
const selfHeight = short || narrow ? 104 : large ? 196 : 148;
|
const selfHeight = short || narrow ? 104 : large ? 196 : 148;
|
||||||
const infoTop = narrow ? hudHeight - selfBottom + 16 : hudHeight - selfBottom - selfHeight + (short ? 0 : 20);
|
const infoTop = narrow ? hudHeight - selfBottom + 16 : hudHeight - selfBottom - selfHeight + (short ? 0 : 20);
|
||||||
style(arena, '--mengsan-profile-info-top', `${infoTop}px`);
|
style(arena, '--mengsan-profile-info-top', `${infoTop}px`);
|
||||||
for (const [key, value] of Object.entries({left: short ? '24px' : narrow ? '22px' : '40px', right:'auto', top:'auto',
|
for (const [key, value] of Object.entries({left:`${selfLeft}px`, right:'auto', top:'auto',
|
||||||
bottom:`${selfBottom}px`, width:short ? '76px' : narrow ? '76px' : large ? '144px' : '104px',
|
bottom:`${selfBottom}px`, width:`${selfWidth}px`,
|
||||||
height:`${selfHeight}px`, transform:'none'})) style(player, key, value);
|
height:`${selfHeight}px`, transform:'none'})) style(player, key, value);
|
||||||
style(arena, '--mengsan-side-dock-bottom', `${selfBottom + selfHeight + 12}px`);
|
const statusBottom = selfBottom + selfHeight + 12;
|
||||||
|
const statusBesidePortrait = height - statusBottom < 36;
|
||||||
|
style(arena, '--mengsan-status-left', `${statusBesidePortrait ? selfLeft + selfWidth + 8 : selfLeft}px`);
|
||||||
|
style(arena, '--mengsan-side-dock-bottom', `${statusBesidePortrait ? 8 : statusBottom}px`);
|
||||||
style(arena, '--mengsan-relic-dock-bottom', `${selfBottom + selfHeight + (narrow ? -4 : 12)}px`);
|
style(arena, '--mengsan-relic-dock-bottom', `${selfBottom + selfHeight + (narrow ? -4 : 12)}px`);
|
||||||
style(arena, '--mengsan-skill-ceiling', `${Math.min(hudHeight - 36, selfBottom + selfHeight)}px`);
|
style(arena, '--mengsan-skill-ceiling', `${Math.min(hudHeight - 36, selfBottom + selfHeight)}px`);
|
||||||
style(arena, '--mengsan-status-height', short ? '52px' : narrow ? '84px' : '160px');
|
style(arena, '--mengsan-status-height', short ? '52px' : narrow ? '84px' : '160px');
|
||||||
@@ -312,7 +338,7 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
right:`${(h.right - a.right + (layout === 'wide' ? 24 : 16) * arenaScale) / scale}px`, bottom:`${(h.bottom - a.bottom + bottom * arenaScale) / scale}px`,
|
right:`${(h.right - a.right + (layout === 'wide' ? 24 : 16) * arenaScale) / scale}px`, bottom:`${(h.bottom - a.bottom + bottom * arenaScale) / scale}px`,
|
||||||
width:`${rail * arenaScale / scale}px`, 'max-height':`${maxHeight * arenaScale / scale}px`})) style(node, key, value);
|
width:`${rail * arenaScale / scale}px`, 'max-height':`${maxHeight * arenaScale / scale}px`})) style(node, key, value);
|
||||||
}
|
}
|
||||||
function syncControls() {
|
function syncControls(response) {
|
||||||
// The actual action controls stay horizontal above the hand; skill references get their own rail.
|
// The actual action controls stay horizontal above the hand; skill references get their own rail.
|
||||||
const candidates = [...new Set([ui.skills, ui.skills2, ui.skills3, ui.skillControl, ui.gskillControl])]
|
const candidates = [...new Set([ui.skills, ui.skills2, ui.skills3, ui.skillControl, ui.gskillControl])]
|
||||||
.filter(node => node?.isConnected && node !== ui.control);
|
.filter(node => node?.isConnected && node !== ui.control);
|
||||||
@@ -339,8 +365,8 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
const hudHeight = hudHeightFor();
|
const hudHeight = hudHeightFor();
|
||||||
const rail = layout === 'wide' ? 142 : layout === 'short' ? 112 : 96;
|
const rail = layout === 'wide' ? 142 : layout === 'short' ? 112 : 96;
|
||||||
const actionBottom = layout === 'narrow' ? hudHeight - 48 : hudHeight + 8;
|
const actionBottom = layout === 'narrow' ? hudHeight - 48 : hudHeight + 8;
|
||||||
const compactActions = arena.clientWidth < 1000;
|
const actionInset = response || arena.clientWidth < 1000 ? '16px' : 'max(var(--mengsan-hud-left),var(--mengsan-hud-right))';
|
||||||
for (const [key,value] of Object.entries({position:'absolute',left:compactActions?'16px':'var(--mengsan-hud-left)',right:compactActions?'16px':'var(--mengsan-hud-right)',top:'auto',bottom:`${actionBottom}px`,width:'auto','max-height':'none',transform:'none'})) style(ui.control,key,value);
|
for (const [key,value] of Object.entries({position:'absolute',left:actionInset,right:actionInset,top:'auto',bottom:`${actionBottom}px`,width:'auto','max-height':'none',transform:'none'})) style(ui.control,key,value);
|
||||||
for (const group of ui.control.children) if (group.classList.contains('control')) {
|
for (const group of ui.control.children) if (group.classList.contains('control')) {
|
||||||
if (external.includes(group)) {
|
if (external.includes(group)) {
|
||||||
ownClass(group,'mengsan-hud-native-skills-shuying');
|
ownClass(group,'mengsan-hud-native-skills-shuying');
|
||||||
@@ -361,8 +387,9 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
ownClass(node,'mengsan-hud-external-action-shuying');
|
ownClass(node,'mengsan-hud-external-action-shuying');
|
||||||
const host=node.offsetParent||arena,a=arena.getBoundingClientRect(),h=host.getBoundingClientRect();
|
const host=node.offsetParent||arena,a=arena.getBoundingClientRect(),h=host.getBoundingClientRect();
|
||||||
const scale=h.width/host.offsetWidth||1,zoom=a.width/arena.clientWidth||1;
|
const scale=h.width/host.offsetWidth||1,zoom=a.width/arena.clientWidth||1;
|
||||||
const center=(parseFloat(arena.style.getPropertyValue('--mengsan-hud-left'))+arena.clientWidth-parseFloat(arena.style.getPropertyValue('--mengsan-hud-right')))/2;
|
const responseConfirm = response && node === ui.confirm;
|
||||||
const side=node===ui.confirm?-1:1;
|
const center=arena.clientWidth/2;
|
||||||
|
const side=responseConfirm ? 0 : node===ui.confirm?-1:1;
|
||||||
for(const [key,value] of Object.entries({position:'absolute',left:`${(a.left+center*zoom-h.left)/scale+side*80}px`,right:'auto',top:'auto',bottom:`${(h.bottom-a.bottom+actionBottom*zoom)/scale}px`,width:`${Math.min(rail,140)}px`,transform:'translateX(-50%)'}))style(node,key,value);
|
for(const [key,value] of Object.entries({position:'absolute',left:`${(a.left+center*zoom-h.left)/scale+side*80}px`,right:'auto',top:'auto',bottom:`${(h.bottom-a.bottom+actionBottom*zoom)/scale}px`,width:`${Math.min(rail,140)}px`,transform:'translateX(-50%)'}))style(node,key,value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -388,8 +415,11 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
healthFill.style.width = `${Math.max(0, Math.min(100, player.maxHp > 0 ? player.hp / player.maxHp * 100 : 0))}%`;
|
healthFill.style.width = `${Math.max(0, Math.min(100, player.maxHp > 0 ? player.hp / player.maxHp * 100 : 0))}%`;
|
||||||
text(energy, `费用 ${player.storage.mengsanEnergy_shuying ?? 0} / ${player.storage.mengsanMaxEnergy_shuying ?? 0}`);
|
text(energy, `费用 ${player.storage.mengsanEnergy_shuying ?? 0} / ${player.storage.mengsanMaxEnergy_shuying ?? 0}`);
|
||||||
syncActors(); syncExternalEquipment(); renderStatuses();
|
syncActors(); syncExternalEquipment(); renderStatuses();
|
||||||
refreshDetails(); syncControls(); syncNotifications();
|
const event = _status.event;
|
||||||
overlays.refresh({ footerHeight:hudHeightFor(), status:_status });
|
const response = event?.player === player && Boolean(event.respondTo || event.name === 'chooseToRespond');
|
||||||
|
refreshDetails(); syncControls(response); syncNotifications();
|
||||||
|
battle.potionUI?.layoutBattleSlots(ui);
|
||||||
|
overlays.refresh({ footerHeight:hudHeightFor(), status:_status, response });
|
||||||
}
|
}
|
||||||
function schedule() {
|
function schedule() {
|
||||||
if (disposed || frozen || document.hidden || frame !== null) return;
|
if (disposed || frozen || document.hidden || frame !== null) return;
|
||||||
@@ -416,6 +446,7 @@ export function mountBattleHUD(player, battle, env) {
|
|||||||
for (const mark of hiddenMarks) mark.classList.remove('mengsan-hud-represented-mark-shuying'); hiddenMarks.clear();
|
for (const mark of hiddenMarks) mark.classList.remove('mengsan-hud-represented-mark-shuying'); hiddenMarks.clear();
|
||||||
for (const restore of restores.reverse()) restore();
|
for (const restore of restores.reverse()) restore();
|
||||||
releaseNodes();
|
releaseNodes();
|
||||||
|
invalidateHandBounds();
|
||||||
root.remove(); link.remove();
|
root.remove(); link.remove();
|
||||||
}
|
}
|
||||||
ownClass(document.body, 'mengsan-hud-active-shuying'); ownClass(arena, 'mengsan-hud-arena-shuying');
|
ownClass(document.body, 'mengsan-hud-active-shuying'); ownClass(arena, 'mengsan-hud-arena-shuying');
|
||||||
|
|||||||
+93
-14
@@ -32,14 +32,18 @@ export function createOverlayLayout(arena, hand, ui, player) {
|
|||||||
for (const [name, had] of record.classes) if (!had) node.classList.remove(name);
|
for (const [name, had] of record.classes) if (!had) node.classList.remove(name);
|
||||||
records.delete(node);
|
records.delete(node);
|
||||||
}
|
}
|
||||||
function mark(node, name) {
|
function recordFor(node) {
|
||||||
let record=records.get(node);
|
let record=records.get(node);
|
||||||
if(!record) {record={styles:new Map(),classes:new Map()};records.set(node,record);}
|
if(!record) {record={styles:new Map(),classes:new Map()};records.set(node,record);}
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
function mark(node, name) {
|
||||||
|
const record = recordFor(node);
|
||||||
if(!record.classes.has(name))record.classes.set(name,node.classList.contains(name));
|
if(!record.classes.has(name))record.classes.set(name,node.classList.contains(name));
|
||||||
node.classList.add(name);return record;
|
node.classList.add(name);return record;
|
||||||
}
|
}
|
||||||
function style(node,key,value) {
|
function style(node,key,value) {
|
||||||
const record=records.get(node);
|
const record=recordFor(node);
|
||||||
if(!record.styles.has(key))record.styles.set(key,{before:node.style.getPropertyValue(key),priority:node.style.getPropertyPriority(key)});
|
if(!record.styles.has(key))record.styles.set(key,{before:node.style.getPropertyValue(key),priority:node.style.getPropertyPriority(key)});
|
||||||
const field=record.styles.get(key);
|
const field=record.styles.get(key);
|
||||||
if(field.requested!==value||node.style.getPropertyValue(key)!==field.last)node.style.setProperty(key,value,'important');
|
if(field.requested!==value||node.style.getPropertyValue(key)!==field.last)node.style.setProperty(key,value,'important');
|
||||||
@@ -52,32 +56,107 @@ export function createOverlayLayout(arena, hand, ui, player) {
|
|||||||
style(node,'left',`${(x-h.left)/sx-host.clientLeft+host.scrollLeft}px`);
|
style(node,'left',`${(x-h.left)/sx-host.clientLeft+host.scrollLeft}px`);
|
||||||
style(node,'top',`${(y-h.top)/sy-host.clientTop+host.scrollTop}px`);
|
style(node,'top',`${(y-h.top)/sy-host.clientTop+host.scrollTop}px`);
|
||||||
}
|
}
|
||||||
|
function hostScale(node) {
|
||||||
|
const host = node.offsetParent || arena;
|
||||||
|
const box = host.getBoundingClientRect();
|
||||||
|
return {x:box.width / host.offsetWidth || 1,y:box.height / host.offsetHeight || 1};
|
||||||
|
}
|
||||||
|
function currentShift(node, scale) {
|
||||||
|
const field = records.get(node)?.styles.get('translate');
|
||||||
|
return field?.last && node.style.getPropertyValue('translate') === field.last
|
||||||
|
? {x:field.x * scale.x,y:field.y * scale.y} : {x:0,y:0};
|
||||||
|
}
|
||||||
|
function shift(node, x, y, scale, used) {
|
||||||
|
if (Math.abs(x) < .05 && Math.abs(y) < .05) return;
|
||||||
|
// Keep the engine's transform animation, but apply the layout shift immediately.
|
||||||
|
if (arena.ownerDocument.defaultView.getComputedStyle(node).transitionProperty === 'all') {
|
||||||
|
style(node, 'transition-property', 'transform, opacity, left, top');
|
||||||
|
}
|
||||||
|
const dx = x / scale.x, dy = y / scale.y;
|
||||||
|
style(node, 'translate', `${dx}px ${dy}px`);
|
||||||
|
Object.assign(records.get(node).styles.get('translate'), {x:dx,y:dy});
|
||||||
|
used.add(node);
|
||||||
|
}
|
||||||
|
function visibleButtons(node, selector) {
|
||||||
|
return [...node.querySelectorAll(selector)]
|
||||||
|
.filter(button => !button.closest('.mengsan-hud-external-control-shuying,.removing,.closing'))
|
||||||
|
.map(button => button.getBoundingClientRect()).filter(box => box.height && box.width);
|
||||||
|
}
|
||||||
|
function alignActions(handTop, center, gap, used, response) {
|
||||||
|
const controls = [ui.control];
|
||||||
|
if (response && ui.confirm?.isConnected && !ui.control.contains(ui.confirm)) controls.push(ui.confirm);
|
||||||
|
let top = Infinity;
|
||||||
|
for (const node of controls) {
|
||||||
|
const isRoot = node === ui.control;
|
||||||
|
const buttons = visibleButtons(node,isRoot ? ':scope > .control > div' : ':scope > div');
|
||||||
|
if (!buttons.length) continue;
|
||||||
|
const confirm = ui.confirm;
|
||||||
|
let responseButtons = [];
|
||||||
|
if (confirm && (node === confirm || node.contains(confirm))) {
|
||||||
|
responseButtons = confirm.node ? [confirm.node.ok,confirm.node.cancel]
|
||||||
|
.filter(button => button?.isConnected && button.getClientRects().length)
|
||||||
|
.map(button => button.getBoundingClientRect()) : visibleButtons(confirm,':scope > div');
|
||||||
|
}
|
||||||
|
const centered = responseButtons.length ? responseButtons : buttons;
|
||||||
|
const left = Math.min(...centered.map(box => box.left));
|
||||||
|
const right = Math.max(...centered.map(box => box.right));
|
||||||
|
const scale = hostScale(node), previous = currentShift(node,scale);
|
||||||
|
const bottom = Math.max(...buttons.map(box => box.bottom)) - previous.y;
|
||||||
|
const offset = response ? handTop - gap - bottom : 0;
|
||||||
|
shift(node,center - (left + right)/2 + previous.x,offset,scale,used);
|
||||||
|
top = Math.min(top, ...buttons.map(box => box.top - previous.y + offset));
|
||||||
|
}
|
||||||
|
return top;
|
||||||
|
}
|
||||||
|
function clearResponseCards(promptTop, battlefieldTop, gap, used) {
|
||||||
|
const cards = (ui.thrown || []).filter(card => card.parentNode === arena && !card.fixed &&
|
||||||
|
!card.matches('.drawingcard,.gainingcard,.movingcard,.removing,.hidden'));
|
||||||
|
const geometry = cards.map(card => {
|
||||||
|
const scale = hostScale(card), previous = currentShift(card,scale), box = card.getBoundingClientRect();
|
||||||
|
return {card,scale,top:box.top - previous.y,bottom:box.bottom - previous.y};
|
||||||
|
});
|
||||||
|
if (!geometry.length) return;
|
||||||
|
const top = Math.min(...geometry.map(box => box.top));
|
||||||
|
const bottom = Math.max(...geometry.map(box => box.bottom));
|
||||||
|
const offset = Math.min(0, Math.max(battlefieldTop + gap - top, promptTop - gap - bottom));
|
||||||
|
// The normal discard position wins whenever it clears the response prompt.
|
||||||
|
for (const {card,scale} of geometry) shift(card,0,offset,scale,used);
|
||||||
|
}
|
||||||
const api = {
|
const api = {
|
||||||
refresh(nextOptions) {
|
refresh(nextOptions) {
|
||||||
options = nextOptions;
|
options = nextOptions;
|
||||||
const {footerHeight,status} = nextOptions;
|
const {footerHeight,status,response} = nextOptions;
|
||||||
const used=new Set(),a=arena.getBoundingClientRect(),zoom=a.width/arena.clientWidth||1;
|
const used=new Set(),a=arena.getBoundingClientRect(),zoom=a.width/arena.clientWidth||1;
|
||||||
const left=parseFloat(arena.style.getPropertyValue('--mengsan-hud-left'))||0;
|
const left=parseFloat(arena.style.getPropertyValue('--mengsan-hud-left'))||0;
|
||||||
const right=parseFloat(arena.style.getPropertyValue('--mengsan-hud-right'))||0;
|
const right=parseFloat(arena.style.getPropertyValue('--mengsan-hud-right'))||0;
|
||||||
const x=a.left+left*zoom,width=Math.max(100,arena.clientWidth-left-right);
|
const x=a.left+left*zoom,width=Math.max(100,arena.clientWidth-left-right);
|
||||||
const controlTop=ui.control.getBoundingClientRect().top;
|
|
||||||
const prompts=new Set(arena.querySelectorAll(':scope > .hand-tip,:scope > .hand-tip-info'));
|
const prompts=new Set(arena.querySelectorAll(':scope > .hand-tip,:scope > .hand-tip-info'));
|
||||||
const dialog=ui.dialog;
|
const dialog=ui.dialog;
|
||||||
if(dialog?.isConnected && !dialog.classList.contains('popped') && !dialog.classList.contains('fullheight') && !dialog.forcebutton && !dialog.buttons?.length && !dialog.querySelector('.button,.card,.player,input,textarea,select') && status.event?.player===player)prompts.add(dialog);
|
if(dialog?.isConnected && !dialog.classList.contains('popped') && !dialog.classList.contains('fullheight') && !dialog.forcebutton && !dialog.buttons?.length && !dialog.querySelector('.button,.card,.player,input,textarea,select') && status.event?.player===player)prompts.add(dialog);
|
||||||
// The event owns simple native prompt dialogs too, without a global game dependency.
|
// The event owns simple native prompt dialogs too, without a global game dependency.
|
||||||
const eventDialog=status.event?.dialog;
|
const eventDialog=status.event?.dialog;
|
||||||
if(eventDialog?.isConnected && eventDialog===dialog && !eventDialog.buttons?.length && !eventDialog.forcebutton && !eventDialog.querySelector('.button,.card,.player,input,textarea,select'))prompts.add(eventDialog);
|
if(eventDialog?.isConnected && eventDialog===dialog && !eventDialog.buttons?.length && !eventDialog.forcebutton && !eventDialog.querySelector('.button,.card,.player,input,textarea,select'))prompts.add(eventDialog);
|
||||||
let promptBottom=Math.min(controlTop-10*zoom,a.bottom-(footerHeight+54)*zoom);
|
|
||||||
for(const node of prompts) {
|
|
||||||
if(node.hidden || node.style.display==='none')continue;
|
|
||||||
mark(node,'mengsan-hud-prompt-shuying');used.add(node);
|
|
||||||
position(node,x,0,width,arena.clientHeight<=500?34:64);
|
|
||||||
const height=node.getBoundingClientRect().height;
|
|
||||||
position(node,x,Math.max(a.top+50*zoom,promptBottom-height),width,arena.clientHeight<=500?34:64);
|
|
||||||
promptBottom=node.getBoundingClientRect().top-6*zoom;
|
|
||||||
}
|
|
||||||
const handBox=hand.getBoundingClientRect();
|
const handBox=hand.getBoundingClientRect();
|
||||||
const handTop=Math.min(handBox.top,...[...hand.querySelectorAll('.handcards>.card')].map(node=>node.getBoundingClientRect().top));
|
const handCards=[...hand.querySelectorAll('.handcards>.card')].map(node=>node.getBoundingClientRect()).filter(box=>box.height&&box.width);
|
||||||
|
const handTop=Math.min(handBox.top,...handCards.map(box=>box.top));
|
||||||
|
const gap=Math.max(4,(arena.clientHeight<=500?6:8)*zoom);
|
||||||
|
const actionTop=alignActions(handCards.length ? Math.min(...handCards.map(box=>box.top)) : handTop,(a.left+a.right)/2,gap,used,response);
|
||||||
|
const controlTop=ui.control.getBoundingClientRect().top;
|
||||||
|
let promptBottom=Math.min(controlTop-10*zoom,a.bottom-(footerHeight+54)*zoom);
|
||||||
|
if(response && Number.isFinite(actionTop))promptBottom=actionTop-gap;
|
||||||
|
let promptTop=Infinity;
|
||||||
|
for(const node of prompts) {
|
||||||
|
if(node.hidden || !node.getClientRects().length)continue;
|
||||||
|
mark(node,'mengsan-hud-prompt-shuying');used.add(node);
|
||||||
|
const promptWidth=response?arena.clientWidth-32:width;
|
||||||
|
const promptX=a.left+(arena.clientWidth-promptWidth)*zoom/2;
|
||||||
|
position(node,promptX,0,promptWidth,arena.clientHeight<=500?34:64);
|
||||||
|
const height=node.getBoundingClientRect().height;
|
||||||
|
position(node,promptX,Math.max(a.top+(response?8:50)*zoom,promptBottom-height),promptWidth,arena.clientHeight<=500?34:64);
|
||||||
|
promptTop=node.getBoundingClientRect().top;
|
||||||
|
promptBottom=promptTop-6*zoom;
|
||||||
|
}
|
||||||
|
if(response && Number.isFinite(promptTop)) clearResponseCards(promptTop,a.top,gap,used);
|
||||||
const popups=popped();
|
const popups=popped();
|
||||||
let hasPopup=false;
|
let hasPopup=false;
|
||||||
for(const node of popups) {
|
for(const node of popups) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
.mengsan-hud-health-track-shuying { width:100%;height:4px;margin:0 0 2px;background:#ffffff1a;border-radius:4px;overflow:hidden; }
|
.mengsan-hud-health-track-shuying { width:100%;height:4px;margin:0 0 2px;background:#ffffff1a;border-radius:4px;overflow:hidden; }
|
||||||
.mengsan-hud-health-track-shuying>span { height:100%;background:#9bb78d; }
|
.mengsan-hud-health-track-shuying>span { height:100%;background:#9bb78d; }
|
||||||
.mengsan-hud-energy-shuying { color:#eacb87;font-size:16px;font-variant-numeric:tabular-nums;white-space:nowrap; }
|
.mengsan-hud-energy-shuying { color:#eacb87;font-size:16px;font-variant-numeric:tabular-nums;white-space:nowrap; }
|
||||||
.mengsan-hud-center-shuying { left:40px;right:auto;top:auto;bottom:var(--mengsan-side-dock-bottom);width:var(--mengsan-profile-width);height:var(--mengsan-status-height); }
|
.mengsan-hud-center-shuying { left:var(--mengsan-status-left);right:auto;top:auto;bottom:var(--mengsan-side-dock-bottom);width:var(--mengsan-profile-width);height:var(--mengsan-status-height); }
|
||||||
.mengsan-hud-shuying .mengsan-hud-statuses-shuying { display:grid;grid-template-columns:repeat(auto-fill,32px);grid-auto-rows:32px;align-content:end;gap:6px;overflow:hidden;white-space:nowrap;height:100%; }
|
.mengsan-hud-shuying .mengsan-hud-statuses-shuying { display:grid;grid-template-columns:repeat(auto-fill,32px);grid-auto-rows:32px;align-content:end;gap:6px;overflow:hidden;white-space:nowrap;height:100%; }
|
||||||
.mengsan-hud-shuying .mengsan-hud-status-shuying { display:flex;align-items:center;justify-content:center;width:32px;height:32px;min-width:0;min-height:32px;padding:2px;background:transparent;border-radius:6px;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:pan-y; }
|
.mengsan-hud-shuying .mengsan-hud-status-shuying { display:flex;align-items:center;justify-content:center;width:32px;height:32px;min-width:0;min-height:32px;padding:2px;background:transparent;border-radius:6px;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:pan-y; }
|
||||||
.mengsan-hud-status-shuying img { width:26px;height:26px;object-fit:contain;pointer-events:none; }
|
.mengsan-hud-status-shuying img { width:26px;height:26px;object-fit:contain;pointer-events:none; }
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
Keep them above the portrait (25) and below action controls (30).
|
Keep them above the portrait (25) and below action controls (30).
|
||||||
Inline elevations used by awakening animations still take precedence. */
|
Inline elevations used by awakening animations still take precedence. */
|
||||||
body.mengsan-hud-active-shuying>#decadeUI-canvas { z-index:28; }
|
body.mengsan-hud-active-shuying>#decadeUI-canvas { z-index:28; }
|
||||||
.mengsan-hud-hand-shuying { position:absolute!important;left:var(--mengsan-hud-left)!important;right:var(--mengsan-hud-right)!important;bottom:68px!important;top:auto!important;width:calc(100% - var(--mengsan-hud-left) - var(--mengsan-hud-right))!important;height:calc(var(--mengsan-hud-height,274px) - 126px)!important;z-index:24!important;background:none!important;border:0!important;transform:none!important;pointer-events:none; }
|
.mengsan-hud-hand-shuying { position:absolute!important;top:auto!important;height:calc(var(--mengsan-hud-height,274px) - 126px)!important;z-index:24!important;background:none!important;border:0!important;transform:none!important;pointer-events:none; }
|
||||||
.mengsan-hud-hand-shuying .handcards>.card { pointer-events:auto; }
|
.mengsan-hud-hand-shuying .handcards>.card { pointer-events:auto; }
|
||||||
.mengsan-hud-mebg-shuying,.mengsan-hud-hand-shuying>.fakeme.avatar { display:none!important; }
|
.mengsan-hud-mebg-shuying,.mengsan-hud-hand-shuying>.fakeme.avatar { display:none!important; }
|
||||||
/* These explicit references cover Decade's nested camp-wrap and hp-wrap as well. */
|
/* These explicit references cover Decade's nested camp-wrap and hp-wrap as well. */
|
||||||
@@ -75,12 +75,10 @@ body.mengsan-hud-active-shuying .mengsan-hud-potion-action-shuying { display:non
|
|||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-hp-shuying,[data-mengsan-hud-layout="short"] .mengsan-hud-block-shuying { font-size:11px; }
|
[data-mengsan-hud-layout="short"] .mengsan-hud-hp-shuying,[data-mengsan-hud-layout="short"] .mengsan-hud-block-shuying { font-size:11px; }
|
||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-name-shuying { font-size:15px; }
|
[data-mengsan-hud-layout="short"] .mengsan-hud-name-shuying { font-size:15px; }
|
||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-energy-shuying { font-size:14px; }
|
[data-mengsan-hud-layout="short"] .mengsan-hud-energy-shuying { font-size:14px; }
|
||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-hand-shuying { bottom:64px!important;height:calc(var(--mengsan-hud-height) - 122px)!important; }
|
[data-mengsan-hud-layout="short"] .mengsan-hud-hand-shuying { height:calc(var(--mengsan-hud-height) - 122px)!important; }
|
||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-center-shuying { top:auto;left:24px; }
|
|
||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-shuying .mengsan-hud-status-shuying { min-height:26px;padding:2px 4px; }
|
[data-mengsan-hud-layout="short"] .mengsan-hud-shuying .mengsan-hud-status-shuying { min-height:26px;padding:2px 4px; }
|
||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-status-shuying img { width:18px;height:18px; }
|
[data-mengsan-hud-layout="short"] .mengsan-hud-status-shuying img { width:18px;height:18px; }
|
||||||
[data-mengsan-hud-layout="narrow"] .mengsan-hud-shuying .mengsan-hud-info-shuying { left:22px;width:76px;font-size:12px;gap:5px; }
|
[data-mengsan-hud-layout="narrow"] .mengsan-hud-shuying .mengsan-hud-info-shuying { left:22px;width:76px;font-size:12px;gap:5px; }
|
||||||
[data-mengsan-hud-layout="narrow"] .mengsan-hud-hand-shuying { bottom:68px!important; }
|
|
||||||
[data-mengsan-hud-layout="narrow"] .mengsan-hud-name-shuying { font-size:16px; }
|
[data-mengsan-hud-layout="narrow"] .mengsan-hud-name-shuying { font-size:16px; }
|
||||||
[data-mengsan-hud-layout="narrow"] .mengsan-hud-status-shuying span { display:none; }
|
[data-mengsan-hud-layout="narrow"] .mengsan-hud-status-shuying span { display:none; }
|
||||||
#arena.mengsan-hud-arena-shuying>.mengsan-hud-notification-shuying { width:148px!important;max-width:148px!important;min-height:30px;height:30px!important;transition:none!important;font:600 16px/30px "Microsoft YaHei",sans-serif!important;white-space:nowrap; }
|
#arena.mengsan-hud-arena-shuying>.mengsan-hud-notification-shuying { width:148px!important;max-width:148px!important;min-height:30px;height:30px!important;transition:none!important;font:600 16px/30px "Microsoft YaHei",sans-serif!important;white-space:nowrap; }
|
||||||
@@ -119,7 +117,6 @@ body.mengsan-hud-active-shuying #arena .mengsan-hud-equips-shuying::-webkit-scro
|
|||||||
[data-mengsan-hud-layout="narrow"] .mengsan-hand-relics-shuying { right:16px!important;width:96px!important;max-width:96px!important;max-height:36px;flex-wrap:nowrap;justify-content:flex-start;overflow-x:auto;overflow-y:hidden;touch-action:pan-x; }
|
[data-mengsan-hud-layout="narrow"] .mengsan-hand-relics-shuying { right:16px!important;width:96px!important;max-width:96px!important;max-height:36px;flex-wrap:nowrap;justify-content:flex-start;overflow-x:auto;overflow-y:hidden;touch-action:pan-x; }
|
||||||
body.mengsan-hud-active-shuying #arena>.mengsan-hud-controls-shuying>.mengsan-hud-native-skills-shuying { flex-direction:column!important;flex-wrap:nowrap!important;align-items:stretch!important;max-width:none!important;overflow:auto!important; }
|
body.mengsan-hud-active-shuying #arena>.mengsan-hud-controls-shuying>.mengsan-hud-native-skills-shuying { flex-direction:column!important;flex-wrap:nowrap!important;align-items:stretch!important;max-width:none!important;overflow:auto!important; }
|
||||||
body.mengsan-hud-active-shuying #arena .mengsan-hud-native-skills-shuying>div { width:100%!important;min-width:0!important;box-sizing:border-box!important;padding:8px 10px!important;min-height:40px!important;font:14px/20px "Microsoft YaHei",sans-serif!important;white-space:normal!important; }
|
body.mengsan-hud-active-shuying #arena .mengsan-hud-native-skills-shuying>div { width:100%!important;min-width:0!important;box-sizing:border-box!important;padding:8px 10px!important;min-height:40px!important;font:14px/20px "Microsoft YaHei",sans-serif!important;white-space:normal!important; }
|
||||||
[data-mengsan-hud-layout="narrow"] .mengsan-hud-center-shuying { left:22px; }
|
|
||||||
[data-mengsan-hud-layout="short"] .mengsan-hud-shuying .mengsan-hud-statuses-shuying { height:100%; }
|
[data-mengsan-hud-layout="short"] .mengsan-hud-shuying .mengsan-hud-statuses-shuying { height:100%; }
|
||||||
.mengsan-hud-prompt-shuying { box-sizing:border-box!important;height:auto!important;min-height:0!important;overflow:auto!important;padding:2px 6px!important;background:none!important;border:0!important;box-shadow:none!important;text-align:center!important;z-index:32!important;color:#f6edcb!important;text-shadow:0 1px 3px #000,0 0 6px #000!important; }
|
.mengsan-hud-prompt-shuying { box-sizing:border-box!important;height:auto!important;min-height:0!important;overflow:auto!important;padding:2px 6px!important;background:none!important;border:0!important;box-shadow:none!important;text-align:center!important;z-index:32!important;color:#f6edcb!important;text-shadow:0 1px 3px #000,0 0 6px #000!important; }
|
||||||
body.mengsan-hud-active-shuying .mengsan-hud-card-intro-shuying { box-sizing:border-box!important;z-index:90!important;height:auto!important;min-height:0!important;overflow:auto!important;border-radius:14px!important;background:#202020f5!important;box-shadow:0 8px 24px #0007!important;color:#f4f4f4!important;transition:none!important; }
|
body.mengsan-hud-active-shuying .mengsan-hud-card-intro-shuying { box-sizing:border-box!important;z-index:90!important;height:auto!important;min-height:0!important;overflow:auto!important;border-radius:14px!important;background:#202020f5!important;box-shadow:0 8px 24px #0007!important;color:#f4f4f4!important;transition:none!important; }
|
||||||
|
|||||||
@@ -415,7 +415,8 @@ export const showMap = (run, { saveRun } = {}) => new Promise(resolve => {
|
|||||||
suppressClick = true;
|
suppressClick = true;
|
||||||
if (!viewport.hasPointerCapture(event.pointerId)) viewport.setPointerCapture(event.pointerId);
|
if (!viewport.hasPointerCapture(event.pointerId)) viewport.setPointerCapture(event.pointerId);
|
||||||
viewport.classList.add("dragging");
|
viewport.classList.add("dragging");
|
||||||
viewport.scrollTop = drag.top - distance;
|
const scale = viewport.getBoundingClientRect().height / viewport.offsetHeight || 1;
|
||||||
|
viewport.scrollTop = drag.top - distance / scale;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
const endDrag = event => {
|
const endDrag = event => {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ export const askMenu = (title, description, choices) => new Promise(resolve => {
|
|||||||
dialog.appendChild(button);
|
dialog.appendChild(button);
|
||||||
}
|
}
|
||||||
dialog.addEventListener("cancel", event => { event.preventDefault(); finish(null); });
|
dialog.addEventListener("cancel", event => { event.preventDefault(); finish(null); });
|
||||||
document.body.appendChild(dialog);
|
document.documentElement.appendChild(dialog);
|
||||||
dialog.showModal();
|
dialog.showModal();
|
||||||
dialog.querySelector("button")?.focus();
|
dialog.querySelector("button")?.focus();
|
||||||
});
|
});
|
||||||
|
|||||||
+11
-4
@@ -10,13 +10,20 @@
|
|||||||
|
|
||||||
.mengsan-battle-potions {
|
.mengsan-battle-potions {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 8px;
|
top: var(--mengsan-potion-top, 8px);
|
||||||
left: 50%;
|
left: var(--mengsan-potion-left, 8px);
|
||||||
transform: translateX(-50%);
|
width: max-content;
|
||||||
max-width: 44%;
|
max-width: calc(50% - 16px);
|
||||||
|
transition: none;
|
||||||
z-index: 7;
|
z-index: 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Decade UI sets data-id during every skill-bar rebuild, before its first paint. */
|
||||||
|
.mengsan-hud-arena-shuying :is(.skill-control, .skill-controlzuoshou, .gskill-control)
|
||||||
|
[data-id^="mengsan_use_"][data-id$="_potion_shuying"] {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
.mengsan-potion-slot {
|
.mengsan-potion-slot {
|
||||||
display: inline-grid;
|
display: inline-grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
|
|||||||
+44
-1
@@ -58,6 +58,45 @@ export function showPotionDescription(node, view) {
|
|||||||
parent.append(view.richDescription.slice(start));
|
parent.append(view.richDescription.slice(start));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function positionBattlePotions(root, strip, ui) {
|
||||||
|
if (!root.clientWidth || !root.clientHeight) return;
|
||||||
|
const view = root.ownerDocument.defaultView;
|
||||||
|
const arena = root.getBoundingClientRect();
|
||||||
|
const scaleX = arena.width / root.clientWidth || 1;
|
||||||
|
const scaleY = arena.height / root.clientHeight || 1;
|
||||||
|
const {width,height} = strip.getBoundingClientRect();
|
||||||
|
const gapX = 8 * scaleX, gapY = 8 * scaleY;
|
||||||
|
const startX = arena.left + gapX;
|
||||||
|
const limitX = arena.left + arena.width / 2 - gapX;
|
||||||
|
const obstacles = [];
|
||||||
|
for (const panel of new Set([ui.cardRoundTime,ui.cardRoundTimeNode,ui.cardPileNumber,
|
||||||
|
ui.time,ui.time3,ui.time4,ui.timeNode,ui.roundmenu])) {
|
||||||
|
if (!panel?.isConnected) continue;
|
||||||
|
const style = view.getComputedStyle(panel);
|
||||||
|
if (style.visibility === 'hidden' || style.display === 'none' || Number(style.opacity) === 0) continue;
|
||||||
|
for (const node of [panel,...panel.querySelectorAll('.cardPileNumber,.roundNumber,.time,.cardPileNumber > span')]) {
|
||||||
|
const box = node.getBoundingClientRect();
|
||||||
|
if (box.width && box.height) obstacles.push(box);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let x = startX, y = arena.top + gapY;
|
||||||
|
for (;;) {
|
||||||
|
const nearby = obstacles.filter(box => box.left < x + width + gapX && box.right + gapX > x &&
|
||||||
|
box.top < y + height + gapY && box.bottom + gapY > y);
|
||||||
|
if (!nearby.length) break;
|
||||||
|
const nextX = Math.max(...nearby.map(box=>box.right)) + gapX;
|
||||||
|
if (nextX + width <= limitX) {
|
||||||
|
x = nextX;
|
||||||
|
} else {
|
||||||
|
x = startX;
|
||||||
|
y = Math.min(...nearby.map(box=>box.bottom)) + gapY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const left = `${(x-arena.left)/scaleX}px`, top = `${(y-arena.top)/scaleY}px`;
|
||||||
|
if (strip.style.getPropertyValue('--mengsan-potion-left') !== left) strip.style.setProperty('--mengsan-potion-left',left);
|
||||||
|
if (strip.style.getPropertyValue('--mengsan-potion-top') !== top) strip.style.setProperty('--mengsan-potion-top',top);
|
||||||
|
}
|
||||||
|
|
||||||
export function mountPotionSlots(root, player, actions = {}) {
|
export function mountPotionSlots(root, player, actions = {}) {
|
||||||
const strip = element("div", "mengsan-potion-slots");
|
const strip = element("div", "mengsan-potion-slots");
|
||||||
if (actions.use) strip.classList.add("mengsan-battle-potions");
|
if (actions.use) strip.classList.add("mengsan-battle-potions");
|
||||||
@@ -142,5 +181,9 @@ export function mountPotionSlots(root, player, actions = {}) {
|
|||||||
strip.addEventListener(type, event => event.stopPropagation());
|
strip.addEventListener(type, event => event.stopPropagation());
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
return { refresh, dispose() { close(); strip.remove(); } };
|
return {
|
||||||
|
refresh,
|
||||||
|
layoutBattleSlots(ui) { if (actions.use && strip.isConnected) positionBattlePotions(root, strip, ui); },
|
||||||
|
dispose() { close(); strip.remove(); },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export function mountRelics(session, run, battleRelics, { stripRoot = ui.me } =
|
|||||||
});
|
});
|
||||||
dialog.addEventListener("keydown", event => event.stopPropagation());
|
dialog.addEventListener("keydown", event => event.stopPropagation());
|
||||||
refresh();
|
refresh();
|
||||||
document.body.appendChild(dialog);
|
document.documentElement.appendChild(dialog);
|
||||||
try { dialog.showModal(); dismiss.focus(); }
|
try { dialog.showModal(); dismiss.focus(); }
|
||||||
catch (error) { close(); throw error; }
|
catch (error) { close(); throw error; }
|
||||||
};
|
};
|
||||||
|
|||||||
+75
-25
@@ -303,9 +303,26 @@
|
|||||||
|
|
||||||
.mengsan-dialogue-stage-shuying {
|
.mengsan-dialogue-stage-shuying {
|
||||||
position: absolute !important;
|
position: absolute !important;
|
||||||
inset: 0 !important;
|
inset: 68px 0 max(8px, env(safe-area-inset-bottom)) !important;
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
height: 100% !important;
|
height: auto !important;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 16px 0 6px;
|
||||||
|
overflow: auto;
|
||||||
|
touch-action: pan-y;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mengsan-dialogue-content-shuying {
|
||||||
|
position: relative !important;
|
||||||
|
display: flex;
|
||||||
|
flex: none;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 28px;
|
||||||
|
margin-top: auto;
|
||||||
|
width: min(1120px, 92%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mengsan-dialogue-chapter-shuying {
|
.mengsan-dialogue-chapter-shuying {
|
||||||
@@ -388,13 +405,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mengsan-dialogue-box-shuying {
|
.mengsan-dialogue-box-shuying {
|
||||||
position: absolute !important;
|
position: relative !important;
|
||||||
left: 50% !important;
|
inset: auto !important;
|
||||||
right: auto !important;
|
width: 100% !important;
|
||||||
bottom: clamp(18px, 4vh, 42px) !important;
|
|
||||||
top: auto !important;
|
|
||||||
transform: translateX(-50%) !important;
|
|
||||||
width: min(1120px, 92vw) !important;
|
|
||||||
height: auto !important;
|
height: auto !important;
|
||||||
min-height: clamp(120px, 20vh, 180px);
|
min-height: clamp(120px, 20vh, 180px);
|
||||||
padding: clamp(32px, 5vh, 46px) clamp(24px, 4vw, 52px) 28px;
|
padding: clamp(32px, 5vh, 46px) clamp(24px, 4vw, 52px) 28px;
|
||||||
@@ -496,9 +509,8 @@
|
|||||||
height: 146px !important;
|
height: 146px !important;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
.mengsan-dialogue-content-shuying { width: 96%; }
|
||||||
.mengsan-dialogue-box-shuying {
|
.mengsan-dialogue-box-shuying {
|
||||||
bottom: 8px !important;
|
|
||||||
width: 96vw !important;
|
|
||||||
min-height: 126px;
|
min-height: 126px;
|
||||||
padding: 30px 18px 24px;
|
padding: 30px 18px 24px;
|
||||||
}
|
}
|
||||||
@@ -548,6 +560,7 @@
|
|||||||
|
|
||||||
.mengsan-map-panel-shuying {
|
.mengsan-map-panel-shuying {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
|
container-type: size;
|
||||||
background:
|
background:
|
||||||
linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
|
linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
|
||||||
linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px);
|
linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px);
|
||||||
@@ -783,7 +796,7 @@
|
|||||||
position: relative !important;
|
position: relative !important;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
display: block !important;
|
display: block !important;
|
||||||
width: min(420px, calc(100vw - 32px));
|
width: min(420px, calc(100% - 32px));
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
border: 0;
|
border: 0;
|
||||||
@@ -920,7 +933,7 @@
|
|||||||
.mengsan-ink-legend-shuying { display: none; }
|
.mengsan-ink-legend-shuying { display: none; }
|
||||||
.mengsan-map-shuying .mengsan-node-shuying { width: 52px; height: 52px; padding: 9px; }
|
.mengsan-map-shuying .mengsan-node-shuying { width: 52px; height: 52px; padding: 9px; }
|
||||||
.mengsan-map-menu-layer-shuying { align-items: flex-end; }
|
.mengsan-map-menu-layer-shuying { align-items: flex-end; }
|
||||||
.mengsan-map-menu-sheet-shuying { width: 100%; height: min(82dvh, 680px) !important; border-right: 0; border-top: 1px solid rgba(210,175,101,.34); border-radius: 16px 16px 0 0; animation-name: mengsan-menu-enter-mobile-shuying; }
|
.mengsan-map-menu-sheet-shuying { width: 100%; height: min(82%, 680px) !important; border-right: 0; border-top: 1px solid rgba(210,175,101,.34); border-radius: 16px 16px 0 0; animation-name: mengsan-menu-enter-mobile-shuying; }
|
||||||
@keyframes mengsan-menu-enter-mobile-shuying { from { opacity: 0; transform: translateY(24px); } }
|
@keyframes mengsan-menu-enter-mobile-shuying { from { opacity: 0; transform: translateY(24px); } }
|
||||||
.mengsan-map-menu-title-shuying { font-size: 24px; }
|
.mengsan-map-menu-title-shuying { font-size: 24px; }
|
||||||
.mengsan-map-menu-header-shuying { inset: 14px 14px auto 14px !important; }
|
.mengsan-map-menu-header-shuying { inset: 14px 14px auto 14px !important; }
|
||||||
@@ -929,6 +942,35 @@
|
|||||||
.mengsan-map-menu-action-shuying { min-height: 64px; }
|
.mengsan-map-menu-action-shuying { min-height: 64px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@container (max-height: 325px) {
|
||||||
|
.mengsan-map-menu-sheet-shuying { overflow-y: auto; overscroll-behavior-y: contain; }
|
||||||
|
.mengsan-map-menu-header-shuying,
|
||||||
|
.mengsan-map-menu-content-shuying,
|
||||||
|
.mengsan-map-menu-footer-shuying {
|
||||||
|
position: relative !important;
|
||||||
|
inset: auto !important;
|
||||||
|
width: auto !important;
|
||||||
|
margin: 0 14px;
|
||||||
|
}
|
||||||
|
.mengsan-map-menu-header-shuying { height: auto !important; min-height: 54px; padding: 4px; }
|
||||||
|
.mengsan-map-menu-content-shuying { overflow: visible; padding-top: 8px; }
|
||||||
|
.mengsan-map-menu-footer-shuying { height: auto !important; padding: 8px 4px; }
|
||||||
|
}
|
||||||
|
@container (max-height: 190px) {
|
||||||
|
.mengsan-map-header-shuying { grid-template-columns: auto minmax(0, 1fr); min-height: 0; gap: 4px 8px; padding: 4px 8px; }
|
||||||
|
.mengsan-map-menu-trigger-shuying { width: 34px; min-width: 34px; min-height: 34px; }
|
||||||
|
.mengsan-map-title-group-shuying > .mengsan-title-shuying { font-size: 16px; }
|
||||||
|
.mengsan-map-header-shuying > .mengsan-map-status-shuying {
|
||||||
|
grid-column: 1 / -1; justify-self: stretch; justify-content: flex-start;
|
||||||
|
min-width: 0; flex-wrap: nowrap; gap: 4px; overflow-x: auto;
|
||||||
|
}
|
||||||
|
.mengsan-map-stat-shuying { flex: 0 0 auto; min-width: 38px; min-height: 24px; padding: 1px 4px; }
|
||||||
|
.mengsan-map-status-shuying .mengsan-potion-slots { flex: none; flex-wrap: nowrap; }
|
||||||
|
.mengsan-map-status-shuying .mengsan-potion-slot { width: 26px; height: 26px; }
|
||||||
|
.mengsan-map-status-shuying .mengsan-potion-import { flex: none; white-space: nowrap; }
|
||||||
|
.mengsan-map-viewport-shuying { padding-block: 0; }
|
||||||
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.mengsan-map-menu-sheet-shuying { animation: none !important; }
|
.mengsan-map-menu-sheet-shuying { animation: none !important; }
|
||||||
.mengsan-map-menu-trigger-shuying,
|
.mengsan-map-menu-trigger-shuying,
|
||||||
@@ -954,6 +996,11 @@
|
|||||||
.mengsan-flow-overlay-shuying {
|
.mengsan-flow-overlay-shuying {
|
||||||
background: radial-gradient(ellipse at 18% 20%, #53635766, transparent 55%), linear-gradient(120deg, #172724f5, #101b1df5);
|
background: radial-gradient(ellipse at 18% 20%, #53635766, transparent 55%), linear-gradient(120deg, #172724f5, #101b1df5);
|
||||||
padding: 80px 24px 28px;
|
padding: 80px 24px 28px;
|
||||||
|
overflow: clip;
|
||||||
|
}
|
||||||
|
.mengsan-flow-overlay-shuying > .mengsan-panel-shuying {
|
||||||
|
min-height: 0;
|
||||||
|
overscroll-behavior: contain;
|
||||||
}
|
}
|
||||||
.mengsan-flow-panel-shuying {
|
.mengsan-flow-panel-shuying {
|
||||||
width: min(680px, 100%) !important;
|
width: min(680px, 100%) !important;
|
||||||
@@ -1156,30 +1203,35 @@ button.mengsan-card-choice-skip-shuying:hover { color: #fff1d5; border-color: #d
|
|||||||
.mengsan-menu-dialog-shuying p { margin: 0 0 24px; color: var(--flow-muted); }
|
.mengsan-menu-dialog-shuying p { margin: 0 0 24px; color: var(--flow-muted); }
|
||||||
.mengsan-menu-dialog-shuying button { display: block; width: 100%; min-height: 48px; margin-top: 12px; border: 1px solid #c4a56888; border-radius: 3px; padding: 10px; font: inherit; color: var(--flow-paper); background: #ffffff08; cursor: pointer; }
|
.mengsan-menu-dialog-shuying button { display: block; width: 100%; min-height: 48px; margin-top: 12px; border: 1px solid #c4a56888; border-radius: 3px; padding: 10px; font: inherit; color: var(--flow-paper); background: #ffffff08; cursor: pointer; }
|
||||||
.mengsan-menu-dialog-shuying button.danger { background: var(--flow-danger); border-color: #d89586; }
|
.mengsan-menu-dialog-shuying button.danger { background: var(--flow-danger); border-color: #d89586; }
|
||||||
.mengsan-dialogue-overlay-shuying { background: radial-gradient(ellipse at 35% 25%, #62736544, transparent 60%), linear-gradient(120deg, #172724ee, #101b1dee); }
|
.mengsan-dialogue-overlay-shuying { container-type: size; background: radial-gradient(ellipse at 35% 25%, #62736544, transparent 60%), linear-gradient(120deg, #172724ee, #101b1dee); }
|
||||||
.mengsan-dialogue-chapter-shuying { top: 26px !important; left: 24px !important; max-width: calc(100% - 160px); color: var(--flow-muted); }
|
.mengsan-dialogue-chapter-shuying { top: 26px !important; left: 50% !important; right: auto !important; transform: translateX(-50%); max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--flow-muted); }
|
||||||
.mengsan-dialogue-box-shuying { border-radius: 4px; border-color: var(--flow-gold); background: #172724f5; padding-bottom: 34px; }
|
.mengsan-dialogue-box-shuying { border-radius: 4px; border-color: var(--flow-gold); background: #172724f5; padding-bottom: 34px; }
|
||||||
.mengsan-dialogue-speaker-shuying { border-radius: 2px; color: #172724; background: #efe5cf; font-family: "KaiTi", "SimSun", serif; }
|
.mengsan-dialogue-speaker-shuying { border-radius: 2px; color: #172724; background: #efe5cf; font-family: "KaiTi", "SimSun", serif; }
|
||||||
.mengsan-dialogue-text-shuying { color: var(--flow-paper); font-size: clamp(17px, 2vw, 22px); line-height: 1.85; max-height: 30vh; overflow: auto; }
|
.mengsan-dialogue-text-shuying { color: var(--flow-paper); font-size: clamp(17px, 2vw, 22px); line-height: 1.85; max-height: 30vh; overflow: auto; }
|
||||||
.mengsan-dialogue-help-shuying { position: absolute !important; bottom: 8px; left: 16px; right: 16px; text-align: center; font-size: 12px; color: var(--flow-muted); pointer-events: none; }
|
.mengsan-dialogue-help-shuying { position: relative !important; flex: none; margin: 8px 16px 0; text-align: center; font-size: 12px; color: var(--flow-muted); pointer-events: none; }
|
||||||
.mengsan-dialogue-choices-shuying { position: absolute !important; left: 50%; bottom: clamp(210px, 32vh, 290px); transform: translateX(-50%); width: min(580px, 88vw); display: grid; gap: 10px; z-index: 5; }
|
.mengsan-dialogue-choices-shuying { position: relative !important; width: min(580px, 100%); display: grid; gap: 10px; z-index: 5; }
|
||||||
|
.mengsan-dialogue-choices-shuying:empty { display: none; }
|
||||||
.mengsan-dialogue-skip-shuying { position: absolute !important; top: max(18px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); z-index: 6; padding: 8px 14px; border: 1px solid var(--flow-gold); border-radius: 4px; color: var(--flow-paper); background: #172724e8; font: inherit; cursor: pointer; }
|
.mengsan-dialogue-skip-shuying { position: absolute !important; top: max(18px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); z-index: 6; padding: 8px 14px; border: 1px solid var(--flow-gold); border-radius: 4px; color: var(--flow-paper); background: #172724e8; font: inherit; cursor: pointer; }
|
||||||
.mengsan-dialogue-skip-shuying:hover, .mengsan-dialogue-skip-shuying:focus-visible { background: #304540; outline: 2px solid var(--flow-gold); outline-offset: 2px; }
|
.mengsan-dialogue-skip-shuying:hover, .mengsan-dialogue-skip-shuying:focus-visible { background: #304540; outline: 2px solid var(--flow-gold); outline-offset: 2px; }
|
||||||
.mengsan-dialogue-choice-shuying { padding: 12px 18px; border: 1px solid var(--flow-gold); border-radius: 4px; color: var(--flow-paper); background: #172724f5; text-align: left; font: inherit; cursor: pointer; }
|
.mengsan-dialogue-choice-shuying { padding: 12px 18px; border: 1px solid var(--flow-gold); border-radius: 4px; color: var(--flow-paper); background: #172724f5; text-align: left; font: inherit; cursor: pointer; }
|
||||||
.mengsan-dialogue-choice-shuying:hover, .mengsan-dialogue-choice-shuying:focus-visible { background: #304540; outline: 2px solid var(--flow-gold); outline-offset: 2px; }
|
.mengsan-dialogue-choice-shuying:hover, .mengsan-dialogue-choice-shuying:focus-visible { background: #304540; outline: 2px solid var(--flow-gold); outline-offset: 2px; }
|
||||||
|
@container (max-height: 280px) {
|
||||||
|
.mengsan-dialogue-stage-shuying { padding-top: 4px; }
|
||||||
|
.mengsan-dialogue-choices-shuying { gap: 6px; }
|
||||||
|
.mengsan-dialogue-choice-shuying { min-height: 36px; padding: 6px 14px; }
|
||||||
|
}
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.mengsan-dialogue-chapter-shuying { display: block !important; font-size: 14px; }
|
.mengsan-dialogue-chapter-shuying { display: block !important; font-size: 14px; }
|
||||||
.mengsan-flow-overlay-shuying { padding: 78px 12px 16px; }
|
.mengsan-flow-overlay-shuying { padding: 78px 12px 16px; }
|
||||||
.mengsan-flow-panel-shuying { padding: 24px 18px; }
|
.mengsan-flow-panel-shuying { padding: 24px 18px; }
|
||||||
.mengsan-flow-panel-shuying > .mengsan-title-shuying { font-size: 30px; }
|
.mengsan-flow-panel-shuying > .mengsan-title-shuying { font-size: 30px; }
|
||||||
.mengsan-flow-panel-shuying .mengsan-choice-shuying { padding: 14px; }
|
.mengsan-flow-panel-shuying .mengsan-choice-shuying { padding: 14px; }
|
||||||
.mengsan-dialogue-box-shuying { bottom: 36px !important; }
|
|
||||||
}
|
}
|
||||||
@media (max-height: 500px) {
|
@media (max-height: 500px) {
|
||||||
.mengsan-flow-overlay-shuying { padding-top: 70px; padding-bottom: 12px; }
|
.mengsan-flow-overlay-shuying { padding-top: 70px; padding-bottom: 12px; }
|
||||||
.mengsan-flow-panel-shuying { padding: 18px 24px; }
|
.mengsan-flow-panel-shuying { padding: 18px 24px; }
|
||||||
.mengsan-flow-panel-shuying > .mengsan-description-shuying { margin-bottom: 16px; }
|
.mengsan-flow-panel-shuying > .mengsan-description-shuying { margin-bottom: 16px; }
|
||||||
.mengsan-dialogue-box-shuying { bottom: 28px !important; min-height: 100px; max-height: 50vh; padding: 24px 20px 20px; }
|
.mengsan-dialogue-box-shuying { min-height: 100px; padding: 24px 20px 20px; }
|
||||||
.mengsan-dialogue-text-shuying { max-height: 24vh; }
|
.mengsan-dialogue-text-shuying { max-height: 24vh; }
|
||||||
.mengsan-dialogue-portrait-frame-shuying {
|
.mengsan-dialogue-portrait-frame-shuying {
|
||||||
height: 110px !important;
|
height: 110px !important;
|
||||||
@@ -1267,7 +1319,8 @@ dialog.mengsan-deck-dialog-shuying::backdrop { background: #080706b8; }
|
|||||||
|
|
||||||
/* Battle-only control; removed with its owning session. */
|
/* Battle-only control; removed with its owning session. */
|
||||||
.mengsan-battle-piles-button-shuying {
|
.mengsan-battle-piles-button-shuying {
|
||||||
position: fixed !important; right: max(14px, env(safe-area-inset-right)); top: 110px;
|
--mengsan-battle-side-top: clamp(4px, calc(100% - 100px), 110px);
|
||||||
|
position: fixed !important; right: max(14px, env(safe-area-inset-right)); top: var(--mengsan-battle-side-top);
|
||||||
z-index: 35; min-width: 64px; min-height: 44px; padding: 8px 14px;
|
z-index: 35; min-width: 64px; min-height: 44px; padding: 8px 14px;
|
||||||
border: 1px solid #dcb578; border-radius: 8px; background: #30251eee;
|
border: 1px solid #dcb578; border-radius: 8px; background: #30251eee;
|
||||||
color: #f4e7cc; font: 16px/1.4 "Microsoft YaHei", sans-serif;
|
color: #f4e7cc; font: 16px/1.4 "Microsoft YaHei", sans-serif;
|
||||||
@@ -1282,7 +1335,7 @@ dialog.mengsan-deck-dialog-shuying::backdrop { background: #080706b8; }
|
|||||||
.mengsan-gm-dialog-shuying .ms-gm-editor { overflow: auto; flex: 1; min-height: 0; border-top: 1px solid #96754e; padding: 12px 4px; }
|
.mengsan-gm-dialog-shuying .ms-gm-editor { overflow: auto; flex: 1; min-height: 0; border-top: 1px solid #96754e; padding: 12px 4px; }
|
||||||
.mengsan-gm-dialog-shuying .ms-gm-affixes { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; margin-top: 12px; }
|
.mengsan-gm-dialog-shuying .ms-gm-affixes { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; margin-top: 12px; }
|
||||||
.mengsan-gm-dialog-shuying .ms-gm-affixes button:disabled { opacity: .55; cursor: not-allowed; }
|
.mengsan-gm-dialog-shuying .ms-gm-affixes button:disabled { opacity: .55; cursor: not-allowed; }
|
||||||
@media (max-height: 500px) { .mengsan-battle-piles-button-shuying { top: 70px; right: max(8px, env(safe-area-inset-right)); } }
|
@media (max-height: 500px) { .mengsan-battle-piles-button-shuying { --mengsan-battle-side-top: clamp(4px, calc(100% - 100px), 70px); right: max(8px, env(safe-area-inset-right)); } }
|
||||||
|
|
||||||
/* Only session-created Mengsan players; retain internal identity and seat order. */
|
/* Only session-created Mengsan players; retain internal identity and seat order. */
|
||||||
.player.mengsan-hide-identity-shuying > .identity {
|
.player.mengsan-hide-identity-shuying > .identity {
|
||||||
@@ -1408,7 +1461,7 @@ body.mengsan-battle-ui-shuying #arena[data-number="3"] > .player:is([data-positi
|
|||||||
height: 22px;
|
height: 22px;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
.mengsan-battle-relics-button-shuying { top: 162px; }
|
.mengsan-battle-relics-button-shuying { top: calc(var(--mengsan-battle-side-top) + 52px); }
|
||||||
.mengsan-hand-relics-shuying {
|
.mengsan-hand-relics-shuying {
|
||||||
position: absolute !important;
|
position: absolute !important;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -1503,9 +1556,6 @@ body.mengsan-battle-ui-shuying #arena[data-number="3"] > .player:is([data-positi
|
|||||||
.mengsan-map-inventory-row-shuying > .mengsan-relic-icon-shuying { width: 40px; height: 40px; }
|
.mengsan-map-inventory-row-shuying > .mengsan-relic-icon-shuying { width: 40px; height: 40px; }
|
||||||
.mengsan-relic-choice-tile-shuying .mengsan-card-choice-art-shuying img { padding: 14px; box-sizing: border-box; background: transparent; }
|
.mengsan-relic-choice-tile-shuying .mengsan-card-choice-art-shuying img { padding: 14px; box-sizing: border-box; background: transparent; }
|
||||||
.mengsan-relic-choice-tile-shuying .mengsan-card-choice-art-shuying:has(img) .mengsan-card-choice-glyph-shuying { display: none; }
|
.mengsan-relic-choice-tile-shuying .mengsan-card-choice-art-shuying:has(img) .mengsan-card-choice-glyph-shuying { display: none; }
|
||||||
@media (max-height: 500px) {
|
|
||||||
.mengsan-battle-relics-button-shuying { top: 122px; }
|
|
||||||
}
|
|
||||||
.mengsan-bonds-shuying {
|
.mengsan-bonds-shuying {
|
||||||
position: relative !important;
|
position: relative !important;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|||||||
@@ -5,6 +5,21 @@ export function createVirtualCardGrid(viewport, grid, createCard) {
|
|||||||
const maxCached = 24;
|
const maxCached = 24;
|
||||||
let records = [], columns = 1, height = 218, gap = 8, padding = 5, viewportHeight = 0;
|
let records = [], columns = 1, height = 218, gap = 8, padding = 5, viewportHeight = 0;
|
||||||
let frame = 0, disposed = false;
|
let frame = 0, disposed = false;
|
||||||
|
function mount(index) {
|
||||||
|
if (mounted.has(index)) return mounted.get(index);
|
||||||
|
const node = cached.get(index) || createCard(records[index], index);
|
||||||
|
cached.delete(index);
|
||||||
|
node.dataset.cardIndex = String(index);
|
||||||
|
node.style.gridRow = String(Math.floor(index / columns) + 1);
|
||||||
|
node.style.gridColumn = String(index % columns + 1);
|
||||||
|
// 保持 DOM 顺序与屏幕顺序一致,方便键盘与读屏浏览。
|
||||||
|
let next = null;
|
||||||
|
for (const [otherIndex, other] of mounted) {
|
||||||
|
if (otherIndex > index && (!next || otherIndex < Number(next.dataset.cardIndex))) next = other;
|
||||||
|
}
|
||||||
|
grid.insertBefore(node, next); mounted.set(index, node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
function draw() {
|
function draw() {
|
||||||
if (disposed || grid.hidden || !viewportHeight) return;
|
if (disposed || grid.hidden || !viewportHeight) return;
|
||||||
const stride = height + gap;
|
const stride = height + gap;
|
||||||
@@ -20,25 +35,26 @@ export function createVirtualCardGrid(viewport, grid, createCard) {
|
|||||||
while (cached.size > maxCached) cached.delete(cached.keys().next().value);
|
while (cached.size > maxCached) cached.delete(cached.keys().next().value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let index = first; index < end; index++) {
|
for (let index = first; index < end; index++) mount(index);
|
||||||
if (mounted.has(index)) continue;
|
|
||||||
const node = cached.get(index) || createCard(records[index], index);
|
|
||||||
cached.delete(index);
|
|
||||||
node.dataset.cardIndex = String(index);
|
|
||||||
node.style.gridRow = String(Math.floor(index / columns) + 1);
|
|
||||||
node.style.gridColumn = String(index % columns + 1);
|
|
||||||
// 保持 DOM 顺序与屏幕顺序一致,方便键盘与读屏浏览。
|
|
||||||
let next = null;
|
|
||||||
for (const [otherIndex, other] of mounted) {
|
|
||||||
if (otherIndex > index && (!next || otherIndex < Number(next.dataset.cardIndex))) next = other;
|
|
||||||
}
|
|
||||||
grid.insertBefore(node, next); mounted.set(index, node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function schedule() {
|
function schedule() {
|
||||||
if (!frame && !disposed) frame = requestAnimationFrame(() => { frame = 0; draw(); });
|
if (!frame && !disposed) frame = requestAnimationFrame(() => { frame = 0; draw(); });
|
||||||
}
|
}
|
||||||
function layout(cardHeight = height) {
|
function rowTop(index) {
|
||||||
|
return padding + Math.floor(index / columns) * (height + gap);
|
||||||
|
}
|
||||||
|
function visiblePositions() {
|
||||||
|
const top = viewport.scrollTop, bottom = top + viewportHeight;
|
||||||
|
const firstRow = Math.max(0, Math.floor((top - padding) / (height + gap)));
|
||||||
|
const positions = [];
|
||||||
|
for (let index = firstRow * columns; index < records.length; index++) {
|
||||||
|
const position = rowTop(index);
|
||||||
|
if (position >= bottom) break;
|
||||||
|
if (position + height > top) positions.push({ index, offset: position - top });
|
||||||
|
}
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
|
function layout(cardHeight = height, position = null) {
|
||||||
height = cardHeight;
|
height = cardHeight;
|
||||||
if (disposed || grid.hidden || !grid.clientWidth) return;
|
if (disposed || grid.hidden || !grid.clientWidth) return;
|
||||||
const style = getComputedStyle(grid);
|
const style = getComputedStyle(grid);
|
||||||
@@ -53,16 +69,21 @@ export function createVirtualCardGrid(viewport, grid, createCard) {
|
|||||||
node.style.gridRow = String(Math.floor(index / columns) + 1);
|
node.style.gridRow = String(Math.floor(index / columns) + 1);
|
||||||
node.style.gridColumn = String(index % columns + 1);
|
node.style.gridColumn = String(index % columns + 1);
|
||||||
}
|
}
|
||||||
|
if (position) viewport.scrollTop = position.index >= 0
|
||||||
|
? rowTop(position.index) - position.offset : position.scrollTop;
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
function focus(index) {
|
function focus(index, { scroll = true } = {}) {
|
||||||
if (!Number.isInteger(index) || index < 0 || index >= records.length || disposed) return;
|
if (!Number.isInteger(index) || index < 0 || index >= records.length || disposed) return;
|
||||||
const top = padding + Math.floor(index / columns) * (height + gap);
|
if (scroll) {
|
||||||
if (top < viewport.scrollTop) viewport.scrollTop = top;
|
const top = rowTop(index);
|
||||||
else if (top + height > viewport.scrollTop + viewportHeight) {
|
if (top < viewport.scrollTop) viewport.scrollTop = top;
|
||||||
viewport.scrollTop = top + height - viewportHeight;
|
else if (top + height > viewport.scrollTop + viewportHeight) {
|
||||||
|
viewport.scrollTop = top + height - viewportHeight;
|
||||||
|
}
|
||||||
|
draw();
|
||||||
}
|
}
|
||||||
draw(); mounted.get(index)?.focus({ preventScroll: true });
|
mount(index).focus({ preventScroll: true });
|
||||||
}
|
}
|
||||||
function keydown(event) {
|
function keydown(event) {
|
||||||
const card = event.target.closest("[data-card-index]");
|
const card = event.target.closest("[data-card-index]");
|
||||||
@@ -83,6 +104,7 @@ export function createVirtualCardGrid(viewport, grid, createCard) {
|
|||||||
records = value; mounted.clear(); cached.clear(); grid.replaceChildren();
|
records = value; mounted.clear(); cached.clear(); grid.replaceChildren();
|
||||||
},
|
},
|
||||||
layout,
|
layout,
|
||||||
|
visiblePositions,
|
||||||
focus,
|
focus,
|
||||||
resume() { draw(); },
|
resume() { draw(); },
|
||||||
dispose() {
|
dispose() {
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ const { game } = await import(new URL("noname.js", document.baseURI).href);
|
|||||||
game.saveConfig("shuYing_mengsan_zip_trial", true);
|
game.saveConfig("shuYing_mengsan_zip_trial", true);
|
||||||
```
|
```
|
||||||
|
|
||||||
每包按 5 MiB 的展开数据量分组,压缩包最大 6 MiB。大于展开上限的单文件继续逐个下载。客户端顺序处理同源同标签的附件,已校验并暂存的文件可供本次安装复用。附件缺失或无法使用时,剩余文件从当前标签的 raw 路径补齐。
|
每包按 10 MiB 的展开数据量分组,压缩包最大 11 MiB。大于展开上限的单文件继续逐个下载。客户端顺序处理同源同标签的附件,已校验并暂存的文件可供本次安装复用。附件缺失或无法使用时,剩余文件从当前标签的 raw 路径补齐。
|
||||||
|
|
||||||
Electron 走原生 HTTPS,Cordova 使用 `FileTransfer` 下载一包到当前操作的临时目录,读取前核对大小,处理结束后清理。网页端走 Fetch,附件域不可读时回退。ZIP 解压需要支持 `DecompressionStream("deflate-raw")`,不支持的客户端继续逐文件下载。
|
Electron 走原生 HTTPS,Cordova 使用 `FileTransfer` 下载一包到当前操作的临时目录,读取前核对大小,处理结束后清理。网页端走 Fetch,附件域不可读时回退。ZIP 解压需要支持 `DecompressionStream("deflate-raw")`,不支持的客户端继续逐文件下载。
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
from generate_manifest import validate_relative_paths
|
from generate_manifest import validate_relative_paths
|
||||||
|
|
||||||
MAX_UNCOMPRESSED_BYTES = 5 * 1024**2
|
MAX_UNCOMPRESSED_BYTES = 10 * 1024**2
|
||||||
MAX_ARCHIVE_BYTES = 6 * 1024**2
|
MAX_ARCHIVE_BYTES = MAX_UNCOMPRESSED_BYTES + 1024**2
|
||||||
|
|
||||||
|
|
||||||
def write_part(root: Path, part: Path, files: list[str], manifest: dict) -> None:
|
def write_part(root: Path, part: Path, files: list[str], manifest: dict) -> None:
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ class MengsanArchivesTest(unittest.TestCase):
|
|||||||
}), encoding="utf-8")
|
}), encoding="utf-8")
|
||||||
|
|
||||||
def test_parts_cover_packable_files_once(self):
|
def test_parts_cover_packable_files_once(self):
|
||||||
first = b"a" * (3 * 1024**2)
|
first = b"a" * (10 * 1024**2)
|
||||||
second = b"b" * (3 * 1024**2)
|
second = b"b"
|
||||||
self.write_snapshot({
|
self.write_snapshot({
|
||||||
"mengsan/b": second,
|
"mengsan/b": second,
|
||||||
"mengsan/oversized": b"c" * (5 * 1024**2 + 1),
|
"mengsan/oversized": b"c" * (10 * 1024**2 + 1),
|
||||||
"mengsan/a": first,
|
"mengsan/a": first,
|
||||||
})
|
})
|
||||||
parts = build_archives(self.root, self.output, "v2.0.2.3-rc.8")
|
parts = build_archives(self.root, self.output, "v2.0.2.3-rc.8")
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ function info(text) {
|
|||||||
return { size: Buffer.byteLength(text), sha256: createHash("sha256").update(text).digest("hex") };
|
return { size: Buffer.byteLength(text), sha256: createHash("sha256").update(text).digest("hex") };
|
||||||
}
|
}
|
||||||
|
|
||||||
function zip(files) {
|
function zip(files, compression = "DEFLATE") {
|
||||||
const archive = new JSZip();
|
const archive = new JSZip();
|
||||||
for (const [name, data] of Object.entries(files)) archive.file(name, data);
|
for (const [name, data] of Object.entries(files)) archive.file(name, data);
|
||||||
return archive.generate({ type: "uint8array", compression: "DEFLATE" });
|
return archive.generate({ type: "uint8array", compression });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setup({ source = "github", parts = [zip(assets)], releaseTag = tag,
|
async function setup({ source = "github", contents = assets, parts = [zip(contents)], releaseTag = tag,
|
||||||
draft = false, failWrite = false, record, trial = true, transport = "browser",
|
draft = false, failWrite = false, record, trial = true, transport = "browser",
|
||||||
blocksBrowserAssets = false, canInflate = true, localVersion = version } = {}) {
|
blocksBrowserAssets = false, canInflate = true, localVersion = version } = {}) {
|
||||||
const github = source == "github";
|
const github = source == "github";
|
||||||
@@ -74,7 +74,7 @@ async function setup({ source = "github", parts = [zip(assets)], releaseTag = ta
|
|||||||
files: { "extension.js": info("main") },
|
files: { "extension.js": info("main") },
|
||||||
modules: { mengsan: { entry: moduleEntry, manifest: modulePath } } };
|
modules: { mengsan: { entry: moduleEntry, manifest: modulePath } } };
|
||||||
const moduleManifest = { algorithm: "sha256", module_id: "mengsan", version,
|
const moduleManifest = { algorithm: "sha256", module_id: "mengsan", version,
|
||||||
files: Object.fromEntries(Object.entries(assets).map(([file, content]) => [file, info(content)])) };
|
files: Object.fromEntries(Object.entries(contents).map(([file, content]) => [file, info(content)])) };
|
||||||
const attachments = parts?.map((part, index) => {
|
const attachments = parts?.map((part, index) => {
|
||||||
const name = `mengsan-${tag}-part-${String(index + 1).padStart(3, "0")}.zip`;
|
const name = `mengsan-${tag}-part-${String(index + 1).padStart(3, "0")}.zip`;
|
||||||
const url = `${repository}/releases/download/${tag}/${name}`;
|
const url = `${repository}/releases/download/${tag}/${name}`;
|
||||||
@@ -159,7 +159,7 @@ async function setup({ source = "github", parts = [zip(assets)], releaseTag = ta
|
|||||||
}
|
}
|
||||||
return new Response(part.bytes || part);
|
return new Response(part.bytes || part);
|
||||||
}
|
}
|
||||||
for (const [file, content] of Object.entries({ ...assets, "extension.js": "main" })) {
|
for (const [file, content] of Object.entries({ ...contents, "extension.js": "main" })) {
|
||||||
if (url == raw(file)) return new Response(content);
|
if (url == raw(file)) return new Response(content);
|
||||||
}
|
}
|
||||||
return new Response(null, { status: 404 });
|
return new Response(null, { status: 404 });
|
||||||
@@ -186,7 +186,7 @@ async function setup({ source = "github", parts = [zip(assets)], releaseTag = ta
|
|||||||
await module.link(() => engine);
|
await module.link(() => engine);
|
||||||
await module.evaluate();
|
await module.evaluate();
|
||||||
const shuYing = { text: { style: {}, showPopover() {}, setAttribute() {}, matches: () => false } };
|
const shuYing = { text: { style: {}, showPopover() {}, setAttribute() {}, matches: () => false } };
|
||||||
return { updater: module.namespace.default, shuYing, requests, releaseUrl, raw, attachments, nativeRequests,
|
return { updater: module.namespace.default, shuYing, requests, releaseUrl, raw, attachments, nativeRequests, contents,
|
||||||
writes, config, files, alerts, errors };
|
writes, config, files, alerts, errors };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ async function install(options) {
|
|||||||
function assertInstalled(result) {
|
function assertInstalled(result) {
|
||||||
assert.deepEqual(result.errors, []);
|
assert.deepEqual(result.errors, []);
|
||||||
assert.equal(result.config[recordKey]?.status, "installed", result.alerts.join("\n"));
|
assert.equal(result.config[recordKey]?.status, "installed", result.alerts.join("\n"));
|
||||||
for (const [file, content] of Object.entries(assets)) {
|
for (const [file, content] of Object.entries(result.contents)) {
|
||||||
assert.equal(new TextDecoder().decode(result.files.get(extensionRoot + file)), content);
|
assert.equal(new TextDecoder().decode(result.files.get(extensionRoot + file)), content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,6 @@ for (const [description, options] of Object.entries({
|
|||||||
"draft release": { draft: true },
|
"draft release": { draft: true },
|
||||||
"invalid ZIP": { parts: [new Uint8Array([1, 2, 3])] },
|
"invalid ZIP": { parts: [new Uint8Array([1, 2, 3])] },
|
||||||
"ZIP contains unlisted entries": { parts: [zip({ ...assets, "../unexpected.js": "x" })] },
|
"ZIP contains unlisted entries": { parts: [zip({ ...assets, "../unexpected.js": "x" })] },
|
||||||
"ZIP above the download budget": { parts: [new Uint8Array(6 * 1024**2 + 1)] },
|
|
||||||
"response larger than its attachment metadata": { parts: [{ size: 1, bytes: zip(assets) }] },
|
"response larger than its attachment metadata": { parts: [{ size: 1, bytes: zip(assets) }] },
|
||||||
})) {
|
})) {
|
||||||
test(`uses same-tag raw after ${description}`, async () => {
|
test(`uses same-tag raw after ${description}`, async () => {
|
||||||
@@ -253,6 +252,21 @@ for (const [description, options] of Object.entries({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("stages a ZIP with exactly 10 MiB of content", async () => {
|
||||||
|
const contents = { ...assets, [asset]: "x".repeat(10 * 1024**2 - Buffer.byteLength(assets[moduleEntry])) };
|
||||||
|
const result = await install({ contents, parts: [zip(contents, "STORE")] });
|
||||||
|
assertInstalled(result);
|
||||||
|
assert.ok(result.requests.includes(result.attachments[0].browser_download_url));
|
||||||
|
assert.ok(!result.requests.includes(result.raw(asset)));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("skips a ZIP above the 11 MiB download limit", async () => {
|
||||||
|
const result = await install({ parts: [new Uint8Array(11 * 1024**2 + 1)] });
|
||||||
|
assertInstalled(result);
|
||||||
|
assert.ok(!result.requests.includes(result.attachments[0].browser_download_url));
|
||||||
|
assert.ok(result.requests.includes(result.raw(asset)));
|
||||||
|
});
|
||||||
|
|
||||||
test("a staging storage failure stops the ZIP install without raw retries", async () => {
|
test("a staging storage failure stops the ZIP install without raw retries", async () => {
|
||||||
const result = await install({ failWrite: true });
|
const result = await install({ failWrite: true });
|
||||||
assert.equal(result.config[recordKey]?.status, "disabled");
|
assert.equal(result.config[recordKey]?.status, "disabled");
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ const giteaRepositoryApi = "https://gitea.diuse.work/api/v1/repos/Diuse/noname-s
|
|||||||
const githubRepositoryApi = "https://api.github.com/repos/Shu-Ying/noname-shuying";
|
const githubRepositoryApi = "https://api.github.com/repos/Shu-Ying/noname-shuying";
|
||||||
const githubRawBase = "https://raw.githubusercontent.com/Shu-Ying/noname-shuying";
|
const githubRawBase = "https://raw.githubusercontent.com/Shu-Ying/noname-shuying";
|
||||||
const coreTempDir = "extension/术樱包/.update_tmp";
|
const coreTempDir = "extension/术樱包/.update_tmp";
|
||||||
const mengsanArchiveBytes = 6 * 1024 * 1024;
|
const mengsanUncompressedBytes = 10 * 1024 * 1024;
|
||||||
const mengsanUncompressedBytes = 5 * 1024 * 1024;
|
const mengsanArchiveBytes = mengsanUncompressedBytes + 1024 * 1024;
|
||||||
let fileMutationUncertain = false;
|
let fileMutationUncertain = false;
|
||||||
const verifiedCacheKey = "shuYing_update_verified_files";
|
const verifiedCacheKey = "shuYing_update_verified_files";
|
||||||
const installedManifestKey = "shuYing_update_installation";
|
const installedManifestKey = "shuYing_update_installation";
|
||||||
|
|||||||
Reference in New Issue
Block a user