summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-22 11:17:48 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-22 11:17:48 +0800
commit1b4c4e0708692d424a575f0d50c349367ffde09d (patch)
treea9a08789161b90fd52666828b6b9ac6abe30aebb /src/LivingVillage.Desktop
parent26afb04feb9a7bec3162eccf64f1df04bfda4def (diff)
downloadliving-village-1b4c4e0708692d424a575f0d50c349367ffde09d.tar.gz
feat(desktop): P28 整图 2px/tile 真实帧取证钩子
- LV_MAPGEN_FIT_WIDTH/HEIGHT 额外渲染整图到指定像素目标(1024x768 -> 恰 2px/tile) - 仅取证模式触发,不进入正常游戏循环
Diffstat (limited to 'src/LivingVillage.Desktop')
-rw-r--r--src/LivingVillage.Desktop/Game.fs18
1 files changed, 18 insertions, 0 deletions
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<MapGen.Result>
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)