From bdc8b4abb0920e292b3004693f98c27669e2c4c15aae3ddf072a6d98d6182d4b Mon Sep 17 00:00:00 2001 From: copecone Date: Tue, 18 Aug 2026 11:02:08 +0900 Subject: [PATCH] Add Custom Output Path API --- API/RenderSession.cs | 6 ++++-- Core/RenderManager.cs | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/API/RenderSession.cs b/API/RenderSession.cs index 84ef6e0..d5ebd4a 100644 --- a/API/RenderSession.cs +++ b/API/RenderSession.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using ADOFAIRenderer.Core; using ADOFAIRenderer.Data; using ADOFAIRenderer.Util; @@ -32,7 +33,7 @@ public class RenderSession private bool _screenPatch = true; private Func _endCondition = () => scrController.instance.state == States.Won; - private string? _outputPath = null; + private string? _outputPath; /// /// Sets whether auto mode is enabled. @@ -92,6 +93,7 @@ public class RenderSession RenderContext.TimePatch = _timePatch; RenderContext.ScreenPatch = _screenPatch; RenderContext.EndCondition = _endCondition; + RenderContext.OutputPath = _outputPath; RenderManager.Instance.levelPath = levelPath; RenderManager.Instance.Configuration = renderConfig; @@ -99,7 +101,7 @@ public class RenderSession RenderManager.Instance.StartLoadingOverride(); if (_outputPath is null) RenderManager.Instance.SetupCaptureDirectory(); - else FileUtil.CreateDirectory(_outputPath); + else FileUtil.CreateDirectory(Path.GetDirectoryName(_outputPath) ?? throw new InvalidOperationException()); RenderManager.Instance.SetupGameScene(); } diff --git a/Core/RenderManager.cs b/Core/RenderManager.cs index 1b65f9e..bc8dc67 100644 --- a/Core/RenderManager.cs +++ b/Core/RenderManager.cs @@ -27,12 +27,14 @@ namespace ADOFAIRenderer.Core public static bool TimePatch = true; public static bool ScreenPatch = true; public static Func EndCondition = () => scrController.instance.state == States.Won; + public static string? OutputPath; public static void Reset() { Auto = true; TimePatch = true; ScreenPatch = true; EndCondition = () => scrController.instance.state == States.Won; + OutputPath = null; } } @@ -411,7 +413,7 @@ namespace ADOFAIRenderer.Core private IEnumerator SetupPlay() { - if (Configuration.AudioConfig.RenderAudio && GetOutputExtension(Configuration.VideoConfig.Codec) != ".mp4") + if (Configuration.AudioConfig.RenderAudio && Configuration.VideoConfig.Codec is Codec.VP9 or Codec.AV1 or Codec.VVC) { Configuration.AudioConfig.AudioSampleRate = 48000; } @@ -506,11 +508,13 @@ namespace ADOFAIRenderer.Core var fileName = startTime.ToString("yyyy-MM-dd HH-mm-ss") + ext; _currentOutPath = Path.Combine(MelonEnvironment.GameRootDirectory, "Render", fileName); + if (RenderContext.OutputPath != null) _currentOutPath = RenderContext.OutputPath; + FFmpegNativeEncoder? videoFFmpeg = null; try { var effectiveVideoFps = Math.Min(videoFPS, renderFPS); - var codecId = GetAudioCodecId(ext); + var codecId = AudioCodecMatch[Configuration.VideoConfig.Codec]; var settings = new FFmpegNativeEncoder.EncoderSettings { Width = Configuration.RenderWidth,