Editor State
SafiEditorState is the source of truth for whether the app is authoring (Edit), simulating (Play), or temporarily halted (Paused). It is the foundation that the upcoming editor toolbar builds on — M1 of the Editor plan.
The engine installs the singleton automatically in safi_app_init with mode = Edit as the default. Systems, panels, and user code read or mutate it via the ECS singleton API or the convenience accessors below.
Struct
API
Thin wrappers over ecs_singleton_get / ecs_singleton_set. The getters return a sensible default (MODE_EDIT, TOOL_SELECT, 0) if the singleton is missing; the setters no-op in the same case.
selected_entity is the single source of truth — the debug UI Scene panel writes it on click and the Inspector, toolbar, and gizmo system all read it from here.
What the mode controls
The mode field gates two pipelines in safi_app_tick:
Edit and Paused keep input pumping, the Inspector live, and the viewport rendering — only gameplay freezes. When re-entering Play, the fixed-step accumulator is drained so the simulation doesn't try to catch up on minutes of paused time. See Scheduler for the full pipeline breakdown and the SafiGamePhase usage pattern.
Typical uses
Toolbar buttons (the future M1 UI writes the mode):
Inspector panels (read the selection):
Opt into Play at startup for demos that don't have a toolbar yet:
Keybind
Pressing F1 toggles Edit ↔ Play; the shortcut is engine-owned (see Editor Shortcuts). In Edit mode any gameplay system registered on SafiGamePhase freezes, so e.g. the gltf_viewer demo's falling cube stops mid-air; flip back to Play and it resumes. This exercises the pipeline gate described in Scheduler.
See also
- Editor Toolbar — the Play / Pause / Stop + tool-picker buttons that write this singleton
- Editor Gizmo — reads
selected_tool+selected_entityto drive the manipulator - Scheduler —
SafiGamePhaseand how gating works under the hood - Scene Serialization —
safi_scene_snapshot_all/safi_scene_restore_snapshot, the primitives Play → Stop uses - Editor plan — milestone-by-milestone breakdown