SHA256
Document UI And Localization
This commit is contained in:
1 parent
a389283d33
commit
0fc01a84de
8 files changed
+910
-71
No files matched your search
+64
-2
@@ -8,9 +8,20 @@ namespace ADOFAIRenderer.UI;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Assets loaded from the mod's embedded asset bundles (fonts and the color conversion compute shader).
|
||||
/// <para>
|
||||
/// <see cref="Load"/> is called once from <c>RenderMod.OnInitializeMelon</c>; the fields stay <c>null</c> until then.
|
||||
/// Bundles are obtained from <c>BundleLoader.GetBundle</c> by name ("fonts", "shaders"). Main thread only.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
internal static class ModAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads the font and shader bundles and the assets inside them, logging after each bundle.
|
||||
/// Exceptions from bundle or asset loading are not caught here and propagate to the caller.
|
||||
/// </summary>
|
||||
public static void Load()
|
||||
{
|
||||
FontBundle = BundleLoader.GetBundle("fonts");
|
||||
@@ -23,24 +34,49 @@ internal static class ModAssets
|
||||
Melon<RenderMod>.Logger.Msg("Shader loaded successfully.");
|
||||
}
|
||||
|
||||
/// <summary>Asset bundle "fonts" holding the TextMeshPro font assets.</summary>
|
||||
public static AssetBundle FontBundle = null!;
|
||||
/// <summary>Asset bundle "shaders" holding the compute shaders.</summary>
|
||||
public static AssetBundle ShaderBundle = null!;
|
||||
|
||||
/// <summary>
|
||||
/// NanumSquare Neo, asset "NanumSquareNeoOTF-Bd SDF" (Bd = Bold weight). Used as the regular UI font of the mod
|
||||
/// (O5Kit <see cref="RendererFontProvider.Regular"/>, DebugMonitorUI text).
|
||||
/// </summary>
|
||||
public static TMP_FontAsset NanumSquareNeoNormal = null!;
|
||||
/// <summary>
|
||||
/// NanumSquare Neo, asset "NanumSquareNeoOTF-Eb SDF" (Eb = ExtraBold weight). Used as the O5Kit medium font
|
||||
/// (<see cref="RendererFontProvider.Medium"/>).
|
||||
/// </summary>
|
||||
public static TMP_FontAsset NanumSquareNeoBold = null!;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Compute shader "ColorConversion" that converts captured frames to the encoder's YUV pixel format on the GPU
|
||||
/// (used by FrameReader).
|
||||
/// </summary>
|
||||
public static ComputeShader ColorConversionShader = null!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// O5Kit font provider for the mod's UI: the bundled NanumSquare Neo fonts for regular and medium text, and O5Kit's
|
||||
/// default monospace font.
|
||||
/// </summary>
|
||||
internal sealed class RendererFontProvider : IFontProvider
|
||||
{
|
||||
/// <summary>O5Kit default provider, used only for <see cref="Monospace"/>.</summary>
|
||||
private static readonly DefaultFontProvider DefaultFontProvider = new();
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>Regular text font: <see cref="ModAssets.NanumSquareNeoNormal"/>.</summary>
|
||||
public TMP_FontAsset Regular => ModAssets.NanumSquareNeoNormal;
|
||||
/// <summary>Medium (emphasis) text font: <see cref="ModAssets.NanumSquareNeoBold"/>.</summary>
|
||||
public TMP_FontAsset Medium => ModAssets.NanumSquareNeoBold;
|
||||
/// <summary>Monospace font (e.g. hex color input): O5Kit's default monospace font.</summary>
|
||||
public TMP_FontAsset Monospace => DefaultFontProvider.Monospace;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the provider disposed. The font assets belong to <see cref="ModAssets"/> and are not unloaded.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
@@ -48,19 +84,39 @@ internal sealed class RendererFontProvider : IFontProvider
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Owner of the mod's O5Kit UI: the shared <see cref="O5Context"/> (config, theme, fonts) and the window manager
|
||||
/// with its canvas.
|
||||
/// <para>
|
||||
/// Added once by <c>RenderMod.OnInitializeMelon</c> to a GameObject kept across scene loads. Other UI code reads
|
||||
/// <see cref="Context"/> and <see cref="WindowManager"/> through the static <see cref="Instance"/>.
|
||||
/// <see cref="Update"/> drives O5Kit's per-frame work (object ticks, tooltip, keyboard shortcuts). Main thread only.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
internal class RendererUIManager : MonoBehaviour
|
||||
{
|
||||
/// <summary>The single instance, assigned in <see cref="Awake"/>.</summary>
|
||||
public static RendererUIManager Instance = null!;
|
||||
|
||||
/// <summary>Shared O5Kit context used to build every mod window and dialog.</summary>
|
||||
public static O5Context Context => Instance._context;
|
||||
/// <summary>Window manager whose canvas holds the mod windows (e.g. RenderConfigWindow).</summary>
|
||||
public O5WindowManager WindowManager => _windowManager;
|
||||
|
||||
private O5Context _context = null!;
|
||||
private O5WindowManager _windowManager = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the O5Kit context with the mod theme and fonts, then the window manager and its canvas
|
||||
/// ("RendererMod_Canvas"), and lowers that canvas's sorting order to <see cref="WindowCanvasSortingOrder"/>.
|
||||
/// </summary>
|
||||
private void Awake() {
|
||||
Instance = this;
|
||||
|
||||
|
||||
// O5Kit config: UI scale 1.0, middle click resets a control to its default value, slider drag sensitivity 1.0.
|
||||
// Theme: O5Kit's dark theme with the mod colors. Colors are RGBA 0..1; the accent color
|
||||
// (1.000, 0.294, 0.079) is orange-red (#FF4B14 approx.). Sizes are canvas units: corner radius 12,
|
||||
// outline width 2, control height 40, body font 18, H1 font 48.
|
||||
_context = new O5Context(
|
||||
config: new O5Config {
|
||||
UIScale = 1.0f,
|
||||
@@ -101,14 +157,20 @@ internal class RendererUIManager : MonoBehaviour
|
||||
if (windowCanvas != null) windowCanvas.sortingOrder = WindowCanvasSortingOrder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sorting order of the window canvas: below CommonWarningDialogUI (32766) and FFmpegDownloadUI (32767), above the
|
||||
/// render overlays (DebugMonitorUI 9999, EscapeHandlerUI 10000).
|
||||
/// </summary>
|
||||
private const int WindowCanvasSortingOrder = 32000;
|
||||
|
||||
/// <summary>Runs O5Kit's per-frame updates: object ticks, tooltip, and keyboard shortcut handling.</summary>
|
||||
private void Update() {
|
||||
O5Object.TickAll();
|
||||
Context.Tooltip.Tick();
|
||||
O5Kit.Input.O5ShortcutManager.HandleUpdate();
|
||||
}
|
||||
|
||||
/// <summary>Disposes the window manager, then the context.</summary>
|
||||
private void OnDestroy() {
|
||||
_windowManager.Dispose();
|
||||
_context.Dispose();
|
||||
|
||||
Reference in new issue
Block a user