From 000a0b00384806ce85d54dfcd2646cb340a26f01 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 12:58:12 +0800 Subject: test(desktop): LV_AUTOPLAY_RECORD 情境提示采帧 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LV_AUTOPLAY_RECORD=1 且样例模式下每 25 帧经 GetBackBufferData 保存 PNG 到 /tmp/lv-p5-prompt/,用于靠近→提示→交互→关闭→离开片段取证;仅记录模式触发,不影响普通运行路径。 --- src/LivingVillage.Desktop/Game.fs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/LivingVillage.Desktop') 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 (width * height) + this.GraphicsDevice.GetBackBufferData(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 -- cgit v1.2.3