MCPcopy Create free account
hub / github.com/PerroEngine/Perro / open_scene_path

Function open_scene_path

perro_editor/res/scripts/assets/editor_assets.rs:543–620  ·  view source on GitHub ↗
(
    ctx: &mut ScriptContext<'_, API>,
    scene_path: &str,
)

Source from the content-addressed store, hash-verified

541 }
542 state.log = format!("expand files\n{} dirs", state.file_expanded_paths.len());
543 });
544 refresh_all(ctx);
545}
546
547pub fn collapse_file_tree_all<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) {
548 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
549 state.file_expanded_paths.clear();
550 state.file_expanded_paths.push("res://".to_string());
551 state.file_scope.clear();
552 if state.active_asset_path.ends_with('/') {
553 state.active_asset_path = "res://".to_string();
554 }
555 state.log = "fold files\nroot".to_string();
556 });
557 refresh_all(ctx);
558}
559
560pub fn open_scene_path<API: ScriptAPI + ?Sized>(
561 ctx: &mut ScriptContext<'_, API>,
562 scene_path: &str,
563) {
564 if scene_path.ends_with('/') {
565 set_log(
566 ctx,
567 &format!("folder\n{}", editor_files::rel_label(scene_path)),
568 );
569 return;
570 }
571 if !scene_path.ends_with(".scn") {
572 set_log(
573 ctx,
574 &format!(
575 "{} file\n{}",
576 editor_files::kind_label(scene_path),
577 editor_files::rel_label(scene_path)
578 ),
579 );
580 refresh_all(ctx);
581 return;
582 }
583 let restored = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
584 let idx = state.open_paths.iter().position(|path| path == scene_path)?;
585 capture_active_scene_session(state);
586 if !restore_scene_session(state, idx) {
587 return None;
588 }
589 state.active_asset_path = scene_path.to_string();
590 state.activity_mode = "scene".to_string();
591 state.sidebar_mode = "scene".to_string();
592 state.log = format!("switch scene\n{}", editor_files::rel_label(scene_path));
593 Some(())
594 })
595 .flatten()
596 .is_some();
597 if restored {
598 rebuild_preview(ctx);
599 refresh_all(ctx);
600 return;

Callers 10

open_asset_ref_pathFunction · 0.85
open_projectFunction · 0.85
open_file_slotFunction · 0.85
click_or_open_file_slotFunction · 0.85
set_active_tabFunction · 0.85
close_scene_tabFunction · 0.85
create_quick_assetFunction · 0.85
open_active_assetFunction · 0.85
delete_active_assetFunction · 0.85
rename_active_assetFunction · 0.85

Calls 9

set_logFunction · 0.85
refresh_allFunction · 0.85
root_viewport_modeFunction · 0.85
rebuild_previewFunction · 0.85
res_to_absFunction · 0.50
load_stringFunction · 0.50
parseFunction · 0.50
as_u32Method · 0.45

Tested by

no test coverage detected