MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _update_script_names

Method _update_script_names

editor/script/script_editor_plugin.cpp:2263–2474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2261}
2262
2263void ScriptEditor::_update_script_names() {
2264 if (restoring_layout) {
2265 return;
2266 }
2267
2268 HashSet<Ref<Script>> used;
2269 Node *edited = EditorNode::get_singleton()->get_edited_scene();
2270 if (edited && EDITOR_GET("text_editor/script_list/highlight_scene_scripts")) {
2271 _find_scripts(edited, edited, used);
2272 }
2273
2274 script_list->clear();
2275 bool split_script_help = EDITOR_GET("text_editor/script_list/group_help_pages");
2276 ScriptSortBy sort_by = (ScriptSortBy)(int)EDITOR_GET("text_editor/script_list/sort_scripts_by");
2277 ScriptListName display_as = (ScriptListName)(int)EDITOR_GET("text_editor/script_list/list_script_names_as");
2278
2279 Vector<_ScriptEditorItemData> sedata;
2280
2281 for (int i = 0; i < tab_container->get_tab_count(); i++) {
2282 ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
2283 if (se) {
2284 Ref<Texture2D> icon = se->get_theme_icon();
2285 String path = se->get_edited_resource()->get_path();
2286 bool saved = !path.is_empty();
2287 String name = se->get_name();
2288 Ref<Script> scr = se->get_edited_resource();
2289
2290 _ScriptEditorItemData sd;
2291 sd.icon = icon;
2292 sd.name = name;
2293 sd.tooltip = saved ? path : TTR("Unsaved file.");
2294 sd.index = i;
2295 sd.used = used.has(se->get_edited_resource());
2296 sd.category = 0;
2297 sd.ref = se;
2298 if (scr.is_valid()) {
2299 sd.tool = scr->is_tool();
2300 }
2301
2302 switch (sort_by) {
2303 case SORT_BY_NAME: {
2304 sd.sort_key = name.to_lower();
2305 } break;
2306 case SORT_BY_PATH: {
2307 sd.sort_key = path;
2308 } break;
2309 case SORT_BY_NONE: {
2310 sd.sort_key = "";
2311 } break;
2312 }
2313
2314 switch (display_as) {
2315 case DISPLAY_NAME: {
2316 sd.name = name;
2317 } break;
2318 case DISPLAY_DIR_AND_NAME: {
2319 if (!path.get_base_dir().get_file().is_empty()) {
2320 sd.name = path.get_base_dir().get_file().path_join(name);

Callers

nothing calls this directly

Calls 15

TTRFunction · 0.85
vformatFunction · 0.85
get_tab_controlMethod · 0.80
to_lowerMethod · 0.80
get_base_dirMethod · 0.80
path_joinMethod · 0.80
unquoteMethod · 0.80
ends_withMethod · 0.80
move_childMethod · 0.80
set_queryMethod · 0.80
set_sMethod · 0.80
get_sMethod · 0.80

Tested by

no test coverage detected