export_template_manager.cpp 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  1. /**************************************************************************/
  2. /* export_template_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 "export_template_manager.h"
  31. #include "core/io/dir_access.h"
  32. #include "core/io/json.h"
  33. #include "core/io/zip_io.h"
  34. #include "core/version.h"
  35. #include "editor/editor_file_system.h"
  36. #include "editor/editor_node.h"
  37. #include "editor/editor_paths.h"
  38. #include "editor/editor_settings.h"
  39. #include "editor/editor_string_names.h"
  40. #include "editor/export/editor_export_preset.h"
  41. #include "editor/progress_dialog.h"
  42. #include "editor/themes/editor_scale.h"
  43. #include "scene/gui/file_dialog.h"
  44. #include "scene/gui/menu_button.h"
  45. #include "scene/gui/separator.h"
  46. #include "scene/gui/tree.h"
  47. #include "scene/main/http_request.h"
  48. enum DownloadsAvailability {
  49. DOWNLOADS_AVAILABLE,
  50. DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE,
  51. DOWNLOADS_NOT_AVAILABLE_FOR_DEV_BUILDS,
  52. };
  53. static DownloadsAvailability _get_downloads_availability() {
  54. const int network_mode = EDITOR_GET("network/connection/network_mode");
  55. if (network_mode == EditorSettings::NETWORK_OFFLINE) {
  56. return DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE;
  57. }
  58. // Downloadable export templates are only available for stable and official alpha/beta/RC builds
  59. // (which always have a number following their status, e.g. "alpha1").
  60. // Therefore, don't display download-related features when using a development version
  61. // (whose builds aren't numbered).
  62. if (String(VERSION_STATUS) == String("dev") ||
  63. String(VERSION_STATUS) == String("alpha") ||
  64. String(VERSION_STATUS) == String("beta") ||
  65. String(VERSION_STATUS) == String("rc")) {
  66. return DOWNLOADS_NOT_AVAILABLE_FOR_DEV_BUILDS;
  67. }
  68. return DOWNLOADS_AVAILABLE;
  69. }
  70. void ExportTemplateManager::_update_template_status() {
  71. // Fetch installed templates from the file system.
  72. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  73. const String &templates_dir = EditorPaths::get_singleton()->get_export_templates_dir();
  74. Error err = da->change_dir(templates_dir);
  75. ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'.");
  76. RBSet<String> templates;
  77. da->list_dir_begin();
  78. if (err == OK) {
  79. String c = da->get_next();
  80. while (!c.is_empty()) {
  81. if (da->current_is_dir() && !c.begins_with(".")) {
  82. templates.insert(c);
  83. }
  84. c = da->get_next();
  85. }
  86. }
  87. da->list_dir_end();
  88. // Update the state of the current version.
  89. String current_version = VERSION_FULL_CONFIG;
  90. current_value->set_text(current_version);
  91. if (templates.has(current_version)) {
  92. current_missing_label->hide();
  93. current_installed_label->show();
  94. current_installed_hb->show();
  95. current_version_exists = true;
  96. } else {
  97. current_installed_label->hide();
  98. current_missing_label->show();
  99. current_installed_hb->hide();
  100. current_version_exists = false;
  101. }
  102. if (is_downloading_templates) {
  103. install_options_vb->hide();
  104. download_progress_hb->show();
  105. } else {
  106. download_progress_hb->hide();
  107. install_options_vb->show();
  108. if (templates.has(current_version)) {
  109. current_installed_path->set_text(templates_dir.path_join(current_version));
  110. }
  111. }
  112. // Update the list of other installed versions.
  113. installed_table->clear();
  114. TreeItem *installed_root = installed_table->create_item();
  115. for (RBSet<String>::Element *E = templates.back(); E; E = E->prev()) {
  116. String version_string = E->get();
  117. if (version_string == current_version) {
  118. continue;
  119. }
  120. TreeItem *ti = installed_table->create_item(installed_root);
  121. ti->set_text(0, version_string);
  122. #ifndef ANDROID_ENABLED
  123. ti->add_button(0, get_editor_theme_icon(SNAME("Folder")), OPEN_TEMPLATE_FOLDER, false, TTR("Open the folder containing these templates."));
  124. #endif
  125. ti->add_button(0, get_editor_theme_icon(SNAME("Remove")), UNINSTALL_TEMPLATE, false, TTR("Uninstall these templates."));
  126. }
  127. }
  128. void ExportTemplateManager::_download_current() {
  129. if (is_downloading_templates) {
  130. return;
  131. }
  132. is_downloading_templates = true;
  133. install_options_vb->hide();
  134. download_progress_hb->show();
  135. if (mirrors_available) {
  136. String mirror_url = _get_selected_mirror();
  137. if (mirror_url.is_empty()) {
  138. _set_current_progress_status(TTR("There are no mirrors available."), true);
  139. return;
  140. }
  141. _download_template(mirror_url, true);
  142. } else if (!is_refreshing_mirrors) {
  143. _set_current_progress_status(TTR("Retrieving the mirror list..."));
  144. _refresh_mirrors();
  145. }
  146. }
  147. void ExportTemplateManager::_download_template(const String &p_url, bool p_skip_check) {
  148. if (!p_skip_check && is_downloading_templates) {
  149. return;
  150. }
  151. is_downloading_templates = true;
  152. install_options_vb->hide();
  153. download_progress_hb->show();
  154. download_progress_bar->show();
  155. download_progress_bar->set_indeterminate(true);
  156. _set_current_progress_status(TTR("Starting the download..."));
  157. download_templates->set_download_file(EditorPaths::get_singleton()->get_cache_dir().path_join("tmp_templates.tpz"));
  158. download_templates->set_use_threads(true);
  159. const String proxy_host = EDITOR_GET("network/http_proxy/host");
  160. const int proxy_port = EDITOR_GET("network/http_proxy/port");
  161. download_templates->set_http_proxy(proxy_host, proxy_port);
  162. download_templates->set_https_proxy(proxy_host, proxy_port);
  163. Error err = download_templates->request(p_url);
  164. if (err != OK) {
  165. _set_current_progress_status(TTR("Error requesting URL:") + " " + p_url, true);
  166. download_progress_hb->hide();
  167. return;
  168. }
  169. set_process(true);
  170. _set_current_progress_status(TTR("Connecting to the mirror..."));
  171. }
  172. void ExportTemplateManager::_download_template_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
  173. switch (p_status) {
  174. case HTTPRequest::RESULT_CANT_RESOLVE: {
  175. _set_current_progress_status(TTR("Can't resolve the requested address."), true);
  176. } break;
  177. case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
  178. case HTTPRequest::RESULT_CONNECTION_ERROR:
  179. case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH:
  180. case HTTPRequest::RESULT_TLS_HANDSHAKE_ERROR:
  181. case HTTPRequest::RESULT_CANT_CONNECT: {
  182. _set_current_progress_status(TTR("Can't connect to the mirror."), true);
  183. } break;
  184. case HTTPRequest::RESULT_NO_RESPONSE: {
  185. _set_current_progress_status(TTR("No response from the mirror."), true);
  186. } break;
  187. case HTTPRequest::RESULT_REQUEST_FAILED: {
  188. _set_current_progress_status(TTR("Request failed."), true);
  189. } break;
  190. case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
  191. _set_current_progress_status(TTR("Request ended up in a redirect loop."), true);
  192. } break;
  193. default: {
  194. if (p_code != 200) {
  195. _set_current_progress_status(TTR("Request failed:") + " " + itos(p_code), true);
  196. } else {
  197. _set_current_progress_status(TTR("Download complete; extracting templates..."));
  198. String path = download_templates->get_download_file();
  199. is_downloading_templates = false;
  200. bool ret = _install_file_selected(path, true);
  201. if (ret) {
  202. // Clean up downloaded file.
  203. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  204. Error err = da->remove(path);
  205. if (err != OK) {
  206. EditorNode::get_singleton()->add_io_error(TTR("Cannot remove temporary file:") + "\n" + path + "\n");
  207. }
  208. } else {
  209. EditorNode::get_singleton()->add_io_error(vformat(TTR("Templates installation failed.\nThe problematic templates archives can be found at '%s'."), path));
  210. }
  211. }
  212. } break;
  213. }
  214. set_process(false);
  215. }
  216. void ExportTemplateManager::_cancel_template_download() {
  217. if (!is_downloading_templates) {
  218. return;
  219. }
  220. download_templates->cancel_request();
  221. download_progress_hb->hide();
  222. install_options_vb->show();
  223. is_downloading_templates = false;
  224. }
  225. void ExportTemplateManager::_refresh_mirrors() {
  226. if (is_refreshing_mirrors) {
  227. return;
  228. }
  229. is_refreshing_mirrors = true;
  230. String current_version = VERSION_FULL_CONFIG;
  231. const String mirrors_metadata_url = "https://godotengine.org/mirrorlist/" + current_version + ".json";
  232. request_mirrors->request(mirrors_metadata_url);
  233. }
  234. void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
  235. if (p_status != HTTPRequest::RESULT_SUCCESS || p_code != 200) {
  236. EditorNode::get_singleton()->show_warning(TTR("Error getting the list of mirrors."));
  237. is_refreshing_mirrors = false;
  238. if (is_downloading_templates) {
  239. _cancel_template_download();
  240. }
  241. return;
  242. }
  243. String response_json;
  244. {
  245. const uint8_t *r = p_data.ptr();
  246. response_json.parse_utf8((const char *)r, p_data.size());
  247. }
  248. JSON json;
  249. Error err = json.parse(response_json);
  250. if (err != OK) {
  251. EditorNode::get_singleton()->show_warning(TTR("Error parsing JSON with the list of mirrors. Please report this issue!"));
  252. is_refreshing_mirrors = false;
  253. if (is_downloading_templates) {
  254. _cancel_template_download();
  255. }
  256. return;
  257. }
  258. mirrors_list->clear();
  259. mirrors_list->add_item(TTR("Best available mirror"), 0);
  260. mirrors_available = false;
  261. Dictionary mirror_data = json.get_data();
  262. if (mirror_data.has("mirrors")) {
  263. Array mirrors = mirror_data["mirrors"];
  264. for (int i = 0; i < mirrors.size(); i++) {
  265. Dictionary m = mirrors[i];
  266. ERR_CONTINUE(!m.has("url") || !m.has("name"));
  267. mirrors_list->add_item(m["name"]);
  268. mirrors_list->set_item_metadata(i + 1, m["url"]);
  269. mirrors_available = true;
  270. }
  271. }
  272. if (!mirrors_available) {
  273. EditorNode::get_singleton()->show_warning(TTR("No download links found for this version. Direct download is only available for official releases."));
  274. if (is_downloading_templates) {
  275. _cancel_template_download();
  276. }
  277. }
  278. is_refreshing_mirrors = false;
  279. if (is_downloading_templates) {
  280. String mirror_url = _get_selected_mirror();
  281. if (mirror_url.is_empty()) {
  282. _set_current_progress_status(TTR("There are no mirrors available."), true);
  283. return;
  284. }
  285. _download_template(mirror_url, true);
  286. }
  287. }
  288. bool ExportTemplateManager::_humanize_http_status(HTTPRequest *p_request, String *r_status, int *r_downloaded_bytes, int *r_total_bytes) {
  289. *r_status = "";
  290. *r_downloaded_bytes = -1;
  291. *r_total_bytes = -1;
  292. bool success = true;
  293. switch (p_request->get_http_client_status()) {
  294. case HTTPClient::STATUS_DISCONNECTED:
  295. *r_status = TTR("Disconnected");
  296. success = false;
  297. break;
  298. case HTTPClient::STATUS_RESOLVING:
  299. *r_status = TTR("Resolving");
  300. break;
  301. case HTTPClient::STATUS_CANT_RESOLVE:
  302. *r_status = TTR("Can't Resolve");
  303. success = false;
  304. break;
  305. case HTTPClient::STATUS_CONNECTING:
  306. *r_status = TTR("Connecting...");
  307. break;
  308. case HTTPClient::STATUS_CANT_CONNECT:
  309. *r_status = TTR("Can't Connect");
  310. success = false;
  311. break;
  312. case HTTPClient::STATUS_CONNECTED:
  313. *r_status = TTR("Connected");
  314. break;
  315. case HTTPClient::STATUS_REQUESTING:
  316. *r_status = TTR("Requesting...");
  317. break;
  318. case HTTPClient::STATUS_BODY:
  319. *r_status = TTR("Downloading");
  320. *r_downloaded_bytes = p_request->get_downloaded_bytes();
  321. *r_total_bytes = p_request->get_body_size();
  322. if (p_request->get_body_size() > 0) {
  323. *r_status += " " + String::humanize_size(p_request->get_downloaded_bytes()) + "/" + String::humanize_size(p_request->get_body_size());
  324. } else {
  325. *r_status += " " + String::humanize_size(p_request->get_downloaded_bytes());
  326. }
  327. break;
  328. case HTTPClient::STATUS_CONNECTION_ERROR:
  329. *r_status = TTR("Connection Error");
  330. success = false;
  331. break;
  332. case HTTPClient::STATUS_TLS_HANDSHAKE_ERROR:
  333. *r_status = TTR("TLS Handshake Error");
  334. success = false;
  335. break;
  336. }
  337. return success;
  338. }
  339. void ExportTemplateManager::_set_current_progress_status(const String &p_status, bool p_error) {
  340. download_progress_label->set_text(p_status);
  341. if (p_error) {
  342. download_progress_bar->hide();
  343. download_progress_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
  344. } else {
  345. download_progress_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SceneStringName(font_color), SNAME("Label")));
  346. }
  347. }
  348. void ExportTemplateManager::_set_current_progress_value(float p_value, const String &p_status) {
  349. download_progress_bar->show();
  350. download_progress_bar->set_indeterminate(false);
  351. download_progress_bar->set_value(p_value);
  352. download_progress_label->set_text(p_status);
  353. }
  354. void ExportTemplateManager::_install_file() {
  355. install_file_dialog->popup_file_dialog();
  356. }
  357. bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_skip_progress) {
  358. Ref<FileAccess> io_fa;
  359. zlib_filefunc_def io = zipio_create_io(&io_fa);
  360. unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
  361. if (!pkg) {
  362. EditorNode::get_singleton()->show_warning(TTR("Can't open the export templates file."));
  363. return false;
  364. }
  365. int ret = unzGoToFirstFile(pkg);
  366. // Count them and find version.
  367. int fc = 0;
  368. String version;
  369. String contents_dir;
  370. while (ret == UNZ_OK) {
  371. unz_file_info info;
  372. char fname[16384];
  373. ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
  374. if (ret != UNZ_OK) {
  375. break;
  376. }
  377. String file = String::utf8(fname);
  378. // Skip the __MACOSX directory created by macOS's built-in file zipper.
  379. if (file.begins_with("__MACOSX")) {
  380. ret = unzGoToNextFile(pkg);
  381. continue;
  382. }
  383. if (file.ends_with("version.txt")) {
  384. Vector<uint8_t> uncomp_data;
  385. uncomp_data.resize(info.uncompressed_size);
  386. // Read.
  387. unzOpenCurrentFile(pkg);
  388. ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
  389. ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
  390. unzCloseCurrentFile(pkg);
  391. String data_str;
  392. data_str.parse_utf8((const char *)uncomp_data.ptr(), uncomp_data.size());
  393. data_str = data_str.strip_edges();
  394. // Version number should be of the form major.minor[.patch].status[.module_config]
  395. // so it can in theory have 3 or more slices.
  396. if (data_str.get_slice_count(".") < 3) {
  397. EditorNode::get_singleton()->show_warning(vformat(TTR("Invalid version.txt format inside the export templates file: %s."), data_str));
  398. unzClose(pkg);
  399. return false;
  400. }
  401. version = data_str;
  402. contents_dir = file.get_base_dir().trim_suffix("/").trim_suffix("\\");
  403. }
  404. if (file.get_file().size() != 0) {
  405. fc++;
  406. }
  407. ret = unzGoToNextFile(pkg);
  408. }
  409. if (version.is_empty()) {
  410. EditorNode::get_singleton()->show_warning(TTR("No version.txt found inside the export templates file."));
  411. unzClose(pkg);
  412. return false;
  413. }
  414. Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  415. String template_path = EditorPaths::get_singleton()->get_export_templates_dir().path_join(version);
  416. Error err = d->make_dir_recursive(template_path);
  417. if (err != OK) {
  418. EditorNode::get_singleton()->show_warning(TTR("Error creating path for extracting templates:") + "\n" + template_path);
  419. unzClose(pkg);
  420. return false;
  421. }
  422. EditorProgress *p = nullptr;
  423. if (!p_skip_progress) {
  424. p = memnew(EditorProgress("ltask", TTR("Extracting Export Templates"), fc));
  425. }
  426. fc = 0;
  427. ret = unzGoToFirstFile(pkg);
  428. while (ret == UNZ_OK) {
  429. // Get filename.
  430. unz_file_info info;
  431. char fname[16384];
  432. ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
  433. if (ret != UNZ_OK) {
  434. break;
  435. }
  436. if (String::utf8(fname).ends_with("/")) {
  437. // File is a directory, ignore it.
  438. // Directories will be created when extracting each file.
  439. ret = unzGoToNextFile(pkg);
  440. continue;
  441. }
  442. String file_path(String::utf8(fname).simplify_path());
  443. String file = file_path.get_file();
  444. // Skip the __MACOSX directory created by macOS's built-in file zipper.
  445. if (file.is_empty() || file.begins_with("__MACOSX")) {
  446. ret = unzGoToNextFile(pkg);
  447. continue;
  448. }
  449. Vector<uint8_t> uncomp_data;
  450. uncomp_data.resize(info.uncompressed_size);
  451. // Read
  452. unzOpenCurrentFile(pkg);
  453. ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
  454. ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
  455. unzCloseCurrentFile(pkg);
  456. String base_dir = file_path.get_base_dir().trim_suffix("/");
  457. if (base_dir != contents_dir && base_dir.begins_with(contents_dir)) {
  458. base_dir = base_dir.substr(contents_dir.length(), file_path.length()).trim_prefix("/");
  459. file = base_dir.path_join(file);
  460. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  461. ERR_CONTINUE(da.is_null());
  462. String output_dir = template_path.path_join(base_dir);
  463. if (!DirAccess::exists(output_dir)) {
  464. Error mkdir_err = da->make_dir_recursive(output_dir);
  465. ERR_CONTINUE(mkdir_err != OK);
  466. }
  467. }
  468. if (p) {
  469. p->step(TTR("Importing:") + " " + file, fc);
  470. }
  471. String to_write = template_path.path_join(file);
  472. Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE);
  473. if (f.is_null()) {
  474. ret = unzGoToNextFile(pkg);
  475. fc++;
  476. ERR_CONTINUE_MSG(true, "Can't open file from path '" + String(to_write) + "'.");
  477. }
  478. f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
  479. f.unref(); // close file.
  480. #ifndef WINDOWS_ENABLED
  481. FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
  482. #endif
  483. ret = unzGoToNextFile(pkg);
  484. fc++;
  485. }
  486. if (p) {
  487. memdelete(p);
  488. }
  489. unzClose(pkg);
  490. _update_template_status();
  491. EditorSettings::get_singleton()->set("_export_template_download_directory", p_file.get_base_dir());
  492. return true;
  493. }
  494. void ExportTemplateManager::_uninstall_template(const String &p_version) {
  495. uninstall_confirm->set_text(vformat(TTR("Remove templates for the version '%s'?"), p_version));
  496. uninstall_confirm->popup_centered();
  497. uninstall_version = p_version;
  498. }
  499. void ExportTemplateManager::_uninstall_template_confirmed() {
  500. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  501. const String &templates_dir = EditorPaths::get_singleton()->get_export_templates_dir();
  502. Error err = da->change_dir(templates_dir);
  503. ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'.");
  504. err = da->change_dir(uninstall_version);
  505. ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir.path_join(uninstall_version) + "'.");
  506. err = da->erase_contents_recursive();
  507. ERR_FAIL_COND_MSG(err != OK, "Could not remove all templates in '" + templates_dir.path_join(uninstall_version) + "'.");
  508. da->change_dir("..");
  509. err = da->remove(uninstall_version);
  510. ERR_FAIL_COND_MSG(err != OK, "Could not remove templates directory at '" + templates_dir.path_join(uninstall_version) + "'.");
  511. _update_template_status();
  512. }
  513. String ExportTemplateManager::_get_selected_mirror() const {
  514. if (mirrors_list->get_item_count() == 1) {
  515. return "";
  516. }
  517. int selected = mirrors_list->get_selected_id();
  518. if (selected == 0) {
  519. // This is a special "best available" value; so pick the first available mirror from the rest of the list.
  520. selected = 1;
  521. }
  522. return mirrors_list->get_item_metadata(selected);
  523. }
  524. void ExportTemplateManager::_mirror_options_button_cbk(int p_id) {
  525. switch (p_id) {
  526. case VISIT_WEB_MIRROR: {
  527. String mirror_url = _get_selected_mirror();
  528. if (mirror_url.is_empty()) {
  529. EditorNode::get_singleton()->show_warning(TTR("There are no mirrors available."));
  530. return;
  531. }
  532. OS::get_singleton()->shell_open(mirror_url);
  533. } break;
  534. case COPY_MIRROR_URL: {
  535. String mirror_url = _get_selected_mirror();
  536. if (mirror_url.is_empty()) {
  537. EditorNode::get_singleton()->show_warning(TTR("There are no mirrors available."));
  538. return;
  539. }
  540. DisplayServer::get_singleton()->clipboard_set(mirror_url);
  541. } break;
  542. }
  543. }
  544. void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button) {
  545. if (p_button != MouseButton::LEFT) {
  546. return;
  547. }
  548. TreeItem *ti = Object::cast_to<TreeItem>(p_item);
  549. if (!ti) {
  550. return;
  551. }
  552. switch (p_id) {
  553. case OPEN_TEMPLATE_FOLDER: {
  554. String version_string = ti->get_text(0);
  555. _open_template_folder(version_string);
  556. } break;
  557. case UNINSTALL_TEMPLATE: {
  558. String version_string = ti->get_text(0);
  559. _uninstall_template(version_string);
  560. } break;
  561. }
  562. }
  563. void ExportTemplateManager::_open_template_folder(const String &p_version) {
  564. const String &templates_dir = EditorPaths::get_singleton()->get_export_templates_dir();
  565. OS::get_singleton()->shell_show_in_file_manager(templates_dir.path_join(p_version), true);
  566. }
  567. void ExportTemplateManager::popup_manager() {
  568. _update_template_status();
  569. switch (_get_downloads_availability()) {
  570. case DOWNLOADS_AVAILABLE: {
  571. current_missing_label->set_text(TTR("Export templates are missing. Download them or install from a file."));
  572. mirrors_list->clear();
  573. mirrors_list->add_item(TTR("Best available mirror"), 0);
  574. mirrors_list->set_disabled(false);
  575. mirrors_list->set_tooltip_text("");
  576. mirror_options_button->set_disabled(false);
  577. download_current_button->set_disabled(false);
  578. download_current_button->set_tooltip_text("");
  579. if (!is_downloading_templates) {
  580. _refresh_mirrors();
  581. }
  582. } break;
  583. case DOWNLOADS_NOT_AVAILABLE_IN_OFFLINE_MODE: {
  584. current_missing_label->set_text(TTR("Export templates are missing. Install them from a file."));
  585. mirrors_list->clear();
  586. mirrors_list->add_item(TTR("Not available in offline mode"), 0);
  587. mirrors_list->set_disabled(true);
  588. mirrors_list->set_tooltip_text(TTR("Template downloading is disabled in offline mode."));
  589. mirror_options_button->set_disabled(true);
  590. download_current_button->set_disabled(true);
  591. download_current_button->set_tooltip_text(TTR("Template downloading is disabled in offline mode."));
  592. } break;
  593. case DOWNLOADS_NOT_AVAILABLE_FOR_DEV_BUILDS: {
  594. current_missing_label->set_text(TTR("Export templates are missing. Install them from a file."));
  595. mirrors_list->clear();
  596. mirrors_list->add_item(TTR("No templates for development builds"), 0);
  597. mirrors_list->set_disabled(true);
  598. mirrors_list->set_tooltip_text(TTR("Official export templates aren't available for development builds."));
  599. mirror_options_button->set_disabled(true);
  600. download_current_button->set_disabled(true);
  601. download_current_button->set_tooltip_text(TTR("Official export templates aren't available for development builds."));
  602. } break;
  603. }
  604. popup_centered(Size2(720, 280) * EDSCALE);
  605. }
  606. void ExportTemplateManager::ok_pressed() {
  607. if (!is_downloading_templates) {
  608. hide();
  609. return;
  610. }
  611. hide_dialog_accept->popup_centered();
  612. }
  613. void ExportTemplateManager::_hide_dialog() {
  614. hide();
  615. }
  616. String ExportTemplateManager::get_android_build_directory(const Ref<EditorExportPreset> &p_preset) {
  617. if (p_preset.is_valid()) {
  618. String gradle_build_dir = p_preset->get("gradle_build/gradle_build_directory");
  619. if (!gradle_build_dir.is_empty()) {
  620. return gradle_build_dir.path_join("build");
  621. }
  622. }
  623. return "res://android/build";
  624. }
  625. String ExportTemplateManager::get_android_source_zip(const Ref<EditorExportPreset> &p_preset) {
  626. if (p_preset.is_valid()) {
  627. String android_source_zip = p_preset->get("gradle_build/android_source_template");
  628. if (!android_source_zip.is_empty()) {
  629. return android_source_zip;
  630. }
  631. }
  632. const String templates_dir = EditorPaths::get_singleton()->get_export_templates_dir().path_join(VERSION_FULL_CONFIG);
  633. return templates_dir.path_join("android_source.zip");
  634. }
  635. String ExportTemplateManager::get_android_template_identifier(const Ref<EditorExportPreset> &p_preset) {
  636. // The template identifier is the Godot version for the default template, and the full path plus md5 hash for custom templates.
  637. if (p_preset.is_valid()) {
  638. String android_source_zip = p_preset->get("gradle_build/android_source_template");
  639. if (!android_source_zip.is_empty()) {
  640. return android_source_zip + String(" [") + FileAccess::get_md5(android_source_zip) + String("]");
  641. }
  642. }
  643. return VERSION_FULL_CONFIG;
  644. }
  645. bool ExportTemplateManager::is_android_template_installed(const Ref<EditorExportPreset> &p_preset) {
  646. return DirAccess::exists(get_android_build_directory(p_preset));
  647. }
  648. bool ExportTemplateManager::can_install_android_template(const Ref<EditorExportPreset> &p_preset) {
  649. return FileAccess::exists(get_android_source_zip(p_preset));
  650. }
  651. Error ExportTemplateManager::install_android_template(const Ref<EditorExportPreset> &p_preset) {
  652. const String source_zip = get_android_source_zip(p_preset);
  653. ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN);
  654. return install_android_template_from_file(source_zip, p_preset);
  655. }
  656. Error ExportTemplateManager::install_android_template_from_file(const String &p_file, const Ref<EditorExportPreset> &p_preset) {
  657. // To support custom Android builds, we install the Java source code and buildsystem
  658. // from android_source.zip to the project's res://android folder.
  659. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
  660. ERR_FAIL_COND_V(da.is_null(), ERR_CANT_CREATE);
  661. String build_dir = get_android_build_directory(p_preset);
  662. String parent_dir = build_dir.get_base_dir();
  663. // Make parent of the build dir (if it does not exist).
  664. da->make_dir_recursive(parent_dir);
  665. {
  666. // Add identifier, to ensure building won't work if the current template doesn't match.
  667. Ref<FileAccess> f = FileAccess::open(parent_dir.path_join(".build_version"), FileAccess::WRITE);
  668. ERR_FAIL_COND_V(f.is_null(), ERR_CANT_CREATE);
  669. f->store_line(get_android_template_identifier(p_preset));
  670. }
  671. // Create the android build directory.
  672. Error err = da->make_dir_recursive(build_dir);
  673. ERR_FAIL_COND_V(err != OK, err);
  674. {
  675. // Add an empty .gdignore file to avoid scan.
  676. Ref<FileAccess> f = FileAccess::open(build_dir.path_join(".gdignore"), FileAccess::WRITE);
  677. ERR_FAIL_COND_V(f.is_null(), ERR_CANT_CREATE);
  678. f->store_line("");
  679. }
  680. // Uncompress source template.
  681. Ref<FileAccess> io_fa;
  682. zlib_filefunc_def io = zipio_create_io(&io_fa);
  683. unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
  684. ERR_FAIL_NULL_V_MSG(pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
  685. int ret = unzGoToFirstFile(pkg);
  686. int total_files = 0;
  687. // Count files to unzip.
  688. while (ret == UNZ_OK) {
  689. total_files++;
  690. ret = unzGoToNextFile(pkg);
  691. }
  692. ret = unzGoToFirstFile(pkg);
  693. ProgressDialog::get_singleton()->add_task("uncompress_src", TTR("Uncompressing Android Build Sources"), total_files);
  694. HashSet<String> dirs_tested;
  695. int idx = 0;
  696. while (ret == UNZ_OK) {
  697. // Get file path.
  698. unz_file_info info;
  699. char fpath[16384];
  700. ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, nullptr, 0, nullptr, 0);
  701. if (ret != UNZ_OK) {
  702. break;
  703. }
  704. String path = String::utf8(fpath);
  705. String base_dir = path.get_base_dir();
  706. if (!path.ends_with("/")) {
  707. Vector<uint8_t> uncomp_data;
  708. uncomp_data.resize(info.uncompressed_size);
  709. // Read.
  710. unzOpenCurrentFile(pkg);
  711. unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
  712. unzCloseCurrentFile(pkg);
  713. if (!dirs_tested.has(base_dir)) {
  714. da->make_dir_recursive(build_dir.path_join(base_dir));
  715. dirs_tested.insert(base_dir);
  716. }
  717. String to_write = build_dir.path_join(path);
  718. Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE);
  719. if (f.is_valid()) {
  720. f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
  721. f.unref(); // close file.
  722. #ifndef WINDOWS_ENABLED
  723. FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
  724. #endif
  725. } else {
  726. ERR_PRINT("Can't uncompress file: " + to_write);
  727. }
  728. }
  729. ProgressDialog::get_singleton()->task_step("uncompress_src", path, idx);
  730. idx++;
  731. ret = unzGoToNextFile(pkg);
  732. }
  733. ProgressDialog::get_singleton()->end_task("uncompress_src");
  734. unzClose(pkg);
  735. EditorFileSystem::get_singleton()->scan_changes();
  736. return OK;
  737. }
  738. void ExportTemplateManager::_notification(int p_what) {
  739. switch (p_what) {
  740. case NOTIFICATION_ENTER_TREE:
  741. case NOTIFICATION_THEME_CHANGED: {
  742. current_value->add_theme_font_override(SceneStringName(font), get_theme_font(SNAME("main"), EditorStringName(EditorFonts)));
  743. current_missing_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
  744. current_installed_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor)));
  745. mirror_options_button->set_button_icon(get_editor_theme_icon(SNAME("GuiTabMenuHl")));
  746. } break;
  747. case NOTIFICATION_VISIBILITY_CHANGED: {
  748. if (!is_visible()) {
  749. set_process(false);
  750. } else if (is_visible() && is_downloading_templates) {
  751. set_process(true);
  752. }
  753. } break;
  754. case NOTIFICATION_PROCESS: {
  755. update_countdown -= get_process_delta_time();
  756. if (update_countdown > 0) {
  757. return;
  758. }
  759. update_countdown = 0.5;
  760. String status;
  761. int downloaded_bytes;
  762. int total_bytes;
  763. bool success = _humanize_http_status(download_templates, &status, &downloaded_bytes, &total_bytes);
  764. if (downloaded_bytes >= 0) {
  765. if (total_bytes > 0) {
  766. _set_current_progress_value(float(downloaded_bytes) / total_bytes, status);
  767. } else {
  768. _set_current_progress_value(0, status);
  769. }
  770. } else {
  771. _set_current_progress_status(status);
  772. }
  773. if (!success) {
  774. set_process(false);
  775. }
  776. } break;
  777. case NOTIFICATION_WM_CLOSE_REQUEST: {
  778. // This won't stop the window from closing, but will show the alert if the download is active.
  779. ok_pressed();
  780. } break;
  781. }
  782. }
  783. ExportTemplateManager::ExportTemplateManager() {
  784. set_title(TTR("Export Template Manager"));
  785. set_hide_on_ok(false);
  786. set_ok_button_text(TTR("Close"));
  787. VBoxContainer *main_vb = memnew(VBoxContainer);
  788. add_child(main_vb);
  789. // Current version controls.
  790. HBoxContainer *current_hb = memnew(HBoxContainer);
  791. main_vb->add_child(current_hb);
  792. Label *current_label = memnew(Label);
  793. current_label->set_theme_type_variation("HeaderSmall");
  794. current_label->set_text(TTR("Current Version:"));
  795. current_hb->add_child(current_label);
  796. current_value = memnew(Label);
  797. current_hb->add_child(current_value);
  798. // Current version statuses.
  799. // Status: Current version is missing.
  800. current_missing_label = memnew(Label);
  801. current_missing_label->set_theme_type_variation("HeaderSmall");
  802. current_missing_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  803. current_missing_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
  804. current_hb->add_child(current_missing_label);
  805. // Status: Current version is installed.
  806. current_installed_label = memnew(Label);
  807. current_installed_label->set_theme_type_variation("HeaderSmall");
  808. current_installed_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  809. current_installed_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
  810. current_installed_label->set_text(TTR("Export templates are installed and ready to be used."));
  811. current_hb->add_child(current_installed_label);
  812. current_installed_label->hide();
  813. // Currently installed template.
  814. current_installed_hb = memnew(HBoxContainer);
  815. main_vb->add_child(current_installed_hb);
  816. current_installed_path = memnew(LineEdit);
  817. current_installed_path->set_editable(false);
  818. current_installed_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  819. current_installed_hb->add_child(current_installed_path);
  820. #ifndef ANDROID_ENABLED
  821. Button *current_open_button = memnew(Button);
  822. current_open_button->set_text(TTR("Open Folder"));
  823. current_open_button->set_tooltip_text(TTR("Open the folder containing installed templates for the current version."));
  824. current_installed_hb->add_child(current_open_button);
  825. current_open_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_open_template_folder).bind(VERSION_FULL_CONFIG));
  826. #endif
  827. current_uninstall_button = memnew(Button);
  828. current_uninstall_button->set_text(TTR("Uninstall"));
  829. current_uninstall_button->set_tooltip_text(TTR("Uninstall templates for the current version."));
  830. current_installed_hb->add_child(current_uninstall_button);
  831. current_uninstall_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_uninstall_template).bind(VERSION_FULL_CONFIG));
  832. main_vb->add_child(memnew(HSeparator));
  833. // Download and install section.
  834. HBoxContainer *install_templates_hb = memnew(HBoxContainer);
  835. main_vb->add_child(install_templates_hb);
  836. // Download and install buttons are available.
  837. install_options_vb = memnew(VBoxContainer);
  838. install_options_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  839. install_templates_hb->add_child(install_options_vb);
  840. HBoxContainer *download_install_hb = memnew(HBoxContainer);
  841. install_options_vb->add_child(download_install_hb);
  842. Label *mirrors_label = memnew(Label);
  843. mirrors_label->set_text(TTR("Download from:"));
  844. download_install_hb->add_child(mirrors_label);
  845. mirrors_list = memnew(OptionButton);
  846. mirrors_list->set_custom_minimum_size(Size2(280, 0) * EDSCALE);
  847. download_install_hb->add_child(mirrors_list);
  848. request_mirrors = memnew(HTTPRequest);
  849. mirrors_list->add_child(request_mirrors);
  850. request_mirrors->connect("request_completed", callable_mp(this, &ExportTemplateManager::_refresh_mirrors_completed));
  851. mirror_options_button = memnew(MenuButton);
  852. mirror_options_button->get_popup()->add_item(TTR("Open in Web Browser"), VISIT_WEB_MIRROR);
  853. mirror_options_button->get_popup()->add_item(TTR("Copy Mirror URL"), COPY_MIRROR_URL);
  854. download_install_hb->add_child(mirror_options_button);
  855. mirror_options_button->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &ExportTemplateManager::_mirror_options_button_cbk));
  856. download_install_hb->add_spacer();
  857. download_current_button = memnew(Button);
  858. download_current_button->set_text(TTR("Download and Install"));
  859. download_current_button->set_tooltip_text(TTR("Download and install templates for the current version from the best possible mirror."));
  860. download_install_hb->add_child(download_current_button);
  861. download_current_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_download_current));
  862. HBoxContainer *install_file_hb = memnew(HBoxContainer);
  863. install_file_hb->set_alignment(BoxContainer::ALIGNMENT_END);
  864. install_options_vb->add_child(install_file_hb);
  865. install_file_button = memnew(Button);
  866. install_file_button->set_text(TTR("Install from File"));
  867. install_file_button->set_tooltip_text(TTR("Install templates from a local file."));
  868. install_file_hb->add_child(install_file_button);
  869. install_file_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_install_file));
  870. // Templates are being downloaded; buttons unavailable.
  871. download_progress_hb = memnew(HBoxContainer);
  872. download_progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  873. install_templates_hb->add_child(download_progress_hb);
  874. download_progress_hb->hide();
  875. download_progress_bar = memnew(ProgressBar);
  876. download_progress_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  877. download_progress_bar->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
  878. download_progress_bar->set_min(0);
  879. download_progress_bar->set_max(1);
  880. download_progress_bar->set_value(0);
  881. download_progress_bar->set_step(0.01);
  882. download_progress_bar->set_editor_preview_indeterminate(true);
  883. download_progress_hb->add_child(download_progress_bar);
  884. download_progress_label = memnew(Label);
  885. download_progress_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
  886. download_progress_hb->add_child(download_progress_label);
  887. Button *download_cancel_button = memnew(Button);
  888. download_cancel_button->set_text(TTR("Cancel"));
  889. download_cancel_button->set_tooltip_text(TTR("Cancel the download of the templates."));
  890. download_progress_hb->add_child(download_cancel_button);
  891. download_cancel_button->connect(SceneStringName(pressed), callable_mp(this, &ExportTemplateManager::_cancel_template_download));
  892. download_templates = memnew(HTTPRequest);
  893. install_templates_hb->add_child(download_templates);
  894. download_templates->connect("request_completed", callable_mp(this, &ExportTemplateManager::_download_template_completed));
  895. main_vb->add_child(memnew(HSeparator));
  896. // Other installed templates table.
  897. HBoxContainer *installed_versions_hb = memnew(HBoxContainer);
  898. main_vb->add_child(installed_versions_hb);
  899. Label *installed_label = memnew(Label);
  900. installed_label->set_theme_type_variation("HeaderSmall");
  901. installed_label->set_text(TTR("Other Installed Versions:"));
  902. installed_versions_hb->add_child(installed_label);
  903. installed_table = memnew(Tree);
  904. installed_table->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
  905. installed_table->set_hide_root(true);
  906. installed_table->set_custom_minimum_size(Size2(0, 100) * EDSCALE);
  907. installed_table->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  908. main_vb->add_child(installed_table);
  909. installed_table->connect("button_clicked", callable_mp(this, &ExportTemplateManager::_installed_table_button_cbk));
  910. // Dialogs.
  911. uninstall_confirm = memnew(ConfirmationDialog);
  912. uninstall_confirm->set_title(TTR("Uninstall Template"));
  913. add_child(uninstall_confirm);
  914. uninstall_confirm->connect(SceneStringName(confirmed), callable_mp(this, &ExportTemplateManager::_uninstall_template_confirmed));
  915. install_file_dialog = memnew(FileDialog);
  916. install_file_dialog->set_title(TTR("Select Template File"));
  917. install_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);
  918. install_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
  919. install_file_dialog->set_current_dir(EDITOR_DEF("_export_template_download_directory", ""));
  920. install_file_dialog->add_filter("*.tpz", TTR("Godot Export Templates"));
  921. install_file_dialog->connect("file_selected", callable_mp(this, &ExportTemplateManager::_install_file_selected).bind(false));
  922. add_child(install_file_dialog);
  923. hide_dialog_accept = memnew(AcceptDialog);
  924. hide_dialog_accept->set_text(TTR("The templates will continue to download.\nYou may experience a short editor freeze when they finish."));
  925. add_child(hide_dialog_accept);
  926. hide_dialog_accept->connect(SceneStringName(confirmed), callable_mp(this, &ExportTemplateManager::_hide_dialog));
  927. }