Add F1 debug menu with paused diagnostics and scene controls
This commit is contained in:
1 parent
8d60a68511
commit
3078b8afd0
21 files changed
+809
-36
No files matched your search
@@ -0,0 +1,120 @@
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using GamePort.Assets;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
public sealed record DebugScene(string LevelFile, string Code, string[] Starts);
|
||||
public enum DebugAction { None, Resume, Camera, SkipCutscene, RefillEnergy, GiveJetpack, ApplySceneTask, LoadScene, Reset }
|
||||
public sealed record DebugMenuView(string[] Lines, int SelectedLine);
|
||||
public sealed record DebugStatus(string Level, string Start, Vector3 Root, float Yaw, float Speed,
|
||||
bool Grounded, float Energy, int Score, int SceneTask, string Cutscene, bool Controlled,
|
||||
int Issues, float FarPlane, bool Inspecting);
|
||||
|
||||
/// <summary>Modern investigation tools, deliberately separate from recovered game UI.</summary>
|
||||
public sealed class DebugMenu
|
||||
{
|
||||
public const uint ToggleKey = 58; // SDL scancode F1; F11 remains fullscreen.
|
||||
public const int ItemCount = 10;
|
||||
public bool Open { get; private set; }
|
||||
public int Selected { get; private set; }
|
||||
public int SceneTask { get; private set; }
|
||||
public string Message { get; set; } = "";
|
||||
private readonly DebugScene[] scenes;
|
||||
private int sceneIndex, startIndex;
|
||||
public DebugScene? Scene => scenes.Length == 0 ? null : scenes[sceneIndex];
|
||||
public string? Start => Scene is { } scene ? scene.Starts[startIndex] : null;
|
||||
|
||||
public DebugMenu(IEnumerable<DebugScene> scenes, string? currentLevel, string? currentStart)
|
||||
{
|
||||
this.scenes = scenes.ToArray();
|
||||
if (this.scenes.Any(s => s.Starts.Length == 0)) throw new ArgumentException("Debug scenes require a startpoint");
|
||||
sceneIndex = Math.Max(0, Array.FindIndex(this.scenes,
|
||||
s => string.Equals(s.LevelFile, currentLevel, StringComparison.OrdinalIgnoreCase)));
|
||||
if (Scene is { } selected)
|
||||
startIndex = Math.Max(0, Array.FindIndex(selected.Starts,
|
||||
s => string.Equals(s, currentStart, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
|
||||
public void Toggle(int currentSceneTask)
|
||||
{
|
||||
Open = !Open;
|
||||
if (Open) { SceneTask = currentSceneTask; Message = ""; }
|
||||
}
|
||||
public void Close() => Open = false;
|
||||
|
||||
public DebugAction Key(uint scancode, bool repeat = false)
|
||||
{
|
||||
if (!Open) return DebugAction.None;
|
||||
if (scancode == 41) { Close(); return DebugAction.None; }
|
||||
if (scancode is 82 or 81)
|
||||
Selected = (Selected + (scancode == 82 ? ItemCount - 1 : 1)) % ItemCount;
|
||||
else if (scancode is 80 or 79 or 75 or 78)
|
||||
{
|
||||
var direction = scancode is 80 or 78 ? -1 : 1;
|
||||
if (Selected == 5)
|
||||
SceneTask = (int)Math.Clamp((long)SceneTask + direction * (scancode is 75 or 78 ? 10 : 1), 0, 999);
|
||||
else if (Selected == 6 && scenes.Length > 0)
|
||||
{ sceneIndex = (sceneIndex + scenes.Length + direction) % scenes.Length; startIndex = 0; }
|
||||
else if (Selected == 7 && Scene is { } scene)
|
||||
startIndex = (startIndex + scene.Starts.Length + direction) % scene.Starts.Length;
|
||||
}
|
||||
else if (scancode is 40 or 88 && !repeat)
|
||||
return Selected switch
|
||||
{
|
||||
0 => DebugAction.Resume, 1 => DebugAction.Camera, 2 => DebugAction.SkipCutscene,
|
||||
3 => DebugAction.RefillEnergy, 4 => DebugAction.GiveJetpack, 5 => DebugAction.ApplySceneTask,
|
||||
8 => Scene == null ? DebugAction.None : DebugAction.LoadScene, 9 => DebugAction.Reset,
|
||||
_ => DebugAction.None
|
||||
};
|
||||
return DebugAction.None;
|
||||
}
|
||||
|
||||
public DebugMenuView View(DebugStatus status)
|
||||
{
|
||||
if (!Open) return new([], -1);
|
||||
var c = CultureInfo.InvariantCulture;
|
||||
string F(float value) => value.ToString("0.0", c);
|
||||
return new([
|
||||
"NEUTRON DEBUG MENU - F1",
|
||||
"PAUSED - MODERN DEBUG TOOLS",
|
||||
$"LEVEL {status.Level} / START {status.Start}",
|
||||
$"ROOT X {F(status.Root.X)} Y {F(status.Root.Y)} Z {F(status.Root.Z)}",
|
||||
$"YAW {F(status.Yaw)} SPEED {F(status.Speed)} GROUNDED {status.Grounded}",
|
||||
$"ENERGY {F(status.Energy)} SCORE {status.Score} SCENE {status.SceneTask}",
|
||||
$"CONTROL {status.Controlled} CUTSCENE {status.Cutscene}",
|
||||
$"ISSUES {status.Issues} FAR {F(status.FarPlane)} CAMERA {(status.Inspecting ? "ORBIT" : "GAMEPLAY")}",
|
||||
"",
|
||||
"RESUME",
|
||||
$"CAMERA: {(status.Inspecting ? "SWITCH TO GAMEPLAY" : "SWITCH TO ORBIT")}",
|
||||
"SKIP CURRENT CUTSCENE",
|
||||
"REFILL ENERGY TO 100",
|
||||
"GIVE / SELECT JET PACK",
|
||||
$"SCENE TASK: {SceneTask} (ENTER APPLIES)",
|
||||
$"LEVEL: {Scene?.LevelFile ?? "UNAVAILABLE"}",
|
||||
$"START: {Start ?? "UNAVAILABLE"}",
|
||||
"LOAD SELECTED LEVEL / START",
|
||||
"RESET CURRENT START",
|
||||
"",
|
||||
"UP/DOWN SELECT LEFT/RIGHT CHANGE ENTER APPLY",
|
||||
"SCENE TASK: PAGE UP/DOWN CHANGES BY 10",
|
||||
"F1 / ESC CLOSE - GAME INPUT IS CAPTURED WHILE OPEN",
|
||||
Message
|
||||
], 9 + Selected);
|
||||
}
|
||||
|
||||
public static DebugScene[] AvailableScenes(string assets, string prepared)
|
||||
{
|
||||
var scenes = new List<DebugScene>();
|
||||
foreach (var path in Directory.EnumerateFiles(AssetPath.Resolve(assets, "gam"))
|
||||
.Where(p => p.EndsWith(".gam", StringComparison.OrdinalIgnoreCase)).OrderBy(Path.GetFileName, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
try { AssetPath.Resolve(prepared, Path.GetFileNameWithoutExtension(path) + "/scene.json"); }
|
||||
catch (FileNotFoundException) { continue; }
|
||||
var level = GamLevel.Load(path);
|
||||
var starts = level.Entities.Where(e => e.Kind == "STRT" && e.Tag is { Length: > 0 }).Select(e => e.Tag!).ToArray();
|
||||
if (level.Player != null && starts.Length > 0) scenes.Add(new(Path.GetFileName(path), level.Code, starts));
|
||||
}
|
||||
return scenes.ToArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
using System.Numerics;
|
||||
using GamePort.Assets;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Modern developer overlay, separate from recovered game UI. Uses a code-built
|
||||
/// 5x7 font and the existing alpha-tested screen-space pipeline; no asset files.
|
||||
/// Allocate once before renderer creation, then update the final merged mesh.
|
||||
/// </summary>
|
||||
public sealed class DebugMenuOverlay
|
||||
{
|
||||
public const int MaxLines = 32;
|
||||
public const int MaxColumns = 76;
|
||||
private const float LineHeight = 13;
|
||||
private const float CharacterAdvance = 7.5f;
|
||||
private const int AtlasWidth = 128, AtlasHeight = 64;
|
||||
private readonly int firstVertex;
|
||||
private readonly uint firstIndex;
|
||||
private readonly int textureId;
|
||||
public Mesh Mesh { get; }
|
||||
|
||||
public DebugMenuOverlay(Mesh combined)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(combined);
|
||||
firstVertex = combined.Vertices.Length;
|
||||
firstIndex = (uint)combined.Indices.Length;
|
||||
var vertices = combined.Vertices.ToList();
|
||||
var indices = combined.Indices.ToList();
|
||||
var draws = combined.Draws.ToList();
|
||||
if (!combined.HasExplicitDraws && draws.Count == 0 && indices.Count > 0)
|
||||
draws.Add(new(0, (uint)indices.Count, -1));
|
||||
var textures = new Dictionary<int, PngImage>(combined.Textures);
|
||||
textureId = int.MinValue;
|
||||
while (textures.ContainsKey(textureId)) textureId++;
|
||||
textures.Add(textureId, CreateFont());
|
||||
// Two solid quads precede a fixed range for each text row. Keeping the
|
||||
// ranges fixed means the Vulkan vertex/index buffers never need resizing.
|
||||
AddRange(1);
|
||||
AddRange(1);
|
||||
for (var row = 0; row < MaxLines; row++) AddRange(MaxColumns);
|
||||
Mesh = new(vertices.ToArray(), indices.ToArray())
|
||||
{
|
||||
Draws = draws.ToArray(), HasExplicitDraws = true,
|
||||
Textures = textures, CollisionPolygons = combined.CollisionPolygons
|
||||
};
|
||||
|
||||
void AddRange(int quads)
|
||||
{
|
||||
var start = (uint)indices.Count;
|
||||
for (var i = 0; i < quads; i++)
|
||||
{
|
||||
var vertex = (uint)vertices.Count;
|
||||
for (var corner = 0; corner < 4; corner++) vertices.Add(new(Vector3.Zero, Vector2.Zero, Vector3.One));
|
||||
indices.AddRange([vertex, vertex + 1, vertex + 2, vertex, vertex + 2, vertex + 3]);
|
||||
}
|
||||
draws.Add(new(start, (uint)quads * 6, textureId) { ScreenSpace = true, Visible = false });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Empty lines hide all overlay draws. Accepts at most32 lines; individual
|
||||
/// lines clip at76 characters. selectedLine is -1 or an index into lines.
|
||||
/// Lowercase renders as uppercase, unsupported characters as question marks.
|
||||
/// Layout uses the same640x480 reference viewport as the original HUD.
|
||||
/// </summary>
|
||||
public void Update(Mesh destination, IReadOnlyList<string> lines, int selectedLine = -1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(destination);
|
||||
ArgumentNullException.ThrowIfNull(lines);
|
||||
if (lines.Count > MaxLines) throw new ArgumentOutOfRangeException(nameof(lines));
|
||||
if (selectedLine < -1 || selectedLine >= lines.Count) throw new ArgumentOutOfRangeException(nameof(selectedLine));
|
||||
if (destination.Vertices.Length < Mesh.Vertices.Length || destination.Indices.Length < Mesh.Indices.Length)
|
||||
throw new ArgumentException("Destination omits debug overlay ranges", nameof(destination));
|
||||
var background = FindDraw(firstIndex, 6);
|
||||
var highlight = FindDraw(firstIndex + 6, 6);
|
||||
background.Visible = lines.Count > 0;
|
||||
highlight.Visible = selectedLine >= 0;
|
||||
var solid = new Vector2(127.5f / AtlasWidth, 63.5f / AtlasHeight);
|
||||
Quad(firstVertex, 18, 18, 604, Math.Clamp(lines.Count * LineHeight + 24, 80, 444), solid, solid, new(.025f, .04f, .07f));
|
||||
Quad(firstVertex + 4, 25, 27 + selectedLine * LineHeight, 590, LineHeight,
|
||||
solid, solid, new(.07f, .24f, .33f));
|
||||
for (var row = 0; row < MaxLines; row++)
|
||||
{
|
||||
var draw = FindDraw(firstIndex + 12 + (uint)(row * MaxColumns * 6), MaxColumns * 6);
|
||||
draw.Visible = row < lines.Count;
|
||||
if (!draw.Visible) continue;
|
||||
var line = lines[row] ?? "";
|
||||
var color = row == 0 ? new Vector3(1, .83f, .35f) : new(.85f, .93f, .98f);
|
||||
for (var column = 0; column < MaxColumns; column++)
|
||||
{
|
||||
var character = column < line.Length ? char.ToUpperInvariant(line[column]) : ' ';
|
||||
if (character is < ' ' or > '~') character = '?';
|
||||
var cell = character - ' ';
|
||||
var x = cell % 16 * 8 + 1;
|
||||
var y = cell / 16 * 8;
|
||||
Quad(firstVertex + 8 + (row * MaxColumns + column) * 4,
|
||||
30 + column * CharacterAdvance, 30 + row * LineHeight, 7, 9.8f,
|
||||
new((float)x / AtlasWidth, (float)y / AtlasHeight),
|
||||
new((x + 5f) / AtlasWidth, (y + 7f) / AtlasHeight), color);
|
||||
}
|
||||
}
|
||||
|
||||
MeshDraw FindDraw(uint start, uint count) => destination.Draws.FirstOrDefault(d =>
|
||||
d.FirstIndex == start && d.IndexCount == count && d.TextureId == textureId && d.ScreenSpace)
|
||||
?? throw new ArgumentException("Destination omits debug overlay draws", nameof(destination));
|
||||
|
||||
void Quad(int start, float x, float y, float width, float height, Vector2 minUv, Vector2 maxUv, Vector3 color)
|
||||
{
|
||||
destination.Vertices[start] = new(Position(x, y), minUv, color);
|
||||
destination.Vertices[start + 1] = new(Position(x + width, y), new(maxUv.X, minUv.Y), color);
|
||||
destination.Vertices[start + 2] = new(Position(x + width, y + height), maxUv, color);
|
||||
destination.Vertices[start + 3] = new(Position(x, y + height), new(minUv.X, maxUv.Y), color);
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector3 Position(float x, float y) => new(2 * x / 640 - 1, 2 * y / 480 - 1, 0);
|
||||
|
||||
private static PngImage CreateFont()
|
||||
{
|
||||
// Seven rows of five bits per glyph. This intentionally simple developer
|
||||
// font is generated from code, not a claim about the original font layout.
|
||||
var glyphs = new Dictionary<char, string>
|
||||
{
|
||||
['A']="0E11111F111111", ['B']="1E11111E11111E", ['C']="0F10101010100F",
|
||||
['D']="1E11111111111E", ['E']="1F10101E10101F", ['F']="1F10101E101010",
|
||||
['G']="0F10101711110F", ['H']="1111111F111111", ['I']="1F04040404041F",
|
||||
['J']="0101010111110E", ['K']="11121418141211", ['L']="1010101010101F",
|
||||
['M']="111B1515111111", ['N']="11191513111111", ['O']="0E11111111110E",
|
||||
['P']="1E11111E101010", ['Q']="0E11111115120D", ['R']="1E11111E141211",
|
||||
['S']="0F10100E01011E", ['T']="1F040404040404", ['U']="1111111111110E",
|
||||
['V']="11111111110A04", ['W']="11111115151B11", ['X']="11110A040A1111",
|
||||
['Y']="11110A04040404", ['Z']="1F01020408101F",
|
||||
['0']="0E11131519110E", ['1']="040C040404040E", ['2']="0E11010204081F",
|
||||
['3']="1E01010E01011E", ['4']="02060A121F0202", ['5']="1F10101E01011E",
|
||||
['6']="0E10101E11110E", ['7']="1F010204080808", ['8']="0E11110E11110E",
|
||||
['9']="0E11110F01010E", [' ']="00000000000000", ['.']="00000000000C0C",
|
||||
[',']="00000000000C08", [':']="000C0C000C0C00", [';']="000C0C000C0C08",
|
||||
['-']="0000001F000000", ['_']="0000000000001F", ['+']="0004041F040400",
|
||||
['=']="00001F001F0000", ['/']="01010204081010", ['\\']="10100804020101",
|
||||
['(']="02040808080402", [')']="08040202020408", ['[']="0E08080808080E",
|
||||
[']']="0E02020202020E", ['<']="01020408040201", ['>']="10080402040810",
|
||||
['!']="04040404040004", ['?']="0E110102040004", ['#']="0A0A1F0A1F0A0A",
|
||||
['%']="19190204081313", ['*']="00150E1F0E1500", ['|']="04040404040404",
|
||||
['\'']="04040800000000", ['"']="0A0A1400000000", ['@']="0E11171517100E",
|
||||
['$']="040F140E051E04", ['&']="0C12140C15120D", ['^']="040A1100000000",
|
||||
['~']="00000D12000000", ['{']="02040408040402", ['}']="08040402040408",
|
||||
['`']="08040200000000"
|
||||
};
|
||||
var pixels = new byte[AtlasWidth * AtlasHeight * 4];
|
||||
for (var i = 0; i < pixels.Length; i += 4) pixels[i] = pixels[i + 1] = pixels[i + 2] = 255;
|
||||
for (var character = ' '; character <= '~'; character++)
|
||||
{
|
||||
var rows = Convert.FromHexString(glyphs.GetValueOrDefault(char.ToUpperInvariant(character), glyphs['?']));
|
||||
var cell = character - ' ';
|
||||
for (var y = 0; y < 7; y++)
|
||||
for (var x = 0; x < 5; x++)
|
||||
if ((rows[y] & (1 << (4 - x))) != 0)
|
||||
pixels[((cell / 16 * 8 + y) * AtlasWidth + cell % 16 * 8 + 1 + x) * 4 + 3] = 255;
|
||||
}
|
||||
pixels[(AtlasWidth * AtlasHeight - 1) * 4 + 3] = 255;
|
||||
return new(AtlasWidth, AtlasHeight, pixels);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ public sealed class SceneAudio : IDisposable
|
||||
private (string Database, int Id)? selectedMusic;
|
||||
private readonly List<SdlAudio> effects = [];
|
||||
private readonly Dictionary<string, SdlAudio> loops = new(StringComparer.OrdinalIgnoreCase);
|
||||
public bool Paused { get; private set; }
|
||||
public int EffectCount => effects.Count;
|
||||
public int LoopCount => loops.Count;
|
||||
public int QueuedEffectBytes => effects.Sum(effect => effect.QueuedBytes) + loops.Values.Sum(effect => effect.QueuedBytes);
|
||||
@@ -26,13 +27,13 @@ public sealed class SceneAudio : IDisposable
|
||||
{
|
||||
StopMusic();
|
||||
if (selectedMusic is { } selection && resources.Wave(selection.Database, selection.Id) is { } wave)
|
||||
music = new(wave.Path, true);
|
||||
music = new(wave.Path, true, Paused);
|
||||
}
|
||||
public void Speech(string database, int id)
|
||||
{
|
||||
StopSpeech();
|
||||
var wave = resources.Wave(database, id) ?? throw new FileNotFoundException($"Missing prepared speech: {database}:{id}");
|
||||
speech = new(wave.Path);
|
||||
speech = new(wave.Path, paused: Paused);
|
||||
}
|
||||
public void StopSpeech() { speech?.Dispose(); speech = null; }
|
||||
// Default current bank set by Jimmy PostLoad423642..656; positional attenuation
|
||||
@@ -41,11 +42,11 @@ public sealed class SceneAudio : IDisposable
|
||||
{
|
||||
var wave = resources.Wave("SoundEffects.omt", id)
|
||||
?? throw new FileNotFoundException($"Missing original default sound effect {id}");
|
||||
if (loopOwner == null) effects.Add(new(wave.Path));
|
||||
if (loopOwner == null) effects.Add(new(wave.Path, paused: Paused));
|
||||
else
|
||||
{
|
||||
StopLoop(loopOwner);
|
||||
loops.Add(loopOwner, new(wave.Path, true));
|
||||
loops.Add(loopOwner, new(wave.Path, true, Paused));
|
||||
}
|
||||
}
|
||||
public void StopLoop(string owner)
|
||||
@@ -60,10 +61,19 @@ public sealed class SceneAudio : IDisposable
|
||||
}
|
||||
public void Pump()
|
||||
{
|
||||
if (Paused) return;
|
||||
music?.Pump(); speech?.Pump();
|
||||
foreach (var effect in loops.Values) effect.Pump();
|
||||
for (var i = effects.Count - 1; i >= 0; i--)
|
||||
if (effects[i].QueuedBytes == 0) { effects[i].Dispose(); effects.RemoveAt(i); }
|
||||
}
|
||||
/// <summary>Modern debug pause; new streams also inherit this state.</summary>
|
||||
public void SetPaused(bool paused)
|
||||
{
|
||||
music?.SetPaused(paused); speech?.SetPaused(paused);
|
||||
foreach (var effect in effects) effect.SetPaused(paused);
|
||||
foreach (var effect in loops.Values) effect.SetPaused(paused);
|
||||
Paused = paused;
|
||||
}
|
||||
public void Dispose() { StopEffects(); StopSpeech(); StopMusic(); }
|
||||
}
|
||||
@@ -9,6 +9,8 @@ public sealed class SdlAudio : IDisposable
|
||||
private nint data;
|
||||
private int length;
|
||||
private readonly bool loop;
|
||||
private bool audioInitialized;
|
||||
public bool Paused { get; private set; }
|
||||
public int QueuedBytes
|
||||
{
|
||||
get
|
||||
@@ -17,10 +19,11 @@ public sealed class SdlAudio : IDisposable
|
||||
return bytes >= 0 ? bytes : throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
}
|
||||
public SdlAudio(string path,bool loop=false)
|
||||
public SdlAudio(string path,bool loop=false,bool paused=false)
|
||||
{
|
||||
this.loop=loop;
|
||||
if(!Sdl.SDL_InitSubSystem(Sdl.InitAudio))throw new InvalidOperationException(Sdl.Error);
|
||||
audioInitialized = true;
|
||||
try
|
||||
{
|
||||
if(!Sdl.SDL_LoadWAV(Path.GetFullPath(path),out var spec,out data,out var size))throw new InvalidOperationException(Sdl.Error);
|
||||
@@ -28,17 +31,28 @@ public sealed class SdlAudio : IDisposable
|
||||
stream=Sdl.SDL_OpenAudioDeviceStream(uint.MaxValue,ref spec,0,0);
|
||||
if(stream==0)throw new InvalidOperationException(Sdl.Error);
|
||||
Queue();
|
||||
if(!Sdl.SDL_ResumeAudioStreamDevice(stream))throw new InvalidOperationException(Sdl.Error);
|
||||
// SDL_OpenAudioDeviceStream starts paused. Keep it paused from its
|
||||
// first sample when created while a debug menu has stopped playback.
|
||||
Paused = true;
|
||||
SetPaused(paused);
|
||||
Console.WriteLine($"SDL3 WAV stream: {spec.Frequency} Hz, {spec.Channels} channel(s), {length} source bytes.");
|
||||
}
|
||||
catch{Dispose();throw;}
|
||||
}
|
||||
public void SetPaused(bool paused)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(stream == 0, this);
|
||||
if (Paused == paused) return;
|
||||
var changed = paused ? Sdl.SDL_PauseAudioStreamDevice(stream) : Sdl.SDL_ResumeAudioStreamDevice(stream);
|
||||
if (!changed) throw new InvalidOperationException(Sdl.Error);
|
||||
Paused = paused;
|
||||
}
|
||||
private void Queue(){if(!Sdl.SDL_PutAudioStreamData(stream,data,length))throw new InvalidOperationException(Sdl.Error);}
|
||||
public void Pump(){if(loop && QueuedBytes<length)Queue();}
|
||||
public void Pump(){if(!Paused && loop && QueuedBytes<length)Queue();}
|
||||
public void Dispose()
|
||||
{
|
||||
if(stream!=0){Sdl.SDL_DestroyAudioStream(stream);stream=0;}
|
||||
if(data!=0){Sdl.SDL_free(data);data=0;}
|
||||
Sdl.SDL_QuitSubSystem(Sdl.InitAudio);
|
||||
if(audioInitialized){Sdl.SDL_QuitSubSystem(Sdl.InitAudio);audioInitialized=false;}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ internal static unsafe class Sdl
|
||||
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)]public static extern void SDL_free(nint buffer);
|
||||
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)]public static extern nint SDL_OpenAudioDeviceStream(uint device,ref AudioSpec spec,nint callback,nint user);
|
||||
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.I1)]public static extern bool SDL_ResumeAudioStreamDevice(nint stream);
|
||||
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.I1)]public static extern bool SDL_PauseAudioStreamDevice(nint stream);
|
||||
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.I1)]public static extern bool SDL_PutAudioStreamData(nint stream,nint buffer,int length);
|
||||
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)]public static extern int SDL_GetAudioStreamQueued(nint stream);
|
||||
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)]public static extern void SDL_DestroyAudioStream(nint stream);
|
||||
|
||||
+170
-28
@@ -83,11 +83,13 @@ internal static class Program
|
||||
--smoke-carl-cutscene Verify input stays locked during the lab conversation
|
||||
--smoke-objective-panel Show original lab objective; --story-time tests timeout
|
||||
--smoke-objective-window SDL O-key reopen/close/timeout check
|
||||
--debug-menu Start with the F1 debug menu open
|
||||
--smoke-debug-menu SDL debug navigation/pause/actions/resize 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
|
||||
Walk: arrows move/turn; Shift, Insert or right mouse jump; R reset.
|
||||
C pauses into inspection / resumes chase camera. F11 fullscreen, Escape quit.
|
||||
F1 debug menu. C pauses into inspection / resumes chase camera. F11 fullscreen, Escape quit.
|
||||
Inspector: arrows/WASD orbit, +/- zoom,
|
||||
F11 fullscreen, Escape quit. Animation preview: 1 idle, 2 run, 3 jump, 4 scratch.
|
||||
Collision/pivot/cadence and animation timing are provisional. Full gameplay remains incomplete.
|
||||
@@ -228,6 +230,7 @@ internal static class Program
|
||||
throw new ArgumentException("Jump binding smoke option requires a movement smoke mode");
|
||||
var practiceWindowSmoke = args.Contains("--smoke-practice-window");
|
||||
var practiceReturnSmoke = args.Contains("--smoke-practice-return");
|
||||
var debugSmoke = args.Contains("--smoke-debug-menu");
|
||||
if (walkSmoke && jetpackSmoke) throw new ArgumentException("Select one movement smoke check");
|
||||
var defaultStory = (defaultScene || args.Contains("--walk")) && !args.Contains("--inspect") && !walkSmoke && !args.Contains("--smoke-window")
|
||||
&& animationPath == null && !args.Contains("--time");
|
||||
@@ -246,6 +249,7 @@ internal static class Program
|
||||
PreviewAnimationLibrary? animations = null;
|
||||
LabSimulation? simulation = null;
|
||||
SceneDirector? director = null;
|
||||
TaskStates? storyTasks = null;
|
||||
SceneActorVisuals? actorVisuals = null;
|
||||
SceneSpriteVisuals? spriteVisuals = null;
|
||||
StaticSceneVisuals? staticVisuals = null;
|
||||
@@ -293,6 +297,7 @@ internal static class Program
|
||||
var save = loadedSave ?? OriginalSave.Load(AssetPath.Resolve(root, "NewGame.tsk"));
|
||||
returnRoot = save.StoredVector;
|
||||
var tasks = new TaskStates(save.Tasks);
|
||||
storyTasks = tasks;
|
||||
director = new SceneDirector(level!, tasks, resources.Duration);
|
||||
interactions = new SceneInteractions(director, tasks, save, level!.Code);
|
||||
objectivePanel = new ObjectivePanel(interactions.CurrentObjective);
|
||||
@@ -341,7 +346,13 @@ internal static class Program
|
||||
mesh = hud.Mesh;
|
||||
Console.WriteLine($"Prepared source model actors: {staticVisuals.ActorCount}.");
|
||||
}
|
||||
Console.WriteLine($"Loaded original geometry: {mesh.Vertices.Length} vertices, {mesh.Indices.Length / 3} triangles, {mesh.Textures.Count + (scene == null ? 1 : 0)} textures.");
|
||||
var debugMenu = new DebugMenu(scene != null && level != null
|
||||
? DebugMenu.AvailableScenes(root, Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene)!, ".."))) : [],
|
||||
Path.GetFileName(levelPath), originalStart?.Tag);
|
||||
if (args.Contains("--debug-menu")) debugMenu.Toggle(storyTasks?.Get("SCENE") ?? 0);
|
||||
var debugOverlay = new DebugMenuOverlay(mesh);
|
||||
mesh = debugOverlay.Mesh;
|
||||
Console.WriteLine($"Loaded original geometry and overlays: {mesh.Vertices.Length} vertices, {mesh.Indices.Length / 3} triangles, {mesh.Textures.Count + (scene == null ? 1 : 0)} textures.");
|
||||
var fixedTimeText = Option(args, "--time");
|
||||
double? fixedTime = fixedTimeText == null ? null : double.Parse(fixedTimeText, System.Globalization.CultureInfo.InvariantCulture);
|
||||
var headless = args.Contains("--headless");
|
||||
@@ -354,7 +365,9 @@ internal static class Program
|
||||
var storyTime = double.Parse(Option(args, "--story-time") ?? "0", System.Globalization.CultureInfo.InvariantCulture);
|
||||
if (!double.IsFinite(storyTime) || storyTime < 0 || storyTime > 3600 || storyTime > 0 && !headless)
|
||||
throw new ArgumentException("Story time must be0..3600 seconds in headless mode.");
|
||||
var frames = int.Parse(Option(args, "--frames") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : headless ? "1" : "0"));
|
||||
var frames = int.Parse(Option(args, "--frames") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : debugSmoke ? "16" : headless ? "1" : "0"));
|
||||
if (debugSmoke && (headless || frames < 16 || director == null || level?.Code != "LV1B" || loadedSave != null || debugMenu.Open))
|
||||
throw new ArgumentException("Debug SDL smoke requires fresh windowed LV1B, closed debug menu and at least16 frames");
|
||||
if (objectiveWindowSmoke && (headless || frames < 180)) throw new ArgumentException("Objective window smoke needs180 window frames");
|
||||
if ((carlSmoke || objectiveSmoke) && (level?.Code != "LV1B" || loadedSave != null || objectiveSmoke && !headless && !objectiveWindowSmoke))
|
||||
throw new ArgumentException("Lab conversation/objective smoke requires fresh LV1B (objective check is headless)");
|
||||
@@ -378,8 +391,9 @@ internal static class Program
|
||||
{
|
||||
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")) : null;
|
||||
? new SdlAudio(audioFile, args.Contains("--loop-audio"), debugMenu.Open) : null;
|
||||
using var sceneAudio = resources != null && !headless && !args.Contains("--mute") ? new SceneAudio(resources) : null;
|
||||
sceneAudio?.SetPaused(debugMenu.Open);
|
||||
double initialPoseTime = 0;
|
||||
if (director != null)
|
||||
{
|
||||
@@ -410,7 +424,7 @@ internal static class Program
|
||||
Console.WriteLine($"Practice RETURN: exact saved root={restored}, root={simulation.ActorRoot}, STRT yaw={simulation.Yaw}, intro suppressed={!director.Playing}, companion restored={companionRestored}.");
|
||||
if (!restored) throw new InvalidOperationException("RETURN did not restore the live departure root without replaying STRT actions");
|
||||
}
|
||||
if (args.Contains("--skip-intro") || jetpackSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
|
||||
if (args.Contains("--skip-intro") || jetpackSmoke || debugSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
|
||||
if (practiceReturnSmoke && level.Code == "VR04")
|
||||
{
|
||||
director.Skip();
|
||||
@@ -456,7 +470,7 @@ internal static class Program
|
||||
if (!practice.Active) throw new InvalidOperationException("Original lab pickup did not open practice modal");
|
||||
if (args.Contains("--smoke-practice-transition") || practiceReturnSmoke) practice.Key(28, Vector2.Zero);
|
||||
}
|
||||
for (var tick = 0; tick < (int)Math.Round(storyTime * 60) && !practice.Active; tick++)
|
||||
for (var tick = 0; tick < (int)Math.Round(storyTime * 60) && !practice.Active && !debugMenu.Open; tick++)
|
||||
{
|
||||
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
|
||||
mechanisms!.Step(FixedStepClock.Step);
|
||||
@@ -469,6 +483,7 @@ internal static class Program
|
||||
}
|
||||
}
|
||||
var keys = new HashSet<uint>();
|
||||
var debugCapturedKeys = new HashSet<uint>();
|
||||
var running = true;
|
||||
var fullscreen = false;
|
||||
var sawKey = false;
|
||||
@@ -494,6 +509,65 @@ internal static class Program
|
||||
double last = clock.Elapsed.TotalSeconds;
|
||||
float angle = 0.6f, elevation = 0.32f;
|
||||
var count = 0;
|
||||
var debugPauseObserved = false;
|
||||
var debugActionsObserved = false;
|
||||
var debugEscapeObserved = false;
|
||||
var debugResumeObserved = false;
|
||||
var debugPausedRoot = simulation?.ActorRoot ?? Vector3.Zero;
|
||||
var debugPausedSteps = simulation?.Steps ?? 0;
|
||||
void ResetScene()
|
||||
{
|
||||
if (simulation == null) { debugMenu.Message = "RESET REQUIRES PLAY MODE"; return; }
|
||||
if (practice.Active) practice.Key(17, Vector2.Zero);
|
||||
simulation.Reset(); poseTime = 0; sceneAudio?.StopSpeech(); director?.Begin(originalStart!);
|
||||
interactions?.Reset(); mechanisms?.Reset();
|
||||
director?.SyncActor(level!.Player!.Tag!, simulation.ActorRoot, new Vector3(0, simulation.Yaw, 0));
|
||||
}
|
||||
void ToggleCamera()
|
||||
{
|
||||
if (originalStart == null) { debugMenu.Message = "CAMERA REQUIRES A SCENE START"; return; }
|
||||
if (simulation == null) { originalCamera = !originalCamera; return; }
|
||||
inspecting = !inspecting;
|
||||
originalCamera = false; target = simulation.ActorRoot; radius = 600;
|
||||
if (window != 0 && !Sdl.SDL_SetWindowTitle(window, inspecting ? animations!.WindowTitle : WalkTitle))
|
||||
throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
void DebugInputBoundary()
|
||||
{
|
||||
debugCapturedKeys.UnionWith(keys);
|
||||
keys.Clear(); mouseJump = false; stepClock.Reset(); last = clock.Elapsed.TotalSeconds;
|
||||
audio?.SetPaused(debugMenu.Open); sceneAudio?.SetPaused(debugMenu.Open);
|
||||
}
|
||||
void DebugCommand(DebugAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case DebugAction.Resume: debugMenu.Close(); break;
|
||||
case DebugAction.Camera: ToggleCamera(); debugMenu.Close(); break;
|
||||
case DebugAction.SkipCutscene:
|
||||
if (director is { Controlled: false }) { sceneAudio?.StopSpeech(); director.Skip(); debugMenu.Message = "CUTSCENE SKIPPED"; }
|
||||
else debugMenu.Message = "NO ACTIVE CUTSCENE";
|
||||
break;
|
||||
case DebugAction.RefillEnergy when simulation != null:
|
||||
simulation.Energy = 100; interactions?.UpdateEnergy(100); debugMenu.Message = "ENERGY REFILLED"; break;
|
||||
case DebugAction.GiveJetpack when interactions != null:
|
||||
interactions.Inventory.SetState(0, 3, 1); interactions.Inventory.SelectGadget(3);
|
||||
debugMenu.Message = "JET PACK GIVEN AND SELECTED"; break;
|
||||
case DebugAction.ApplySceneTask when storyTasks != null:
|
||||
storyTasks.SetExisting("SCENE", debugMenu.SceneTask); debugMenu.Message = $"SCENE TASK SET TO {debugMenu.SceneTask}"; break;
|
||||
case DebugAction.LoadScene when simulation != null && interactions != null && debugMenu.Scene is { } selected:
|
||||
var prepared = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, ".."));
|
||||
var selectedWorld = Mesh.LoadSceneJson(AssetPath.Resolve(prepared,
|
||||
Path.GetFileNameWithoutExtension(selected.LevelFile) + "/scene.json"));
|
||||
var selectedStart = GamLevel.Load(AssetPath.Resolve(root, "gam/" + selected.LevelFile)).FindStart(debugMenu.Start)!;
|
||||
if (new SceneCollision(selectedWorld).GroundHeight(selectedStart.Position, 2500) == null)
|
||||
{ debugMenu.Message = "SELECTED START HAS NO SUPPORTED FLOOR"; break; }
|
||||
RequestTransition(new(selected.LevelFile, debugMenu.Start!, 0, -1)); debugMenu.Close(); break;
|
||||
case DebugAction.Reset: ResetScene(); debugMenu.Close(); break;
|
||||
case DebugAction.None: break;
|
||||
default: debugMenu.Message = "ACTION REQUIRES PLAY MODE"; break;
|
||||
}
|
||||
}
|
||||
Vector2 Pointer()
|
||||
{
|
||||
Sdl.SDL_GetMouseState(out var x, out var y);
|
||||
@@ -524,9 +598,27 @@ internal static class Program
|
||||
if (e.Type is Sdl.Quit or 0x210) running = false;
|
||||
if (e.Type is Sdl.WindowResized or Sdl.WindowPixelSizeChanged) renderer.Resize();
|
||||
if (e.Type is Sdl.WindowFocusLost or Sdl.WindowMinimized)
|
||||
{ keys.Clear(); mouseJump = false; active = false; stepClock.Reset(); }
|
||||
{ keys.Clear(); debugCapturedKeys.Clear(); mouseJump = false; active = false; stepClock.Reset(); }
|
||||
if (e.Type is Sdl.WindowFocusGained or Sdl.WindowRestored)
|
||||
{ active = true; stepClock.Reset(); last = clock.Elapsed.TotalSeconds; }
|
||||
if (e.Type == Sdl.KeyUp && debugCapturedKeys.Remove(e.Scancode)) continue;
|
||||
if (e.Type == Sdl.KeyDown && !debugMenu.Open && debugCapturedKeys.Contains(e.Scancode)) continue;
|
||||
if (e.Type == Sdl.KeyDown && e.Scancode == DebugMenu.ToggleKey)
|
||||
{
|
||||
debugCapturedKeys.Add(e.Scancode);
|
||||
if (e.Repeat == 0) { debugMenu.Toggle(storyTasks?.Get("SCENE") ?? 0); DebugInputBoundary(); }
|
||||
continue;
|
||||
}
|
||||
if (debugMenu.Open)
|
||||
{
|
||||
if (e.Type == Sdl.KeyDown)
|
||||
{
|
||||
debugCapturedKeys.Add(e.Scancode);
|
||||
DebugCommand(debugMenu.Key(e.Scancode, e.Repeat != 0));
|
||||
if (!debugMenu.Open) DebugInputBoundary();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (practice.Active && e.Type == Sdl.MouseButtonDown)
|
||||
{ if (e.MouseButton == 1) practice.Click(Pointer()); keys.Clear(); mouseJump = false; stepClock.Reset(); continue; }
|
||||
if (practice.Active && e.Type == Sdl.KeyDown)
|
||||
@@ -558,22 +650,11 @@ internal static class Program
|
||||
}
|
||||
if (e.Scancode == 6 && e.Repeat == 0 && originalStart != null)
|
||||
{
|
||||
if (simulation != null)
|
||||
{
|
||||
inspecting = !inspecting;
|
||||
keys.Clear(); mouseJump = false; stepClock.Reset();
|
||||
originalCamera = false;
|
||||
target = simulation.ActorRoot;
|
||||
radius = 600;
|
||||
if (!Sdl.SDL_SetWindowTitle(window, inspecting ? animations!.WindowTitle : WalkTitle)) throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
else originalCamera = !originalCamera;
|
||||
ToggleCamera(); keys.Clear(); mouseJump = false; stepClock.Reset();
|
||||
}
|
||||
if (!inspecting && e.Scancode == 21 && e.Repeat == 0)
|
||||
{
|
||||
simulation!.Reset(); poseTime = 0; sceneAudio?.StopSpeech(); director?.Begin(originalStart!);
|
||||
interactions?.Reset(); mechanisms?.Reset();
|
||||
director?.SyncActor(level!.Player!.Tag!, simulation.ActorRoot, new Vector3(0, simulation.Yaw, 0));
|
||||
ResetScene();
|
||||
}
|
||||
if (e.Scancode == 68 && e.Repeat == 0)
|
||||
{
|
||||
@@ -587,9 +668,10 @@ internal static class Program
|
||||
var elapsed = now - last;
|
||||
var dt = (float)Math.Min(elapsed, 0.1);
|
||||
last = now;
|
||||
if (simulation != null && !inspecting && !practice.Active && (active || headless || walkSmoke || jetpackSmoke || objectiveWindowSmoke))
|
||||
if (debugMenu.Open) animationStarted += elapsed;
|
||||
if (simulation != null && !debugMenu.Open && !inspecting && !practice.Active && (active || headless || walkSmoke || jetpackSmoke || objectiveWindowSmoke || debugSmoke))
|
||||
{
|
||||
var steps = headless || walkSmoke || jetpackSmoke || practiceWindowSmoke || carlSmoke || objectiveWindowSmoke ? 1 : stepClock.Advance(elapsed);
|
||||
var steps = headless || walkSmoke || jetpackSmoke || practiceWindowSmoke || carlSmoke || objectiveWindowSmoke || debugSmoke ? 1 : stepClock.Advance(elapsed);
|
||||
for (var step = 0; step < steps; step++)
|
||||
{
|
||||
var input = carlSmoke ? new PlayerInput(true, false, true, false, true)
|
||||
@@ -629,7 +711,7 @@ internal static class Program
|
||||
}
|
||||
characterModel = simulation.Model;
|
||||
}
|
||||
if (inspecting)
|
||||
if (inspecting && !debugMenu.Open)
|
||||
{
|
||||
if (keys.Contains(80) || keys.Contains(4)) angle -= dt;
|
||||
if (keys.Contains(79) || keys.Contains(7)) angle += dt;
|
||||
@@ -659,11 +741,17 @@ internal static class Program
|
||||
staticVisuals?.Update(mesh);
|
||||
jetpackVisuals?.Update(mesh, simulation!);
|
||||
spriteVisuals?.FaceCamera(renderEye, renderTarget, mesh);
|
||||
objectivePanel?.Key(keys.Contains(18) && !inspecting && !practice.Active
|
||||
objectivePanel?.Key(keys.Contains(18) && !debugMenu.Open && !inspecting && !practice.Active
|
||||
&& 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);
|
||||
var debugView = debugMenu.View(new(level?.Code ?? "PREVIEW", originalStart?.Tag ?? "NONE",
|
||||
simulation?.ActorRoot ?? Vector3.Zero, simulation?.Yaw ?? 0, simulation?.Speed ?? 0,
|
||||
simulation?.Grounded ?? false, simulation?.Energy ?? 0, interactions?.Score ?? 0,
|
||||
storyTasks?.Get("SCENE") ?? 0, director?.CurrentTag ?? "NONE", director?.Controlled ?? false,
|
||||
director?.Issues.Count ?? 0, SceneProjection.FarPlane(level?.Code), inspecting));
|
||||
debugOverlay.Update(mesh, debugView.Lines, debugView.SelectedLine);
|
||||
var projection = originalCamera || simulation != null && !inspecting
|
||||
? 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);
|
||||
@@ -673,12 +761,60 @@ internal static class Program
|
||||
animations.Current.Sample(simulation != null && !inspecting ? poseTime
|
||||
: fixedTime ?? (headless ? count / 60.0 : now - animationStarted),
|
||||
mesh.Vertices.AsSpan(characterOffset, animations.Current.Base.Vertices.Length), characterModel);
|
||||
renderer.UpdateVertices(mesh.Vertices);
|
||||
}
|
||||
renderer.UpdateVertices(mesh.Vertices);
|
||||
renderer.Render(view * projection);
|
||||
count++;
|
||||
audio?.Pump();
|
||||
sceneAudio?.Pump();
|
||||
if (debugSmoke)
|
||||
{
|
||||
void Push(uint key, bool down = true, bool repeat = false)
|
||||
{
|
||||
var e = new Sdl.Event { Type = down ? Sdl.KeyDown : Sdl.KeyUp, Scancode = key,
|
||||
Down = down ? (byte)1 : (byte)0, Repeat = repeat ? (byte)1 : (byte)0 };
|
||||
if (!Sdl.SDL_PushEvent(ref e)) throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
void Tap(uint key) { Push(key); Push(key, false); }
|
||||
if (count == 1)
|
||||
{
|
||||
debugPausedRoot = simulation!.ActorRoot; debugPausedSteps = simulation.Steps;
|
||||
director!.Trigger("neutron1a"); // Exercise opening the menu during an actual source MCA.
|
||||
Push(82); Tap(DebugMenu.ToggleKey);
|
||||
if (!Sdl.SDL_SetWindowSize(window, 800, 600)) throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
if (count == 3)
|
||||
{
|
||||
debugPauseObserved = debugMenu.Open && simulation!.ActorRoot == debugPausedRoot
|
||||
&& simulation.Steps == debugPausedSteps && sceneAudio?.Paused != false && director!.Playing;
|
||||
Tap(81); Tap(81); Tap(40); // Skip cutscene.
|
||||
Tap(81); Tap(40); // Refill.
|
||||
Tap(81); Tap(40); // Jet pack.
|
||||
Tap(81); Tap(75); Tap(40); // SCENE30 ->40 via staged PageUp then apply.
|
||||
}
|
||||
if (count == 5)
|
||||
{
|
||||
debugActionsObserved = debugMenu.Open && director!.Controlled && !director.Playing
|
||||
&& simulation!.Energy == 100 && interactions!.Inventory.State(0, 3) == 1
|
||||
&& storyTasks!.Get("SCENE") == 40 && simulation.ActorRoot == debugPausedRoot
|
||||
&& simulation.Steps == debugPausedSteps;
|
||||
if (Option(args, "--screenshot") is { } debugScreenshot)
|
||||
renderer.SavePpm(Path.ChangeExtension(debugScreenshot, ".open.ppm"));
|
||||
}
|
||||
if (count == 7) { Push(41); Push(41, repeat: true); Push(82, repeat: true); }
|
||||
if (count == 8)
|
||||
{
|
||||
debugEscapeObserved = running && !debugMenu.Open && sceneAudio?.Paused != true
|
||||
&& MathF.Abs(simulation!.ActorRoot.X - debugPausedRoot.X) < .001f
|
||||
&& MathF.Abs(simulation.ActorRoot.Z - debugPausedRoot.Z) < .001f;
|
||||
Push(41, false); Push(82, false); Push(82); // Release captured input, then a fresh movement press.
|
||||
}
|
||||
if (count == 12)
|
||||
{
|
||||
debugResumeObserved = simulation!.Steps > debugPausedSteps && simulation.Travel > 1;
|
||||
Push(82, false);
|
||||
}
|
||||
}
|
||||
if (objectiveWindowSmoke)
|
||||
{
|
||||
if (count == 1) objectiveWasHidden = !objectivePanel!.PadVisible;
|
||||
@@ -712,7 +848,7 @@ internal static class Program
|
||||
if (!Sdl.SDL_PushEvent(ref cycle)) throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
}
|
||||
if ((smoke || walkSmoke || jetpackSmoke || practiceWindowSmoke || objectiveWindowSmoke) && renderer.Width == 800 && renderer.Height == 600) didResize = true;
|
||||
if ((smoke || walkSmoke || jetpackSmoke || practiceWindowSmoke || objectiveWindowSmoke || debugSmoke) && renderer.Width == 800 && renderer.Height == 600) didResize = true;
|
||||
if (frames > 0 && count >= frames) break;
|
||||
if (transitionRequest != null) break;
|
||||
}
|
||||
@@ -727,6 +863,11 @@ internal static class Program
|
||||
if (Math.Abs(pixels[i] - 31) + Math.Abs(pixels[i + 1] - 51) + Math.Abs(pixels[i + 2] - 76) > 6) changed++;
|
||||
Console.WriteLine($"Rendered {count} frame(s), {changed} non-background pixels, {renderer.ValidationErrors} Vulkan validation error(s).");
|
||||
if (simulation != null) Console.WriteLine(simulation.Report);
|
||||
if (debugSmoke)
|
||||
{
|
||||
Console.WriteLine($"Debug SDL check: paused={debugPauseObserved}, actions={debugActionsObserved}, Escape/input capture={debugEscapeObserved}, resumed={debugResumeObserved}, resize800x600={didResize}.");
|
||||
if (!debugPauseObserved || !debugActionsObserved || !debugEscapeObserved || !debugResumeObserved || !didResize) return 2;
|
||||
}
|
||||
if (carlSmoke)
|
||||
{
|
||||
var locked = director is { Controlled: false, Playing: true, CurrentTag: "neutron1a" } && simulation!.Steps == 0;
|
||||
@@ -778,7 +919,8 @@ internal static class Program
|
||||
var nextArgs = new List<string>();
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (args[i] is "--smoke-transition" or "--smoke-lab-route" or "--smoke-practice-prompt" or "--smoke-practice-transition") continue;
|
||||
if (args[i] is "--smoke-transition" or "--smoke-lab-route" or "--smoke-practice-prompt" or "--smoke-practice-transition"
|
||||
or "--debug-menu" or "--smoke-debug-menu") continue;
|
||||
if (args[i] is "--scene" or "--level" or "--start" or "--load-save" or "--story-time") { i++; continue; }
|
||||
nextArgs.Add(args[i]);
|
||||
}
|
||||
@@ -818,7 +960,7 @@ internal static class Program
|
||||
}
|
||||
}
|
||||
|
||||
private const string WalkTitle = "Jimmy Neutron — lab checkpoint | Arrows move | Shift / Insert / right mouse jump | R reset | C inspect";
|
||||
private const string WalkTitle = "Jimmy Neutron — lab checkpoint | Arrows move | Shift / Insert / right mouse jump | F1 debug | R reset | C inspect";
|
||||
|
||||
private static int VerifyAssets(string root)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user