summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 12:58:12 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 12:58:12 +0800
commit000a0b00384806ce85d54dfcd2646cb340a26f01 (patch)
tree0ef1cb8b79758000c2b181e879e73809ed448da8
parent12616f1d67d936a542e1e22926fb0ebcd4108906 (diff)
downloadliving-village-000a0b00384806ce85d54dfcd2646cb340a26f01.tar.gz
test(desktop): LV_AUTOPLAY_RECORD 情境提示采帧
LV_AUTOPLAY_RECORD=1 且样例模式下每 25 帧经 GetBackBufferData 保存 PNG 到 /tmp/lv-p5-prompt/,用于靠近→提示→交互→关闭→离开片段取证;仅记录模式触发,不影响普通运行路径。
-rw-r--r--src/LivingVillage.Desktop/Game.fs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs
index 1db5c3d..1d50f3d 100644
--- a/src/LivingVillage.Desktop/Game.fs
+++ b/src/LivingVillage.Desktop/Game.fs
@@ -147,6 +147,8 @@ type LivingVillageGame() as this =
let mutable hudStatus = ""
let mutable hudStatusAt = 0L
let mutable pauseHelpControl: SimulationControl option = None
+ let recordMode = Environment.GetEnvironmentVariable("LV_AUTOPLAY_RECORD") = "1"
+ let mutable recordIndex = 0
do
graphics.PreferredBackBufferWidth <- 1280
@@ -530,6 +532,21 @@ type LivingVillageGame() as this =
this.DrawM5Overlay()
else
this.DrawWorldView()
+ if recordMode && sampleMode then
+ recordIndex <- recordIndex + 1
+ if recordIndex % 25 = 0 then
+ let directory = "/tmp/lv-p5-prompt"
+ System.IO.Directory.CreateDirectory directory |> ignore
+ let width, height =
+ this.GraphicsDevice.PresentationParameters.BackBufferWidth,
+ this.GraphicsDevice.PresentationParameters.BackBufferHeight
+ let buffer = Array.zeroCreate<Color> (width * height)
+ this.GraphicsDevice.GetBackBufferData<Color>(buffer)
+ use texture = new Texture2D(this.GraphicsDevice, width, height)
+ texture.SetData(buffer)
+ let path = sprintf "%s/rec-frame-%04d.png" directory recordIndex
+ use stream = System.IO.File.Create(path)
+ texture.SaveAsPng(stream, width, height)
member private this.DrawMenu() =
let viewport = this.GraphicsDevice.Viewport