Skip to main content

Module commands

Module commands 

Source
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. Drains pending_browse_project_folder and pending_menu_action in 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]: sets MaterialRef::Asset(uuid) on every selected entity, where uuid is derived from the chosen .kmat’s forward-slash relative path.
process_pending_assign_texture
Drains [EditorState::pending_assign_texture]: assigns a dropped texture or .kmat to a specific entity. A .kmat becomes a MaterialRef::Asset; an image becomes the base_color_texture of a fresh inline standard material.
process_pending_prefab_spawn
Drains [EditorState::pending_prefab_spawn] and instantiates the referenced .kprefab into 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 under assets/materials/<name>.kmat, reindexes the VFS, then rewrites the entity’s component to MaterialRef::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 a MeshRef::Asset entity at the drop point. Set by dragging a mesh tile onto the viewport; the asset_resolver_system loads 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-runtime binary 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 material for 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 direct std::fs for arbitrary out-of-project Save-As destinations. Defaults to the EditorInterchange strategy. 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_dispatch but with an explicit serialization goal. Used by “Export Scene as RON” (HumanReadableDebug) and any future Save-As strategy picker.
write_prefab_through_vfs 🔒