diff --git a/.gitignore b/.gitignore index 7721943..ac73146 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ tools/*.mjs !/tools/test_mengsan_zip_install.mjs !/mengsan/tools/test-hud-status.cjs !/mengsan/tools/test-battle-hud.cjs +!/mengsan/tools/test-journey-ui-zoom.cjs !/mengsan/tools/import-status-icons.cjs /.update_tmp/ diff --git a/docs/reviews/mengsan-battle-ui.md b/docs/reviews/mengsan-battle-ui.md index 74c97c6..b80403a 100644 --- a/docs/reviews/mengsan-battle-ui.md +++ b/docs/reviews/mengsan-battle-ui.md @@ -5,6 +5,7 @@ | 场景 | 操作与通过标准 | | --- | --- | | 触屏拖牌与目标连线 | 从手牌拖出一张【杀】并移动到可选敌人。线起点贴在拖动牌上缘中央,终点跟随触点,两端误差各不超过 2 CSS px。取消手势后线立即消失。对合法目标松手后拖线立即消失,原生提交只触发一次。完整对局中再检查提交后的出牌特效能指向实际目标。 | +| 普通出牌布局与缩放 | 在主动出牌阶段检查手牌扇面、提示语和「确定/回合结束」按钮组。三者共用战场中线,误差不超过 2 CSS px。改变界面缩放后重新检查对齐和拖牌线两端。 | | 出牌响应布局与按钮交互 | 敌人出【杀】,选择【闪】,观察场上出牌副本、响应文字与「确定/取消」两键的整体边界。三者从上到下共用战场中线,横向中心误差不超过 2 CSS px,牌面、提示、按钮和选中手牌之间有可见间距。确认和取消分别可点击,响应结束后场上的牌恢复原生位置。 | | 弃牌时技能栏稳定 | 启用十周年 UI,进入需弃置两张手牌的场景并点选第一张。技能栏在重建的首帧起就不出现重复的药水按钮,普通技能仍可见,弃牌计数正常更新。 | | 战斗药水槽与计数信息 | 持有药水进入战斗。药水槽位于左上区域,可贴近轮数、时间及牌堆数量控件,各自的可见区域互不重叠。点按药水可打开详情,并能在可用阶段正常使用。 | @@ -18,8 +19,10 @@ $env:HUD_REVIEW = '1' node mengsan/tools/test-battle-hud.cjs ``` -需要截图时,将 `HUD_ARTIFACTS` 指向已建立的临时目录。完整矩阵覆盖原生 UI、十周年 UI 的手杀、十周年和新杀风格,以及 1080×486、812×375、667×375,含 0.64 页面缩放和非整数像素比。各场景检查拖牌、出牌连线、响应和药水槽位置,启用十周年 UI 的场景另测弃牌时的技能栏重建。 +需要截图时,将 `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)。 diff --git a/docs/reviews/mengsan-ui-zoom.md b/docs/reviews/mengsan-ui-zoom.md new file mode 100644 index 0000000..188c31a --- /dev/null +++ b/docs/reviews/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 风格,在常用倍率和一个较高倍率下复核受影响的操作。优先确认触屏地图滚动、剧情分支点按、较长内容滑动和弹窗关闭。报告逐项标注通过、失败或未验。 diff --git a/extension.js b/extension.js index c9e19cd..2244b16 100644 --- a/extension.js +++ b/extension.js @@ -6,7 +6,7 @@ import { configureDiagnostics } from "./diagnostics/index.js"; export const type = "extension"; export let shuYing = new Object(); -const shuYingLocalVersion = "2.0.2.3-rc.10"; +const shuYingLocalVersion = "2.0.2.3-rc.11"; shuYing.name = "术樱包"; shuYing.editable = false; diff --git a/mengsan/tools/test-battle-hud.cjs b/mengsan/tools/test-battle-hud.cjs index eb81c9e..c90d66d 100644 --- a/mengsan/tools/test-battle-hud.cjs +++ b/mengsan/tools/test-battle-hud.cjs @@ -9,6 +9,7 @@ const { chromium } = require(packages ? path.join(packages, 'playwright') : 'pla 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 box = await locator.boundingBox(); const point = {x:box.x + box.width / 2,y:box.y + box.height / 2}; @@ -46,6 +47,18 @@ async function checkMobileTargetLine(page, artifact) { 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(); @@ -61,6 +74,7 @@ async function checkMobileTargetLine(page, artifact) { 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'); @@ -78,6 +92,46 @@ async function checkMobileTargetLine(page, artifact) { 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'); @@ -86,11 +140,12 @@ async function checkCommittedLine(page, skin) { 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:() => { + engine.setUI({arena,create:{div:selector => { const node = document.createElement('div'); - node.className = 'linexy hidden'; + 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; @@ -102,7 +157,7 @@ async function checkCommittedLine(page, skin) { 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)}}; + window.decadeUI ??= {boundsCaches:{hand:new BoundsCache(hand)}}; actor.checkBoundsCache = target.checkBoundsCache = function() { this.cacheLeft = this.offsetLeft; this.cacheTop = this.offsetTop; @@ -124,11 +179,30 @@ async function checkCommittedLine(page, skin) { 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) { @@ -333,15 +407,16 @@ async function checkMobileResponseLayout(page, skin, artifact) { const restored = await page.evaluate(() => { delete hudEventState.event.respondTo; hud.refresh(); - return ui.control.style.translate === '' && reviewResponse.card.style.translate === ''; + 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 = `
测试技能
结束出牌
`; -const importMap = reviewOnly ? fs.readFileSync(path.join(app,'index.html'),'utf8').match(/