Das G3-HUD ist abgenommen; der Meilenstein U3 ist damit fertig. - Prüfung (Port von verify_g3, Teile A–H plus I): 718 Prüfungen ohne Fehler. Teil I prüft die Feld-Darstellung um das HUD (U3-Zugabe aus dem Motivvergleich): Aufstellungsflächen, Grotteneingang, ruhender Boss, Namensschilder, Eigentümer-Ring, Ancient-Balken. - Feld um das HUD: Namensschilder für Helden (mit Stufe), Angriffs- champions und den eingesetzten Boss („für Blau“), Eigentümer-Ring, Ancient-Balken bei Schaden, ruhende Schlundkrone auf dem Podest, eigener Grotteneingang, Aufstellungsflächen als eigene Objekte. - Schriften korrigiert: Die Referenz deklariert Cantarell 560/700–760 und Cinzel 700, wendet die Gewichte aber nie an (variation_opentype mit dem String-Schlüssel „wght“ wird von Godot ignoriert). G3 zeigt Regular 400, der Port ebenso — Cinzel-Regular statt Bold, keine Kontur zur Aufdickung. Laufweite aus spacing_glyph umgerechnet; dunkler Saum als Schatten statt TextCore-Kontur. - Werkzeuge: HudViewsTests (14 G3-Motive), HudPlaytest (Spieltest über die echte Oberfläche per Befehlsdateien), ui_ms_per_frame im LuneBenchmark. Layout folgt den echten Panelhöhen, Kamera startet wie Godot _ready auf der eigenen Lane. - Tests: EditMode 23/23, PlayMode 13/13, Kerntests 402/402, Verify 718/0. Fingerabdrücke der Bot-Partien unverändert (DCE95C96556F3A1A, 7B8E43AEFC0D60C5). - Bilder: 14 Motive bei 1920×1080, Auflösungen 1152×720 bis 2560×1440, Prüf-Schlüsselbilder, Spieltest-Screenshots. - Leistung (macOS-Player mit HUD, 116 Einheiten): 169 fps Übersicht, 218 fps Mid nah; HUD-Skripte 0,090 bzw. 0,078 ms je Bild. - Dokumentation: U3-UI (U3D, Schriftbefund), PORT-QA (U3), PORT-STATUS (U3 fertig, U4 nächster Schritt), KNOWN-BEHAVIOR-DIFFERENCES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.8 KiB
C#
67 lines
2.8 KiB
C#
using System.IO;
|
||
using UnityEngine;
|
||
|
||
namespace Luneraria.UI
|
||
{
|
||
/// <summary>
|
||
/// Screenshots of the scene with the HUD on top, also in batch mode: the camera renders into
|
||
/// one texture, the HUD panel into its own (premultiplied alpha), and both are composed on the
|
||
/// CPU. Used by the U3 tests and captures; the player can also capture the real screen.
|
||
/// </summary>
|
||
public static class LuneHudCapture
|
||
{
|
||
public static Texture2D Read(RenderTexture texture)
|
||
{
|
||
RenderTexture previous = RenderTexture.active;
|
||
RenderTexture.active = texture;
|
||
var image = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false);
|
||
image.ReadPixels(new Rect(0, 0, texture.width, texture.height), 0, 0);
|
||
image.Apply();
|
||
RenderTexture.active = previous;
|
||
return image;
|
||
}
|
||
|
||
public static Texture2D RenderScene(Camera camera, int width, int height)
|
||
{
|
||
var target = new RenderTexture(width, height, 24, RenderTextureFormat.ARGB32) { antiAliasing = 4 };
|
||
RenderTexture previous = camera.targetTexture;
|
||
float aspect = camera.aspect;
|
||
camera.aspect = (float)width / height;
|
||
camera.targetTexture = target;
|
||
camera.Render();
|
||
camera.targetTexture = previous;
|
||
camera.aspect = aspect;
|
||
Texture2D image = Read(target);
|
||
target.Release();
|
||
Object.Destroy(target);
|
||
return image;
|
||
}
|
||
|
||
/// <summary>HUD (premultiplied alpha) over the scene: out = hud + scene · (1 − hud alpha).</summary>
|
||
public static Texture2D Compose(Texture2D scene, Texture2D hud)
|
||
{
|
||
Color32[] under = scene.GetPixels32();
|
||
Color32[] over = hud.GetPixels32();
|
||
var result = new Color32[under.Length];
|
||
for (int index = 0; index < under.Length; index++)
|
||
{
|
||
Color32 a = over[index];
|
||
Color32 b = under[index];
|
||
int keep = 255 - a.a;
|
||
result[index] = new Color32((byte)Mathf.Min(255, a.r + b.r * keep / 255), (byte)Mathf.Min(255, a.g + b.g * keep / 255), (byte)Mathf.Min(255, a.b + b.b * keep / 255), 255);
|
||
}
|
||
var image = new Texture2D(scene.width, scene.height, TextureFormat.RGBA32, false);
|
||
image.SetPixels32(result);
|
||
image.Apply();
|
||
return image;
|
||
}
|
||
|
||
/// <summary>PNG, or JPEG (quality 90) for a .jpg file.</summary>
|
||
public static void Save(Texture2D image, string file)
|
||
{
|
||
Directory.CreateDirectory(Path.GetDirectoryName(file));
|
||
bool jpeg = file.EndsWith(".jpg", System.StringComparison.OrdinalIgnoreCase);
|
||
File.WriteAllBytes(file, jpeg ? image.EncodeToJPG(90) : image.EncodeToPNG());
|
||
}
|
||
}
|
||
}
|