kitgit

tirbofish/dropbear · diff

953f5ec · tk

Merge branch 'main' of github.com:4tkbytes/dropbear

Unverified

diff --git a/Cargo.toml b/Cargo.toml
index 090d228..52e9f71 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,7 +8,6 @@ package.readme = "README.md"
 resolver = "3"
 members = [ "dropbear-engine", "dropbear-shader", "dropbear_future-queue", "eucalyptus-core", "eucalyptus-editor", "magna-carta", "redback-runtime"]
 
-
 [workspace.dependencies]
 anyhow = { version = "1.0", features = ["backtrace"] }
 app_dirs2 = "2.5"
diff --git a/eucalyptus-core/src/states.rs b/eucalyptus-core/src/states.rs
index e7fdd72..93aae3d 100644
--- a/eucalyptus-core/src/states.rs
+++ b/eucalyptus-core/src/states.rs
@@ -34,6 +34,57 @@ pub static SOURCE: Lazy<RwLock<SourceConfig>> = Lazy::new(|| RwLock::new(SourceC
 
 pub static SCENES: Lazy<RwLock<Vec<SceneConfig>>> = Lazy::new(|| RwLock::new(Vec::new()));
 
+/// Removes a scene with the provided name from the in-memory scene cache.
+/// Returns `true` when a scene was removed and `false` when no matching scene existed.
+pub fn unload_scene(scene_name: &str) -> bool {
+    let mut scenes = SCENES.write();
+    let initial_len = scenes.len();
+    scenes.retain(|scene| scene.scene_name != scene_name);
+    let removed = scenes.len() != initial_len;
+
+    if removed {
+        log::info!("Unloaded scene '{}' from memory", scene_name);
+    } else {
+        log::debug!("Scene '{}' was not loaded; nothing to unload", scene_name);
+    }
+
+    removed
+}
+
+/// Reads a scene configuration from disk based on the active project's path.
+pub fn load_scene(scene_name: &str) -> anyhow::Result<SceneConfig> {
+    let scene_path = {
+        let project = PROJECT.read();
+        if project.project_path.as_os_str().is_empty() {
+            return Err(anyhow::anyhow!("Project path is not set; cannot load scenes"));
+        }
+
+        project
+            .project_path
+            .join("scenes")
+            .join(format!("{}.eucs", scene_name))
+    };

Large diffs are not rendered by default. Showing the first 50 of 667 lines. Show full diff