summaryrefslogtreecommitdiff
path: root/editor/project_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r--editor/project_manager.cpp121
1 files changed, 88 insertions, 33 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 16605f2ebd..666f08cb2d 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -152,7 +152,7 @@ private:
return "";
}
- } else if (mode == MODE_NEW) {
+ } else {
// check if the specified folder is empty, even though this is not an error, it is good to check here
d->list_dir_begin();
@@ -174,13 +174,6 @@ private:
get_ok()->set_disabled(true);
return "";
}
-
- } else if (d->file_exists("project.godot")) {
-
- set_message(TTR("Please choose a folder that does not contain a 'project.godot' file."), MESSAGE_ERROR);
- memdelete(d);
- get_ok()->set_disabled(true);
- return "";
}
set_message("");
@@ -257,8 +250,10 @@ private:
void _create_folder() {
- if (project_name->get_text() == "" || created_folder_path != "")
+ if (project_name->get_text() == "" || created_folder_path != "" || project_name->get_text().ends_with(".") || project_name->get_text().ends_with(" ")) {
+ set_message(TTR("Invalid Project Name."), MESSAGE_WARNING);
return;
+ }
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (d->change_dir(project_path->get_text()) == OK) {
@@ -311,8 +306,9 @@ private:
ProjectSettings *current = memnew(ProjectSettings);
- if (current->setup(dir, "")) {
- set_message(TTR("Couldn't get project.godot in project path."), MESSAGE_ERROR);
+ int err = current->setup(dir, "");
+ if (err != OK) {
+ set_message(vformat(TTR("Couldn't load project.godot in project path (error %d). It may be missing or corrupted."), err), MESSAGE_ERROR);
} else {
ProjectSettings::CustomMap edited_settings;
edited_settings["application/config/name"] = project_name->get_text();
@@ -531,11 +527,18 @@ public:
set_title(TTR("Rename Project"));
get_ok()->set_text(TTR("Rename"));
name_container->show();
+ status_rect->hide();
+ msg->hide();
+ get_ok()->set_disabled(false);
ProjectSettings *current = memnew(ProjectSettings);
- if (current->setup(project_path->get_text(), "")) {
- set_message(TTR("Couldn't get project.godot in the project path."), MESSAGE_ERROR);
+ int err = current->setup(project_path->get_text(), "");
+ if (err != OK) {
+ set_message(vformat(TTR("Couldn't load project.godot in project path (error %d). It may be missing or corrupted."), err), MESSAGE_ERROR);
+ status_rect->show();
+ msg->show();
+ get_ok()->set_disabled(true);
} else if (current->has_setting("application/config/name")) {
project_name->set_text(current->get("application/config/name"));
}
@@ -543,8 +546,6 @@ public:
project_name->call_deferred("grab_focus");
create_dir->hide();
- status_rect->hide();
- msg->hide();
} else {
@@ -632,7 +633,7 @@ public:
project_path->set_h_size_flags(SIZE_EXPAND_FILL);
pphb->add_child(project_path);
- // status button
+ // status icon
status_rect = memnew(TextureRect);
status_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
pphb->add_child(status_rect);
@@ -690,7 +691,7 @@ void ProjectManager::_notification(int p_what) {
} break;
case NOTIFICATION_READY: {
- if (scroll_children->get_child_count() == 0)
+ if (scroll_children->get_child_count() == 0 && StreamPeerSSL::is_available())
open_templates->popup_centered_minsize();
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -716,6 +717,12 @@ void ProjectManager::_update_project_buttons() {
CanvasItem *item = Object::cast_to<CanvasItem>(scroll_children->get_child(i));
item->update();
+
+ Button *show = Object::cast_to<Button>(item->get_node(NodePath("project/path_box/show")));
+ if (show) {
+ String current = item->get_meta("name");
+ show->set_visible(selected_list.has(current));
+ }
}
erase_btn->set_disabled(selected_list.size() < 1);
@@ -1095,9 +1102,26 @@ void ProjectManager::_load_recent_projects() {
title->add_color_override("font_color", font_color);
title->set_clip_text(true);
vb->add_child(title);
+
+ HBoxContainer *path_hb = memnew(HBoxContainer);
+ path_hb->set_name("path_box");
+ path_hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ vb->add_child(path_hb);
+
+ Button *show = memnew(Button);
+ show->set_name("show");
+ show->set_icon(get_icon("Filesystem", "EditorIcons"));
+ show->set_flat(true);
+ show->set_modulate(Color(1, 1, 1, 0.5));
+ path_hb->add_child(show);
+ show->connect("pressed", this, "_show_project", varray(path));
+ show->set_tooltip(TTR("Show In File Manager"));
+ show->set_visible(false);
+
Label *fpath = memnew(Label(path));
fpath->set_name("path");
- vb->add_child(fpath);
+ path_hb->add_child(fpath);
+ fpath->set_h_size_flags(SIZE_EXPAND_FILL);
fpath->set_modulate(Color(1, 1, 1, 0.5));
fpath->add_color_override("font_color", font_color);
fpath->set_clip_text(true);
@@ -1127,7 +1151,7 @@ void ProjectManager::_on_project_created(const String &dir) {
bool has_already = false;
for (int i = 0; i < scroll_children->get_child_count(); i++) {
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path")));
+ Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path_box/path")));
if (fpath->get_text() == dir) {
has_already = true;
break;
@@ -1145,7 +1169,7 @@ void ProjectManager::_on_project_created(const String &dir) {
void ProjectManager::_update_scroll_position(const String &dir) {
for (int i = 0; i < scroll_children->get_child_count(); i++) {
HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
- Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path")));
+ Label *fpath = Object::cast_to<Label>(hb->get_node(NodePath("project/path_box/path")));
if (fpath->get_text() == dir) {
last_clicked = hb->get_meta("name");
selected_list.clear();
@@ -1263,6 +1287,11 @@ void ProjectManager::_run_project() {
}
}
+void ProjectManager::_show_project(const String &p_path) {
+
+ OS::get_singleton()->shell_open(String("file://") + p_path);
+}
+
void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects) {
List<String> subdirs;
@@ -1451,6 +1480,7 @@ void ProjectManager::_bind_methods() {
ClassDB::bind_method("_open_project_confirm", &ProjectManager::_open_project_confirm);
ClassDB::bind_method("_run_project", &ProjectManager::_run_project);
ClassDB::bind_method("_run_project_confirm", &ProjectManager::_run_project_confirm);
+ ClassDB::bind_method("_show_project", &ProjectManager::_show_project);
ClassDB::bind_method("_scan_projects", &ProjectManager::_scan_projects);
ClassDB::bind_method("_scan_begin", &ProjectManager::_scan_begin);
ClassDB::bind_method("_import_project", &ProjectManager::_import_project);
@@ -1489,18 +1519,43 @@ ProjectManager::ProjectManager() {
EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came
{
- int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode");
- if (dpi_mode == 0) {
- const int screen = OS::get_singleton()->get_current_screen();
- editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
- } else if (dpi_mode == 1) {
- editor_set_scale(0.75);
- } else if (dpi_mode == 2) {
- editor_set_scale(1.0);
- } else if (dpi_mode == 3) {
- editor_set_scale(1.5);
- } else if (dpi_mode == 4) {
- editor_set_scale(2.0);
+ int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale");
+ float custom_display_scale = EditorSettings::get_singleton()->get("interface/editor/custom_display_scale");
+
+ switch (display_scale) {
+ case 0: {
+ // Try applying a suitable display scale automatically
+ const int screen = OS::get_singleton()->get_current_screen();
+ editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
+ } break;
+
+ case 1: {
+ editor_set_scale(0.75);
+ } break;
+
+ case 2: {
+ editor_set_scale(1.0);
+ } break;
+
+ case 3: {
+ editor_set_scale(1.25);
+ } break;
+
+ case 4: {
+ editor_set_scale(1.5);
+ } break;
+
+ case 5: {
+ editor_set_scale(1.75);
+ } break;
+
+ case 6: {
+ editor_set_scale(2.0);
+ } break;
+
+ default: {
+ editor_set_scale(custom_display_scale);
+ } break;
}
}
@@ -1542,7 +1597,7 @@ ProjectManager::ProjectManager() {
String hash = String(VERSION_HASH);
if (hash.length() != 0)
hash = "." + hash.left(7);
- l->set_text("v" VERSION_MKSTRING "" + hash);
+ l->set_text("v" VERSION_FULL_BUILD "" + hash);
l->set_align(Label::ALIGN_CENTER);
top_hb->add_child(l);