Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/project_manager/project_dialog.cpp
9903 views
1
/**************************************************************************/
2
/* project_dialog.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
31
#include "project_dialog.h"
32
33
#include "core/config/project_settings.h"
34
#include "core/io/dir_access.h"
35
#include "core/io/zip_io.h"
36
#include "core/version.h"
37
#include "editor/editor_string_names.h"
38
#include "editor/gui/editor_file_dialog.h"
39
#include "editor/settings/editor_settings.h"
40
#include "editor/themes/editor_icons.h"
41
#include "editor/themes/editor_scale.h"
42
#include "editor/version_control/editor_vcs_interface.h"
43
#include "scene/gui/check_box.h"
44
#include "scene/gui/check_button.h"
45
#include "scene/gui/line_edit.h"
46
#include "scene/gui/option_button.h"
47
#include "scene/gui/separator.h"
48
#include "scene/gui/texture_rect.h"
49
50
void ProjectDialog::_set_message(const String &p_msg, MessageType p_type, InputType p_input_type) {
51
msg->set_text(p_msg);
52
get_ok_button()->set_disabled(p_type == MESSAGE_ERROR);
53
54
Ref<Texture2D> new_icon;
55
switch (p_type) {
56
case MESSAGE_ERROR: {
57
msg->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
58
new_icon = get_editor_theme_icon(SNAME("StatusError"));
59
} break;
60
case MESSAGE_WARNING: {
61
msg->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
62
new_icon = get_editor_theme_icon(SNAME("StatusWarning"));
63
} break;
64
case MESSAGE_SUCCESS: {
65
msg->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("success_color"), EditorStringName(Editor)));
66
new_icon = get_editor_theme_icon(SNAME("StatusSuccess"));
67
} break;
68
}
69
70
if (p_input_type == PROJECT_PATH) {
71
project_status_rect->set_texture(new_icon);
72
} else if (p_input_type == INSTALL_PATH) {
73
install_status_rect->set_texture(new_icon);
74
}
75
}
76
77
static bool is_zip_file(Ref<DirAccess> p_d, const String &p_path) {
78
return p_path.get_extension() == "zip" && p_d->file_exists(p_path);
79
}
80
81
void ProjectDialog::_validate_path() {
82
_set_message("", MESSAGE_SUCCESS, PROJECT_PATH);
83
_set_message("", MESSAGE_SUCCESS, INSTALL_PATH);
84
85
if (project_name->get_text().strip_edges().is_empty()) {
86
_set_message(TTRC("It would be a good idea to name your project."), MESSAGE_ERROR);
87
return;
88
}
89
90
Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
91
String path = project_path->get_text().simplify_path();
92
93
String target_path = path;
94
InputType target_path_input_type = PROJECT_PATH;
95
96
if (mode == MODE_IMPORT) {
97
if (path.get_file().strip_edges() == "project.godot") {
98
path = path.get_base_dir();
99
project_path->set_text(path);
100
}
101
102
if (is_zip_file(d, path)) {
103
zip_path = path;
104
} else if (is_zip_file(d, path.strip_edges())) {
105
zip_path = path.strip_edges();
106
} else {
107
zip_path = "";
108
}
109
110
if (!zip_path.is_empty()) {
111
target_path = install_path->get_text().simplify_path();
112
target_path_input_type = INSTALL_PATH;
113
114
create_dir->show();
115
install_path_container->show();
116
117
Ref<FileAccess> io_fa;
118
zlib_filefunc_def io = zipio_create_io(&io_fa);
119
120
unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
121
if (!pkg) {
122
_set_message(TTRC("Invalid \".zip\" project file; it is not in ZIP format."), MESSAGE_ERROR);
123
unzClose(pkg);
124
return;
125
}
126
127
int ret = unzGoToFirstFile(pkg);
128
while (ret == UNZ_OK) {
129
unz_file_info info;
130
char fname[16384];
131
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
132
ERR_FAIL_COND_MSG(ret != UNZ_OK, "Failed to get current file info.");
133
134
String name = String::utf8(fname);
135
136
// Skip the __MACOSX directory created by macOS's built-in file zipper.
137
if (name.begins_with("__MACOSX")) {
138
ret = unzGoToNextFile(pkg);
139
continue;
140
}
141
142
if (name.get_file() == "project.godot") {
143
break; // ret == UNZ_OK.
144
}
145
146
ret = unzGoToNextFile(pkg);
147
}
148
149
if (ret == UNZ_END_OF_LIST_OF_FILE) {
150
_set_message(TTRC("Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."), MESSAGE_ERROR);
151
unzClose(pkg);
152
return;
153
}
154
155
unzClose(pkg);
156
} else if (d->dir_exists(path) && d->file_exists(path.path_join("project.godot"))) {
157
zip_path = "";
158
159
create_dir->hide();
160
install_path_container->hide();
161
162
_set_message(TTRC("Valid project found at path."), MESSAGE_SUCCESS);
163
} else {
164
create_dir->hide();
165
install_path_container->hide();
166
167
_set_message(TTRC("Please choose a \"project.godot\", a directory with one, or a \".zip\" file."), MESSAGE_ERROR);
168
return;
169
}
170
}
171
172
if (target_path.is_relative_path()) {
173
_set_message(TTRC("The path specified is invalid."), MESSAGE_ERROR, target_path_input_type);
174
return;
175
}
176
177
if (target_path.get_file() != OS::get_singleton()->get_safe_dir_name(target_path.get_file())) {
178
_set_message(TTRC("The directory name specified contains invalid characters or trailing whitespace."), MESSAGE_ERROR, target_path_input_type);
179
return;
180
}
181
182
String working_dir = d->get_current_dir();
183
String executable_dir = OS::get_singleton()->get_executable_path().get_base_dir();
184
if (target_path == working_dir || target_path == executable_dir) {
185
_set_message(TTRC("Creating a project at the engine's working directory or executable directory is not allowed, as it would prevent the project manager from starting."), MESSAGE_ERROR, target_path_input_type);
186
return;
187
}
188
189
// TODO: The following 5 lines could be simplified if OS.get_user_home_dir() or SYSTEM_DIR_HOME is implemented. See: https://github.com/godotengine/godot-proposals/issues/4851.
190
#ifdef WINDOWS_ENABLED
191
String home_dir = OS::get_singleton()->get_environment("USERPROFILE");
192
#else
193
String home_dir = OS::get_singleton()->get_environment("HOME");
194
#endif
195
String documents_dir = OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);
196
if (target_path == home_dir || target_path == documents_dir) {
197
_set_message(TTRC("You cannot save a project at the selected path. Please create a subfolder or choose a new path."), MESSAGE_ERROR, target_path_input_type);
198
return;
199
}
200
201
is_folder_empty = true;
202
if (mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE || (mode == MODE_IMPORT && target_path_input_type == InputType::INSTALL_PATH)) {
203
if (create_dir->is_pressed()) {
204
if (!d->dir_exists(target_path.get_base_dir())) {
205
_set_message(TTRC("The parent directory of the path specified doesn't exist."), MESSAGE_ERROR, target_path_input_type);
206
return;
207
}
208
209
if (d->dir_exists(target_path)) {
210
// The path is not necessarily empty here, but we will update the message later if it isn't.
211
_set_message(TTRC("The project folder already exists and is empty."), MESSAGE_SUCCESS, target_path_input_type);
212
} else {
213
_set_message(TTRC("The project folder will be automatically created."), MESSAGE_SUCCESS, target_path_input_type);
214
}
215
} else {
216
if (!d->dir_exists(target_path)) {
217
_set_message(TTRC("The path specified doesn't exist."), MESSAGE_ERROR, target_path_input_type);
218
return;
219
}
220
221
// The path is not necessarily empty here, but we will update the message later if it isn't.
222
_set_message(TTRC("The project folder exists and is empty."), MESSAGE_SUCCESS, target_path_input_type);
223
}
224
225
// Check if the directory is empty. Not an error, but we want to warn the user.
226
if (d->change_dir(target_path) == OK) {
227
d->list_dir_begin();
228
String n = d->get_next();
229
while (!n.is_empty()) {
230
if (n[0] != '.') {
231
// Allow `.`, `..` (reserved current/parent folder names)
232
// and hidden files/folders to be present.
233
// For instance, this lets users initialize a Git repository
234
// and still be able to create a project in the directory afterwards.
235
is_folder_empty = false;
236
break;
237
}
238
n = d->get_next();
239
}
240
d->list_dir_end();
241
242
if (!is_folder_empty) {
243
_set_message(TTRC("The selected path is not empty. Choosing an empty folder is highly recommended."), MESSAGE_WARNING, target_path_input_type);
244
}
245
}
246
}
247
}
248
249
String ProjectDialog::_get_target_path() {
250
if (mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE) {
251
return project_path->get_text();
252
} else if (mode == MODE_IMPORT) {
253
return install_path->get_text();
254
} else {
255
ERR_FAIL_V("");
256
}
257
}
258
void ProjectDialog::_set_target_path(const String &p_text) {
259
if (mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE) {
260
project_path->set_text(p_text);
261
} else if (mode == MODE_IMPORT) {
262
install_path->set_text(p_text);
263
} else {
264
ERR_FAIL();
265
}
266
}
267
268
void ProjectDialog::_update_target_auto_dir() {
269
String new_auto_dir;
270
if (mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE) {
271
new_auto_dir = project_name->get_text();
272
} else if (mode == MODE_IMPORT) {
273
new_auto_dir = project_path->get_text().get_file().get_basename();
274
}
275
int naming_convention = (int)EDITOR_GET("project_manager/directory_naming_convention");
276
switch (naming_convention) {
277
case 0: // No convention
278
break;
279
case 1: // kebab-case
280
new_auto_dir = new_auto_dir.to_kebab_case();
281
break;
282
case 2: // snake_case
283
new_auto_dir = new_auto_dir.to_snake_case();
284
break;
285
case 3: // camelCase
286
new_auto_dir = new_auto_dir.to_camel_case();
287
break;
288
case 4: // PascalCase
289
new_auto_dir = new_auto_dir.to_pascal_case();
290
break;
291
case 5: // Title Case
292
new_auto_dir = new_auto_dir.capitalize();
293
break;
294
default:
295
ERR_FAIL_MSG("Invalid directory naming convention.");
296
break;
297
}
298
new_auto_dir = OS::get_singleton()->get_safe_dir_name(new_auto_dir);
299
300
if (create_dir->is_pressed()) {
301
String target_path = _get_target_path();
302
303
if (target_path.get_file() == auto_dir) {
304
// Update target dir name to new project name / ZIP name.
305
target_path = target_path.get_base_dir().path_join(new_auto_dir);
306
}
307
308
_set_target_path(target_path);
309
}
310
311
auto_dir = new_auto_dir;
312
}
313
314
void ProjectDialog::_create_dir_toggled(bool p_pressed) {
315
String target_path = _get_target_path();
316
317
if (create_dir->is_pressed()) {
318
// (Re-)append target dir name.
319
if (last_custom_target_dir.is_empty()) {
320
target_path = target_path.path_join(auto_dir);
321
} else {
322
target_path = target_path.path_join(last_custom_target_dir);
323
}
324
} else {
325
// Strip any trailing slash.
326
target_path = target_path.rstrip("/\\");
327
// Save and remove target dir name.
328
if (target_path.get_file() == auto_dir) {
329
last_custom_target_dir = "";
330
} else {
331
last_custom_target_dir = target_path.get_file();
332
}
333
target_path = target_path.get_base_dir();
334
}
335
336
_set_target_path(target_path);
337
_validate_path();
338
}
339
340
void ProjectDialog::_project_name_changed() {
341
if (mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE) {
342
_update_target_auto_dir();
343
}
344
345
_validate_path();
346
}
347
348
void ProjectDialog::_project_path_changed() {
349
if (mode == MODE_IMPORT) {
350
_update_target_auto_dir();
351
}
352
353
_validate_path();
354
}
355
356
void ProjectDialog::_install_path_changed() {
357
_validate_path();
358
}
359
360
void ProjectDialog::_browse_project_path() {
361
String path = project_path->get_text();
362
if (path.is_relative_path()) {
363
path = EDITOR_GET("filesystem/directories/default_project_path");
364
}
365
if (mode == MODE_IMPORT && install_path->is_visible_in_tree()) {
366
// Select last ZIP file.
367
fdialog_project->set_current_path(path);
368
} else if ((mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE) && create_dir->is_pressed()) {
369
// Select parent directory of project path.
370
fdialog_project->set_current_dir(path.get_base_dir());
371
} else {
372
// Select project path.
373
fdialog_project->set_current_dir(path);
374
}
375
376
if (mode == MODE_IMPORT) {
377
fdialog_project->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_ANY);
378
fdialog_project->clear_filters();
379
fdialog_project->add_filter("project.godot", vformat("%s %s", GODOT_VERSION_NAME, TTR("Project")));
380
fdialog_project->add_filter("*.zip", TTR("ZIP File"));
381
} else {
382
fdialog_project->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
383
}
384
385
hide();
386
fdialog_project->popup_file_dialog();
387
}
388
389
void ProjectDialog::_browse_install_path() {
390
ERR_FAIL_COND_MSG(mode != MODE_IMPORT, "Install path is only used for MODE_IMPORT.");
391
392
String path = install_path->get_text();
393
if (path.is_relative_path() || !DirAccess::dir_exists_absolute(path)) {
394
path = EDITOR_GET("filesystem/directories/default_project_path");
395
}
396
if (create_dir->is_pressed()) {
397
// Select parent directory of install path.
398
fdialog_install->set_current_dir(path.get_base_dir());
399
} else {
400
// Select install path.
401
fdialog_install->set_current_dir(path);
402
}
403
404
fdialog_install->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
405
fdialog_install->popup_file_dialog();
406
}
407
408
void ProjectDialog::_project_path_selected(const String &p_path) {
409
show_dialog(false);
410
411
if (create_dir->is_pressed() && (mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE)) {
412
// Replace parent directory, but keep target dir name.
413
project_path->set_text(p_path.path_join(project_path->get_text().get_file()));
414
} else {
415
project_path->set_text(p_path);
416
}
417
418
_project_path_changed();
419
420
if (install_path->is_visible_in_tree()) {
421
// ZIP is selected; focus install path.
422
install_path->grab_focus();
423
} else {
424
get_ok_button()->grab_focus();
425
}
426
}
427
428
void ProjectDialog::_install_path_selected(const String &p_path) {
429
ERR_FAIL_COND_MSG(mode != MODE_IMPORT, "Install path is only used for MODE_IMPORT.");
430
431
if (create_dir->is_pressed()) {
432
// Replace parent directory, but keep target dir name.
433
install_path->set_text(p_path.path_join(install_path->get_text().get_file()));
434
} else {
435
install_path->set_text(p_path);
436
}
437
438
_install_path_changed();
439
440
get_ok_button()->grab_focus();
441
}
442
443
void ProjectDialog::_reset_name() {
444
project_name->set_text(TTR("New Game Project"));
445
}
446
447
void ProjectDialog::_renderer_selected() {
448
ERR_FAIL_NULL(renderer_button_group->get_pressed_button());
449
450
String renderer_type = renderer_button_group->get_pressed_button()->get_meta(SNAME("rendering_method"));
451
452
bool rd_error = false;
453
454
if (renderer_type == "forward_plus") {
455
renderer_info->set_text(
456
String::utf8("• ") + TTR("Supports desktop platforms only.") +
457
String::utf8("\n• ") + TTR("Advanced 3D graphics available.") +
458
String::utf8("\n• ") + TTR("Can scale to large complex scenes.") +
459
String::utf8("\n• ") + TTR("Uses RenderingDevice backend.") +
460
String::utf8("\n• ") + TTR("Slower rendering of simple scenes."));
461
rd_error = !rendering_device_supported;
462
} else if (renderer_type == "mobile") {
463
renderer_info->set_text(
464
String::utf8("• ") + TTR("Supports desktop + mobile platforms.") +
465
String::utf8("\n• ") + TTR("Less advanced 3D graphics.") +
466
String::utf8("\n• ") + TTR("Less scalable for complex scenes.") +
467
String::utf8("\n• ") + TTR("Uses RenderingDevice backend.") +
468
String::utf8("\n• ") + TTR("Fast rendering of simple scenes."));
469
rd_error = !rendering_device_supported;
470
} else if (renderer_type == "gl_compatibility") {
471
renderer_info->set_text(
472
String::utf8("• ") + TTR("Supports desktop, mobile + web platforms.") +
473
String::utf8("\n• ") + TTR("Least advanced 3D graphics.") +
474
String::utf8("\n• ") + TTR("Intended for low-end/older devices.") +
475
String::utf8("\n• ") + TTR("Uses OpenGL 3 backend (OpenGL 3.3/ES 3.0/WebGL2).") +
476
String::utf8("\n• ") + TTR("Fastest rendering of simple scenes."));
477
} else {
478
WARN_PRINT("Unknown renderer type. Please report this as a bug on GitHub.");
479
}
480
481
rd_not_supported->set_visible(rd_error);
482
get_ok_button()->set_disabled(rd_error);
483
if (rd_error) {
484
// Needs to be set here since theme colors aren't available at startup.
485
rd_not_supported->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
486
}
487
}
488
489
void ProjectDialog::_nonempty_confirmation_ok_pressed() {
490
is_folder_empty = true;
491
ok_pressed();
492
}
493
494
void ProjectDialog::ok_pressed() {
495
// Before we create a project, check that the target folder is empty.
496
// If not, we need to ask the user if they're sure they want to do this.
497
if (!is_folder_empty) {
498
if (!nonempty_confirmation) {
499
nonempty_confirmation = memnew(ConfirmationDialog);
500
nonempty_confirmation->set_title(TTRC("Warning: This folder is not empty"));
501
nonempty_confirmation->set_text(TTRC("You are about to create a Godot project in a non-empty folder.\nThe entire contents of this folder will be imported as project resources!\n\nAre you sure you wish to continue?"));
502
nonempty_confirmation->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_nonempty_confirmation_ok_pressed));
503
add_child(nonempty_confirmation);
504
}
505
nonempty_confirmation->popup_centered();
506
return;
507
}
508
509
String path = project_path->get_text();
510
511
if (mode == MODE_NEW) {
512
if (create_dir->is_pressed()) {
513
Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
514
if (!d->dir_exists(path) && d->make_dir(path) != OK) {
515
_set_message(TTRC("Couldn't create project directory, check permissions."), MESSAGE_ERROR);
516
return;
517
}
518
}
519
520
PackedStringArray project_features = ProjectSettings::get_required_features();
521
ProjectSettings::CustomMap initial_settings;
522
523
// Be sure to change this code if/when renderers are changed.
524
// Default values are "forward_plus" for the main setting, "mobile" for the mobile override,
525
// and "gl_compatibility" for the web override.
526
String renderer_type = renderer_button_group->get_pressed_button()->get_meta(SNAME("rendering_method"));
527
initial_settings["rendering/renderer/rendering_method"] = renderer_type;
528
529
EditorSettings::get_singleton()->set("project_manager/default_renderer", renderer_type);
530
EditorSettings::get_singleton()->save();
531
532
if (renderer_type == "forward_plus") {
533
project_features.push_back("Forward Plus");
534
} else if (renderer_type == "mobile") {
535
project_features.push_back("Mobile");
536
} else if (renderer_type == "gl_compatibility") {
537
project_features.push_back("GL Compatibility");
538
// Also change the default rendering method for the mobile override.
539
initial_settings["rendering/renderer/rendering_method.mobile"] = "gl_compatibility";
540
} else {
541
WARN_PRINT("Unknown renderer type. Please report this as a bug on GitHub.");
542
}
543
544
project_features.sort();
545
initial_settings["application/config/features"] = project_features;
546
initial_settings["application/config/name"] = project_name->get_text().strip_edges();
547
initial_settings["application/config/icon"] = "res://icon.svg";
548
549
Error err = ProjectSettings::get_singleton()->save_custom(path.path_join("project.godot"), initial_settings, Vector<String>(), false);
550
if (err != OK) {
551
_set_message(TTRC("Couldn't create project.godot in project path."), MESSAGE_ERROR);
552
return;
553
}
554
555
// Store default project icon in SVG format.
556
Ref<FileAccess> fa_icon = FileAccess::open(path.path_join("icon.svg"), FileAccess::WRITE, &err);
557
if (err != OK) {
558
_set_message(TTRC("Couldn't create icon.svg in project path."), MESSAGE_ERROR);
559
return;
560
}
561
fa_icon->store_string(get_default_project_icon());
562
563
EditorVCSInterface::create_vcs_metadata_files(EditorVCSInterface::VCSMetadata(vcs_metadata_selection->get_selected()), path);
564
565
// Ensures external editors and IDEs use UTF-8 encoding.
566
const String editor_config_path = path.path_join(".editorconfig");
567
Ref<FileAccess> f = FileAccess::open(editor_config_path, FileAccess::WRITE);
568
if (f.is_null()) {
569
// .editorconfig isn't so critical.
570
ERR_PRINT("Couldn't create .editorconfig in project path.");
571
} else {
572
f->store_line("root = true");
573
f->store_line("");
574
f->store_line("[*]");
575
f->store_line("charset = utf-8");
576
f->close();
577
FileAccess::set_hidden_attribute(editor_config_path, true);
578
}
579
}
580
581
// Two cases for importing a ZIP.
582
switch (mode) {
583
case MODE_IMPORT: {
584
if (zip_path.is_empty()) {
585
break;
586
}
587
588
path = install_path->get_text().simplify_path();
589
[[fallthrough]];
590
}
591
case MODE_INSTALL: {
592
ERR_FAIL_COND(zip_path.is_empty());
593
594
Ref<FileAccess> io_fa;
595
zlib_filefunc_def io = zipio_create_io(&io_fa);
596
597
unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
598
if (!pkg) {
599
dialog_error->set_text(TTRC("Error opening package file, not in ZIP format."));
600
dialog_error->popup_centered();
601
return;
602
}
603
604
// Find the first directory with a "project.godot".
605
String zip_root;
606
int ret = unzGoToFirstFile(pkg);
607
while (ret == UNZ_OK) {
608
unz_file_info info;
609
char fname[16384];
610
unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
611
ERR_FAIL_COND_MSG(ret != UNZ_OK, "Failed to get current file info.");
612
613
String name = String::utf8(fname);
614
615
// Skip the __MACOSX directory created by macOS's built-in file zipper.
616
if (name.begins_with("__MACOSX")) {
617
ret = unzGoToNextFile(pkg);
618
continue;
619
}
620
621
if (name.get_file() == "project.godot") {
622
zip_root = name.get_base_dir();
623
break;
624
}
625
626
ret = unzGoToNextFile(pkg);
627
}
628
629
if (ret == UNZ_END_OF_LIST_OF_FILE) {
630
_set_message(TTRC("Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."), MESSAGE_ERROR);
631
unzClose(pkg);
632
return;
633
}
634
635
if (create_dir->is_pressed()) {
636
Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
637
if (!d->dir_exists(path) && d->make_dir(path) != OK) {
638
_set_message(TTRC("Couldn't create project directory, check permissions."), MESSAGE_ERROR);
639
return;
640
}
641
}
642
643
ret = unzGoToFirstFile(pkg);
644
645
Vector<String> failed_files;
646
while (ret == UNZ_OK) {
647
//get filename
648
unz_file_info info;
649
char fname[16384];
650
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
651
ERR_FAIL_COND_MSG(ret != UNZ_OK, "Failed to get current file info.");
652
653
String name = String::utf8(fname);
654
655
// Skip the __MACOSX directory created by macOS's built-in file zipper.
656
if (name.begins_with("__MACOSX")) {
657
ret = unzGoToNextFile(pkg);
658
continue;
659
}
660
661
String rel_path = name.trim_prefix(zip_root);
662
if (rel_path.is_empty()) { // Root.
663
} else if (rel_path.ends_with("/")) { // Directory.
664
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
665
da->make_dir(path.path_join(rel_path));
666
} else { // File.
667
Vector<uint8_t> uncomp_data;
668
uncomp_data.resize(info.uncompressed_size);
669
670
unzOpenCurrentFile(pkg);
671
ret = unzReadCurrentFile(pkg, uncomp_data.ptrw(), uncomp_data.size());
672
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", rel_path));
673
unzCloseCurrentFile(pkg);
674
675
Ref<FileAccess> f = FileAccess::open(path.path_join(rel_path), FileAccess::WRITE);
676
if (f.is_valid()) {
677
f->store_buffer(uncomp_data.ptr(), uncomp_data.size());
678
} else {
679
failed_files.push_back(rel_path);
680
}
681
}
682
683
ret = unzGoToNextFile(pkg);
684
}
685
686
unzClose(pkg);
687
688
if (failed_files.size()) {
689
String err_msg = TTR("The following files failed extraction from package:") + "\n\n";
690
for (int i = 0; i < failed_files.size(); i++) {
691
if (i > 15) {
692
err_msg += "\nAnd " + itos(failed_files.size() - i) + " more files.";
693
break;
694
}
695
err_msg += failed_files[i] + "\n";
696
}
697
698
dialog_error->set_text(err_msg);
699
dialog_error->popup_centered();
700
return;
701
}
702
} break;
703
default: {
704
} break;
705
}
706
707
if (mode == MODE_DUPLICATE) {
708
Ref<DirAccess> dir = DirAccess::open(original_project_path);
709
Error err = FAILED;
710
if (dir.is_valid()) {
711
err = dir->copy_dir(".", path, -1, true);
712
}
713
if (err != OK) {
714
dialog_error->set_text(vformat(TTR("Couldn't duplicate project (error %d)."), err));
715
dialog_error->popup_centered();
716
return;
717
}
718
}
719
720
if (mode == MODE_RENAME || mode == MODE_INSTALL || mode == MODE_DUPLICATE) {
721
// Load project.godot as ConfigFile to set the new name.
722
ConfigFile cfg;
723
String project_godot = path.path_join("project.godot");
724
Error err = cfg.load(project_godot);
725
if (err != OK) {
726
dialog_error->set_text(vformat(TTR("Couldn't load project at '%s' (error %d). It may be missing or corrupted."), project_godot, err));
727
dialog_error->popup_centered();
728
return;
729
}
730
cfg.set_value("application", "config/name", project_name->get_text().strip_edges());
731
err = cfg.save(project_godot);
732
if (err != OK) {
733
dialog_error->set_text(vformat(TTR("Couldn't save project at '%s' (error %d)."), project_godot, err));
734
dialog_error->popup_centered();
735
return;
736
}
737
}
738
739
hide();
740
if (mode == MODE_NEW || mode == MODE_IMPORT || mode == MODE_INSTALL) {
741
#ifdef ANDROID_ENABLED
742
// Create a .nomedia file to hide assets from media apps on Android.
743
// Android 11 has some issues with nomedia files, so it's disabled there. See GH-106479, GH-105399 for details.
744
// NOTE: Nomedia file is also handled during the first filesystem scan. See editor_file_system.cpp -> EditorFileSystem::scan().
745
String sdk_version = OS::get_singleton()->get_version().get_slicec('.', 0);
746
if (sdk_version != "30") {
747
const String nomedia_file_path = path.path_join(".nomedia");
748
Ref<FileAccess> f2 = FileAccess::open(nomedia_file_path, FileAccess::WRITE);
749
if (f2.is_null()) {
750
// .nomedia isn't so critical.
751
ERR_PRINT("Couldn't create .nomedia in project path.");
752
} else {
753
f2->close();
754
}
755
}
756
#endif
757
emit_signal(SNAME("project_created"), path, edit_check_box->is_pressed());
758
} else if (mode == MODE_DUPLICATE) {
759
emit_signal(SNAME("project_duplicated"), original_project_path, path, edit_check_box->is_visible() && edit_check_box->is_pressed());
760
} else if (mode == MODE_RENAME) {
761
emit_signal(SNAME("projects_updated"));
762
}
763
}
764
765
void ProjectDialog::set_zip_path(const String &p_path) {
766
zip_path = p_path;
767
}
768
769
void ProjectDialog::set_zip_title(const String &p_title) {
770
zip_title = p_title;
771
}
772
773
void ProjectDialog::set_original_project_path(const String &p_path) {
774
original_project_path = p_path;
775
}
776
777
void ProjectDialog::set_duplicate_can_edit(bool p_duplicate_can_edit) {
778
duplicate_can_edit = p_duplicate_can_edit;
779
}
780
781
void ProjectDialog::set_mode(Mode p_mode) {
782
mode = p_mode;
783
}
784
785
void ProjectDialog::set_project_name(const String &p_name) {
786
project_name->set_text(p_name);
787
}
788
789
void ProjectDialog::set_project_path(const String &p_path) {
790
project_path->set_text(p_path);
791
}
792
793
void ProjectDialog::ask_for_path_and_show() {
794
_reset_name();
795
_browse_project_path();
796
}
797
798
void ProjectDialog::show_dialog(bool p_reset_name) {
799
if (mode == MODE_RENAME) {
800
// Name and path are set in `ProjectManager::_rename_project`.
801
project_path->set_editable(false);
802
803
set_title(TTRC("Rename Project"));
804
set_ok_button_text(TTRC("Rename"));
805
806
create_dir->hide();
807
project_status_rect->hide();
808
project_browse->hide();
809
edit_check_box->hide();
810
811
name_container->show();
812
install_path_container->hide();
813
renderer_container->hide();
814
default_files_container->hide();
815
816
callable_mp((Control *)project_name, &Control::grab_focus).call_deferred();
817
callable_mp(project_name, &LineEdit::select_all).call_deferred();
818
} else {
819
if (p_reset_name) {
820
_reset_name();
821
}
822
project_path->set_editable(true);
823
824
if (mode == MODE_DUPLICATE) {
825
String original_dir = original_project_path.get_base_dir();
826
project_path->set_text(original_dir);
827
install_path->set_text(original_dir);
828
fdialog_project->set_current_dir(original_dir);
829
} else {
830
String fav_dir = EDITOR_GET("filesystem/directories/default_project_path");
831
fav_dir = fav_dir.simplify_path();
832
if (!fav_dir.is_empty()) {
833
project_path->set_text(fav_dir);
834
install_path->set_text(fav_dir);
835
fdialog_project->set_current_dir(fav_dir);
836
} else {
837
Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
838
project_path->set_text(d->get_current_dir());
839
install_path->set_text(d->get_current_dir());
840
fdialog_project->set_current_dir(d->get_current_dir());
841
}
842
}
843
844
create_dir->show();
845
project_status_rect->show();
846
project_browse->show();
847
edit_check_box->show();
848
849
if (mode == MODE_IMPORT) {
850
set_title(TTRC("Import Existing Project"));
851
set_ok_button_text(TTRC("Import"));
852
853
name_container->hide();
854
install_path_container->hide();
855
renderer_container->hide();
856
default_files_container->hide();
857
858
// Project path dialog is also opened; no need to change focus.
859
} else if (mode == MODE_NEW) {
860
set_title(TTRC("Create New Project"));
861
set_ok_button_text(TTRC("Create"));
862
863
name_container->show();
864
install_path_container->hide();
865
renderer_container->show();
866
default_files_container->show();
867
868
callable_mp((Control *)project_name, &Control::grab_focus).call_deferred();
869
callable_mp(project_name, &LineEdit::select_all).call_deferred();
870
} else if (mode == MODE_INSTALL) {
871
set_title(TTR("Install Project:") + " " + zip_title);
872
set_ok_button_text(TTRC("Install"));
873
874
project_name->set_text(zip_title);
875
876
name_container->show();
877
install_path_container->hide();
878
renderer_container->hide();
879
default_files_container->hide();
880
881
callable_mp((Control *)project_path, &Control::grab_focus).call_deferred();
882
} else if (mode == MODE_DUPLICATE) {
883
set_title(TTRC("Duplicate Project"));
884
set_ok_button_text(TTRC("Duplicate"));
885
886
name_container->show();
887
install_path_container->hide();
888
renderer_container->hide();
889
default_files_container->hide();
890
if (!duplicate_can_edit) {
891
edit_check_box->hide();
892
}
893
894
callable_mp((Control *)project_name, &Control::grab_focus).call_deferred();
895
callable_mp(project_name, &LineEdit::select_all).call_deferred();
896
}
897
898
auto_dir = "";
899
last_custom_target_dir = "";
900
_update_target_auto_dir();
901
if (create_dir->is_pressed()) {
902
// Append `auto_dir` to target path.
903
_create_dir_toggled(true);
904
}
905
}
906
907
_validate_path();
908
909
popup_centered(Size2(500, 0) * EDSCALE);
910
}
911
912
void ProjectDialog::_notification(int p_what) {
913
switch (p_what) {
914
case NOTIFICATION_TRANSLATION_CHANGED: {
915
_renderer_selected();
916
} break;
917
918
case NOTIFICATION_THEME_CHANGED: {
919
create_dir->set_button_icon(get_editor_theme_icon(SNAME("FolderCreate")));
920
project_browse->set_button_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
921
install_browse->set_button_icon(get_editor_theme_icon(SNAME("FolderBrowse")));
922
} break;
923
case NOTIFICATION_READY: {
924
fdialog_project = memnew(EditorFileDialog);
925
fdialog_project->set_previews_enabled(false); // Crucial, otherwise the engine crashes.
926
fdialog_project->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
927
fdialog_project->connect("dir_selected", callable_mp(this, &ProjectDialog::_project_path_selected));
928
fdialog_project->connect("file_selected", callable_mp(this, &ProjectDialog::_project_path_selected));
929
fdialog_project->connect("canceled", callable_mp(this, &ProjectDialog::show_dialog).bind(false), CONNECT_DEFERRED);
930
callable_mp((Node *)this, &Node::add_sibling).call_deferred(fdialog_project, false);
931
} break;
932
}
933
}
934
935
void ProjectDialog::_bind_methods() {
936
ADD_SIGNAL(MethodInfo("project_created"));
937
ADD_SIGNAL(MethodInfo("project_duplicated"));
938
ADD_SIGNAL(MethodInfo("projects_updated"));
939
}
940
941
ProjectDialog::ProjectDialog() {
942
VBoxContainer *vb = memnew(VBoxContainer);
943
add_child(vb);
944
945
name_container = memnew(VBoxContainer);
946
vb->add_child(name_container);
947
948
Label *l = memnew(Label);
949
l->set_text(TTRC("Project Name:"));
950
name_container->add_child(l);
951
952
project_name = memnew(LineEdit);
953
project_name->set_virtual_keyboard_show_on_focus(false);
954
project_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
955
name_container->add_child(project_name);
956
957
project_path_container = memnew(VBoxContainer);
958
vb->add_child(project_path_container);
959
960
HBoxContainer *pphb_label = memnew(HBoxContainer);
961
project_path_container->add_child(pphb_label);
962
963
l = memnew(Label);
964
l->set_text(TTRC("Project Path:"));
965
l->set_h_size_flags(Control::SIZE_EXPAND_FILL);
966
pphb_label->add_child(l);
967
968
create_dir = memnew(CheckButton);
969
create_dir->set_text(TTRC("Create Folder"));
970
create_dir->set_pressed(true);
971
pphb_label->add_child(create_dir);
972
create_dir->connect(SceneStringName(toggled), callable_mp(this, &ProjectDialog::_create_dir_toggled));
973
974
HBoxContainer *pphb = memnew(HBoxContainer);
975
project_path_container->add_child(pphb);
976
977
project_path = memnew(LineEdit);
978
project_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
979
project_path->set_accessibility_name(TTRC("Project Path:"));
980
project_path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
981
pphb->add_child(project_path);
982
983
install_path_container = memnew(VBoxContainer);
984
vb->add_child(install_path_container);
985
986
l = memnew(Label);
987
l->set_text(TTRC("Project Installation Path:"));
988
install_path_container->add_child(l);
989
990
HBoxContainer *iphb = memnew(HBoxContainer);
991
install_path_container->add_child(iphb);
992
993
install_path = memnew(LineEdit);
994
install_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
995
install_path->set_accessibility_name(TTRC("Project Installation Path:"));
996
install_path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
997
iphb->add_child(install_path);
998
999
// status icon
1000
project_status_rect = memnew(TextureRect);
1001
project_status_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
1002
pphb->add_child(project_status_rect);
1003
1004
project_browse = memnew(Button);
1005
project_browse->set_text(TTRC("Browse"));
1006
project_browse->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_browse_project_path));
1007
pphb->add_child(project_browse);
1008
1009
// install status icon
1010
install_status_rect = memnew(TextureRect);
1011
install_status_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
1012
iphb->add_child(install_status_rect);
1013
1014
install_browse = memnew(Button);
1015
install_browse->set_text(TTRC("Browse"));
1016
install_browse->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_browse_install_path));
1017
iphb->add_child(install_browse);
1018
1019
msg = memnew(Label);
1020
msg->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
1021
msg->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
1022
msg->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
1023
msg->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
1024
vb->add_child(msg);
1025
1026
// Renderer selection.
1027
renderer_container = memnew(VBoxContainer);
1028
vb->add_child(renderer_container);
1029
l = memnew(Label);
1030
l->set_text(TTRC("Renderer:"));
1031
renderer_container->add_child(l);
1032
HBoxContainer *rshc = memnew(HBoxContainer);
1033
renderer_container->add_child(rshc);
1034
renderer_button_group.instantiate();
1035
1036
// Left hand side, used for checkboxes to select renderer.
1037
Container *rvb = memnew(VBoxContainer);
1038
rshc->add_child(rvb);
1039
1040
String default_renderer_type = "forward_plus";
1041
if (EditorSettings::get_singleton()->has_setting("project_manager/default_renderer")) {
1042
default_renderer_type = EditorSettings::get_singleton()->get_setting("project_manager/default_renderer");
1043
}
1044
1045
rendering_device_supported = DisplayServer::is_rendering_device_supported();
1046
1047
if (!rendering_device_supported) {
1048
default_renderer_type = "gl_compatibility";
1049
}
1050
1051
Button *rs_button = memnew(CheckBox);
1052
rs_button->set_button_group(renderer_button_group);
1053
rs_button->set_text(TTRC("Forward+"));
1054
#ifndef RD_ENABLED
1055
rs_button->set_disabled(true);
1056
#endif
1057
rs_button->set_meta(SNAME("rendering_method"), "forward_plus");
1058
rs_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_renderer_selected));
1059
rvb->add_child(rs_button);
1060
if (default_renderer_type == "forward_plus") {
1061
rs_button->set_pressed(true);
1062
}
1063
rs_button = memnew(CheckBox);
1064
rs_button->set_button_group(renderer_button_group);
1065
rs_button->set_text(TTRC("Mobile"));
1066
#ifndef RD_ENABLED
1067
rs_button->set_disabled(true);
1068
#endif
1069
rs_button->set_meta(SNAME("rendering_method"), "mobile");
1070
rs_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_renderer_selected));
1071
rvb->add_child(rs_button);
1072
if (default_renderer_type == "mobile") {
1073
rs_button->set_pressed(true);
1074
}
1075
rs_button = memnew(CheckBox);
1076
rs_button->set_button_group(renderer_button_group);
1077
rs_button->set_text(TTRC("Compatibility"));
1078
#if !defined(GLES3_ENABLED)
1079
rs_button->set_disabled(true);
1080
#endif
1081
rs_button->set_meta(SNAME("rendering_method"), "gl_compatibility");
1082
rs_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectDialog::_renderer_selected));
1083
rvb->add_child(rs_button);
1084
#if defined(GLES3_ENABLED)
1085
if (default_renderer_type == "gl_compatibility") {
1086
rs_button->set_pressed(true);
1087
}
1088
#endif
1089
rshc->add_child(memnew(VSeparator));
1090
1091
// Right hand side, used for text explaining each choice.
1092
rvb = memnew(VBoxContainer);
1093
rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
1094
rshc->add_child(rvb);
1095
renderer_info = memnew(Label);
1096
renderer_info->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
1097
renderer_info->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
1098
renderer_info->set_modulate(Color(1, 1, 1, 0.7));
1099
rvb->add_child(renderer_info);
1100
1101
rd_not_supported = memnew(Label);
1102
rd_not_supported->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
1103
rd_not_supported->set_text(vformat(TTRC("RenderingDevice-based methods not available on this GPU:\n%s\nPlease use the Compatibility renderer."), RenderingServer::get_singleton()->get_video_adapter_name()));
1104
rd_not_supported->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
1105
rd_not_supported->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
1106
rd_not_supported->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
1107
rd_not_supported->set_visible(false);
1108
renderer_container->add_child(rd_not_supported);
1109
1110
_renderer_selected();
1111
1112
l = memnew(Label);
1113
l->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
1114
l->set_text(TTRC("The renderer can be changed later, but scenes may need to be adjusted."));
1115
// Add some extra spacing to separate it from the list above and the buttons below.
1116
l->set_custom_minimum_size(Size2(0, 40) * EDSCALE);
1117
l->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
1118
l->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
1119
l->set_modulate(Color(1, 1, 1, 0.7));
1120
renderer_container->add_child(l);
1121
1122
default_files_container = memnew(HBoxContainer);
1123
vb->add_child(default_files_container);
1124
l = memnew(Label);
1125
l->set_text(TTRC("Version Control Metadata:"));
1126
default_files_container->add_child(l);
1127
vcs_metadata_selection = memnew(OptionButton);
1128
vcs_metadata_selection->set_custom_minimum_size(Size2(100, 20));
1129
vcs_metadata_selection->add_item(TTRC("None"), (int)EditorVCSInterface::VCSMetadata::NONE);
1130
vcs_metadata_selection->add_item(TTRC("Git"), (int)EditorVCSInterface::VCSMetadata::GIT);
1131
vcs_metadata_selection->select((int)EditorVCSInterface::VCSMetadata::GIT);
1132
vcs_metadata_selection->set_accessibility_name(TTRC("Version Control Metadata:"));
1133
default_files_container->add_child(vcs_metadata_selection);
1134
Control *spacer = memnew(Control);
1135
spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL);
1136
default_files_container->add_child(spacer);
1137
fdialog_install = memnew(EditorFileDialog);
1138
fdialog_install->set_previews_enabled(false); //Crucial, otherwise the engine crashes.
1139
fdialog_install->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
1140
add_child(fdialog_install);
1141
1142
Control *spacer2 = memnew(Control);
1143
spacer2->set_v_size_flags(Control::SIZE_EXPAND_FILL);
1144
vb->add_child(spacer2);
1145
1146
edit_check_box = memnew(CheckBox);
1147
edit_check_box->set_text(TTRC("Edit Now"));
1148
edit_check_box->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
1149
edit_check_box->set_pressed(true);
1150
vb->add_child(edit_check_box);
1151
1152
project_name->connect(SceneStringName(text_changed), callable_mp(this, &ProjectDialog::_project_name_changed).unbind(1));
1153
project_name->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectDialog::ok_pressed).unbind(1));
1154
1155
project_path->connect(SceneStringName(text_changed), callable_mp(this, &ProjectDialog::_project_path_changed).unbind(1));
1156
project_path->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectDialog::ok_pressed).unbind(1));
1157
1158
install_path->connect(SceneStringName(text_changed), callable_mp(this, &ProjectDialog::_install_path_changed).unbind(1));
1159
install_path->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectDialog::ok_pressed).unbind(1));
1160
1161
fdialog_install->connect("dir_selected", callable_mp(this, &ProjectDialog::_install_path_selected));
1162
fdialog_install->connect("file_selected", callable_mp(this, &ProjectDialog::_install_path_selected));
1163
1164
set_hide_on_ok(false);
1165
1166
dialog_error = memnew(AcceptDialog);
1167
add_child(dialog_error);
1168
}
1169
1170