Skip to main content

Project

Struct Project 

Source
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: ProjectManifest

Implementations§

Source§

impl Project

Source

fn assets_dir(&self) -> PathBuf

Source

pub fn textures_dir(&self) -> PathBuf

Source

pub fn models_dir(&self) -> PathBuf

Source

pub fn scripts_dir(&self) -> PathBuf

Source

fn scenes_dir(&self) -> PathBuf

Source

pub fn start_scene_path(&self) -> PathBuf

The absolute path to the project’s start scene — see ProjectManifest::start_scene.

Source

fn manifest_path(&self) -> PathBuf

Source

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.

Source

pub fn open(root: PathBuf) -> Result<Self>

Opens an existing project folder by reading its manifest.

Source

pub fn save_scene( &self, path: &Path, world: &World, assets: &HashMap<Entity, RenderableAsset>, ) -> Result<()>

Saves world to the scene file at path (project-relative).

Source

pub fn load_scene(&self, path: &Path) -> Result<SceneFile>

Loads the scene file at path (project-relative).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

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

§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

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