Expand description
Editor command dispatch — file I/O, build-game, menu actions.
Free functions invoked from EditorApp::update. They take only the
state they actually need so each one is independently testable and
easy to refactor as commands grow.
Functions§
- apply_
delete 🔒 - apply_
new_ 🔒scene - apply_
open 🔒 - apply_
pause 🔒 - apply_
play 🔒 - apply_
redo 🔒 - apply_
save 🔒 - apply_
save_ 🔒as - apply_
stop 🔒 - apply_
undo 🔒 - browse_
and_ open_ project - Bridge: open a folder picker and rebuild the project VFS at the new location. Used when the user invokes “File > Open Project…” while another project is already loaded.
- load_
scene_ dispatch - Load dispatch: same shape as
save_scene_dispatch. Loads a scene, clearing every entity reference the editor still holds. - process_
menu_ actions - Process every pending menu action queued in
EditorState. Drainspending_browse_project_folderandpending_menu_actionin turn. - process_
pending_ asset_ file_ ops - Drains the asset-explorer file operations (new folder / rename / move /
delete-to-trash / duplicate). Each routes through
ProjectVfs, which keeps the identity registry consistent so references survive renames and moves. - process_
pending_ assign_ material - Drains [
EditorState::pending_assign_material]: setsMaterialRef::Asset(uuid)on every selected entity, whereuuidis derived from the chosen.kmat’s forward-slash relative path. - process_
pending_ assign_ texture - Drains [
EditorState::pending_assign_texture]: assigns a dropped texture or.kmatto a specific entity. A.kmatbecomes aMaterialRef::Asset; an image becomes thebase_color_textureof a fresh inline standard material. - process_
pending_ prefab_ spawn - Drains [
EditorState::pending_prefab_spawn] and instantiates the referenced.kprefabinto the live world via [instantiate_subtree]. The forward-slash relative path resolves through the project’s VFS /AssetService. - process_
pending_ save_ as_ material - Drains [
EditorState::pending_save_as_material]: serializes the entity’s inline material to a.kmat(RON), writes it underassets/materials/<name>.kmat, reindexes the VFS, then rewrites the entity’s component toMaterialRef::Asset(uuid)so it references the freshly-saved shared, reloadable asset. - process_
pending_ save_ as_ prefab - Drains [
EditorState::pending_save_as_prefab] and [EditorState::pending_save_as_prefab_at], writing the entity’s subtree as a.kprefab(Recipe-encoded). - process_
pending_ spawn_ mesh_ asset - Drains [
EditorState::pending_spawn_mesh_asset]: spawns aMeshRef::Assetentity at the drop point. Set by dragging a mesh tile onto the viewport; theasset_resolver_systemloads the mesh next tick. - refresh_
asset_ 🔒cache - Recomputes the asset-browser cache (entries + directories) after a file operation and bumps the epoch so the panel rescans its flattened view.
- resolve_
asset_ 🔒uuid - Resolves a forward-slash relative asset path to its UUID through the open project’s identity registry, falling back to the path-derived default when no project is open.
- run_
build_ game - Build Game dispatch: packs the project’s assets, copies the host-target
khora-runtimebinary into<project>/dist/<target>/, and writes the runtime config so the staged binary auto-loads the project’s default scene. Reports progress + final path through the editor’s logger. - sanitize_
material_ 🔒name - Strips characters unsafe in cross-platform file names from a material
name, falling back to
materialfor an empty result. - save_
prefab_ 🔒to_ project_ path - save_
scene_ dispatch - Save dispatch: routes through the project VFS when the target path
lives under
<project>/assets/, falls back to directstd::fsfor arbitrary out-of-project Save-As destinations. Defaults to theEditorInterchangestrategy. Returns whether the scene reached disk. Failures are logged by the write paths themselves; the flag lets a caller react instead of assuming success. - save_
scene_ dispatch_ with_ goal - Same as
save_scene_dispatchbut with an explicit serialization goal. Used by “Export Scene as RON” (HumanReadableDebug) and any future Save-As strategy picker. - write_
prefab_ 🔒through_ vfs