Keep presentation alive across levels and scale UI for widescreen

This commit is contained in:
UnixNight committed 2026-10-25 03:14:04 -04:00
1 parent 113e9a41cc
commit 69d0187a21
26 files changed
+889 -70

No files matched your search

+5 -2
View File
@@ -72,12 +72,14 @@ public sealed class SceneHud
/// <summary>Writes the final merged buffer, including when later visual composers copied these vertices.</summary>
public void Update(Mesh destination, int currentObjective, bool objectivesVisible, bool practiceVisible,
float objectiveYOffset = -69, bool objectiveContentVisible = true)
float objectiveYOffset = -69, bool objectiveContentVisible = true,
uint viewportWidth = 640, uint viewportHeight = 480)
{
if (!float.IsFinite(objectiveYOffset) || objectiveYOffset < -480 || objectiveYOffset > 480)
throw new ArgumentOutOfRangeException(nameof(objectiveYOffset));
if (destination.Vertices.Length < Mesh.Vertices.Length || destination.Indices.Length < Mesh.Indices.Length)
throw new ArgumentException("Destination omits HUD ranges", nameof(destination));
var viewport = new UiViewport(viewportWidth, viewportHeight);
foreach (var quad in quads)
{
var draw = destination.Draws.FirstOrDefault(d => d.FirstIndex == quad.FirstIndex && d.ScreenSpace
@@ -88,7 +90,8 @@ public sealed class SceneHud
var digit = quad.Canvas is >= 83 and <= 85;
var x = quad.Canvas == 169 ? 210f : digit ? 393f : 384f;
var y = quad.Canvas == 169 ? 210f : (quad.Canvas == 156 ? 380f : digit ? 450f : 448f) + objectiveYOffset;
Vector3 Position(float px, float py) => new(2 * px / 640 - 1, 2 * py / 480 - 1, 0);
var anchor = quad.Canvas == 169 ? viewport.CenterOffset : viewport.BottomRightOffset;
Vector3 Position(float px, float py) => viewport.ToNdc(new Vector2(px, py) + anchor);
destination.Vertices[quad.VertexOffset].Position = Position(x, y);
destination.Vertices[quad.VertexOffset + 1].Position = Position(x + quad.Width, y);
destination.Vertices[quad.VertexOffset + 2].Position = Position(x + quad.Width, y + quad.Height);