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

Function delete_active_asset

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

Source from the content-addressed store, hash-verified

1139 state.log = format!("dup asset\n{target}");
1140 });
1141 refresh_all(ctx);
1142 }
1143 Err(err) => set_log(ctx, &format!("dup asset fail\n{source}\n{err}")),
1144 }
1145}
1146
1147pub fn copy_active_asset_path<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) {
1148 let changed = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
1149 if state.active_asset_path.is_empty() {
1150 state.log = "asset path fail\nselect asset".to_string();
1151 } else {
1152 state.log = format!("asset path\n{}", state.active_asset_path);
1153 }
1154 true
1155 })
1156 .unwrap_or(false);
1157 if changed {
1158 refresh_all(ctx);
1159 }
1160}
1161
1162pub fn open_active_asset<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) {
1163 let path = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
1164 if state.active_asset_path.is_empty() {
1165 state.log = "open asset fail\nselect asset".to_string();
1166 return None;
1167 }
1168 let path = state.active_asset_path.clone();
1169 state.sidebar_mode = "files".to_string();
1170 state.activity_mode = "scene".to_string();
1171 state.file_scope = parent_res_folder(&path);
1172 reveal_file_path_in_tree(state, &path);
1173 Some(path)
1174 })
1175 .flatten();
1176 let Some(path) = path else {
1177 refresh_all(ctx);
1178 return;
1179 };
1180 if path.ends_with('/') {
1181 let _ = with_state_mut!(ctx.run, EditorState, ctx.id, |state| {
1182 toggle_file_folder_expanded(state, &path);
1183 state.file_scope = path.clone();
1184 state.log = format!("folder\n{}", editor_files::rel_label(&path));
1185 });
1186 refresh_all(ctx);
1187 return;
1188 }
1189 if path.ends_with(".panim") {
1190 open_animation_path(ctx, &path);
1191 } else if is_gltf_path(&path) {
1192 open_gltf_path(ctx, &path);
1193 } else if path.ends_with(".scn") {
1194 open_scene_path(ctx, &path);
1195 } else {
1196 set_log(
1197 ctx,
1198 &format!(

Callers 1

update_editor_shortcutsFunction · 0.85

Calls 5

set_logFunction · 0.85
open_scene_pathFunction · 0.85
clear_previewFunction · 0.85
refresh_allFunction · 0.85
res_to_absFunction · 0.50

Tested by

no test coverage detected