SHA256
80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
using System;
|
|
using ADOFAIRenderer.Core;
|
|
using ADOFAIRenderer.Data;
|
|
|
|
namespace ADOFAIRenderer.API;
|
|
|
|
/// <summary>
|
|
/// Fluent builder for configuring and starting a render session.
|
|
/// </summary>
|
|
public class RenderSession
|
|
{
|
|
private bool _auto = true;
|
|
|
|
/// <summary>
|
|
/// Specifies the types of patches that can be configured for a render session.
|
|
/// </summary>
|
|
public enum PatchType
|
|
{
|
|
/// <summary>
|
|
/// Time-related patch controlling frame timing and clock synchronization.
|
|
/// </summary>
|
|
Time,
|
|
|
|
/// <summary>
|
|
/// Screen-related patch controlling screen resolution.
|
|
/// </summary>
|
|
Screen
|
|
}
|
|
|
|
private bool _timePatch = true;
|
|
private bool _screenPatch = true;
|
|
|
|
/// <summary>
|
|
/// Sets whether automatic rendering is enabled.
|
|
/// </summary>
|
|
/// <param name="enabled"><c>true</c> to enable automatic rendering; otherwise, <c>false</c>. Default is <c>true</c>.</param>
|
|
/// <returns>The current <see cref="RenderSession"/> instance for method chaining.</returns>
|
|
public RenderSession WithAuto(bool enabled = true)
|
|
{
|
|
_auto = enabled;
|
|
return this;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets whether a specific patch type is enabled for the render session.
|
|
/// </summary>
|
|
/// <param name="patchType">The <see cref="PatchType"/> to configure.</param>
|
|
/// <param name="enabled"><c>true</c> to enable the specified patch; otherwise, <c>false</c>. Default is <c>true</c>.</param>
|
|
/// <returns>The current <see cref="RenderSession"/> instance for method chaining.</returns>
|
|
/// <exception cref="ArgumentOutOfRangeException">Thrown when an unsupported <see cref="PatchType"/> is provided.</exception>
|
|
public RenderSession WithPatch(PatchType patchType, bool enabled = true)
|
|
{
|
|
switch (patchType)
|
|
{
|
|
case PatchType.Time: _timePatch = enabled; break;
|
|
case PatchType.Screen: _screenPatch = enabled; break;
|
|
default: throw new ArgumentOutOfRangeException(nameof(patchType), patchType, null);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Applies the configured flags and initiates the render session.
|
|
/// </summary>
|
|
/// <param name="renderConfig">The configuration settings for the render session.</param>
|
|
/// <param name="levelPath">The file path of the level to render.</param>
|
|
public void Start(RenderConfig renderConfig, string levelPath)
|
|
{
|
|
RenderContext.Auto = _auto;
|
|
RenderContext.TimePatch = _timePatch;
|
|
RenderContext.ScreenPatch = _screenPatch;
|
|
|
|
RenderManager.Instance.levelPath = levelPath;
|
|
RenderManager.Instance.Configuration = renderConfig;
|
|
|
|
RenderManager.Instance.SetupCaptureDirectory();
|
|
RenderManager.Instance.SetupGameScene();
|
|
}
|
|
} |