(
ctx: &mut ScriptContext<'_, API>,
scene_path: &str,
)
| 541 | } |
| 542 | state.log = format!("expand files\n{} dirs", state.file_expanded_paths.len()); |
| 543 | }); |
| 544 | refresh_all(ctx); |
| 545 | } |
| 546 | |
| 547 | pub 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 | |
| 560 | pub 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; |
no test coverage detected