Collisions: init bucket heads to -1 (QueryAabb hung before the first rebuild), reset query stamps on truncated QueryAabb (later queries silently dropped entities), inside-origin raycasts hit at fraction 0 for circles too, exactly-touching boxes now pair like touching circles. Graphics: render into the letterbox viewport so the picture matches ScreenToWorld/WorldToScreen instead of stretching; Y-sort by the transform pivot rather than the quad center; lock-free snapshot LayerRegistry (parallel submit read it unsynchronized); validate InitialCapacity; warn when UseRenderer2D drops options of a later scene. Core: scenes are explicitly single-use (re-loading threw silently duplicated systems/entities before — now it throws), Scene.RegisterUnload for per-scene resources, a switch requested during the reveal phase covers again instead of hard-swapping, borderless fullscreen (HardwareModeSwitch off), InputCapture service for input-suppressing overlays, host disposes the transition renderer and IDisposable services on shutdown. Input: game input reads as released while InputCapture is held; mouse position and wheel freeze so deltas stay zero. DevConsole: holds InputCapture while open (typing no longer drives the camera), Revision increments only under the lock, quoted command arguments, history capped at 256. UI: scene Desktop skips Myra input processing while the console is open (clicks no longer fall through), is disposed on scene unload, and Myra init no longer depends on a process-static flag. Audio: validate channel count/sample rate before stopping the previous track, empty looped oggs no longer hang FillBuffers, the instance stops when a non-looping track drains (IsPlaying was stuck true). Atlases: metadata v2 stores per-source size+mtime snapshots, so timestamp-preserving copies and renames invalidate correctly; loader checks the version and disposes pages on partial load failure; shared pages never exceed a non-POT MaxPageSize; oversized items pack first onto exact-size pages instead of splitting an open shared page; the CLI validates numeric options. Assets.Generator: file names are escaped in XML docs and string literals, members no longer collide with the enclosing class (CS0542), and the Assets root is resolved against build_property.projectdir so nested "Assets" directories do not shift region paths. Pathfinding: queries throw when the grid was resized after construction; generation stamps survive int overflow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
56f2a85478
commit
501d81e19f
@@ -9,41 +9,66 @@ namespace MrGameEng.UI;
|
||||
/// <summary>
|
||||
/// Draw system rendering the scene's Myra <see cref="Desktop"/>. Must run after the scene's
|
||||
/// world rendering (register UI last in the draw phase) — the UI is drawn on top in window
|
||||
/// pixels and also processes mouse/keyboard interaction during render.
|
||||
/// pixels and also processes mouse/keyboard interaction during render. While
|
||||
/// <see cref="InputCapture.Captured"/> is set (developer console open), the desktop is drawn
|
||||
/// without processing input, so overlay clicks and keystrokes do not fall through to it.
|
||||
/// </summary>
|
||||
public sealed class UiRenderSystem : BaseSystem
|
||||
{
|
||||
private readonly Desktop _desktop;
|
||||
private readonly InputCapture? _capture;
|
||||
|
||||
/// <summary>Creates the system for <paramref name="desktop"/>.</summary>
|
||||
public UiRenderSystem(Desktop desktop) => _desktop = desktop;
|
||||
public UiRenderSystem(Desktop desktop, InputCapture? capture = null)
|
||||
{
|
||||
_desktop = desktop;
|
||||
_capture = capture;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnUpdateGroup() => _desktop.Render();
|
||||
protected override void OnUpdateGroup()
|
||||
{
|
||||
if (_capture?.Captured == true)
|
||||
{
|
||||
// Render() = UpdateInput + UpdateLayout + RenderVisual; пропускаем только ввод.
|
||||
_desktop.UpdateLayout();
|
||||
_desktop.RenderVisual();
|
||||
}
|
||||
else
|
||||
{
|
||||
_desktop.Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Wires the UI module (Myra) into a <see cref="Scene"/>.</summary>
|
||||
public static class SceneUiExtensions
|
||||
{
|
||||
private static bool _environmentInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Myra <see cref="Desktop"/> for this scene and registers
|
||||
/// <see cref="UiRenderSystem"/> in the draw phase. Call from <c>OnLoad</c>
|
||||
/// <b>after</b> <c>UseRenderer2D()</c> so the UI draws on top of the world.
|
||||
/// Build the UI by assigning <see cref="Desktop.Root"/>.
|
||||
/// Build the UI by assigning <see cref="Desktop.Root"/>. The desktop is disposed
|
||||
/// automatically when the scene unloads.
|
||||
/// </summary>
|
||||
public static Desktop UseUI(this Scene scene)
|
||||
{
|
||||
// Геттер MyraEnvironment.Game бросает исключение, пока Game не задан — проверять через ??= нельзя.
|
||||
if (!_environmentInitialized)
|
||||
var services = scene.Context.Services;
|
||||
|
||||
// Присваивание идемпотентно; геттер MyraEnvironment.Game бросает исключение, пока
|
||||
// Game не задан, поэтому проверять текущее значение перед записью нельзя.
|
||||
MyraEnvironment.Game = services.Get<Game>();
|
||||
|
||||
var capture = services.GetOrDefault<InputCapture>();
|
||||
if (capture is null)
|
||||
{
|
||||
MyraEnvironment.Game = scene.Context.Services.Get<Game>();
|
||||
_environmentInitialized = true;
|
||||
capture = new InputCapture();
|
||||
services.Add(capture);
|
||||
}
|
||||
|
||||
var desktop = new Desktop();
|
||||
scene.DrawSystems.Add(new UiRenderSystem(desktop));
|
||||
scene.RegisterUnload(desktop.Dispose);
|
||||
scene.DrawSystems.Add(new UiRenderSystem(desktop, capture));
|
||||
return desktop;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user