IPlayModeController (Engine.Editor.Contracts) wraps IWorld.Snapshot()/ Restore() as EnterPlay/ExitPlay — the entire mechanism is that one snapshot, per Snapshot's own doc comment. Exposed as a service, not just something engine.editor's UI calls directly, so a future non-UI driver (a test harness, a headless "play for N frames" CLI command) can drive Play mode without depending on ImGui. Engine.Host now looks up IPlayModeController once and checks IsPlaying every frame before running Stage.Update: Edit mode still renders the scene (so the view isn't frozen and the editor UI stays responsive) but never ticks it, same distinction Unity draws between its Scene and Game views. A project with no engine.editor loaded sees no behavior change — Update runs unconditionally, same as before this existed. Added "play"/"stop" as stdin commands alongside the existing "r" and "screenshot", both real controls (not just test scaffolding) for driving Play mode without a mouse — which is also how this got verified: an interactive run sent "play", screenshotted, sent "stop", and the log shows "Entered Play mode in 13.2ms", the real editor path exercising the same under-100ms budget WorldSnapshotTests already proves at the kernel level. The Lingua Editor panel's button/label flip Play/(Edit mode) to Stop/(Playing) correctly across both screenshots. Also fixes a real layout bug hit while verifying this: SetNextWindowPos with ImGuiCond.FirstUseEver only applies with no prior imgui.ini entry for that window title, and this project had already accumulated one from earlier runs (all three panels stacked exactly on top of each other) — gave each panel its own default position and .gitignore'd imgui.ini, which is per-machine session state, not source. Full suite still green: 65 tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
22 lines
796 B
C#
22 lines
796 B
C#
namespace Engine.Editor.Contracts;
|
|
|
|
/// <summary>
|
|
/// Play/Stop, backed by IWorld.Snapshot()/Restore() — see those doc
|
|
/// comments for why a scene-format snapshot, not a separate clone
|
|
/// mechanism, is what Play mode actually is. Engine.Host reads IsPlaying
|
|
/// each frame to decide whether to run Stage.Update at all: Edit mode
|
|
/// renders the scene but never ticks it, same as Unity's Scene view versus
|
|
/// Game view distinction. Exposed as a service (not something only
|
|
/// engine.editor's own UI calls) so a future non-UI driver — a test
|
|
/// harness, a CLI "play for N frames and dump" command — can drive Play
|
|
/// mode without depending on ImGui at all.
|
|
/// </summary>
|
|
public interface IPlayModeController
|
|
{
|
|
bool IsPlaying { get; }
|
|
|
|
void EnterPlay();
|
|
|
|
void ExitPlay();
|
|
}
|