SHA256
Add Custom Output Path API
This commit is contained in:
1 parent
2a5ceb4889
commit
bdc8b4abb0
2 files changed
+10
-4
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using ADOFAIRenderer.Core;
|
using ADOFAIRenderer.Core;
|
||||||
using ADOFAIRenderer.Data;
|
using ADOFAIRenderer.Data;
|
||||||
using ADOFAIRenderer.Util;
|
using ADOFAIRenderer.Util;
|
||||||
@@ -32,7 +33,7 @@ public class RenderSession
|
|||||||
private bool _screenPatch = true;
|
private bool _screenPatch = true;
|
||||||
private Func<bool> _endCondition = () => scrController.instance.state == States.Won;
|
private Func<bool> _endCondition = () => scrController.instance.state == States.Won;
|
||||||
|
|
||||||
private string? _outputPath = null;
|
private string? _outputPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets whether auto mode is enabled.
|
/// Sets whether auto mode is enabled.
|
||||||
@@ -92,6 +93,7 @@ public class RenderSession
|
|||||||
RenderContext.TimePatch = _timePatch;
|
RenderContext.TimePatch = _timePatch;
|
||||||
RenderContext.ScreenPatch = _screenPatch;
|
RenderContext.ScreenPatch = _screenPatch;
|
||||||
RenderContext.EndCondition = _endCondition;
|
RenderContext.EndCondition = _endCondition;
|
||||||
|
RenderContext.OutputPath = _outputPath;
|
||||||
|
|
||||||
RenderManager.Instance.levelPath = levelPath;
|
RenderManager.Instance.levelPath = levelPath;
|
||||||
RenderManager.Instance.Configuration = renderConfig;
|
RenderManager.Instance.Configuration = renderConfig;
|
||||||
@@ -99,7 +101,7 @@ public class RenderSession
|
|||||||
RenderManager.Instance.StartLoadingOverride();
|
RenderManager.Instance.StartLoadingOverride();
|
||||||
|
|
||||||
if (_outputPath is null) RenderManager.Instance.SetupCaptureDirectory();
|
if (_outputPath is null) RenderManager.Instance.SetupCaptureDirectory();
|
||||||
else FileUtil.CreateDirectory(_outputPath);
|
else FileUtil.CreateDirectory(Path.GetDirectoryName(_outputPath) ?? throw new InvalidOperationException());
|
||||||
|
|
||||||
RenderManager.Instance.SetupGameScene();
|
RenderManager.Instance.SetupGameScene();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ namespace ADOFAIRenderer.Core
|
|||||||
public static bool TimePatch = true;
|
public static bool TimePatch = true;
|
||||||
public static bool ScreenPatch = true;
|
public static bool ScreenPatch = true;
|
||||||
public static Func<bool> EndCondition = () => scrController.instance.state == States.Won;
|
public static Func<bool> EndCondition = () => scrController.instance.state == States.Won;
|
||||||
|
public static string? OutputPath;
|
||||||
|
|
||||||
public static void Reset()
|
public static void Reset()
|
||||||
{
|
{
|
||||||
Auto = true;
|
Auto = true;
|
||||||
TimePatch = true; ScreenPatch = true;
|
TimePatch = true; ScreenPatch = true;
|
||||||
EndCondition = () => scrController.instance.state == States.Won;
|
EndCondition = () => scrController.instance.state == States.Won;
|
||||||
|
OutputPath = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,7 +413,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
|
|
||||||
private IEnumerator SetupPlay()
|
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;
|
Configuration.AudioConfig.AudioSampleRate = 48000;
|
||||||
}
|
}
|
||||||
@@ -506,11 +508,13 @@ namespace ADOFAIRenderer.Core
|
|||||||
var fileName = startTime.ToString("yyyy-MM-dd HH-mm-ss") + ext;
|
var fileName = startTime.ToString("yyyy-MM-dd HH-mm-ss") + ext;
|
||||||
_currentOutPath = Path.Combine(MelonEnvironment.GameRootDirectory, "Render", fileName);
|
_currentOutPath = Path.Combine(MelonEnvironment.GameRootDirectory, "Render", fileName);
|
||||||
|
|
||||||
|
if (RenderContext.OutputPath != null) _currentOutPath = RenderContext.OutputPath;
|
||||||
|
|
||||||
FFmpegNativeEncoder? videoFFmpeg = null;
|
FFmpegNativeEncoder? videoFFmpeg = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var effectiveVideoFps = Math.Min(videoFPS, renderFPS);
|
var effectiveVideoFps = Math.Min(videoFPS, renderFPS);
|
||||||
var codecId = GetAudioCodecId(ext);
|
var codecId = AudioCodecMatch[Configuration.VideoConfig.Codec];
|
||||||
var settings = new FFmpegNativeEncoder.EncoderSettings
|
var settings = new FFmpegNativeEncoder.EncoderSettings
|
||||||
{
|
{
|
||||||
Width = Configuration.RenderWidth,
|
Width = Configuration.RenderWidth,
|
||||||
|
|||||||
Reference in new issue
Block a user