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

Method _menu_option

editor/script/script_editor_plugin.cpp:1384–1702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382}
1383
1384void ScriptEditor::_menu_option(int p_option) {
1385 ScriptEditorBase *current = _get_current_editor();
1386 switch (p_option) {
1387 case FILE_MENU_NEW: {
1388 script_create_dialog->config("Node", "new_script", false, false);
1389 script_create_dialog->popup_centered();
1390 } break;
1391 case FILE_MENU_NEW_TEXTFILE: {
1392 file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
1393 file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
1394 file_dialog_option = FILE_MENU_NEW_TEXTFILE;
1395
1396 file_dialog->clear_filters();
1397 for (const String &E : textfile_extensions) {
1398 file_dialog->add_filter("*." + E, E.to_upper());
1399 }
1400 file_dialog->set_title(TTRC("New Text File..."));
1401 file_dialog->popup_file_dialog();
1402 open_textfile_after_create = true;
1403 } break;
1404 case FILE_MENU_OPEN: {
1405 file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
1406 file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
1407 file_dialog_option = FILE_MENU_OPEN;
1408
1409 List<String> extensions;
1410 ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
1411 file_dialog->clear_filters();
1412 for (const String &extension : extensions) {
1413 file_dialog->add_filter("*." + extension, extension.to_upper());
1414 }
1415
1416 for (const String &E : textfile_extensions) {
1417 file_dialog->add_filter("*." + E, E.to_upper());
1418 }
1419
1420 file_dialog->set_title(TTRC("Open File"));
1421 file_dialog->popup_file_dialog();
1422 return;
1423 } break;
1424 case FILE_MENU_REOPEN_CLOSED: {
1425 if (previous_scripts.is_empty()) {
1426 return;
1427 }
1428
1429 String path = previous_scripts.back()->get();
1430 previous_scripts.pop_back();
1431
1432 List<String> extensions;
1433 ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
1434 ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
1435 bool built_in = !path.is_resource_file();
1436
1437 if (extensions.find(path.get_extension()) || built_in) {
1438 if (built_in) {
1439 String res_path = path.get_slice("::", 0);
1440 EditorNode::get_singleton()->load_scene_or_resource(res_path, false, false);
1441 }

Callers

nothing calls this directly

Calls 15

TTRFunction · 0.85
vformatFunction · 0.85
popup_centeredMethod · 0.80
to_upperMethod · 0.80
is_resource_fileMethod · 0.80
get_sliceMethod · 0.80
show_warningMethod · 0.80
to_lowerMethod · 0.80
get_base_dirMethod · 0.80

Tested by

no test coverage detected