From 2a5ceb4889beb85ee9f675c8b194f833226daf0d45ac5406e806a38d061c4463 Mon Sep 17 00:00:00 2001 From: copecone Date: Tue, 18 Aug 2026 11:02:08 +0900 Subject: [PATCH] Add `RenderSession.WithOutputPath` --- API/RenderSession.cs | 21 ++++++++++++++++----- Core/RenderManager.cs | 5 +---- RenderMod.cs | 2 +- Util/FileUtil.cs | 11 ++++++++--- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/API/RenderSession.cs b/API/RenderSession.cs index 3cf321f..84ef6e0 100644 --- a/API/RenderSession.cs +++ b/API/RenderSession.cs @@ -1,6 +1,7 @@ using System; using ADOFAIRenderer.Core; using ADOFAIRenderer.Data; +using ADOFAIRenderer.Util; namespace ADOFAIRenderer.API; @@ -29,13 +30,14 @@ public class RenderSession private bool _timePatch = true; private bool _screenPatch = true; - - private static Func _endCondition = () => scrController.instance.state == States.Won; + private Func _endCondition = () => scrController.instance.state == States.Won; + + private string? _outputPath = null; /// - /// Sets whether automatic rendering is enabled. + /// Sets whether auto mode is enabled. /// - /// true to enable automatic rendering; otherwise, false. Default is true. + /// true to enable auto mode; otherwise, false. Default is true. /// The current instance for method chaining. public RenderSession WithAuto(bool enabled = true) { @@ -73,6 +75,12 @@ public class RenderSession return this; } + public RenderSession WithOutputPath(string? outputPath) + { + _outputPath = outputPath; + return this; + } + /// /// Applies the configured flags and initiates the render session. /// @@ -89,7 +97,10 @@ public class RenderSession RenderManager.Instance.Configuration = renderConfig; RenderManager.Instance.StartLoadingOverride(); - RenderManager.Instance.SetupCaptureDirectory(); + + if (_outputPath is null) RenderManager.Instance.SetupCaptureDirectory(); + else FileUtil.CreateDirectory(_outputPath); + RenderManager.Instance.SetupGameScene(); } } \ No newline at end of file diff --git a/Core/RenderManager.cs b/Core/RenderManager.cs index 4b849c3..1b65f9e 100644 --- a/Core/RenderManager.cs +++ b/Core/RenderManager.cs @@ -392,10 +392,7 @@ namespace ADOFAIRenderer.Core public void SetupCaptureDirectory() { var renderDir = Path.Combine(MelonEnvironment.GameRootDirectory, "Render"); - if (!Directory.Exists(renderDir)) - { - Directory.CreateDirectory(renderDir); - } + FileUtil.CreateDirectory(renderDir); } public void SetupGameScene() diff --git a/RenderMod.cs b/RenderMod.cs index cc7f0a2..593aaa5 100644 --- a/RenderMod.cs +++ b/RenderMod.cs @@ -58,7 +58,7 @@ namespace ADOFAIRenderer if (EventSystem.current == null) return; var currentModule = EventSystem.current.currentInputModule; - if (currentModule != null) return; + if (currentModule) return; Melon.Logger.Msg("Unity 6 인풋 모듈 이식."); var newModule = EventSystem.current.gameObject.AddComponent(); diff --git a/Util/FileUtil.cs b/Util/FileUtil.cs index 4081c8f..cca31c6 100644 --- a/Util/FileUtil.cs +++ b/Util/FileUtil.cs @@ -1,6 +1,11 @@ -namespace ADOFAIRenderer.Util; +using System.IO; -public class FileUtil +namespace ADOFAIRenderer.Util; + +internal static class FileUtil { - + public static void CreateDirectory(string path) + { + if (!Directory.Exists(path)) Directory.CreateDirectory(path); + } } \ No newline at end of file