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

Function open_file_slot

perro_editor/res/scripts/assets/editor_assets.rs:336–382  ·  view source on GitHub ↗
(ctx: &mut ScriptContext<'_, API>, idx: usize)

Source from the content-addressed store, hash-verified

334 {
335 state.file_expanded_paths.push("res://".to_string());
336 }
337 state.project_file_sigs = editor_file_watch::scan_project(root_path.as_path());
338 state.log = format!("refresh project\nassets={count}");
339 });
340 rebuild_preview(ctx);
341 }
342 Err(err) => set_log(ctx, &format!("refresh fail\n{err}")),
343 }
344 refresh_all(ctx);
345}
346
347pub fn open_file_slot<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>, idx: usize) {
348 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
349 clear_destructive_confirmation(state)
350 });
351 let res_path = with_state!(ctx.run, EditorState, ctx.id, |state| {
352 filtered_file_paths(state).get(idx).cloned()
353 }).unwrap_or_default();
354 let Some(scene_path) = res_path else {
355 return;
356 };
357 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
358 state.active_asset_path = scene_path.clone();
359 state.sidebar_mode = "files".to_string();
360 });
361 if scene_path.ends_with('/') {
362 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
363 toggle_file_folder_expanded(state, &scene_path);
364 state.file_scope = scene_path.clone();
365 state.file_filter.clear();
366 state.active_asset_path = scene_path.clone();
367 state.activity_mode = "scene".to_string();
368 state.sidebar_mode = "files".to_string();
369 state.log = format!("folder\n{}", editor_files::rel_label(&scene_path));
370 });
371 set_log(ctx, &format!("folder\n{scene_path}"));
372 refresh_all(ctx);
373 return;
374 }
375 if scene_path.ends_with(".panim") {
376 open_animation_path(ctx, &scene_path);
377 return;
378 }
379 if is_gltf_path(&scene_path) {
380 open_gltf_path(ctx, &scene_path);
381 return;
382 }
383 if !scene_path.ends_with(".scn") {
384 set_log(
385 ctx,

Callers 3

open_active_fileFunction · 0.85
click_or_open_file_slotFunction · 0.85
open_first_sceneFunction · 0.85

Calls 6

set_logFunction · 0.85
refresh_allFunction · 0.85
open_animation_pathFunction · 0.85
open_gltf_pathFunction · 0.85
open_scene_pathFunction · 0.85
is_gltf_pathFunction · 0.50

Tested by

no test coverage detected