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: f32Elapsed 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: EditorSettingsEditor-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
impl EditorScene
Sourcepub fn opening(action: PendingAction) -> Self
pub fn opening(action: PendingAction) -> Self
Builds a scene that will create or open action’s project root on its first update.
Sourcefn queue_action(&mut self, action: PendingAction)
fn queue_action(&mut self, action: PendingAction)
Queues action to start on the next update.
Sourcefn start_load(&mut self, action: PendingAction)
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.
Sourcefn switch_or_open_scene(&mut self, path: PathBuf)
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.
Sourcefn close_scene_tab(&mut self, path: PathBuf)
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.
Sourcefn rename_scene(&mut self, old_path: PathBuf, new_stem: String)
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.
Sourcefn rename_script(&mut self, old_path: PathBuf, new_stem: String)
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.
Sourcefn start_play(&mut self, renderer: &Renderer<'_>)
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).
Sourcefn stop_play(&mut self)
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.
Sourcefn request_play(&mut self, renderer: &Renderer<'_>)
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.
Sourcefn save_all_dirty(&mut self) -> bool
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
impl Scene for EditorScene
fn update( &mut self, delta_time: f32, input_state: &InputState, mouse_state: &MouseState, renderer: Option<&mut Renderer<'_>>, ) -> SceneTransition
fn render(&mut self, pass: &mut DrawPass<'_>)
Source§fn on_window_event(&mut self, event: &WindowEvent)
fn on_window_event(&mut self, event: &WindowEvent)
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,
)
fn render_overlay( &mut self, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, view: &TextureView, )
egui UI). Default is a no-op.Auto Trait Implementations§
impl !Freeze for EditorScene
impl !RefUnwindSafe for EditorScene
impl !Send for EditorScene
impl !Sync for EditorScene
impl !UnwindSafe for EditorScene
impl Unpin for EditorScene
impl UnsafeUnpin for EditorScene
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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