Strip leading/trailing whitespace for project name in the project manager
This affects creating projects and renaming them.
(cherry picked from commit 86455d0c58
)
This commit is contained in:
parent
030f0f58a3
commit
94e0d02079
1 changed files with 10 additions and 13 deletions
|
@ -312,7 +312,7 @@ private:
|
||||||
if (sp != "") {
|
if (sp != "") {
|
||||||
|
|
||||||
// If the project name is empty or default, infer the project name from the selected folder name
|
// If the project name is empty or default, infer the project name from the selected folder name
|
||||||
if (project_name->get_text() == "" || project_name->get_text() == TTR("New Game Project")) {
|
if (project_name->get_text().strip_edges() == "" || project_name->get_text().strip_edges() == TTR("New Game Project")) {
|
||||||
sp = sp.replace("\\", "/");
|
sp = sp.replace("\\", "/");
|
||||||
int lidx = sp.find_last("/");
|
int lidx = sp.find_last("/");
|
||||||
|
|
||||||
|
@ -399,20 +399,17 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void _create_folder() {
|
void _create_folder() {
|
||||||
|
const String project_name_no_edges = project_name->get_text().strip_edges();
|
||||||
if (project_name->get_text() == "" || created_folder_path != "" || project_name->get_text().ends_with(".") || project_name->get_text().ends_with(" ")) {
|
if (project_name_no_edges == "" || created_folder_path != "" || project_name_no_edges.ends_with(".")) {
|
||||||
set_message(TTR("Invalid Project Name."), MESSAGE_WARNING);
|
set_message(TTR("Invalid project name."), MESSAGE_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||||
if (d->change_dir(project_path->get_text()) == OK) {
|
if (d->change_dir(project_path->get_text()) == OK) {
|
||||||
|
if (!d->dir_exists(project_name_no_edges)) {
|
||||||
if (!d->dir_exists(project_name->get_text())) {
|
if (d->make_dir(project_name_no_edges) == OK) {
|
||||||
|
d->change_dir(project_name_no_edges);
|
||||||
if (d->make_dir(project_name->get_text()) == OK) {
|
|
||||||
|
|
||||||
d->change_dir(project_name->get_text());
|
|
||||||
String dir_str = d->get_current_dir();
|
String dir_str = d->get_current_dir();
|
||||||
project_path->set_text(dir_str);
|
project_path->set_text(dir_str);
|
||||||
_path_text_changed(dir_str);
|
_path_text_changed(dir_str);
|
||||||
|
@ -440,7 +437,7 @@ private:
|
||||||
|
|
||||||
_test_path();
|
_test_path();
|
||||||
|
|
||||||
if (p_text == "")
|
if (p_text.strip_edges() == "")
|
||||||
set_message(TTR("It would be a good idea to name your project."), MESSAGE_ERROR);
|
set_message(TTR("It would be a good idea to name your project."), MESSAGE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +460,7 @@ private:
|
||||||
set_message(vformat(TTR("Couldn't load project.godot in project path (error %d). It may be missing or corrupted."), err), MESSAGE_ERROR);
|
set_message(vformat(TTR("Couldn't load project.godot in project path (error %d). It may be missing or corrupted."), err), MESSAGE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
ProjectSettings::CustomMap edited_settings;
|
ProjectSettings::CustomMap edited_settings;
|
||||||
edited_settings["application/config/name"] = project_name->get_text();
|
edited_settings["application/config/name"] = project_name->get_text().strip_edges();
|
||||||
|
|
||||||
if (current->save_custom(dir2.plus_file("project.godot"), edited_settings, Vector<String>(), true) != OK) {
|
if (current->save_custom(dir2.plus_file("project.godot"), edited_settings, Vector<String>(), true) != OK) {
|
||||||
set_message(TTR("Couldn't edit project.godot in project path."), MESSAGE_ERROR);
|
set_message(TTR("Couldn't edit project.godot in project path."), MESSAGE_ERROR);
|
||||||
|
@ -496,7 +493,7 @@ private:
|
||||||
initial_settings["rendering/vram_compression/import_etc2"] = false;
|
initial_settings["rendering/vram_compression/import_etc2"] = false;
|
||||||
initial_settings["rendering/vram_compression/import_etc"] = true;
|
initial_settings["rendering/vram_compression/import_etc"] = true;
|
||||||
}
|
}
|
||||||
initial_settings["application/config/name"] = project_name->get_text();
|
initial_settings["application/config/name"] = project_name->get_text().strip_edges();
|
||||||
initial_settings["application/config/icon"] = "res://icon.png";
|
initial_settings["application/config/icon"] = "res://icon.png";
|
||||||
initial_settings["rendering/environment/default_environment"] = "res://default_env.tres";
|
initial_settings["rendering/environment/default_environment"] = "res://default_env.tres";
|
||||||
initial_settings["physics/common/enable_pause_aware_picking"] = true;
|
initial_settings["physics/common/enable_pause_aware_picking"] = true;
|
||||||
|
|
Loading…
Reference in a new issue