From 1b4c4e0708692d424a575f0d50c349367ffde09d Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 22 Sep 2026 11:17:48 +0800 Subject: feat(desktop): P28 整图 2px/tile 真实帧取证钩子 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - LV_MAPGEN_FIT_WIDTH/HEIGHT 额外渲染整图到指定像素目标(1024x768 -> 恰 2px/tile) - 仅取证模式触发,不进入正常游戏循环 --- src/LivingVillage.Desktop/Game.fs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs index 591d1b9..824c1c1 100644 --- a/src/LivingVillage.Desktop/Game.fs +++ b/src/LivingVillage.Desktop/Game.fs @@ -296,6 +296,15 @@ type LivingVillageGame() as this = match Environment.GetEnvironmentVariable("LV_MAPGEN_SEED") with | null | "" -> 4242UL | v -> match UInt64.TryParse v with (true, value) -> value | _ -> 4242UL + // P28 证据钩子:额外把整图按指定像素目标渲染一次(用于 1 tile≈2px 的缩放可读性取证)。 + let mapGenFitWidth = + match Environment.GetEnvironmentVariable("LV_MAPGEN_FIT_WIDTH") with + | null | "" -> 0 + | v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 0 + let mapGenFitHeight = + match Environment.GetEnvironmentVariable("LV_MAPGEN_FIT_HEIGHT") with + | null | "" -> 0 + | v -> match Int32.TryParse v with (true, value) when value > 0 -> value | _ -> 0 let mutable mapGenResult = Unchecked.defaultof let mutable mapGenGenMs = 0.0 @@ -891,6 +900,15 @@ type LivingVillageGame() as this = fittedTexture.SaveAsPng(stream, fittedTexture.Width, fittedTexture.Height) printfn "mapgen-fitted drawn=%d png=%dx%d" fittedDrawn fittedTexture.Width fittedTexture.Height + // P28:整图按指定像素目标再渲染一次(真实帧)。1024x768 -> 512x384 图恰为 2px/tile, + // 用于证明两民居变体在「整图 1 tile≈2px」缩放下肉眼可分。 + if mapGenFitWidth > 0 && mapGenFitHeight > 0 then + let fitDrawn, fitTexture = this.RenderMapGen mapGenFitWidth mapGenFitHeight 0 0 true + use _fit = fitTexture + use fitStream = System.IO.File.Create(sprintf "%s/p28-fit-%dx%d-seed%d.png" recordDirectory mapGenFitWidth mapGenFitHeight (int mapGenResult.Seed)) + fitTexture.SaveAsPng(fitStream, mapGenFitWidth, mapGenFitHeight) + printfn "mapgen-fit drawn=%d png=%dx%d" fitDrawn mapGenFitWidth mapGenFitHeight + let clampRange maximum value = max 0 (min (max 0 maximum) value) let camX = clampRange (mapGenResult.Width * Sim.tilePixels - viewport.Width) ((mapGenResult.Width * Sim.tilePixels - viewport.Width) / 2) let camY = clampRange (mapGenResult.Height * Sim.tilePixels - viewport.Height) ((mapGenResult.Height * Sim.tilePixels - viewport.Height) / 2) -- cgit v1.2.3