SHA256
58 lines
2.6 KiB
C#
58 lines
2.6 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using ADOFAIRenderer.Core;
|
|
using HarmonyLib;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace ADOFAIRenderer.Patch.Game;
|
|
|
|
/// <summary>
|
|
/// Replaces the game's status text (normally "Autoplay", "Auto tile" or "Debug Mode") with the render status.
|
|
/// <para>
|
|
/// Patched member: <c>scrShowIfDebug.Update()</c>, which each frame sets its UI <c>Text</c> (<c>txt</c>) to the autoplay /
|
|
/// auto-tile / debug label or hides it (no-HUD modes, recording mode), in <c>defaultColor</c> (green) or orange for auto tiles.
|
|
/// </para>
|
|
/// <para>
|
|
/// Active while <see cref="RenderManager.IsActive"/> (stage >= OnScene). The postfix overwrites whatever the original set,
|
|
/// every frame, so the text is shown even in the game's no-HUD modes.
|
|
/// </para>
|
|
/// </summary>
|
|
[HarmonyPatch(typeof(scrShowIfDebug))]
|
|
// ReSharper disable once InconsistentNaming
|
|
public static class scrShowIfDebugPatch
|
|
{
|
|
/// <summary>
|
|
/// Postfix of <c>scrShowIfDebug.Update</c>. Shows, in the default (green) color:
|
|
/// <list type="bullet">
|
|
/// <item>"Render in Ns.." during the countdown (N = <c>RenderManager.countdown</c>, seconds), otherwise "Render";</item>
|
|
/// <item>after the end condition is met (<c>endFrame</c> != -1), a second line "Waiting for X.Xs.." with the remaining
|
|
/// part of <c>DelayAfterEnd</c> in render seconds ((frameCount - endFrame) / RenderFPS elapsed), clamped at 0.</item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="___txt">Private field <c>txt</c>: the status Text component.</param>
|
|
/// <param name="___defaultColor">Private field <c>defaultColor</c>: the game's status text color.</param>
|
|
[HarmonyPostfix]
|
|
[HarmonyPatch("Update")]
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
private static void IgnoreInput(Text ___txt, Color ___defaultColor)
|
|
{
|
|
if (!RenderManager.IsActive) return;
|
|
|
|
___txt.enabled = true;
|
|
___txt.text = "Render";
|
|
if (RenderManager.Instance)
|
|
{
|
|
if (RenderManager.Instance.countdown > 0) ___txt.text = $"Render in {RenderManager.Instance.countdown}s..";
|
|
|
|
if (RenderManager.Instance.endFrame != -1)
|
|
{
|
|
var elapsedFrames = RenderManager.Instance.frameCount - RenderManager.Instance.endFrame;
|
|
var remainingTime = RenderManager.Instance.Configuration.DelayAfterEnd - elapsedFrames / RenderManager.Instance.Configuration.RenderFPS;
|
|
if (remainingTime < 0) remainingTime = 0;
|
|
___txt.text += $"\nWaiting for {remainingTime:F1}s..";
|
|
}
|
|
}
|
|
|
|
___txt.color = ___defaultColor;
|
|
}
|
|
} |