Keep presentation alive across levels and scale UI for widescreen
This commit is contained in:
1 parent
113e9a41cc
commit
69d0187a21
26 files changed
+889
-70
No files matched your search
+33
-23
@@ -15,12 +15,13 @@ internal static class Program
|
||||
{
|
||||
try
|
||||
{
|
||||
using var presentation = new RenderSession();
|
||||
OriginalSave? carriedSave = null;
|
||||
var returning = false;
|
||||
var diagnostics = new DebugDiagnostics { Enabled = args.Contains("--debug-overlay") };
|
||||
while (true)
|
||||
{
|
||||
var result = Run(args, carriedSave, returning, diagnostics, out var continuation);
|
||||
var result = Run(args, carriedSave, returning, diagnostics, presentation, out var continuation);
|
||||
if (result != 0 || continuation == null) return result;
|
||||
args = continuation.Args; carriedSave = continuation.Save; returning = continuation.Returning;
|
||||
}
|
||||
@@ -39,7 +40,8 @@ internal static class Program
|
||||
|
||||
private sealed record SceneContinuation(string[] Args, OriginalSave Save, bool Returning);
|
||||
|
||||
private static int Run(string[] args, OriginalSave? carriedSave, bool returning, DebugDiagnostics diagnostics, out SceneContinuation? continuation)
|
||||
private static int Run(string[] args, OriginalSave? carriedSave, bool returning, DebugDiagnostics diagnostics,
|
||||
RenderSession presentation, out SceneContinuation? continuation)
|
||||
{
|
||||
continuation = null;
|
||||
if (args.Contains("--help"))
|
||||
@@ -68,6 +70,7 @@ internal static class Program
|
||||
--headless Render offscreen through Vulkan
|
||||
--screenshot PATH Save actual GPU readback as PPM
|
||||
--frames N Exit after N frames (headless default: 1)
|
||||
--width N --height N Initial window/offscreen size (default960x720)
|
||||
--audio PATH Play recovered WAV; --loop-audio repeats it
|
||||
--audio-smoke PATH Verify audio-stream consumption
|
||||
--scene-audio-smoke PATH Verify music/speech streams from entities.json
|
||||
@@ -88,6 +91,7 @@ internal static class Program
|
||||
--debug-overlay Start with live F2 diagnostics visible
|
||||
--smoke-debug-menu SDL debug navigation/pause/actions/resize check
|
||||
--smoke-debug-overlay SDL live diagnostics/input/menu/resize check
|
||||
--smoke-window-transitions Persistent window/renderer and widescreen UI check
|
||||
--verify-assets Decode all original PNG/ASE files
|
||||
--smoke-window Test keyboard event/resize (requires --frames 6 or more)
|
||||
--no-validation Disable development validation
|
||||
@@ -100,6 +104,19 @@ internal static class Program
|
||||
return 0;
|
||||
}
|
||||
var root = AssetPath.FindOriginal(Option(args, "--assets"));
|
||||
if (args.Contains("--smoke-window-transitions"))
|
||||
{
|
||||
var preparedCandidates = new List<string>();
|
||||
if (Option(args, "--scene") is { } explicitScene)
|
||||
preparedCandidates.Add(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(explicitScene)!, "..")));
|
||||
preparedCandidates.AddRange([Path.Combine(AppContext.BaseDirectory, "scenes"), "artifacts/extracted"]);
|
||||
var prepared = preparedCandidates
|
||||
.FirstOrDefault(p => File.Exists(Path.Combine(p, "ui/ui.json")))
|
||||
?? throw new DirectoryNotFoundException("Prepare scene/UI assets before window transition check");
|
||||
var output = Option(args, "--screenshot") is { } capture
|
||||
? Path.Combine(Path.GetDirectoryName(Path.GetFullPath(capture))!, "window-transitions") : "artifacts/window-transitions";
|
||||
return WindowTransitionSmoke.Run(presentation, root, Path.GetFullPath(prepared), output, !args.Contains("--no-validation"));
|
||||
}
|
||||
var saveOutput = Option(args, "--write-save");
|
||||
if (saveOutput != null)
|
||||
{
|
||||
@@ -386,17 +403,15 @@ internal static class Program
|
||||
throw new ArgumentException("Invalid frame count; window smoke requires at least six frames.");
|
||||
if (practiceWindowSmoke && (headless || frames < 12 || level?.Code != "LV1B" || loadedSave != null))
|
||||
throw new ArgumentException("Practice window smoke requires fresh LV1B and at least12 windowed frames.");
|
||||
nint window = 0;
|
||||
if (!headless)
|
||||
var width = uint.Parse(Option(args, "--width") ?? "960");
|
||||
var height = uint.Parse(Option(args, "--height") ?? "720");
|
||||
if (width is < 64 or > 8192 || height is < 64 or > 8192) throw new ArgumentException("Viewport dimensions must be64..8192");
|
||||
var renderer = presentation.LoadScene(mesh, texture, headless,
|
||||
walking ? WalkTitle : animations?.WindowTitle ?? "Jimmy Neutron — scene preview | C camera",
|
||||
width, height, !args.Contains("--no-validation"));
|
||||
var window = presentation.Window;
|
||||
Console.WriteLine($"Scene presentation: revision={renderer.SceneRevision}, windows={presentation.WindowCreationCount}, renderers={presentation.RendererCreationCount}, window ID={(window == 0 ? 0 : Sdl.SDL_GetWindowID(window))}, size={renderer.Width}x{renderer.Height}.");
|
||||
{
|
||||
if (!Sdl.SDL_Init(Sdl.InitVideo)) throw new InvalidOperationException(Sdl.Error);
|
||||
window = Sdl.SDL_CreateWindow(walking ? WalkTitle : animations?.WindowTitle ?? "Jimmy Neutron — scene preview | C camera", 960, 720,
|
||||
Sdl.WindowVulkan | Sdl.WindowResizable | Sdl.WindowHighPixelDensity);
|
||||
if (window == 0) { Sdl.SDL_Quit(); throw new InvalidOperationException(Sdl.Error); }
|
||||
}
|
||||
try
|
||||
{
|
||||
using var renderer = new VulkanRenderer(mesh, texture, 960, 720, window, !args.Contains("--no-validation"));
|
||||
using var audio = Option(args, "--audio") is { } audioFile
|
||||
? new SdlAudio(audioFile, args.Contains("--loop-audio"), debugMenu.Open) : null;
|
||||
using var sceneAudio = resources != null && !headless && !args.Contains("--mute") ? new SceneAudio(resources) : null;
|
||||
@@ -492,14 +507,13 @@ internal static class Program
|
||||
var keys = new HashSet<uint>();
|
||||
var debugCapturedKeys = new HashSet<uint>();
|
||||
var running = true;
|
||||
var fullscreen = false;
|
||||
var sawKey = false;
|
||||
var didResize = false;
|
||||
var clock = Stopwatch.StartNew();
|
||||
var animationStarted = 0.0;
|
||||
var animationSwitched = false;
|
||||
var inspecting = !walking;
|
||||
var active = true;
|
||||
var active = presentation.HasInputFocus;
|
||||
var mouseJump = false;
|
||||
var stepClock = new FixedStepClock();
|
||||
double poseTime = initialPoseTime;
|
||||
@@ -597,7 +611,7 @@ internal static class Program
|
||||
{
|
||||
Sdl.SDL_GetMouseState(out var x, out var y);
|
||||
if (!Sdl.SDL_GetWindowSize(window, out var w, out var h) || w < 1 || h < 1) return Vector2.Zero;
|
||||
return new(x * 640 / w, y * 480 / h);
|
||||
return new UiViewport(renderer.Width, renderer.Height).InverseModal(new(x, y), (uint)w, (uint)h);
|
||||
}
|
||||
while (running)
|
||||
{
|
||||
@@ -689,8 +703,7 @@ internal static class Program
|
||||
}
|
||||
if (e.Scancode == 68 && e.Repeat == 0)
|
||||
{
|
||||
fullscreen = !fullscreen;
|
||||
if (!Sdl.SDL_SetWindowFullscreen(window, fullscreen)) throw new InvalidOperationException(Sdl.Error);
|
||||
presentation.ToggleFullscreen();
|
||||
}
|
||||
}
|
||||
if (e.Type == Sdl.KeyUp) keys.Remove(e.Scancode);
|
||||
@@ -776,7 +789,7 @@ internal static class Program
|
||||
&& director is { Controlled: true, InventoryEnabled: true });
|
||||
objectivePanel?.Step(0, director?.ControlledTag != null, practice.Active);
|
||||
hud?.Update(mesh, interactions!.CurrentObjective, level!.Code == "LV1B" && objectivePanel!.PadVisible,
|
||||
practice.Active, objectivePanel!.YOffset, objectivePanel.ContentVisible);
|
||||
practice.Active, objectivePanel!.YOffset, objectivePanel.ContentVisible, renderer.Width, renderer.Height);
|
||||
var gameplayProjection = originalCamera || simulation != null && !inspecting;
|
||||
var cameraMode = !inspecting && director?.CameraEye != null ? "CUTSCENE"
|
||||
: simulation != null && !inspecting ? "GAMEPLAY" : originalCamera ? "STRT" : "ORBIT";
|
||||
@@ -795,7 +808,8 @@ internal static class Program
|
||||
renderer.ValidationErrors, debugMenu.Open || practice.Active || inspecting || !active));
|
||||
var liveDebugVisible = !debugMenu.Open && liveDebugLines.Length > 0;
|
||||
debugOverlay.Update(mesh, debugMenu.Open ? debugView.Lines : liveDebugLines,
|
||||
debugMenu.Open ? debugView.SelectedLine : -1, compact: !debugMenu.Open);
|
||||
debugMenu.Open ? debugView.SelectedLine : -1, compact: !debugMenu.Open,
|
||||
viewportWidth: renderer.Width, viewportHeight: renderer.Height);
|
||||
var projection = gameplayProjection
|
||||
? SceneProjection.CreateGameplay(level?.Code, (float)renderer.Width / renderer.Height)
|
||||
: Matrix4x4.CreatePerspectiveFieldOfView(MathF.PI / 3, (float)renderer.Width / renderer.Height, Math.Max(radius / 10000, 0.01f), radius * 20);
|
||||
@@ -1066,10 +1080,6 @@ internal static class Program
|
||||
}
|
||||
return renderer.ValidationErrors > 0 || changed == 0 ? 2 : 0;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (window != 0) { Sdl.SDL_DestroyWindow(window); Sdl.SDL_Quit(); }
|
||||
}
|
||||
}
|
||||
|
||||
private const string WalkTitle = "Jimmy Neutron — lab checkpoint | Arrows move | Shift / Insert / right mouse jump | F1 menu | F2 overlay | R reset | C inspect";
|
||||
|
||||
Reference in new issue
Block a user