Skip to main content

EditorScene

Struct EditorScene 

Source
pub struct EditorScene {
Show 19 fields open_scenes: Vec<OpenScene>, active_scene: usize, hover_blink_time: f32, project: Option<Project>, last_mouse_pos: (f32, f32), recent: RecentProjects, load: Option<LoadState>, egui: EguiLayer, assets_expanded: bool, texture_previews: HashMap<PathBuf, TextureHandle>, mode: EditorMode, script_errors: Vec<(String, Instant)>, export_status: Option<(String, Instant)>, settings: EditorSettings, renaming_script: Option<PathBuf>, script_rename_buffer: String, renaming_scene: Option<PathBuf>, scene_rename_buffer: String, play_confirmation: Option<Vec<PathBuf>>,
}

Fields§

§open_scenes: Vec<OpenScene>

Every scene currently open for editing — always has at least one entry (a blank placeholder before any project is opened, same as the editor’s old always-present single World), so Self::active_scene is always a valid index into it.

§active_scene: usize§hover_blink_time: f32

Elapsed time accumulator driving the hover blink, shared across tabs since it’s a plain animation clock, not per-scene state.

§project: Option<Project>§last_mouse_pos: (f32, f32)§recent: RecentProjects§load: Option<LoadState>§egui: EguiLayer§assets_expanded: bool§texture_previews: HashMap<PathBuf, TextureHandle>

Cached texture thumbnails for the Assets panel, keyed by project-relative path — global rather than per-tab since it’s a decode cache for the project’s assets/ folder, not scene-specific state; cleared only when a different project is opened.

§mode: EditorMode§script_errors: Vec<(String, Instant)>

Recent script compile/runtime errors and when each was recorded, for the overlay in [ui::draw_script_error_overlay] — pruned by SCRIPT_ERROR_DISPLAY each frame and cleared outright on Stop.

§export_status: Option<(String, Instant)>

The outcome of the last Export (see ui::draw_export_status_overlay), and when it was recorded — aged out after EXPORT_STATUS_DISPLAY, same shape as script_errors but for one message instead of a list.

§settings: EditorSettings

Editor-wide preferences (currently just the external editor “Open Script” launches), persisted next to the executable like RecentProjects.

§renaming_script: Option<PathBuf>

The script currently being renamed inline in the Assets panel, if any — mirrors renaming/rename_buffer above, just keyed by a script’s project-relative path instead of an [Entity] since scripts aren’t ECS entities.

§script_rename_buffer: String§renaming_scene: Option<PathBuf>

Mirrors renaming_script/script_rename_buffer, for a scene tile in the Assets panel’s Scenes section.

§scene_rename_buffer: String§play_confirmation: Option<Vec<PathBuf>>

Some(dirty tab paths) while the pre-Play “unsaved changes” dialog (see draw_play_confirmation) is up, blocking the rest of update until resolved — set when Play is requested while any tab is dirty, cleared once the user picks Save & Play, Play Without Saving, or Cancel.

Implementations§

Source§

impl EditorScene

Source

pub fn opening(action: PendingAction) -> Self

Builds a scene that will create or open action’s project root on its first update.

Source

fn queue_action(&mut self, action: PendingAction)

Queues action to start on the next update.

Source

fn start_load(&mut self, action: PendingAction)

Resolves action into an open Project (fast: just filesystem/manifest/scene-file work, no asset decoding), replacing every currently open tab with the project’s start scene and queuing its entities — if any — to be loaded incrementally afterward. Records the project in the recent-projects list. A different project’s tabs are meaningless once the project changes, so unlike Self::switch_or_open_scene there’s nothing to preserve here.

Source

fn switch_or_open_scene(&mut self, path: PathBuf)

Switches to path (project-relative) within the currently open project: if it’s already open in a tab, just activates that tab (no reload — the whole point of keeping scenes loaded). Otherwise loads it as a brand new tab, appended once loaded, leaving every other tab untouched. A no-op if no project is open, or if path fails to load (reported, no tab opened, so a corrupt scene file doesn’t risk getting silently overwritten by a later Save). Stops Play first if it’s running — a live ScriptRuntime holds Entity handles into whichever tab was active when Play started, and switching away from it would leave those pointing at nothing.

Source

fn close_scene_tab(&mut self, path: PathBuf)

Closes the tab for path, autosaving it first — a no-op if it’s the only tab open (a project always keeps at least one scene open for editing) or if path isn’t open. Stops Play first if the tab being closed is the one Play is currently targeting.

Source

fn rename_scene(&mut self, old_path: PathBuf, new_stem: String)

Renames the scene file at old_path (project-relative) to new_stem, keeping its extension, then updates ProjectManifest.start_scene (if it named the renamed scene) and any open tab’s identity to match. Refuses (and reports, rather than silently overwriting) if something is already using the target name. Doesn’t fix up scene.change("...") calls inside script source — see ui::draw_scene_tile’s doc comment for why that’s not possible the way Self::rename_script fixes up ScriptAttachments.

Source

fn rename_script(&mut self, old_path: PathBuf, new_stem: String)

Renames the script file at old_path (project-relative) to new_stem, keeping its extension, then fixes up and saves every [libdqg::scripting::ScriptAttachment] that referenced the old path — in every open tab’s live World (saved immediately, not just left dirty) and every scene file on disk that isn’t currently open. A script can be attached to entities in any scene in the project, not just whichever one happens to be the active tab, so both are needed — fixing up only the active World (as an earlier, single-scene version of this did) would silently leave every other scene’s reference pointing at a file that no longer exists. Refuses (and reports, rather than silently overwriting) if something is already using the target name.

Copies rather than renames the file up front, deleting the original only once every scene has been migrated (or confirmed not to reference it) — a scene file that fails to load or save partway through this (corrupt on disk, a failed write, …) is rare but not impossible, and with a plain rename that failure would leave that scene’s attachment pointing at a file that’s already gone. Copying first means both names stay valid on disk for the duration, so a partial failure just leaves some scenes referencing the old name and some the new one — both of which still resolve — rather than a dangling reference.

Source

fn start_play(&mut self, renderer: &Renderer<'_>)

Snapshots the active tab’s whole [World] and starts every enabled script attachment (in order) on every entity that has one, then switches to EditorMode::Playing. A no-op if there’s no open project (the Play button is disabled in that case anyway — see ui::draw_menu_bar).

Source

fn stop_play(&mut self)

Restores the whole [World] start_play snapshotted (into whichever tab was active when Play started) and drops the [ScriptRuntime] (and with it every script’s persistent state), switching back to EditorMode::Edit.

Source

fn request_play(&mut self, renderer: &Renderer<'_>)

Handles a Play click: if any tab is dirty, holds off starting Play and instead raises the confirmation dialog (see Self::play_confirmation) — scene.change(...) reads straight off disk, so a script that jumps to a dirty other tab during this session would otherwise silently see whatever was last saved there, not what’s on screen right now. Starts Play immediately, with no prompt, if nothing is dirty.

Source

fn save_all_dirty(&mut self) -> bool

Saves every dirty open tab (not just the active one) — the “Save & Play” choice in the pre-Play confirmation dialog, and also what a successful Export does before packaging (see Scene::update’s export_project handling) — both need every tab’s on-disk copy current, not just whichever one is active. Returns true only if every dirty tab was actually saved — callers that need every on-disk scene current before proceeding (Export; the pre-Play confirmation’s “Save & Play”) must check this rather than assuming a save attempt is the same as a successful one.

Trait Implementations§

Source§

impl Scene for EditorScene

Source§

fn update( &mut self, delta_time: f32, input_state: &InputState, mouse_state: &MouseState, renderer: Option<&mut Renderer<'_>>, ) -> SceneTransition

Source§

fn render(&mut self, pass: &mut DrawPass<'_>)

Source§

fn on_window_event(&mut self, event: &WindowEvent)

Receives every raw winit window event, ahead of any App-level handling. Default is a no-op; override to feed events into something like egui-winit that needs the raw stream.
Source§

fn render_overlay( &mut self, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, view: &TextureView, )

Called after the main render pass has ended but before the frame is submitted, with the same encoder/target view so a second pass can be recorded on top (e.g. compositing an egui UI). Default is a no-op.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more