diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 00:26:05 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 00:26:05 +0800 |
| commit | 81a84f9f86d59387a349caa339148c7a7a6d1e72 (patch) | |
| tree | caa7f9209f5337f23e5961920e3b06a69368930a /src/LivingVillage.Desktop | |
| parent | f9e77256f9b8d3bd35a0cbe732af49d283930a5d (diff) | |
| download | living-village-81a84f9f86d59387a349caa339148c7a7a6d1e72.tar.gz | |
feat(desktop): P16-FIX 开始界面截图模式(LV_AUTOPLAY_MENU_SHOT)+ 真实菜单证据补拍
Diffstat (limited to 'src/LivingVillage.Desktop')
| -rw-r--r-- | src/LivingVillage.Desktop/Game.fs | 53 | ||||
| -rw-r--r-- | src/LivingVillage.Desktop/LaunchScreen.fs | 15 |
2 files changed, 56 insertions, 12 deletions
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs index 3bb43f8..3f3a1d8 100644 --- a/src/LivingVillage.Desktop/Game.fs +++ b/src/LivingVillage.Desktop/Game.fs @@ -97,6 +97,7 @@ type LivingVillageGame() as this = let autoplay = (Environment.GetEnvironmentVariable("LV_AUTOPLAY") = "1") || (Environment.GetEnvironmentVariable("LV_MAP_TOUR") = "1") let autoplayFlow = Environment.GetEnvironmentVariable("LV_AUTOPLAY_FLOW") = "1" let sampleMode = Environment.GetEnvironmentVariable("LV_AUTOPLAY_SAMPLE") = "1" + let menuShotMode = Environment.GetEnvironmentVariable("LV_AUTOPLAY_MENU_SHOT") = "1" let daylightAutoplay = Environment.GetEnvironmentVariable("LV_AUTOPLAY_DAYLIGHT") = "1" let automated = autoplay || autoplayFlow let modeName = @@ -143,6 +144,7 @@ type LivingVillageGame() as this = let mutable splashActive = true let mutable splashFrame = 0L let mutable menuEntranceFrame = 0L + let mutable menuShotFrame = 0L let mutable autoplayFrames = 0 let mutable flowStep = 0 let mutable flowHold = 0 @@ -316,6 +318,12 @@ type LivingVillageGame() as this = printfn (if nextState.TimedOut then "sample result=timeout" else "sample result=ok") this.Exit() + /// P16-FIX:菜单截图模式。停在开始界面,按确定性帧表向下切到「读档」,帧表见 MenuShotScript。 + member private this.RunMenuShot () = + menuShotFrame <- menuShotFrame + 1L + if menuShotFrame = MenuShotScript.downFrame then + this.DispatchMenuInput Down + member private this.RunMapTour () = let (tileX, tileY) = tourWaypoints.[tourIndex % tourWaypoints.Length] let position : Vec2 = @@ -542,6 +550,8 @@ type LivingVillageGame() as this = this.RunAutoplayFlow() elif menu.Page = Playing then this.UpdatePlaying gameTime kb pressed pressedAny + elif menuShotMode then + this.RunMenuShot() else this.UpdateMenu pressed if menu.Page <> Playing then @@ -605,6 +615,33 @@ type LivingVillageGame() as this = | None -> () spriteBatch.End() + /// 将当前后台缓冲存为 PNG(取证用;record 与菜单截图共用)。 + member private this.SaveBackBuffer (path: string) = + let width = this.GraphicsDevice.PresentationParameters.BackBufferWidth + let height = 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) + use stream = System.IO.File.Create(path) + texture.SaveAsPng(stream, width, height) + + /// P16-FIX:按 MenuShotScript 帧表落菜单/启动画面截图,拍完即退出。 + member private this.CaptureMenuShot () = + let save name = + System.IO.Directory.CreateDirectory recordDirectory |> ignore + this.SaveBackBuffer(sprintf "%s/%s.png" recordDirectory name) + if splashActive then + if splashFrame = MenuShotScript.splashMidFrame then + save MenuShotScript.splashMidName + elif menuShotFrame = MenuShotScript.initialFrame then + save MenuShotScript.initialName + elif menuShotFrame = MenuShotScript.loadFrame then + save MenuShotScript.loadName + elif menuShotFrame = MenuShotScript.exitFrame then + printfn "menu-shot=done frames=%d" menuShotFrame + this.Exit() + override this.Draw(gameTime: GameTime) = if splashActive then this.DrawSplash() @@ -618,18 +655,10 @@ type LivingVillageGame() as this = if recordMode && sampleMode then recordIndex <- recordIndex + 1 if recordIndex % recordEvery = 0 then - let directory = recordDirectory - 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) + System.IO.Directory.CreateDirectory recordDirectory |> ignore + this.SaveBackBuffer(sprintf "%s/rec-frame-%04d.png" recordDirectory recordIndex) + if menuShotMode then + this.CaptureMenuShot() /// 启动画面:分层天色 + 屋脊/水面剪影 + 标题淡入上浮 + 跳过提示,全部为帧计数纯函数。 member private this.DrawSplash() = diff --git a/src/LivingVillage.Desktop/LaunchScreen.fs b/src/LivingVillage.Desktop/LaunchScreen.fs index 0977777..0fecc6d 100644 --- a/src/LivingVillage.Desktop/LaunchScreen.fs +++ b/src/LivingVillage.Desktop/LaunchScreen.fs @@ -30,3 +30,18 @@ module LaunchScreen = /// Esc 或 空格 触发跳过(调用方用“按下沿”结果,不做按键状态判定)。 let skipRequested (escapePressed: bool) (spacePressed: bool) : bool = escapePressed || spacePressed + +/// P16-FIX 证据补拍:开始界面菜单截图的确定性帧表(纯数据,Game 与回归测试共用)。 +/// 帧号均为 60Hz Update 计数:splash 淡入中 -> 菜单入场完成(初始高亮「开始」)-> 向下 +/// -> 高亮「读档」-> 退出。输出文件名不含目录与扩展名。 +module MenuShotScript = + + let splashMidName = "frame-splash-mid-01" + let initialName = "menu-real-initial" + let loadName = "menu-real-load" + + let splashMidFrame = 30L + let initialFrame = 130L + let downFrame = 140L + let loadFrame = 150L + let exitFrame = 170L |
