From d4cd19d96c3b672ae82cad07f833034605c73473 Mon Sep 17 00:00:00 2001 From: troytt <47798984@qq.com> Date: Mon, 28 Sep 2026 09:14:47 +0000 Subject: [PATCH] fix(frontend): load full 34-frame /ui/cursor.png atlas and render Loadingscreen.dc6 at 1.13c 256x256 centered size --- src/frontend/bnet-main.ts | 2 +- src/frontend/frontend-renderer.ts | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/frontend/bnet-main.ts b/src/frontend/bnet-main.ts index 7c5c1bd..c0ffefb 100644 --- a/src/frontend/bnet-main.ts +++ b/src/frontend/bnet-main.ts @@ -88,7 +88,7 @@ async function main(): Promise { await renderer.load('/ui/frontend') // Bind mouse & keyboard events onto the 800x600 front-end canvas - canvas.addEventListener('mousemove', (e) => { + window.addEventListener('mousemove', (e) => { if (state.stage === 'in_game') return const pt = renderer.eventToCanvasCoords(e) renderer.handleMouseMove(pt.x, pt.y, performance.now()) diff --git a/src/frontend/frontend-renderer.ts b/src/frontend/frontend-renderer.ts index 25a1715..7e6dd33 100644 --- a/src/frontend/frontend-renderer.ts +++ b/src/frontend/frontend-renderer.ts @@ -289,7 +289,7 @@ export class FrontendRenderer { } } - // Load cursor-hand.png + // Load full 34-frame cursor atlas (/ui/cursor.png, 256x176: protate, ohand, orotate, buysell) promises.push( new Promise((resolve) => { const img = new Image() @@ -298,7 +298,7 @@ export class FrontendRenderer { resolve() } img.onerror = () => resolve() - img.src = '/ui/cursor-hand.png' + img.src = '/ui/cursor.png' }), ) @@ -1513,8 +1513,15 @@ export class FrontendRenderer { if (!img) return const idx = Math.max(0, Math.min(doorStrip.frames.length - 1, this.state.doorFrame)) const f = doorStrip.frames[idx]! - // Center the 640x480 door loading frame in the 800x600 canvas at (80, 60) (or scale 800x600) - ctx.drawImage(img, f.x, f.y, f.w, f.h, 80, 60, 640, 480) + // Per D2Client.dll 0x6fb71935..0x6fb71971: + // Loadingscreen.dc6 is 256x256 (0x100x0x100), drawn 1:1 centered at: + // x = (screenW / 2) - 0x80 = 400 - 128 = 272 + // y_bottom = (screenH / 2) + 0x80 = 300 + 128 = 428 -> y_top = 428 - 256 = 172 + const drawW = f.w + const drawH = f.h + const drawX = Math.floor((800 - drawW) / 2) + const drawY = Math.floor((600 - drawH) / 2) + ctx.drawImage(img, f.x, f.y, f.w, f.h, drawX, drawY, drawW, drawH) } /** @@ -1526,8 +1533,8 @@ export class FrontendRenderer { const x = ((e.clientX - rect.left) / rect.width) * 800 const y = ((e.clientY - rect.top) / rect.height) * 600 return { - x: Math.max(0, Math.min(800, x)), - y: Math.max(0, Math.min(600, y)), + x: Math.max(0, Math.min(792, x)), + y: Math.max(0, Math.min(592, y)), } }