SHA256
70 lines
2.9 KiB
C#
70 lines
2.9 KiB
C#
using System;
|
|
using ADOFAIRenderer;
|
|
using ADOFAIRenderer.Core;
|
|
using ADOFAIRenderer.Core.Data;
|
|
using ADOFAIRenderer.UI;
|
|
using FFmpeg.AutoGen;
|
|
using MelonLoader;
|
|
using MelonLoader.Utils;
|
|
using UnityEngine;
|
|
using Object = UnityEngine.Object;
|
|
|
|
[assembly: MelonInfo(typeof(RenderMod), "ADOFAI Renderer", "0.3.1-INDEV", "ADOFAI Editor Forum")]
|
|
[assembly: MelonGame("7th Beat Games", "A Dance of Fire and Ice")]
|
|
|
|
namespace ADOFAIRenderer;
|
|
|
|
/// <summary>
|
|
/// MelonLoader entry point of the mod. Loads the settings and localization, points FFmpeg.AutoGen at the native
|
|
/// FFmpeg libraries, and creates the persistent manager objects (RenderManager, FirstUpdateHook, RendererUIManager).
|
|
/// </summary>
|
|
internal class RenderMod : MelonMod
|
|
{
|
|
/// <summary>
|
|
/// When true, the render button is not added to the level editor (scnEditorPatch checks it in scnEditor.Start).
|
|
/// Set by the user from the NVIDIA driver warning dialog (FirstUpdateHook). Main thread only.
|
|
/// </summary>
|
|
// ReSharper disable once MemberCanBePrivate.Global
|
|
public static bool IsFeatureDisabled = false;
|
|
|
|
/// <summary>
|
|
/// Expiration time of this build (UTC). After it, the render configuration window shows an "expired" note next to
|
|
/// the version text. It does not block rendering.
|
|
/// </summary>
|
|
public static DateTime ExpirationTime = new(2026, 11, 21, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
/// <summary>
|
|
/// Called once by MelonLoader after the mod assembly is loaded.
|
|
/// The native FFmpeg libraries are loaded from MelonLoader's UserLibs directory.
|
|
/// The three manager GameObjects are marked DontDestroyOnLoad so they survive scene changes.
|
|
/// </summary>
|
|
public override void OnInitializeMelon()
|
|
{
|
|
GlobalSettings.Load();
|
|
Localization.LocalizationManager.Initialize();
|
|
ffmpeg.RootPath = MelonEnvironment.UserLibsDirectory;
|
|
|
|
var renderManagerObj = new GameObject("Render Manager");
|
|
var updateHookerObj = new GameObject("Update Hooker");
|
|
var uiManagerObj = new GameObject("Renderer UI Manager");
|
|
Object.DontDestroyOnLoad(renderManagerObj);
|
|
Object.DontDestroyOnLoad(updateHookerObj);
|
|
Object.DontDestroyOnLoad(uiManagerObj);
|
|
|
|
renderManagerObj.AddComponent<RenderManager>();
|
|
updateHookerObj.AddComponent<FirstUpdateHook>();
|
|
uiManagerObj.AddComponent<RendererUIManager>();
|
|
ModAssets.Load();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called by MelonLoader when the game quits. Aborts an active render (encoders disposed, render thread joined,
|
|
/// unfinished output file deleted) through RenderManager.CleanUpActiveRender.
|
|
/// </summary>
|
|
public override void OnApplicationQuit()
|
|
{
|
|
if (RenderManager.Instance == null) return;
|
|
Melon<RenderMod>.Logger.Msg("MelonLoader shutdown detected: Forcefully terminating and cleaning up active RenderManager processes.");
|
|
RenderManager.Instance.CleanUpActiveRender();
|
|
}
|
|
} |