simvx.editor.state

Editor State — Central state manager for the editor.

Module Contents

Classes

State

Central state manager holding all editor state.

Data

log

API

simvx.editor.state.log

‘getLogger(…)’

class simvx.editor.state.State[source]

Bases: simvx.core.file_state.FileStateMixin, simvx.editor.live_file_ops.LiveFileOps, simvx.editor.scene_file_ops.SceneFileOps, simvx.editor.script_ops.ScriptOps, simvx.editor.node_ops.NodeOps

Central state manager holding all editor state.

Acts as the single source of truth for the editor — panels read from and write to this object, coordinating via signals.

Scene-specific state (edited_scene, selection, undo_stack, editor_camera, viewport_mode, _modified) is delegated to the active scene tab via WorkspaceTabs. Fallback objects are used when no scene tab is active.

Operations are organised into mixins:

  • SceneFileOps — new/open/save scene, file dialogs, recent files

  • ScriptOps — attach/detach/create/save scripts

  • NodeOps — node CRUD, placement mode, scene title

Initialization

property edited_scene: simvx.core.SceneTree[source]
property current_scene_path: pathlib.Path | None[source]
property selection: simvx.core.Selection[source]
property undo_stack: simvx.core.UndoStack[source]
property editor_camera: simvx.core.OrbitCamera3D[source]
property viewport_mode: str[source]
property project_root: str[source]
property modified: bool[source]
dirty_paths() set[pathlib.Path][source]

Return the resolved file paths of all open buffers with unsaved changes.

Combines dirty file-backed script tabs and dirty scene tabs (the latter only when the scene has been saved at least once and therefore has a path on disk). Used by the file browser’s git-status dot to colour in-editor unsaved files yellow (Status.MODIFIED_UNSAVED).

Wrapped in a try/except: this runs in the GitStatusProvider polling thread; any exception there would kill the poller, so we swallow and log instead.

play_scene()[source]

Enter play mode on the active scene tab.

Delegates to PlayMode when available (creates an isolated game tree). Falls back to the legacy embed-in-viewport approach otherwise.

pause_scene()[source]

Toggle pause during play mode.

stop_scene()[source]

Exit play mode and restore the scene.

open_file(path: str | pathlib.Path) None
instantiate_class(cls: type) simvx.core.Node | None
classify_file(module: types.ModuleType, file_path: str) str
find_node_classes(module: types.ModuleType) list[tuple[str, type]]
get_primary_class(module: types.ModuleType, file_path: str) type | None
new_scene(root_type: type = Node, *, populate: bool = False)
open_scene(path: str | pathlib.Path)
save_scene(path: str | pathlib.Path | None = None, *, force: bool = False)
set_script_text(text: str)
attach_script(node: simvx.core.Node, path: str, class_name: str = '')
detach_script(node: simvx.core.Node)
create_script(node: simvx.core.Node, template_name: str, class_name: str, rel_path: str) str | None
get_scene_title() str
find_node(path: str) simvx.core.Node | None
rename_node(node: simvx.core.Node, new_name: str)
set_node_property(node: simvx.core.Node, prop: str, value)
add_node(node: simvx.core.Node, parent: simvx.core.Node | None = None)
remove_node(node: simvx.core.Node)
duplicate_node(node: simvx.core.Node) simvx.core.Node | None
enter_place_mode(node_class: type)
cancel_place_mode()
place_node_at(x: float, y: float, parent: simvx.core.Node | None = None)