project_manager.cpp 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978
  1. /**************************************************************************/
  2. /* project_manager.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "project_manager.h"
  31. #include "core/config/project_settings.h"
  32. #include "core/io/config_file.h"
  33. #include "core/io/dir_access.h"
  34. #include "core/io/file_access.h"
  35. #include "core/os/keyboard.h"
  36. #include "core/os/os.h"
  37. #include "core/version.h"
  38. #include "editor/asset_library/asset_library_editor_plugin.h"
  39. #include "editor/editor_string_names.h"
  40. #include "editor/gui/editor_about.h"
  41. #include "editor/gui/editor_file_dialog.h"
  42. #include "editor/gui/editor_title_bar.h"
  43. #include "editor/gui/editor_version_button.h"
  44. #include "editor/inspector/editor_inspector.h"
  45. #include "editor/project_manager/engine_update_label.h"
  46. #include "editor/project_manager/project_dialog.h"
  47. #include "editor/project_manager/project_list.h"
  48. #include "editor/project_manager/project_tag.h"
  49. #include "editor/project_manager/quick_settings_dialog.h"
  50. #include "editor/settings/editor_settings.h"
  51. #include "editor/themes/editor_scale.h"
  52. #include "editor/themes/editor_theme_manager.h"
  53. #include "main/main.h"
  54. #include "scene/gui/check_box.h"
  55. #include "scene/gui/flow_container.h"
  56. #include "scene/gui/line_edit.h"
  57. #include "scene/gui/margin_container.h"
  58. #include "scene/gui/menu_bar.h"
  59. #include "scene/gui/option_button.h"
  60. #include "scene/gui/panel_container.h"
  61. #include "scene/gui/rich_text_label.h"
  62. #include "scene/gui/separator.h"
  63. #include "scene/main/window.h"
  64. #include "scene/theme/theme_db.h"
  65. #include "servers/display/display_server.h"
  66. #include "servers/navigation_3d/navigation_server_3d.h"
  67. #ifndef PHYSICS_2D_DISABLED
  68. #include "servers/physics_2d/physics_server_2d.h"
  69. #endif // PHYSICS_2D_DISABLED
  70. #ifndef PHYSICS_3D_DISABLED
  71. #include "servers/physics_3d/physics_server_3d.h"
  72. #endif // PHYSICS_3D_DISABLED
  73. constexpr int GODOT4_CONFIG_VERSION = 5;
  74. ProjectManager *ProjectManager::singleton = nullptr;
  75. // Notifications.
  76. void ProjectManager::_notification(int p_what) {
  77. switch (p_what) {
  78. case NOTIFICATION_ENTER_TREE: {
  79. Engine::get_singleton()->set_editor_hint(false);
  80. Window *main_window = get_window();
  81. if (main_window) {
  82. // Handle macOS fullscreen and extend-to-title changes.
  83. main_window->connect("titlebar_changed", callable_mp(this, &ProjectManager::_titlebar_resized));
  84. }
  85. // Theme has already been created in the constructor, so we can skip that step.
  86. _update_theme(true);
  87. } break;
  88. case NOTIFICATION_READY: {
  89. DisplayServer::get_singleton()->screen_set_keep_on(EDITOR_GET("interface/editor/keep_screen_on"));
  90. const int default_sorting = (int)EDITOR_GET("project_manager/sorting_order");
  91. filter_option->select(default_sorting);
  92. project_list->set_order_option(default_sorting, false);
  93. _select_main_view(MAIN_VIEW_PROJECTS);
  94. _update_list_placeholder();
  95. _titlebar_resized();
  96. } break;
  97. case NOTIFICATION_TRANSLATION_CHANGED: {
  98. // TRANSLATORS: This refers to the application where users manage their Godot projects.
  99. SceneTree::get_singleton()->get_root()->set_title(GODOT_VERSION_NAME + String(" - ") + TTR("Project Manager", "Application"));
  100. const String line1 = TTR("You don't have any projects yet.");
  101. const String line2 = TTR("Get started by creating a new one,\nimporting one that exists, or by downloading a project template from the Asset Library!");
  102. empty_list_message->set_text(vformat("[center][b]%s[/b] %s[/center]", line1, line2));
  103. _titlebar_resized();
  104. } break;
  105. case NOTIFICATION_VISIBILITY_CHANGED: {
  106. set_process_shortcut_input(is_visible_in_tree());
  107. } break;
  108. case NOTIFICATION_WM_CLOSE_REQUEST: {
  109. _dim_window();
  110. } break;
  111. case NOTIFICATION_WM_ABOUT: {
  112. _show_about();
  113. } break;
  114. case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
  115. if (EditorThemeManager::is_generated_theme_outdated()) {
  116. _update_theme();
  117. }
  118. _update_list_placeholder();
  119. } break;
  120. }
  121. }
  122. // Utility data.
  123. Ref<Texture2D> ProjectManager::_file_dialog_get_icon(const String &p_path) {
  124. if (p_path.has_extension("godot")) {
  125. return singleton->icon_type_cache["GodotMonochrome"];
  126. }
  127. return singleton->icon_type_cache["Object"];
  128. }
  129. Ref<Texture2D> ProjectManager::_file_dialog_get_thumbnail(const String &p_path) {
  130. if (p_path.has_extension("godot")) {
  131. return singleton->icon_type_cache["GodotFile"];
  132. }
  133. return Ref<Texture2D>();
  134. }
  135. void ProjectManager::_build_icon_type_cache(Ref<Theme> p_theme) {
  136. if (p_theme.is_null()) {
  137. return;
  138. }
  139. List<StringName> tl;
  140. p_theme->get_icon_list(EditorStringName(EditorIcons), &tl);
  141. for (const StringName &name : tl) {
  142. icon_type_cache[name] = p_theme->get_icon(name, EditorStringName(EditorIcons));
  143. }
  144. }
  145. // Main layout.
  146. void ProjectManager::_update_size_limits() {
  147. const Size2 minimum_size = Size2(720, 450) * EDSCALE;
  148. // Define a minimum window size to prevent UI elements from overlapping or being cut off.
  149. Window *w = Object::cast_to<Window>(SceneTree::get_singleton()->get_root());
  150. if (w) {
  151. // Calling Window methods this early doesn't sync properties with DS.
  152. w->set_min_size(minimum_size);
  153. DisplayServer::get_singleton()->window_set_min_size(minimum_size);
  154. }
  155. Size2 real_size = DisplayServer::get_singleton()->window_get_size();
  156. Rect2i screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen());
  157. if (screen_rect.size != Vector2i()) {
  158. // Center the window on the screen.
  159. Vector2i window_position;
  160. window_position.x = screen_rect.position.x + (screen_rect.size.x - real_size.x) / 2;
  161. window_position.y = screen_rect.position.y + (screen_rect.size.y - real_size.y) / 2;
  162. // Limit popup menus to prevent unusably long lists.
  163. // We try to set it to half the screen resolution, but no smaller than the minimum window size.
  164. Size2 half_screen_rect = (screen_rect.size * EDSCALE) / 2;
  165. Size2 maximum_popup_size = MAX(half_screen_rect, minimum_size);
  166. quick_settings_dialog->update_size_limits(maximum_popup_size);
  167. }
  168. }
  169. void ProjectManager::_update_theme(bool p_skip_creation) {
  170. if (!p_skip_creation) {
  171. theme = EditorThemeManager::generate_theme(theme);
  172. DisplayServer::set_early_window_clear_color_override(true, theme->get_color("background", EditorStringName(Editor)));
  173. }
  174. Vector<Ref<Theme>> editor_themes;
  175. editor_themes.push_back(theme);
  176. editor_themes.push_back(ThemeDB::get_singleton()->get_default_theme());
  177. ThemeContext *node_tc = ThemeDB::get_singleton()->get_theme_context(this);
  178. if (node_tc) {
  179. node_tc->set_themes(editor_themes);
  180. } else {
  181. ThemeDB::get_singleton()->create_theme_context(this, editor_themes);
  182. }
  183. Window *owner_window = get_window();
  184. if (owner_window) {
  185. ThemeContext *window_tc = ThemeDB::get_singleton()->get_theme_context(owner_window);
  186. if (window_tc) {
  187. window_tc->set_themes(editor_themes);
  188. } else {
  189. ThemeDB::get_singleton()->create_theme_context(owner_window, editor_themes);
  190. }
  191. }
  192. // Update styles.
  193. {
  194. const int top_bar_separation = get_theme_constant("top_bar_separation", EditorStringName(Editor));
  195. root_container->add_theme_constant_override("margin_left", top_bar_separation);
  196. root_container->add_theme_constant_override("margin_top", top_bar_separation);
  197. root_container->add_theme_constant_override("margin_bottom", top_bar_separation);
  198. root_container->add_theme_constant_override("margin_right", top_bar_separation);
  199. main_vbox->add_theme_constant_override("separation", top_bar_separation);
  200. background_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox("Background", EditorStringName(EditorStyles)));
  201. main_view_container->add_theme_style_override(SceneStringName(panel), get_theme_stylebox("panel_container", "ProjectManager"));
  202. title_bar_logo->set_button_icon(get_editor_theme_icon("TitleBarLogo"));
  203. _set_main_view_icon(MAIN_VIEW_PROJECTS, get_editor_theme_icon("ProjectList"));
  204. _set_main_view_icon(MAIN_VIEW_ASSETLIB, get_editor_theme_icon("AssetLib"));
  205. // Project list.
  206. {
  207. loading_label->add_theme_font_override(SceneStringName(font), get_theme_font("bold", EditorStringName(EditorFonts)));
  208. project_list_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox("project_list", "ProjectManager"));
  209. empty_list_create_project->set_button_icon(get_editor_theme_icon("Add"));
  210. empty_list_import_project->set_button_icon(get_editor_theme_icon("Load"));
  211. empty_list_open_assetlib->set_button_icon(get_editor_theme_icon("AssetLib"));
  212. empty_list_online_warning->add_theme_font_override(SceneStringName(font), get_theme_font("italic", EditorStringName(EditorFonts)));
  213. empty_list_online_warning->add_theme_color_override(SceneStringName(font_color), get_theme_color("font_placeholder_color", EditorStringName(Editor)));
  214. // Top bar.
  215. search_box->set_right_icon(get_editor_theme_icon("Search"));
  216. quick_settings_button->set_button_icon(get_editor_theme_icon("Tools"));
  217. // Sidebar.
  218. create_btn->set_button_icon(get_editor_theme_icon("Add"));
  219. import_btn->set_button_icon(get_editor_theme_icon("Load"));
  220. scan_btn->set_button_icon(get_editor_theme_icon("Search"));
  221. open_btn->set_button_icon(get_editor_theme_icon("Edit"));
  222. open_options_btn->set_button_icon(get_editor_theme_icon("Collapse"));
  223. run_btn->set_button_icon(get_editor_theme_icon("Play"));
  224. rename_btn->set_button_icon(get_editor_theme_icon("Rename"));
  225. duplicate_btn->set_button_icon(get_editor_theme_icon("Duplicate"));
  226. manage_tags_btn->set_button_icon(get_editor_theme_icon("Script"));
  227. erase_btn->set_button_icon(get_editor_theme_icon("Remove"));
  228. erase_missing_btn->set_button_icon(get_editor_theme_icon("Clear"));
  229. create_tag_btn->set_button_icon(get_editor_theme_icon("Add"));
  230. donate_btn->set_button_icon(get_editor_theme_icon("Heart"));
  231. tag_error->add_theme_color_override(SceneStringName(font_color), get_theme_color("error_color", EditorStringName(Editor)));
  232. tag_edit_error->add_theme_color_override(SceneStringName(font_color), get_theme_color("error_color", EditorStringName(Editor)));
  233. const int h_separation = get_theme_constant("sidebar_button_icon_separation", "ProjectManager");
  234. create_btn->add_theme_constant_override("h_separation", h_separation);
  235. import_btn->add_theme_constant_override("h_separation", h_separation);
  236. scan_btn->add_theme_constant_override("h_separation", h_separation);
  237. open_btn->add_theme_constant_override("h_separation", h_separation);
  238. run_btn->add_theme_constant_override("h_separation", h_separation);
  239. rename_btn->add_theme_constant_override("h_separation", h_separation);
  240. duplicate_btn->add_theme_constant_override("h_separation", h_separation);
  241. manage_tags_btn->add_theme_constant_override("h_separation", h_separation);
  242. erase_btn->add_theme_constant_override("h_separation", h_separation);
  243. erase_missing_btn->add_theme_constant_override("h_separation", h_separation);
  244. open_btn_container->add_theme_constant_override("separation", 0);
  245. open_options_popup->set_item_icon(0, get_editor_theme_icon("Notification"));
  246. open_options_popup->set_item_icon(1, get_editor_theme_icon("NodeWarning"));
  247. }
  248. // Dialogs
  249. migration_guide_button->set_button_icon(get_editor_theme_icon("ExternalLink"));
  250. // Asset library popup.
  251. if (asset_library && EDITOR_GET("interface/theme/style") == "Classic") {
  252. // Removes extra border margins.
  253. asset_library->add_theme_style_override(SceneStringName(panel), memnew(StyleBoxEmpty));
  254. }
  255. }
  256. #ifdef ANDROID_ENABLED
  257. DisplayServer::get_singleton()->window_set_color(theme->get_color("background", EditorStringName(Editor)));
  258. #endif
  259. }
  260. Button *ProjectManager::_add_main_view(MainViewTab p_id, const String &p_name, const Ref<Texture2D> &p_icon, Control *p_view_control) {
  261. ERR_FAIL_INDEX_V(p_id, MAIN_VIEW_MAX, nullptr);
  262. ERR_FAIL_COND_V(main_view_map.has(p_id), nullptr);
  263. ERR_FAIL_COND_V(main_view_toggle_map.has(p_id), nullptr);
  264. Button *toggle_button = memnew(Button);
  265. toggle_button->set_flat(true);
  266. toggle_button->set_theme_type_variation("MainScreenButton");
  267. toggle_button->set_toggle_mode(true);
  268. toggle_button->set_button_group(main_view_toggles_group);
  269. toggle_button->set_text(p_name);
  270. toggle_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_select_main_view).bind((int)p_id));
  271. main_view_toggles->add_child(toggle_button);
  272. main_view_toggle_map[p_id] = toggle_button;
  273. _set_main_view_icon(p_id, p_icon);
  274. p_view_control->set_visible(false);
  275. main_view_container->add_child(p_view_control);
  276. main_view_map[p_id] = p_view_control;
  277. return toggle_button;
  278. }
  279. void ProjectManager::_set_main_view_icon(MainViewTab p_id, const Ref<Texture2D> &p_icon) {
  280. ERR_FAIL_INDEX(p_id, MAIN_VIEW_MAX);
  281. ERR_FAIL_COND(!main_view_toggle_map.has(p_id));
  282. Button *toggle_button = main_view_toggle_map[p_id];
  283. Ref<Texture2D> old_icon = toggle_button->get_button_icon();
  284. if (old_icon.is_valid()) {
  285. old_icon->disconnect_changed(callable_mp((Control *)toggle_button, &Control::update_minimum_size));
  286. }
  287. if (p_icon.is_valid()) {
  288. toggle_button->set_button_icon(p_icon);
  289. // Make sure the control is updated if the icon is reimported.
  290. p_icon->connect_changed(callable_mp((Control *)toggle_button, &Control::update_minimum_size));
  291. } else {
  292. toggle_button->set_button_icon(Ref<Texture2D>());
  293. }
  294. }
  295. void ProjectManager::_select_main_view(int p_id) {
  296. MainViewTab view_id = (MainViewTab)p_id;
  297. ERR_FAIL_INDEX(view_id, MAIN_VIEW_MAX);
  298. ERR_FAIL_COND(!main_view_map.has(view_id));
  299. ERR_FAIL_COND(!main_view_toggle_map.has(view_id));
  300. if (current_main_view != view_id) {
  301. main_view_toggle_map[current_main_view]->set_pressed_no_signal(false);
  302. main_view_map[current_main_view]->set_visible(false);
  303. current_main_view = view_id;
  304. }
  305. main_view_toggle_map[current_main_view]->set_pressed_no_signal(true);
  306. main_view_map[current_main_view]->set_visible(true);
  307. #ifndef ANDROID_ENABLED
  308. if (current_main_view == MAIN_VIEW_PROJECTS && search_box->is_inside_tree()) {
  309. // Automatically grab focus when the user moves from the Templates tab
  310. // back to the Projects tab.
  311. // Needs to be deferred, otherwise the focus outline is always drawn.
  312. callable_mp((Control *)search_box, &Control::grab_focus).call_deferred(true);
  313. }
  314. // The Templates tab's search field is focused on display in the asset
  315. // library editor plugin code.
  316. #endif
  317. }
  318. void ProjectManager::_show_about() {
  319. about_dialog->popup_centered(Size2(780, 500) * EDSCALE);
  320. }
  321. void ProjectManager::_open_asset_library_confirmed() {
  322. const int network_mode = EDITOR_GET("network/connection/network_mode");
  323. if (network_mode == EditorSettings::NETWORK_OFFLINE) {
  324. EditorSettings::get_singleton()->set_setting("network/connection/network_mode", EditorSettings::NETWORK_ONLINE);
  325. EditorSettings::get_singleton()->notify_changes();
  326. EditorSettings::get_singleton()->save();
  327. }
  328. asset_library->disable_community_support();
  329. _select_main_view(MAIN_VIEW_ASSETLIB);
  330. }
  331. void ProjectManager::_project_list_menu_option(int p_option) {
  332. switch (p_option) {
  333. case ProjectList::MENU_EDIT:
  334. _open_selected_projects();
  335. break;
  336. case ProjectList::MENU_EDIT_VERBOSE:
  337. open_in_verbose_mode = true;
  338. _open_selected_projects_check_warnings();
  339. break;
  340. case ProjectList::MENU_EDIT_RECOVERY:
  341. _open_recovery_mode_ask(true);
  342. break;
  343. case ProjectList::MENU_RUN:
  344. _run_project_confirm();
  345. break;
  346. case ProjectList::MENU_SHOW_IN_FILE_MANAGER:
  347. _show_project_in_file_manager();
  348. break;
  349. case ProjectList::MENU_COPY_PATH: {
  350. const Vector<ProjectList::Item> &selected_list = project_list->get_selected_projects();
  351. if (selected_list.is_empty()) {
  352. return;
  353. }
  354. DisplayServer::get_singleton()->clipboard_set(selected_list[0].path);
  355. } break;
  356. case ProjectList::MENU_RENAME:
  357. _rename_project();
  358. break;
  359. case ProjectList::MENU_MANAGE_TAGS:
  360. _manage_project_tags();
  361. break;
  362. case ProjectList::MENU_DUPLICATE:
  363. _duplicate_project();
  364. break;
  365. case ProjectList::MENU_REMOVE:
  366. _erase_project();
  367. break;
  368. }
  369. }
  370. void ProjectManager::_show_error(const String &p_message, const Size2 &p_min_size) {
  371. error_dialog->set_text(p_message);
  372. error_dialog->popup_centered(p_min_size);
  373. }
  374. void ProjectManager::_dim_window() {
  375. // This method must be called before calling `get_tree()->quit()`.
  376. // Otherwise, its effect won't be visible
  377. // Dim the project manager window while it's quitting to make it clearer that it's busy.
  378. // No transition is applied, as the effect needs to be visible immediately
  379. float c = 0.5f;
  380. Color dim_color = Color(c, c, c);
  381. set_modulate(dim_color);
  382. }
  383. // Quick settings.
  384. void ProjectManager::_show_quick_settings() {
  385. quick_settings_dialog->popup_centered(Size2(640, 200) * EDSCALE);
  386. }
  387. void ProjectManager::_restart_confirmed() {
  388. List<String> args = OS::get_singleton()->get_cmdline_args();
  389. Error err = OS::get_singleton()->create_instance(args);
  390. ERR_FAIL_COND(err);
  391. _dim_window();
  392. get_tree()->quit();
  393. }
  394. // Project list.
  395. void ProjectManager::_update_list_placeholder() {
  396. if (project_list->get_project_count() > 0) {
  397. empty_list_placeholder->hide();
  398. return;
  399. }
  400. empty_list_open_assetlib->set_visible(asset_library);
  401. const int network_mode = EDITOR_GET("network/connection/network_mode");
  402. if (network_mode == EditorSettings::NETWORK_OFFLINE) {
  403. empty_list_open_assetlib->set_text(TTRC("Go Online and Open Asset Library"));
  404. empty_list_online_warning->set_visible(true);
  405. } else {
  406. empty_list_open_assetlib->set_text(TTRC("Open Asset Library"));
  407. empty_list_online_warning->set_visible(false);
  408. }
  409. empty_list_placeholder->show();
  410. }
  411. void ProjectManager::_scan_projects() {
  412. scan_dir->popup_file_dialog();
  413. }
  414. void ProjectManager::_run_project() {
  415. const HashSet<String> &selected_list = project_list->get_selected_project_keys();
  416. if (selected_list.size() < 1) {
  417. return;
  418. }
  419. if (selected_list.size() > 1) {
  420. multi_run_ask->set_text(vformat(TTR("Are you sure to run %d projects at once?"), selected_list.size()));
  421. multi_run_ask->popup_centered();
  422. } else {
  423. _run_project_confirm();
  424. }
  425. }
  426. void ProjectManager::_run_project_confirm() {
  427. Vector<ProjectList::Item> selected_list = project_list->get_selected_projects();
  428. for (int i = 0; i < selected_list.size(); ++i) {
  429. const String &selected_main = selected_list[i].main_scene;
  430. if (selected_main.is_empty()) {
  431. _show_error(TTRC("Can't run project: Project has no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category."));
  432. continue;
  433. }
  434. const String &path = selected_list[i].path;
  435. // `.substr(6)` on `ProjectSettings::get_singleton()->get_imported_files_path()` strips away the leading "res://".
  436. if (!DirAccess::exists(path.path_join(ProjectSettings::get_singleton()->get_imported_files_path().substr(6)))) {
  437. _show_error(TTRC("Can't run project: Assets need to be imported first.\nPlease edit the project to trigger the initial import."));
  438. continue;
  439. }
  440. print_line("Running project: " + path);
  441. List<String> args;
  442. for (const String &a : Main::get_forwardable_cli_arguments(Main::CLI_SCOPE_PROJECT)) {
  443. args.push_back(a);
  444. }
  445. args.push_back("--path");
  446. args.push_back(path);
  447. Error err = OS::get_singleton()->create_instance(args);
  448. ERR_FAIL_COND(err);
  449. }
  450. }
  451. void ProjectManager::_open_selected_projects() {
  452. // Show loading text to tell the user that the project manager is busy loading.
  453. // This is especially important for the Web project manager.
  454. loading_label->show();
  455. const HashSet<String> &selected_list = project_list->get_selected_project_keys();
  456. for (const String &path : selected_list) {
  457. String conf = path.path_join("project.godot");
  458. if (!FileAccess::exists(conf)) {
  459. loading_label->hide();
  460. _show_error(vformat(TTR("Can't open project at '%s'.\nProject file doesn't exist or is inaccessible."), path));
  461. return;
  462. }
  463. print_line("Editing project: " + path);
  464. List<String> args;
  465. for (const String &a : Main::get_forwardable_cli_arguments(Main::CLI_SCOPE_TOOL)) {
  466. args.push_back(a);
  467. }
  468. args.push_back("--path");
  469. args.push_back(path);
  470. args.push_back("--editor");
  471. if (open_in_recovery_mode) {
  472. args.push_back("--recovery-mode");
  473. }
  474. if (open_in_verbose_mode) {
  475. args.push_back("--verbose");
  476. }
  477. Error err = OS::get_singleton()->create_instance(args);
  478. if (err != OK) {
  479. loading_label->hide();
  480. _show_error(vformat(TTR("Can't open project at '%s'.\nFailed to start the editor."), path));
  481. ERR_PRINT(vformat("Failed to start an editor instance for the project at '%s', error code %d.", path, err));
  482. return;
  483. }
  484. }
  485. project_list->project_opening_initiated = true;
  486. _dim_window();
  487. get_tree()->quit();
  488. }
  489. void ProjectManager::_open_selected_projects_check_warnings() {
  490. const HashSet<String> &selected_list = project_list->get_selected_project_keys();
  491. if (selected_list.size() < 1) {
  492. return;
  493. }
  494. const Size2i popup_min_size = Size2i(400.0 * EDSCALE, 0);
  495. if (selected_list.size() > 1) {
  496. multi_open_ask->set_text(vformat(TTR("You requested to open %d projects in parallel. Do you confirm?\nNote that usual checks for engine version compatibility will be bypassed."), selected_list.size()));
  497. multi_open_ask->popup_centered(popup_min_size);
  498. return;
  499. }
  500. ProjectList::Item project = project_list->get_selected_projects()[0];
  501. if (project.missing) {
  502. return;
  503. }
  504. // Update the project settings or don't open.
  505. const int config_version = project.version;
  506. PackedStringArray unsupported_features = project.unsupported_features;
  507. ask_update_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_LEFT); // Reset in case of previous center align.
  508. ask_update_backup->set_pressed(false);
  509. full_convert_button->hide();
  510. migration_guide_button->hide();
  511. ask_update_backup->hide();
  512. ask_update_settings->get_ok_button()->set_text("OK");
  513. // Check if the config_version property was empty or 0.
  514. if (config_version == 0) {
  515. ask_update_label->set_text(vformat(TTR("The selected project \"%s\" does not specify its supported Godot version in its configuration file (\"project.godot\").\n\nProject path: %s\n\nIf you proceed with opening it, it will be converted to Godot's current configuration file format.\n\nWarning: You won't be able to open the project with previous versions of the engine anymore."), project.project_name, project.path));
  516. ask_update_settings->popup_centered(popup_min_size);
  517. return;
  518. }
  519. // Check if we need to convert project settings from an earlier engine version.
  520. if (config_version < ProjectSettings::CONFIG_VERSION) {
  521. if (config_version == GODOT4_CONFIG_VERSION - 1 && ProjectSettings::CONFIG_VERSION == GODOT4_CONFIG_VERSION) { // Conversion from Godot 3 to 4.
  522. full_convert_button->show();
  523. ask_update_label->set_text(vformat(TTR("The selected project \"%s\" was generated by Godot 3.x, and needs to be converted for Godot 4.x.\n\nProject path: %s\n\nYou have three options:\n- Convert only the configuration file (\"project.godot\"). Use this to open the project without attempting to convert its scenes, resources and scripts.\n- Convert the entire project including its scenes, resources and scripts (recommended if you are upgrading).\n- Do nothing and go back.\n\nWarning: If you select a conversion option, you won't be able to open the project with previous versions of the engine anymore."), project.project_name, project.path));
  524. ask_update_settings->get_ok_button()->set_text(TTRC("Convert project.godot Only"));
  525. } else {
  526. ask_update_label->set_text(vformat(TTR("The selected project \"%s\" was generated by an older engine version, and needs to be converted for this version.\n\nProject path: %s\n\nDo you want to convert it?\n\nWarning: You won't be able to open the project with previous versions of the engine anymore."), project.project_name, project.path));
  527. ask_update_settings->get_ok_button()->set_text(TTRC("Convert project.godot"));
  528. }
  529. ask_update_backup->show();
  530. migration_guide_button->show();
  531. ask_update_settings->popup_centered(popup_min_size);
  532. ask_update_settings->get_cancel_button()->grab_focus(); // To prevent accidents.
  533. return;
  534. }
  535. // Check if the file was generated by a newer, incompatible engine version.
  536. if (config_version > ProjectSettings::CONFIG_VERSION) {
  537. _show_error(vformat(TTR("Can't open project \"%s\" at the following path:\n\n%s\n\nThe project settings were created by a newer engine version, whose settings are not compatible with this version."), project.project_name, project.path), popup_min_size);
  538. return;
  539. }
  540. // Check if the project is using features not supported by this build of Godot.
  541. if (!unsupported_features.is_empty()) {
  542. String warning_message = "";
  543. for (int i = 0; i < unsupported_features.size(); i++) {
  544. const String &feature = unsupported_features[i];
  545. if (feature == "Double Precision") {
  546. ask_update_backup->show();
  547. warning_message += TTR("Warning: This project uses double precision floats, but this version of\nGodot uses single precision floats. Opening this project may cause data loss.\n\n");
  548. unsupported_features.remove_at(i);
  549. i--;
  550. } else if (feature == "C#") {
  551. warning_message += TTR("Warning: This project uses C#, but this build of Godot does not have\nthe Mono module. If you proceed you will not be able to use any C# scripts.\n\n");
  552. unsupported_features.remove_at(i);
  553. i--;
  554. } else if (ProjectList::project_feature_looks_like_version(feature)) {
  555. ask_update_backup->show();
  556. migration_guide_button->show();
  557. version_convert_feature = feature;
  558. warning_message += vformat(TTR("Warning: This project was last edited in Godot %s. Opening will change it to Godot %s.\n\n"), Variant(feature), Variant(GODOT_VERSION_BRANCH));
  559. unsupported_features.remove_at(i);
  560. i--;
  561. }
  562. }
  563. if (!unsupported_features.is_empty()) {
  564. String unsupported_features_str = String(", ").join(unsupported_features);
  565. warning_message += vformat(TTR("Warning: This project uses the following features not supported by this build of Godot:\n\n%s\n\n"), unsupported_features_str);
  566. }
  567. warning_message += TTR("Open anyway? Project will be modified.");
  568. ask_update_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
  569. ask_update_label->set_text(warning_message);
  570. ask_update_settings->popup_centered(popup_min_size);
  571. return;
  572. }
  573. // Open if the project is up-to-date.
  574. _open_selected_projects();
  575. }
  576. void ProjectManager::_open_selected_projects_check_recovery_mode() {
  577. Vector<ProjectList::Item> selected_projects = project_list->get_selected_projects();
  578. if (selected_projects.is_empty()) {
  579. return;
  580. }
  581. const ProjectList::Item &project = selected_projects[0];
  582. if (project.missing) {
  583. return;
  584. }
  585. open_in_verbose_mode = false;
  586. open_in_recovery_mode = false;
  587. // Check if the project failed to load during last startup.
  588. if (project.recovery_mode) {
  589. _open_recovery_mode_ask(false);
  590. return;
  591. }
  592. _open_selected_projects_check_warnings();
  593. }
  594. void ProjectManager::_open_selected_projects_with_migration() {
  595. if (ask_update_backup->is_pressed() && project_list->get_selected_projects().size() == 1) {
  596. ask_update_settings->hide();
  597. ask_update_backup->set_pressed(false);
  598. _duplicate_project_with_action(POST_DUPLICATE_ACTION_OPEN);
  599. return;
  600. }
  601. #ifndef DISABLE_DEPRECATED
  602. if (project_list->get_selected_projects().size() == 1) {
  603. // Only migrate if a single project is opened.
  604. _minor_project_migrate();
  605. }
  606. #endif
  607. _open_selected_projects();
  608. }
  609. void ProjectManager::_install_project(const String &p_zip_path, const String &p_title) {
  610. project_dialog->set_mode(ProjectDialog::MODE_INSTALL);
  611. project_dialog->set_zip_path(p_zip_path);
  612. project_dialog->set_zip_title(p_title);
  613. project_dialog->show_dialog();
  614. }
  615. void ProjectManager::_import_project() {
  616. project_dialog->set_mode(ProjectDialog::MODE_IMPORT);
  617. project_dialog->ask_for_path_and_show();
  618. }
  619. void ProjectManager::_new_project() {
  620. project_dialog->set_mode(ProjectDialog::MODE_NEW);
  621. project_dialog->show_dialog();
  622. }
  623. void ProjectManager::_rename_project() {
  624. const Vector<ProjectList::Item> &selected_list = project_list->get_selected_projects();
  625. if (selected_list.is_empty()) {
  626. return;
  627. }
  628. for (const ProjectList::Item &E : selected_list) {
  629. project_dialog->set_project_name(E.project_name);
  630. project_dialog->set_project_path(E.path);
  631. project_dialog->set_mode(ProjectDialog::MODE_RENAME);
  632. project_dialog->show_dialog();
  633. }
  634. }
  635. void ProjectManager::_duplicate_project() {
  636. _duplicate_project_with_action(POST_DUPLICATE_ACTION_NONE);
  637. }
  638. void ProjectManager::_duplicate_project_with_action(PostDuplicateAction p_post_action) {
  639. Vector<ProjectList::Item> selected_projects = project_list->get_selected_projects();
  640. if (selected_projects.is_empty()) {
  641. return;
  642. }
  643. post_duplicate_action = p_post_action;
  644. const ProjectList::Item &project = selected_projects[0];
  645. project_dialog->set_mode(ProjectDialog::MODE_DUPLICATE);
  646. project_dialog->set_project_name(vformat("%s (%s)", project.project_name, p_post_action == POST_DUPLICATE_ACTION_NONE ? "Copy" : project.project_version));
  647. project_dialog->set_original_project_path(project.path);
  648. project_dialog->set_duplicate_can_edit(p_post_action == POST_DUPLICATE_ACTION_NONE);
  649. project_dialog->show_dialog(false);
  650. }
  651. void ProjectManager::_show_project_in_file_manager() {
  652. const Vector<ProjectList::Item> &selected_list = project_list->get_selected_projects();
  653. if (selected_list.is_empty()) {
  654. return;
  655. }
  656. for (const ProjectList::Item &E : selected_list) {
  657. OS::get_singleton()->shell_show_in_file_manager(E.path, true);
  658. }
  659. }
  660. void ProjectManager::_erase_project() {
  661. const HashSet<String> &selected_list = project_list->get_selected_project_keys();
  662. if (selected_list.is_empty()) {
  663. return;
  664. }
  665. String confirm_message;
  666. if (selected_list.size() >= 2) {
  667. confirm_message = vformat(TTR("Remove %d projects from the list?"), selected_list.size());
  668. } else {
  669. confirm_message = TTRC("Remove this project from the list?");
  670. }
  671. erase_ask_label->set_text(confirm_message);
  672. //delete_project_contents->set_pressed(false);
  673. erase_ask->popup_centered();
  674. }
  675. void ProjectManager::_erase_missing_projects() {
  676. erase_missing_ask->set_text(TTRC("Remove all missing projects from the list?\nThe project folders' contents won't be modified."));
  677. erase_missing_ask->popup_centered();
  678. }
  679. void ProjectManager::_erase_project_confirm() {
  680. project_list->erase_selected_projects(false);
  681. _update_project_buttons();
  682. _update_list_placeholder();
  683. }
  684. void ProjectManager::_erase_missing_projects_confirm() {
  685. project_list->erase_missing_projects();
  686. _update_project_buttons();
  687. _update_list_placeholder();
  688. }
  689. void ProjectManager::_update_project_buttons() {
  690. Vector<ProjectList::Item> selected_projects = project_list->get_selected_projects();
  691. bool empty_selection = selected_projects.is_empty();
  692. bool is_missing_project_selected = false;
  693. for (int i = 0; i < selected_projects.size(); ++i) {
  694. if (selected_projects[i].missing) {
  695. is_missing_project_selected = true;
  696. break;
  697. }
  698. }
  699. erase_btn->set_disabled(empty_selection);
  700. open_btn->set_disabled(empty_selection || is_missing_project_selected);
  701. open_options_btn->set_disabled(empty_selection || is_missing_project_selected);
  702. rename_btn->set_disabled(empty_selection || is_missing_project_selected);
  703. duplicate_btn->set_disabled(empty_selection || is_missing_project_selected);
  704. manage_tags_btn->set_disabled(empty_selection || is_missing_project_selected || selected_projects.size() > 1);
  705. run_btn->set_disabled(empty_selection || is_missing_project_selected);
  706. erase_missing_btn->set_disabled(!project_list->is_any_project_missing());
  707. }
  708. void ProjectManager::_open_options_popup() {
  709. Rect2 rect = open_btn_container->get_screen_rect();
  710. rect.position.y += rect.size.height;
  711. open_options_popup->set_size(Size2(rect.size.width, 0));
  712. open_options_popup->set_position(rect.position);
  713. open_options_popup->popup();
  714. }
  715. void ProjectManager::_open_recovery_mode_ask(bool manual) {
  716. String recovery_mode_details;
  717. // Only show the initial crash preamble if this popup wasn't manually triggered.
  718. if (!manual) {
  719. recovery_mode_details +=
  720. TTR("It looks like Godot crashed when opening this project the last time. If you're having problems editing this project, you can try to open it in Recovery Mode.") +
  721. String::utf8("\n\n");
  722. }
  723. recovery_mode_details +=
  724. TTR("Recovery Mode is a special mode that may help to recover projects that crash the engine during initialization. This mode temporarily disables the following features:") +
  725. String::utf8("\n\n• ") + TTR("Tool scripts") +
  726. String::utf8("\n• ") + TTR("Editor plugins") +
  727. String::utf8("\n• ") + TTR("GDExtension addons") +
  728. String::utf8("\n• ") + TTR("Automatic scene restoring") +
  729. String::utf8("\n\n") + TTR("This mode is intended only for basic editing to troubleshoot such issues, and therefore it will not be possible to run the project during this mode. It is also a good idea to make a backup of your project before proceeding.") +
  730. String::utf8("\n\n") + TTR("Edit the project in Recovery Mode?");
  731. open_recovery_mode_ask->set_text(recovery_mode_details);
  732. open_recovery_mode_ask->popup_centered(Size2(550, 70) * EDSCALE);
  733. }
  734. void ProjectManager::_on_projects_updated() {
  735. Vector<ProjectList::Item> selected_projects = project_list->get_selected_projects();
  736. int index = 0;
  737. for (int i = 0; i < selected_projects.size(); ++i) {
  738. index = project_list->refresh_project(selected_projects[i].path);
  739. }
  740. if (index != -1) {
  741. project_list->ensure_project_visible(index);
  742. }
  743. project_list->update_dock_menu();
  744. }
  745. void ProjectManager::_on_open_options_selected(int p_option) {
  746. switch (p_option) {
  747. case 0: // Edit in verbose mode.
  748. open_in_verbose_mode = true;
  749. _open_selected_projects_check_warnings();
  750. break;
  751. case 1: // Edit in recovery mode.
  752. _open_recovery_mode_ask(true);
  753. break;
  754. }
  755. }
  756. void ProjectManager::_on_recovery_mode_popup_open_normal() {
  757. open_recovery_mode_ask->hide();
  758. open_in_recovery_mode = false;
  759. _open_selected_projects_check_warnings();
  760. }
  761. void ProjectManager::_on_recovery_mode_popup_open_recovery() {
  762. open_in_recovery_mode = true;
  763. _open_selected_projects_check_warnings();
  764. }
  765. void ProjectManager::_on_project_created(const String &dir, bool edit) {
  766. project_list->add_project(dir, false);
  767. project_list->save_config();
  768. search_box->clear();
  769. int i = project_list->refresh_project(dir);
  770. project_list->ensure_project_visible(i);
  771. _update_list_placeholder();
  772. if (edit) {
  773. _open_selected_projects_check_warnings();
  774. }
  775. project_list->update_dock_menu();
  776. }
  777. void ProjectManager::_on_project_duplicated(const String &p_original_path, const String &p_duplicate_path, bool p_edit) {
  778. if (post_duplicate_action == POST_DUPLICATE_ACTION_NONE) {
  779. _on_project_created(p_duplicate_path, p_edit);
  780. } else {
  781. project_list->add_project(p_duplicate_path, false);
  782. project_list->save_config();
  783. if (post_duplicate_action == POST_DUPLICATE_ACTION_OPEN) {
  784. _open_selected_projects_with_migration();
  785. } else if (post_duplicate_action == POST_DUPLICATE_ACTION_FULL_CONVERSION) {
  786. _full_convert_button_pressed();
  787. }
  788. project_list->update_dock_menu();
  789. }
  790. post_duplicate_action = POST_DUPLICATE_ACTION_NONE;
  791. }
  792. void ProjectManager::_on_order_option_changed(int p_idx) {
  793. if (is_inside_tree()) {
  794. project_list->set_order_option(p_idx, true);
  795. }
  796. }
  797. void ProjectManager::_on_search_term_changed(const String &p_term) {
  798. project_list->set_search_term(p_term);
  799. project_list->sort_projects();
  800. // Select the first visible project in the list.
  801. // This makes it possible to open a project without ever touching the mouse,
  802. // as the search field is automatically focused on startup.
  803. project_list->select_first_visible_project();
  804. _update_project_buttons();
  805. }
  806. void ProjectManager::_on_search_term_submitted(const String &p_text) {
  807. if (current_main_view != MAIN_VIEW_PROJECTS) {
  808. return;
  809. }
  810. _open_selected_projects_check_recovery_mode();
  811. }
  812. LineEdit *ProjectManager::get_search_box() {
  813. return search_box;
  814. }
  815. // Project tag management.
  816. void ProjectManager::_manage_project_tags() {
  817. for (int i = 0; i < project_tags->get_child_count(); i++) {
  818. project_tags->get_child(i)->queue_free();
  819. }
  820. const ProjectList::Item item = project_list->get_selected_projects()[0];
  821. current_project_tags = item.tags;
  822. for (const String &tag : current_project_tags) {
  823. ProjectTag *tag_control = memnew(ProjectTag(tag, true));
  824. project_tags->add_child(tag_control);
  825. tag_control->connect_button_to(callable_mp(this, &ProjectManager::_delete_project_tag).bind(tag));
  826. }
  827. tag_edit_error->hide();
  828. tag_manage_dialog->popup_centered(Vector2i(500, 0) * EDSCALE);
  829. }
  830. void ProjectManager::_add_project_tag(const String &p_tag) {
  831. if (current_project_tags.has(p_tag)) {
  832. return;
  833. }
  834. current_project_tags.append(p_tag);
  835. ProjectTag *tag_control = memnew(ProjectTag(p_tag, true));
  836. project_tags->add_child(tag_control);
  837. tag_control->connect_button_to(callable_mp(this, &ProjectManager::_delete_project_tag).bind(p_tag));
  838. }
  839. void ProjectManager::_delete_project_tag(const String &p_tag) {
  840. current_project_tags.erase(p_tag);
  841. for (int i = 0; i < project_tags->get_child_count(); i++) {
  842. ProjectTag *tag_control = Object::cast_to<ProjectTag>(project_tags->get_child(i));
  843. if (tag_control && tag_control->get_tag() == p_tag) {
  844. memdelete(tag_control);
  845. break;
  846. }
  847. }
  848. }
  849. void ProjectManager::_apply_project_tags() {
  850. PackedStringArray tags;
  851. for (int i = 0; i < project_tags->get_child_count(); i++) {
  852. ProjectTag *tag_control = Object::cast_to<ProjectTag>(project_tags->get_child(i));
  853. if (tag_control) {
  854. tags.append(tag_control->get_tag());
  855. }
  856. }
  857. const String project_godot = project_list->get_selected_projects()[0].path.path_join("project.godot");
  858. ProjectSettings *cfg = memnew(ProjectSettings(project_godot));
  859. if (!cfg->is_project_loaded()) {
  860. memdelete(cfg);
  861. tag_edit_error->set_text(vformat(TTR("Couldn't load project at '%s'. It may be missing or corrupted."), project_godot));
  862. tag_edit_error->show();
  863. callable_mp((Window *)tag_manage_dialog, &Window::show).call_deferred(); // Make sure the dialog does not disappear.
  864. return;
  865. } else {
  866. tags.sort();
  867. cfg->set("application/config/tags", tags);
  868. Error err = cfg->save_custom(project_godot);
  869. memdelete(cfg);
  870. if (err != OK) {
  871. tag_edit_error->set_text(vformat(TTR("Couldn't save project at '%s' (error %d)."), project_godot, err));
  872. tag_edit_error->show();
  873. callable_mp((Window *)tag_manage_dialog, &Window::show).call_deferred();
  874. return;
  875. }
  876. }
  877. _on_projects_updated();
  878. }
  879. void ProjectManager::_set_new_tag_name(const String p_name) {
  880. create_tag_dialog->get_ok_button()->set_disabled(true);
  881. if (p_name.strip_edges().is_empty()) {
  882. tag_error->set_text(TTRC("Tag name can't be empty."));
  883. return;
  884. }
  885. if (p_name[0] == '_' || p_name[p_name.length() - 1] == '_') {
  886. tag_error->set_text(TTRC("Tag name can't begin or end with underscore."));
  887. return;
  888. }
  889. bool was_underscore = false;
  890. for (const char32_t &c : p_name.span()) {
  891. // Treat spaces as underscores, as we convert spaces to underscores automatically in the tag input field.
  892. if (c == '_' || c == ' ') {
  893. if (was_underscore) {
  894. tag_error->set_text(TTRC("Tag name can't contain consecutive underscores or spaces."));
  895. return;
  896. }
  897. was_underscore = true;
  898. } else {
  899. was_underscore = false;
  900. }
  901. }
  902. for (const String &c : forbidden_tag_characters) {
  903. if (p_name.contains(c)) {
  904. tag_error->set_text(vformat(TTR("These characters are not allowed in tags: %s."), String(" ").join(forbidden_tag_characters)));
  905. return;
  906. }
  907. }
  908. tag_error->set_text("");
  909. create_tag_dialog->get_ok_button()->set_disabled(false);
  910. }
  911. void ProjectManager::_create_new_tag() {
  912. if (!tag_error->get_text().is_empty()) {
  913. return;
  914. }
  915. create_tag_dialog->hide(); // When using text_submitted, need to hide manually.
  916. // Enforce a valid tag name (no spaces, lowercase only) automatically.
  917. // The project manager displays underscores as spaces, and capitalization is performed automatically.
  918. const String new_tag = new_tag_name->get_text().strip_edges().to_lower().replace_char(' ', '_');
  919. add_new_tag(new_tag);
  920. _add_project_tag(new_tag);
  921. }
  922. void ProjectManager::add_new_tag(const String &p_tag) {
  923. if (!tag_set.has(p_tag)) {
  924. tag_set.insert(p_tag);
  925. ProjectTag *tag_control = memnew(ProjectTag(p_tag));
  926. all_tags->add_child(tag_control);
  927. all_tags->move_child(tag_control, -2);
  928. tag_control->connect_button_to(callable_mp(this, &ProjectManager::_add_project_tag).bind(p_tag));
  929. }
  930. }
  931. // Project converter/migration tool.
  932. #ifndef DISABLE_DEPRECATED
  933. void ProjectManager::_minor_project_migrate() {
  934. const ProjectList::Item migrated_project = project_list->get_selected_projects()[0];
  935. if (version_convert_feature.begins_with("4.3")) {
  936. // Migrate layout after scale changes.
  937. const float edscale = EDSCALE;
  938. if (edscale != 1.0) {
  939. Ref<ConfigFile> layout_file;
  940. layout_file.instantiate();
  941. const String layout_path = migrated_project.path.path_join(".godot/editor/editor_layout.cfg");
  942. Error err = layout_file->load(layout_path);
  943. if (err == OK) {
  944. for (int i = 0; i < 4; i++) {
  945. const String key = "dock_hsplit_" + itos(i + 1);
  946. int old_value = layout_file->get_value("docks", key, 0);
  947. if (old_value != 0) {
  948. layout_file->set_value("docks", key, old_value / edscale);
  949. }
  950. }
  951. layout_file->save(layout_path);
  952. }
  953. }
  954. }
  955. }
  956. #endif
  957. void ProjectManager::_full_convert_button_pressed() {
  958. ask_update_settings->hide();
  959. if (ask_update_backup->is_pressed()) {
  960. ask_update_backup->set_pressed(false);
  961. _duplicate_project_with_action(POST_DUPLICATE_ACTION_FULL_CONVERSION);
  962. return;
  963. }
  964. ask_full_convert_dialog->popup_centered(Size2i(600.0 * EDSCALE, 0));
  965. ask_full_convert_dialog->get_cancel_button()->grab_focus();
  966. }
  967. void ProjectManager::_migration_guide_button_pressed() {
  968. const String url = vformat("%s/tutorials/migrating/index.html", GODOT_VERSION_DOCS_URL);
  969. OS::get_singleton()->shell_open(url);
  970. }
  971. void ProjectManager::_perform_full_project_conversion() {
  972. Vector<ProjectList::Item> selected_list = project_list->get_selected_projects();
  973. if (selected_list.is_empty()) {
  974. return;
  975. }
  976. const String &path = selected_list[0].path;
  977. print_line("Converting project: " + path);
  978. List<String> args;
  979. args.push_back("--path");
  980. args.push_back(path);
  981. args.push_back("--convert-3to4");
  982. args.push_back("--rendering-driver");
  983. args.push_back(Main::get_rendering_driver_name());
  984. Error err = OS::get_singleton()->create_instance(args);
  985. ERR_FAIL_COND(err);
  986. project_list->set_project_version(path, GODOT4_CONFIG_VERSION);
  987. }
  988. // Input and I/O.
  989. void ProjectManager::shortcut_input(const Ref<InputEvent> &p_ev) {
  990. ERR_FAIL_COND(p_ev.is_null());
  991. Ref<InputEventKey> k = p_ev;
  992. if (k.is_valid()) {
  993. if (!k->is_pressed()) {
  994. return;
  995. }
  996. // Pressing Command + Q quits the Project Manager
  997. // This is handled by the platform implementation on macOS,
  998. // so only define the shortcut on other platforms
  999. #ifndef MACOS_ENABLED
  1000. if (k->get_keycode_with_modifiers() == (KeyModifierMask::META | Key::Q)) {
  1001. _dim_window();
  1002. get_tree()->quit();
  1003. }
  1004. #endif
  1005. if (current_main_view != MAIN_VIEW_PROJECTS) {
  1006. return;
  1007. }
  1008. bool keycode_handled = true;
  1009. switch (k->get_keycode()) {
  1010. case Key::ENTER: {
  1011. _open_selected_projects_check_recovery_mode();
  1012. } break;
  1013. case Key::HOME: {
  1014. if (project_list->get_project_count() > 0) {
  1015. project_list->ensure_project_visible(0);
  1016. }
  1017. } break;
  1018. case Key::END: {
  1019. if (project_list->get_project_count() > 0) {
  1020. project_list->ensure_project_visible(project_list->get_project_count() - 1);
  1021. }
  1022. } break;
  1023. case Key::F: {
  1024. if (k->is_command_or_control_pressed()) {
  1025. search_box->grab_focus();
  1026. } else {
  1027. keycode_handled = false;
  1028. }
  1029. } break;
  1030. case Key::A: {
  1031. if (k->is_command_or_control_pressed()) {
  1032. if (k->is_shift_pressed()) {
  1033. project_list->deselect_all_visible_projects();
  1034. } else {
  1035. project_list->select_all_visible_projects();
  1036. }
  1037. _update_project_buttons();
  1038. }
  1039. } break;
  1040. default: {
  1041. keycode_handled = false;
  1042. } break;
  1043. }
  1044. if (keycode_handled) {
  1045. accept_event();
  1046. }
  1047. }
  1048. }
  1049. void ProjectManager::_files_dropped(PackedStringArray p_files) {
  1050. // TODO: Support installing multiple ZIPs at the same time?
  1051. if (p_files.size() == 1 && p_files[0].ends_with(".zip")) {
  1052. const String &file = p_files[0];
  1053. _install_project(file, file.get_file().get_basename().capitalize());
  1054. return;
  1055. }
  1056. HashSet<String> folders_set;
  1057. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  1058. for (int i = 0; i < p_files.size(); i++) {
  1059. const String &file = p_files[i];
  1060. folders_set.insert(da->dir_exists(file) ? file : file.get_base_dir());
  1061. }
  1062. ERR_FAIL_COND(folders_set.is_empty()); // This can't really happen, we consume every dropped file path above.
  1063. PackedStringArray folders;
  1064. for (const String &E : folders_set) {
  1065. folders.push_back(E);
  1066. }
  1067. project_list->find_projects_multiple(folders);
  1068. }
  1069. void ProjectManager::_titlebar_resized() {
  1070. DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(title_bar->get_global_position().y + title_bar->get_size().y / 2, title_bar->get_global_position().y + title_bar->get_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
  1071. const Vector3i &margin = DisplayServer::get_singleton()->window_get_safe_title_margins(DisplayServer::MAIN_WINDOW_ID);
  1072. if (left_menu_spacer) {
  1073. int w = (root_container->is_layout_rtl()) ? margin.y : margin.x;
  1074. left_menu_spacer->set_custom_minimum_size(Size2(w, 0));
  1075. }
  1076. if (right_menu_spacer) {
  1077. int w = (root_container->is_layout_rtl()) ? margin.x : margin.y;
  1078. right_menu_spacer->set_custom_minimum_size(Size2(w, 0));
  1079. }
  1080. if (title_bar) {
  1081. title_bar->set_custom_minimum_size(Size2(0, margin.z - title_bar->get_global_position().y));
  1082. }
  1083. }
  1084. void ProjectManager::_open_donate_page() {
  1085. OS::get_singleton()->shell_open("https://fund.godotengine.org/?ref=project_manager");
  1086. }
  1087. // Object methods.
  1088. ProjectManager::ProjectManager() {
  1089. singleton = this;
  1090. // Turn off some servers we aren't going to be using in the Project Manager.
  1091. NavigationServer3D::get_singleton()->set_active(false);
  1092. PhysicsServer3D::get_singleton()->set_active(false);
  1093. PhysicsServer2D::get_singleton()->set_active(false);
  1094. // Initialize settings.
  1095. {
  1096. if (!EditorSettings::get_singleton()) {
  1097. EditorSettings::create();
  1098. }
  1099. EditorSettings::get_singleton()->set_optimize_save(false); // Just write settings as they come.
  1100. {
  1101. bool agile_input_event_flushing = EDITOR_GET("input/buffering/agile_event_flushing");
  1102. bool use_accumulated_input = EDITOR_GET("input/buffering/use_accumulated_input");
  1103. Input::get_singleton()->set_agile_input_event_flushing(agile_input_event_flushing);
  1104. Input::get_singleton()->set_use_accumulated_input(use_accumulated_input);
  1105. }
  1106. int display_scale = EDITOR_GET("interface/editor/display_scale");
  1107. switch (display_scale) {
  1108. case 0:
  1109. // Try applying a suitable display scale automatically.
  1110. EditorScale::set_scale(EditorSettings::get_auto_display_scale());
  1111. break;
  1112. case 1:
  1113. EditorScale::set_scale(0.75);
  1114. break;
  1115. case 2:
  1116. EditorScale::set_scale(1.0);
  1117. break;
  1118. case 3:
  1119. EditorScale::set_scale(1.25);
  1120. break;
  1121. case 4:
  1122. EditorScale::set_scale(1.5);
  1123. break;
  1124. case 5:
  1125. EditorScale::set_scale(1.75);
  1126. break;
  1127. case 6:
  1128. EditorScale::set_scale(2.0);
  1129. break;
  1130. default:
  1131. EditorScale::set_scale(EDITOR_GET("interface/editor/custom_display_scale"));
  1132. break;
  1133. }
  1134. FileDialog::set_get_icon_callback(callable_mp_static(ProjectManager::_file_dialog_get_icon));
  1135. FileDialog::set_get_thumbnail_callback(callable_mp_static(ProjectManager::_file_dialog_get_thumbnail));
  1136. FileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files"));
  1137. FileDialog::set_default_display_mode((FileDialog::DisplayMode)EDITOR_GET("filesystem/file_dialog/display_mode").operator int());
  1138. int swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
  1139. if (swap_cancel_ok != 0) { // 0 is auto, set in register_scene based on DisplayServer.
  1140. // Swap on means OK first.
  1141. AcceptDialog::set_swap_cancel_ok(swap_cancel_ok == 2);
  1142. }
  1143. OS::get_singleton()->set_low_processor_usage_mode(true);
  1144. }
  1145. SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped));
  1146. // Initialize UI.
  1147. {
  1148. int pm_root_dir = EDITOR_GET("interface/editor/ui_layout_direction");
  1149. Control::set_root_layout_direction(pm_root_dir);
  1150. Window::set_root_layout_direction(pm_root_dir);
  1151. EditorThemeManager::initialize();
  1152. theme = EditorThemeManager::generate_theme();
  1153. DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), EditorStringName(Editor)));
  1154. set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
  1155. _build_icon_type_cache(theme);
  1156. }
  1157. // Project manager layout.
  1158. background_panel = memnew(Panel);
  1159. add_child(background_panel);
  1160. background_panel->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
  1161. root_container = memnew(MarginContainer);
  1162. add_child(root_container);
  1163. root_container->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
  1164. main_vbox = memnew(VBoxContainer);
  1165. root_container->add_child(main_vbox);
  1166. // Title bar.
  1167. bool can_expand = bool(EDITOR_GET("interface/editor/expand_to_title")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_EXTEND_TO_TITLE);
  1168. {
  1169. title_bar = memnew(EditorTitleBar);
  1170. main_vbox->add_child(title_bar);
  1171. if (can_expand) {
  1172. // Add spacer to avoid other controls under window minimize/maximize/close buttons (left side).
  1173. left_menu_spacer = memnew(Control);
  1174. left_menu_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
  1175. title_bar->add_child(left_menu_spacer);
  1176. }
  1177. HBoxContainer *left_hbox = memnew(HBoxContainer);
  1178. left_hbox->set_alignment(BoxContainer::ALIGNMENT_BEGIN);
  1179. left_hbox->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1180. left_hbox->set_stretch_ratio(1.0);
  1181. title_bar->add_child(left_hbox);
  1182. title_bar_logo = memnew(Button);
  1183. title_bar_logo->set_flat(true);
  1184. title_bar_logo->set_tooltip_text(TTR("About Godot"));
  1185. left_hbox->add_child(title_bar_logo);
  1186. title_bar_logo->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_show_about));
  1187. bool global_menu = !bool(EDITOR_GET("interface/editor/use_embedded_menu")) && NativeMenu::get_singleton()->has_feature(NativeMenu::FEATURE_GLOBAL_MENU);
  1188. if (global_menu) {
  1189. MenuBar *main_menu_bar = memnew(MenuBar);
  1190. main_menu_bar->set_start_index(0); // Main menu, add to the start of global menu.
  1191. main_menu_bar->set_prefer_global_menu(true);
  1192. left_hbox->add_child(main_menu_bar);
  1193. if (NativeMenu::get_singleton()->has_system_menu(NativeMenu::WINDOW_MENU_ID)) {
  1194. PopupMenu *window_menu = memnew(PopupMenu);
  1195. window_menu->set_system_menu(NativeMenu::WINDOW_MENU_ID);
  1196. window_menu->set_name(TTRC("Window"));
  1197. main_menu_bar->add_child(window_menu);
  1198. }
  1199. if (NativeMenu::get_singleton()->has_system_menu(NativeMenu::HELP_MENU_ID)) {
  1200. PopupMenu *help_menu = memnew(PopupMenu);
  1201. help_menu->set_system_menu(NativeMenu::HELP_MENU_ID);
  1202. help_menu->set_name(TTRC("Help"));
  1203. main_menu_bar->add_child(help_menu);
  1204. }
  1205. }
  1206. if (can_expand) {
  1207. // Spacer to center main toggles.
  1208. left_spacer = memnew(Control);
  1209. left_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
  1210. title_bar->add_child(left_spacer);
  1211. }
  1212. main_view_toggles = memnew(HBoxContainer);
  1213. main_view_toggles->set_alignment(BoxContainer::ALIGNMENT_CENTER);
  1214. main_view_toggles->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1215. main_view_toggles->set_stretch_ratio(2.0);
  1216. title_bar->add_child(main_view_toggles);
  1217. title_bar->set_center_control(main_view_toggles);
  1218. if (can_expand) {
  1219. // Spacer to center main toggles.
  1220. right_spacer = memnew(Control);
  1221. right_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
  1222. title_bar->add_child(right_spacer);
  1223. }
  1224. main_view_toggles_group.instantiate();
  1225. HBoxContainer *right_hbox = memnew(HBoxContainer);
  1226. right_hbox->set_alignment(BoxContainer::ALIGNMENT_END);
  1227. right_hbox->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1228. right_hbox->set_stretch_ratio(1.0);
  1229. title_bar->add_child(right_hbox);
  1230. quick_settings_button = memnew(Button);
  1231. quick_settings_button->set_flat(true);
  1232. quick_settings_button->set_text(TTRC("Settings"));
  1233. right_hbox->add_child(quick_settings_button);
  1234. quick_settings_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_show_quick_settings));
  1235. if (can_expand) {
  1236. // Add spacer to avoid other controls under the window minimize/maximize/close buttons (right side).
  1237. right_menu_spacer = memnew(Control);
  1238. right_menu_spacer->set_mouse_filter(Control::MOUSE_FILTER_PASS);
  1239. title_bar->add_child(right_menu_spacer);
  1240. }
  1241. }
  1242. main_view_container = memnew(PanelContainer);
  1243. main_view_container->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  1244. main_vbox->add_child(main_view_container);
  1245. // Project list view.
  1246. {
  1247. local_projects_vb = memnew(VBoxContainer);
  1248. local_projects_vb->set_name("LocalProjectsTab");
  1249. _add_main_view(MAIN_VIEW_PROJECTS, TTRC("Projects"), Ref<Texture2D>(), local_projects_vb);
  1250. // Project list's top bar.
  1251. {
  1252. HBoxContainer *hb = memnew(HBoxContainer);
  1253. hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1254. local_projects_vb->add_child(hb);
  1255. create_btn = memnew(Button);
  1256. create_btn->set_text(TTRC("Create"));
  1257. create_btn->set_shortcut(ED_SHORTCUT("project_manager/new_project", TTRC("New Project"), KeyModifierMask::CMD_OR_CTRL | Key::N));
  1258. create_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_new_project));
  1259. hb->add_child(create_btn);
  1260. import_btn = memnew(Button);
  1261. import_btn->set_text(TTRC("Import"));
  1262. import_btn->set_shortcut(ED_SHORTCUT("project_manager/import_project", TTRC("Import Project"), KeyModifierMask::CMD_OR_CTRL | Key::I));
  1263. import_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_import_project));
  1264. hb->add_child(import_btn);
  1265. scan_btn = memnew(Button);
  1266. scan_btn->set_text(TTRC("Scan"));
  1267. scan_btn->set_shortcut(ED_SHORTCUT("project_manager/scan_projects", TTRC("Scan Projects"), KeyModifierMask::CMD_OR_CTRL | Key::S));
  1268. scan_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_scan_projects));
  1269. hb->add_child(scan_btn);
  1270. loading_label = memnew(Label(TTRC("Loading, please wait...")));
  1271. loading_label->set_accessibility_live(DisplayServer::AccessibilityLiveMode::LIVE_ASSERTIVE);
  1272. loading_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1273. loading_label->hide();
  1274. hb->add_child(loading_label);
  1275. search_box = memnew(LineEdit);
  1276. search_box->set_placeholder(TTRC("Filter Projects"));
  1277. search_box->set_accessibility_name(TTRC("Filter Projects"));
  1278. search_box->set_tooltip_text(TTRC("This field filters projects by name and last path component.\nTo filter projects by name and full path, the query must contain at least one `/` character."));
  1279. search_box->set_clear_button_enabled(true);
  1280. search_box->connect(SceneStringName(text_changed), callable_mp(this, &ProjectManager::_on_search_term_changed));
  1281. search_box->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectManager::_on_search_term_submitted));
  1282. search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1283. hb->add_child(search_box);
  1284. sort_label = memnew(Label);
  1285. sort_label->set_text(TTRC("Sort:"));
  1286. hb->add_child(sort_label);
  1287. filter_option = memnew(OptionButton);
  1288. filter_option->set_clip_text(true);
  1289. filter_option->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1290. filter_option->set_stretch_ratio(0.3);
  1291. filter_option->set_accessibility_name(TTRC("Sort:"));
  1292. filter_option->connect(SceneStringName(item_selected), callable_mp(this, &ProjectManager::_on_order_option_changed));
  1293. hb->add_child(filter_option);
  1294. filter_option->add_item(TTRC("Last Edited"));
  1295. filter_option->add_item(TTRC("Name"));
  1296. filter_option->add_item(TTRC("Path"));
  1297. filter_option->add_item(TTRC("Tags"));
  1298. }
  1299. // Project list and its sidebar.
  1300. {
  1301. HBoxContainer *project_list_hbox = memnew(HBoxContainer);
  1302. local_projects_vb->add_child(project_list_hbox);
  1303. project_list_hbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  1304. project_list_panel = memnew(PanelContainer);
  1305. project_list_panel->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1306. project_list_hbox->add_child(project_list_panel);
  1307. project_list = memnew(ProjectList);
  1308. project_list->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
  1309. project_list_panel->add_child(project_list);
  1310. project_list->connect(ProjectList::SIGNAL_LIST_CHANGED, callable_mp(this, &ProjectManager::_update_project_buttons));
  1311. project_list->connect(ProjectList::SIGNAL_LIST_CHANGED, callable_mp(this, &ProjectManager::_update_list_placeholder));
  1312. project_list->connect(ProjectList::SIGNAL_SELECTION_CHANGED, callable_mp(this, &ProjectManager::_update_project_buttons));
  1313. project_list->connect(ProjectList::SIGNAL_PROJECT_ASK_OPEN, callable_mp(this, &ProjectManager::_open_selected_projects_check_recovery_mode));
  1314. project_list->connect(ProjectList::SIGNAL_MENU_OPTION_SELECTED, callable_mp(this, &ProjectManager::_project_list_menu_option));
  1315. // Empty project list placeholder.
  1316. {
  1317. empty_list_placeholder = memnew(VBoxContainer);
  1318. empty_list_placeholder->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
  1319. empty_list_placeholder->add_theme_constant_override("separation", 16 * EDSCALE);
  1320. empty_list_placeholder->hide();
  1321. project_list_panel->add_child(empty_list_placeholder);
  1322. empty_list_message = memnew(RichTextLabel);
  1323. empty_list_message->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
  1324. empty_list_message->set_use_bbcode(true);
  1325. empty_list_message->set_fit_content(true);
  1326. empty_list_message->set_h_size_flags(SIZE_EXPAND_FILL);
  1327. empty_list_message->add_theme_style_override(CoreStringName(normal), memnew(StyleBoxEmpty));
  1328. empty_list_placeholder->add_child(empty_list_message);
  1329. FlowContainer *empty_list_actions = memnew(FlowContainer);
  1330. empty_list_actions->set_alignment(FlowContainer::ALIGNMENT_CENTER);
  1331. empty_list_placeholder->add_child(empty_list_actions);
  1332. empty_list_create_project = memnew(Button);
  1333. empty_list_create_project->set_text(TTRC("Create New Project"));
  1334. empty_list_create_project->set_theme_type_variation("PanelBackgroundButton");
  1335. empty_list_actions->add_child(empty_list_create_project);
  1336. empty_list_create_project->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_new_project));
  1337. empty_list_import_project = memnew(Button);
  1338. empty_list_import_project->set_text(TTRC("Import Existing Project"));
  1339. empty_list_import_project->set_theme_type_variation("PanelBackgroundButton");
  1340. empty_list_actions->add_child(empty_list_import_project);
  1341. empty_list_import_project->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_import_project));
  1342. empty_list_open_assetlib = memnew(Button);
  1343. empty_list_open_assetlib->set_text(TTRC("Open Asset Library"));
  1344. empty_list_open_assetlib->set_theme_type_variation("PanelBackgroundButton");
  1345. empty_list_actions->add_child(empty_list_open_assetlib);
  1346. empty_list_open_assetlib->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_asset_library_confirmed));
  1347. empty_list_online_warning = memnew(Label);
  1348. empty_list_online_warning->set_focus_mode(FOCUS_ACCESSIBILITY);
  1349. empty_list_online_warning->set_horizontal_alignment(HorizontalAlignment::HORIZONTAL_ALIGNMENT_CENTER);
  1350. empty_list_online_warning->set_custom_minimum_size(Size2(220, 0) * EDSCALE);
  1351. empty_list_online_warning->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
  1352. empty_list_online_warning->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1353. empty_list_online_warning->set_text(TTRC("Note: The Asset Library requires an online connection and involves sending data over the internet."));
  1354. empty_list_placeholder->add_child(empty_list_online_warning);
  1355. }
  1356. // The side bar with the edit, run, rename, etc. buttons.
  1357. VBoxContainer *project_list_sidebar = memnew(VBoxContainer);
  1358. project_list_sidebar->set_custom_minimum_size(Size2(120, 120));
  1359. project_list_hbox->add_child(project_list_sidebar);
  1360. project_list_sidebar->add_child(memnew(HSeparator));
  1361. ScrollContainer *sidebar_scroll_containter = memnew(ScrollContainer);
  1362. sidebar_scroll_containter->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
  1363. sidebar_scroll_containter->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  1364. project_list_sidebar->add_child(sidebar_scroll_containter);
  1365. VBoxContainer *sidebar_buttons_containter = memnew(VBoxContainer);
  1366. sidebar_scroll_containter->add_child(sidebar_buttons_containter);
  1367. open_btn_container = memnew(HBoxContainer);
  1368. open_btn_container->set_anchors_preset(Control::PRESET_FULL_RECT);
  1369. sidebar_buttons_containter->add_child(open_btn_container);
  1370. open_btn = memnew(Button);
  1371. open_btn->set_text(TTRC("Edit"));
  1372. open_btn->set_shortcut(ED_SHORTCUT("project_manager/edit_project", TTRC("Edit Project"), KeyModifierMask::CMD_OR_CTRL | Key::E));
  1373. open_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_selected_projects_check_recovery_mode));
  1374. open_btn->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  1375. open_btn_container->add_child(open_btn);
  1376. open_btn_container->add_child(memnew(VSeparator));
  1377. open_options_btn = memnew(Button);
  1378. open_options_btn->set_accessibility_name(TTRC("Options"));
  1379. open_options_btn->set_icon_alignment(HorizontalAlignment::HORIZONTAL_ALIGNMENT_CENTER);
  1380. open_options_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_options_popup));
  1381. open_btn_container->add_child(open_options_btn);
  1382. open_options_popup = memnew(PopupMenu);
  1383. open_options_popup->add_item(TTRC("Edit in verbose mode"));
  1384. open_options_popup->add_item(TTRC("Edit in recovery mode"));
  1385. open_options_popup->connect(SceneStringName(id_pressed), callable_mp(this, &ProjectManager::_on_open_options_selected));
  1386. open_options_btn->add_child(open_options_popup);
  1387. open_btn_container->set_custom_minimum_size(Size2(120, open_btn->get_combined_minimum_size().y));
  1388. run_btn = memnew(Button);
  1389. run_btn->set_text(TTRC("Run"));
  1390. run_btn->set_shortcut(ED_SHORTCUT("project_manager/run_project", TTRC("Run Project"), KeyModifierMask::CMD_OR_CTRL | Key::R));
  1391. run_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_run_project));
  1392. sidebar_buttons_containter->add_child(run_btn);
  1393. rename_btn = memnew(Button);
  1394. rename_btn->set_text(TTRC("Rename"));
  1395. // The F2 shortcut isn't overridden with Enter on macOS as Enter is already used to edit a project.
  1396. rename_btn->set_shortcut(ED_SHORTCUT("project_manager/rename_project", TTRC("Rename Project"), Key::F2));
  1397. rename_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_rename_project));
  1398. sidebar_buttons_containter->add_child(rename_btn);
  1399. duplicate_btn = memnew(Button);
  1400. duplicate_btn->set_text(TTRC("Duplicate"));
  1401. duplicate_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_duplicate_project));
  1402. sidebar_buttons_containter->add_child(duplicate_btn);
  1403. manage_tags_btn = memnew(Button);
  1404. manage_tags_btn->set_text(TTRC("Manage Tags"));
  1405. manage_tags_btn->set_shortcut(ED_SHORTCUT("project_manager/project_tags", TTRC("Manage Tags"), KeyModifierMask::CMD_OR_CTRL | Key::T));
  1406. sidebar_buttons_containter->add_child(manage_tags_btn);
  1407. erase_btn = memnew(Button);
  1408. erase_btn->set_text(TTRC("Remove"));
  1409. erase_btn->set_shortcut(ED_SHORTCUT("project_manager/remove_project", TTRC("Remove Project"), Key::KEY_DELETE));
  1410. erase_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_erase_project));
  1411. sidebar_buttons_containter->add_child(erase_btn);
  1412. erase_missing_btn = memnew(Button);
  1413. erase_missing_btn->set_text(TTRC("Remove Missing"));
  1414. erase_missing_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_erase_missing_projects));
  1415. sidebar_buttons_containter->add_child(erase_missing_btn);
  1416. donate_btn = memnew(Button);
  1417. donate_btn->set_text(TTRC("Donate"));
  1418. donate_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_donate_page));
  1419. project_list_sidebar->add_child(donate_btn);
  1420. }
  1421. }
  1422. // Asset library view.
  1423. if (AssetLibraryEditorPlugin::is_available()) {
  1424. asset_library = memnew(EditorAssetLibrary(true));
  1425. asset_library->set_name("AssetLibraryTab");
  1426. _add_main_view(MAIN_VIEW_ASSETLIB, TTRC("Asset Library"), Ref<Texture2D>(), asset_library);
  1427. asset_library->connect("install_asset", callable_mp(this, &ProjectManager::_install_project));
  1428. } else {
  1429. VBoxContainer *asset_library_filler = memnew(VBoxContainer);
  1430. asset_library_filler->set_name("AssetLibraryTab");
  1431. Button *asset_library_toggle = _add_main_view(MAIN_VIEW_ASSETLIB, TTRC("Asset Library"), Ref<Texture2D>(), asset_library_filler);
  1432. asset_library_toggle->set_disabled(true);
  1433. asset_library_toggle->set_tooltip_text(TTRC("Asset Library not available (due to using Web editor, or because SSL support disabled)."));
  1434. }
  1435. // Footer bar.
  1436. {
  1437. HBoxContainer *footer_bar = memnew(HBoxContainer);
  1438. footer_bar->set_alignment(BoxContainer::ALIGNMENT_END);
  1439. footer_bar->add_theme_constant_override("separation", 20 * EDSCALE);
  1440. main_vbox->add_child(footer_bar);
  1441. #ifdef ENGINE_UPDATE_CHECK_ENABLED
  1442. EngineUpdateLabel *update_label = memnew(EngineUpdateLabel);
  1443. footer_bar->add_child(update_label);
  1444. update_label->connect("offline_clicked", callable_mp(this, &ProjectManager::_show_quick_settings));
  1445. #endif
  1446. EditorVersionButton *version_btn = memnew(EditorVersionButton(EditorVersionButton::FORMAT_WITH_BUILD));
  1447. // Fade the version label to be less prominent, but still readable.
  1448. version_btn->set_self_modulate(Color(1, 1, 1, 0.6));
  1449. footer_bar->add_child(version_btn);
  1450. }
  1451. // Dialogs.
  1452. {
  1453. quick_settings_dialog = memnew(QuickSettingsDialog);
  1454. add_child(quick_settings_dialog);
  1455. quick_settings_dialog->connect("restart_required", callable_mp(this, &ProjectManager::_restart_confirmed));
  1456. scan_dir = memnew(EditorFileDialog);
  1457. scan_dir->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
  1458. scan_dir->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
  1459. scan_dir->set_title(TTRC("Select a Folder to Scan")); // Must be after mode or it's overridden.
  1460. scan_dir->set_current_dir(EDITOR_GET("filesystem/directories/default_project_path"));
  1461. add_child(scan_dir);
  1462. scan_dir->connect("dir_selected", callable_mp(project_list, &ProjectList::find_projects));
  1463. erase_missing_ask = memnew(ConfirmationDialog);
  1464. erase_missing_ask->set_ok_button_text(TTRC("Remove All"));
  1465. erase_missing_ask->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_erase_missing_projects_confirm));
  1466. add_child(erase_missing_ask);
  1467. erase_ask = memnew(ConfirmationDialog);
  1468. erase_ask->set_ok_button_text(TTRC("Remove"));
  1469. erase_ask->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_erase_project_confirm));
  1470. add_child(erase_ask);
  1471. VBoxContainer *erase_ask_vb = memnew(VBoxContainer);
  1472. erase_ask->add_child(erase_ask_vb);
  1473. erase_ask_label = memnew(Label);
  1474. erase_ask_label->set_focus_mode(FOCUS_ACCESSIBILITY);
  1475. erase_ask_vb->add_child(erase_ask_label);
  1476. // Comment out for now until we have a better warning system to
  1477. // ensure users delete their project only.
  1478. //delete_project_contents = memnew(CheckBox);
  1479. //delete_project_contents->set_text(TTRC("Also delete project contents (no undo!)"));
  1480. //erase_ask_vb->add_child(delete_project_contents);
  1481. multi_open_ask = memnew(ConfirmationDialog);
  1482. multi_open_ask->set_ok_button_text(TTRC("Edit"));
  1483. multi_open_ask->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_selected_projects));
  1484. add_child(multi_open_ask);
  1485. multi_run_ask = memnew(ConfirmationDialog);
  1486. multi_run_ask->set_ok_button_text(TTRC("Run"));
  1487. multi_run_ask->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_run_project_confirm));
  1488. add_child(multi_run_ask);
  1489. open_recovery_mode_ask = memnew(ConfirmationDialog);
  1490. open_recovery_mode_ask->set_min_size(Size2(550, 70) * EDSCALE);
  1491. open_recovery_mode_ask->set_autowrap(true);
  1492. open_recovery_mode_ask->add_button(TTRC("Edit normally"))->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_on_recovery_mode_popup_open_normal));
  1493. open_recovery_mode_ask->set_ok_button_text(TTRC("Edit in Recovery Mode"));
  1494. open_recovery_mode_ask->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_on_recovery_mode_popup_open_recovery));
  1495. add_child(open_recovery_mode_ask);
  1496. ask_update_settings = memnew(ConfirmationDialog);
  1497. add_child(ask_update_settings);
  1498. ask_update_vb = memnew(VBoxContainer);
  1499. ask_update_settings->add_child(ask_update_vb);
  1500. ask_update_label = memnew(Label);
  1501. ask_update_label->set_focus_mode(FOCUS_ACCESSIBILITY);
  1502. ask_update_label->set_custom_minimum_size(Size2(300 * EDSCALE, 1));
  1503. ask_update_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
  1504. ask_update_label->set_v_size_flags(SIZE_EXPAND_FILL);
  1505. ask_update_vb->add_child(ask_update_label);
  1506. ask_update_backup = memnew(CheckBox);
  1507. ask_update_backup->set_text(TTRC("Backup project first"));
  1508. ask_update_backup->set_h_size_flags(SIZE_SHRINK_CENTER);
  1509. ask_update_vb->add_child(ask_update_backup);
  1510. ask_update_settings->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_selected_projects_with_migration));
  1511. int ed_swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
  1512. if (ed_swap_cancel_ok == 0) {
  1513. ed_swap_cancel_ok = DisplayServer::get_singleton()->get_swap_cancel_ok() ? 2 : 1;
  1514. }
  1515. full_convert_button = ask_update_settings->add_button(TTRC("Convert Full Project"), ed_swap_cancel_ok != 2);
  1516. full_convert_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_full_convert_button_pressed));
  1517. migration_guide_button = ask_update_settings->add_button(TTRC("See Migration Guide"), ed_swap_cancel_ok != 2);
  1518. migration_guide_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_migration_guide_button_pressed));
  1519. ask_full_convert_dialog = memnew(ConfirmationDialog);
  1520. ask_full_convert_dialog->set_autowrap(true);
  1521. ask_full_convert_dialog->set_text(TTRC("This option will perform full project conversion, updating scenes, resources and scripts from Godot 3 to work in Godot 4.\n\nNote that this is a best-effort conversion, i.e. it makes upgrading the project easier, but it will not open out-of-the-box and will still require manual adjustments.\n\nIMPORTANT: Make sure to backup your project before converting, as this operation makes it impossible to open it in older versions of Godot."));
  1522. ask_full_convert_dialog->connect(SceneStringName(confirmed), callable_mp(this, &ProjectManager::_perform_full_project_conversion));
  1523. add_child(ask_full_convert_dialog);
  1524. project_dialog = memnew(ProjectDialog);
  1525. project_dialog->connect("projects_updated", callable_mp(this, &ProjectManager::_on_projects_updated));
  1526. project_dialog->connect("project_created", callable_mp(this, &ProjectManager::_on_project_created));
  1527. project_dialog->connect("project_duplicated", callable_mp(this, &ProjectManager::_on_project_duplicated));
  1528. add_child(project_dialog);
  1529. error_dialog = memnew(AcceptDialog);
  1530. error_dialog->set_title(TTRC("Error"));
  1531. add_child(error_dialog);
  1532. about_dialog = memnew(EditorAbout);
  1533. add_child(about_dialog);
  1534. }
  1535. // Tag management.
  1536. {
  1537. tag_manage_dialog = memnew(ConfirmationDialog);
  1538. add_child(tag_manage_dialog);
  1539. tag_manage_dialog->set_title(TTRC("Manage Project Tags"));
  1540. tag_manage_dialog->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_apply_project_tags));
  1541. manage_tags_btn->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_manage_project_tags));
  1542. VBoxContainer *tag_vb = memnew(VBoxContainer);
  1543. tag_manage_dialog->add_child(tag_vb);
  1544. Label *label = memnew(Label(TTRC("Project Tags")));
  1545. tag_vb->add_child(label);
  1546. label->set_theme_type_variation("HeaderMedium");
  1547. label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
  1548. label = memnew(Label(TTRC("Click tag to remove it from the project.")));
  1549. tag_vb->add_child(label);
  1550. label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
  1551. project_tags = memnew(HFlowContainer);
  1552. tag_vb->add_child(project_tags);
  1553. project_tags->set_custom_minimum_size(Vector2(0, 100) * EDSCALE);
  1554. tag_vb->add_child(memnew(HSeparator));
  1555. label = memnew(Label(TTRC("All Tags")));
  1556. tag_vb->add_child(label);
  1557. label->set_theme_type_variation("HeaderMedium");
  1558. label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
  1559. label = memnew(Label(TTRC("Click tag to add it to the project.")));
  1560. tag_vb->add_child(label);
  1561. label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
  1562. all_tags = memnew(HFlowContainer);
  1563. tag_vb->add_child(all_tags);
  1564. all_tags->set_custom_minimum_size(Vector2(0, 100) * EDSCALE);
  1565. tag_edit_error = memnew(Label);
  1566. tag_vb->add_child(tag_edit_error);
  1567. tag_edit_error->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
  1568. create_tag_dialog = memnew(ConfirmationDialog);
  1569. tag_manage_dialog->add_child(create_tag_dialog);
  1570. create_tag_dialog->set_title(TTRC("Create New Tag"));
  1571. create_tag_dialog->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_create_new_tag));
  1572. tag_vb = memnew(VBoxContainer);
  1573. create_tag_dialog->add_child(tag_vb);
  1574. Label *info = memnew(Label(TTRC("Tags are capitalized automatically when displayed.")));
  1575. tag_vb->add_child(info);
  1576. new_tag_name = memnew(LineEdit);
  1577. tag_vb->add_child(new_tag_name);
  1578. new_tag_name->set_accessibility_name(TTRC("New Tag Name"));
  1579. new_tag_name->set_placeholder(TTRC("example_tag (will display as Example Tag)"));
  1580. new_tag_name->connect(SceneStringName(text_changed), callable_mp(this, &ProjectManager::_set_new_tag_name));
  1581. new_tag_name->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectManager::_create_new_tag).unbind(1));
  1582. create_tag_dialog->connect("about_to_popup", callable_mp(new_tag_name, &LineEdit::clear));
  1583. create_tag_dialog->connect("about_to_popup", callable_mp((Control *)new_tag_name, &Control::grab_focus).bind(false), CONNECT_DEFERRED);
  1584. tag_error = memnew(Label);
  1585. tag_error->set_focus_mode(FOCUS_ACCESSIBILITY);
  1586. tag_vb->add_child(tag_error);
  1587. create_tag_btn = memnew(Button);
  1588. create_tag_btn->set_accessibility_name(TTRC("Create Tag"));
  1589. all_tags->add_child(create_tag_btn);
  1590. create_tag_btn->connect(SceneStringName(pressed), callable_mp((Window *)create_tag_dialog, &Window::popup_centered).bind(Vector2i(500, 0) * EDSCALE));
  1591. _set_new_tag_name("");
  1592. }
  1593. // Initialize project list.
  1594. {
  1595. project_list->load_project_list();
  1596. Ref<DirAccess> dir_access = DirAccess::create(DirAccess::AccessType::ACCESS_FILESYSTEM);
  1597. String default_project_path = EDITOR_GET("filesystem/directories/default_project_path");
  1598. if (!default_project_path.is_empty() && !dir_access->dir_exists(default_project_path)) {
  1599. Error error = dir_access->make_dir_recursive(default_project_path);
  1600. if (error != OK) {
  1601. ERR_PRINT("Could not create default project directory at: " + default_project_path);
  1602. }
  1603. }
  1604. String autoscan_path = EDITOR_GET("filesystem/directories/autoscan_project_path");
  1605. if (!autoscan_path.is_empty()) {
  1606. if (dir_access->dir_exists(autoscan_path)) {
  1607. project_list->find_projects(autoscan_path);
  1608. } else {
  1609. Error error = dir_access->make_dir_recursive(autoscan_path);
  1610. if (error != OK) {
  1611. ERR_PRINT("Could not create project autoscan directory at: " + autoscan_path);
  1612. }
  1613. }
  1614. }
  1615. project_list->update_project_list();
  1616. initialized = true;
  1617. }
  1618. // Extend menu bar to window title.
  1619. if (can_expand) {
  1620. DisplayServer::get_singleton()->process_events();
  1621. DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE, true, DisplayServer::MAIN_WINDOW_ID);
  1622. title_bar->set_can_move_window(true);
  1623. title_bar->connect(SceneStringName(item_rect_changed), callable_mp(this, &ProjectManager::_titlebar_resized));
  1624. }
  1625. _update_size_limits();
  1626. }
  1627. ProjectManager::~ProjectManager() {
  1628. singleton = nullptr;
  1629. EditorInspector::cleanup_plugins();
  1630. if (EditorSettings::get_singleton()) {
  1631. EditorSettings::destroy();
  1632. }
  1633. EditorThemeManager::finalize();
  1634. }