pub struct Project {
pub root: PathBuf,
pub manifest: ProjectManifest,
}Expand description
A project on disk: a folder containing a manifest plus assets/, scenes/, scripts/
subfolders. Entities can attach one or more .rhai files from scripts/ — see
Project::list_scripts/Project::create_script and
[libdqg::scripting::ScriptRuntime].
Fields§
§root: PathBuf§manifest: ProjectManifestImplementations§
Source§impl Project
impl Project
fn assets_dir(&self) -> PathBuf
pub fn textures_dir(&self) -> PathBuf
pub fn models_dir(&self) -> PathBuf
pub fn scripts_dir(&self) -> PathBuf
fn scenes_dir(&self) -> PathBuf
Sourcepub fn start_scene_path(&self) -> PathBuf
pub fn start_scene_path(&self) -> PathBuf
The absolute path to the project’s start scene — see ProjectManifest::start_scene.
fn manifest_path(&self) -> PathBuf
Sourcepub fn create(root: PathBuf) -> Result<Self>
pub fn create(root: PathBuf) -> Result<Self>
Creates a new project folder at root: assets/{textures,models}/, scenes/,
scripts/, a manifest, and an empty scene file so Project::open/Project::load_scene
always find a valid file even before the first save.
Sourcepub fn open(root: PathBuf) -> Result<Self>
pub fn open(root: PathBuf) -> Result<Self>
Opens an existing project folder by reading its manifest.
Sourcepub fn save_scene(
&self,
path: &Path,
world: &World,
assets: &HashMap<Entity, RenderableAsset>,
) -> Result<()>
pub fn save_scene( &self, path: &Path, world: &World, assets: &HashMap<Entity, RenderableAsset>, ) -> Result<()>
Saves world to the scene file at path (project-relative).
Sourcepub fn load_scene(&self, path: &Path) -> Result<SceneFile>
pub fn load_scene(&self, path: &Path) -> Result<SceneFile>
Loads the scene file at path (project-relative).
Sourcepub fn list_scenes(&self) -> Vec<PathBuf>
pub fn list_scenes(&self) -> Vec<PathBuf>
Lists .ron scene files already in the project (relative to the project root), for the
Assets panel’s Scenes section. Same shape as Project::list_scripts.
Sourcepub fn create_scene(&self) -> Result<PathBuf>
pub fn create_scene(&self) -> Result<PathBuf>
Creates a new empty .ron scene file in scenes/, for the Assets panel’s “New Scene”
button — the create-from-scratch counterpart to Project::create_script. Never
overwrites: tries Scene.ron, then Scene2.ron, … Returns its project-relative path.
Sourcepub fn set_start_scene(&mut self, scene: PathBuf) -> Result<()>
pub fn set_start_scene(&mut self, scene: PathBuf) -> Result<()>
Marks scene (project-relative) as the project’s start scene and persists the manifest
immediately, so it survives without an explicit project-level Save step. Normalizes
scene’s separators (see to_portable_path) in case the caller built it some way other
than one of this struct’s own path-returning methods.
Transactional: if serializing or writing the manifest fails, self.manifest.start_scene
is restored to whatever it was before this call, so a failure here never leaves the
in-memory manifest disagreeing with what’s actually on disk — callers don’t each need
their own copy of that rollback.
Sourcepub fn list_assets(&self, kind: RenderableKind) -> Vec<PathBuf>
pub fn list_assets(&self, kind: RenderableKind) -> Vec<PathBuf>
Lists assets of the given kind already in the project (relative to the project root),
for the Assets panel and the inspector’s attach-renderable picker to share. Filtered to
each kind’s own extension(s) — models_dir() also holds .mtl files and any textures an
imported .obj depends on (see import_obj_dependencies), neither of which is itself an
attachable model.
Sourcepub fn list_scripts(&self) -> Vec<PathBuf>
pub fn list_scripts(&self) -> Vec<PathBuf>
Lists .rhai script files already in the project (relative to the project root), for
the Assets panel and the inspector’s attach-script picker to share. Same shape as
Project::list_assets, just for the one script kind instead of a
RenderableKind-style enum.
Sourcepub fn create_script(&self) -> Result<PathBuf>
pub fn create_script(&self) -> Result<PathBuf>
Creates a new .rhai file in the project’s scripts/ folder, pre-filled with
on_start/on_update boilerplate (see SCRIPT_BOILERPLATE), and returns its path
relative to the project root — for the Assets panel’s “New Script” button, the
create-from-scratch counterpart to Project::import_asset. Never overwrites an
existing file: tries Script.rhai, then Script2.rhai, Script3.rhai, … until it
finds a name nothing is using yet.
Sourcepub fn import_asset(&self, src: &Path) -> Result<PathBuf>
pub fn import_asset(&self, src: &Path) -> Result<PathBuf>
Copies src into the project’s assets/ folder, sorted into textures//models//
scripts/ by extension (anything else falls back to a flat assets/ folder). Importing
an .obj also copies its referenced .mtl file(s) and the textures those reference, so
the model still loads from its new location. Returns the new path, relative to the
project root.
Sourcefn import_obj_dependencies(obj_src: &Path, dest_dir: &Path) -> Result<()>
fn import_obj_dependencies(obj_src: &Path, dest_dir: &Path) -> Result<()>
Best-effort copy of an OBJ’s mtllib material file(s) and the textures they reference
(map_Kd/map_Ka/map_Ks/bump/… lines), alongside it in dest_dir, mirroring
[Model::load]’s own path resolution (relative to the OBJ’s/MTL’s own directory) so the
copied files still resolve once loaded from the project. Not a full MTL parser — assumes
the referenced filename is the last whitespace-separated token on the line, which covers
typical exporter output.
Auto Trait Implementations§
impl Freeze for Project
impl RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl UnsafeUnpin for Project
impl UnwindSafe for Project
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> DowncastSync for T
impl<T> DowncastSync for T
§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