diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/LivingVillage.Desktop/Game.fs | 17 |
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 |
