aboutsummaryrefslogtreecommitdiff
path: root/editor/project_manager.cpp
diff options
context:
space:
mode:
authorAndreas Haas2017-04-16 10:17:24 +0200
committerAndreas Haas2017-04-16 10:19:07 +0200
commitc06a2db63a85c23fa35058f5bfd62245ed998951 (patch)
treef97462cfc99d5ac40238e5bb3adc3ea7131a5019 /editor/project_manager.cpp
parente46af1e23668e23160604742f8f1d22898796d1c (diff)
downloadgodot-c06a2db63a85c23fa35058f5bfd62245ed998951.tar.gz
godot-c06a2db63a85c23fa35058f5bfd62245ed998951.tar.zst
godot-c06a2db63a85c23fa35058f5bfd62245ed998951.zip
Use .godot as file extension for project files.
Now project files don't have to be named "godot.cfg" anymore, they can have any name so as long as it ends with *.godot. Also godot will automatically start the editor now if launched with a project file as an argument. This allows for double-clicking of projects to open them :) Code-wise this should be complete, but there's still work to do: - Make a nice icon for godot projects. - Work on installers/packaging -> register the extension and icon with godot. - Update the 2.1 to 3.0 exporter. Tested on linux and windows so far.
Diffstat (limited to 'editor/project_manager.cpp')
-rw-r--r--editor/project_manager.cpp42
1 files changed, 31 insertions, 11 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 7e9dc5f4f..35b897381 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -50,6 +50,19 @@
#include "scene/gui/tool_button.h"
#include "version.h"
+static String _find_project_file(DirAccess *p_da) {
+ p_da->list_dir_begin();
+ while (true) {
+ String f = p_da->get_next();
+ if (f == "")
+ break;
+ if (f.get_extension() == "godot")
+ return p_da->get_current_dir() + "/" + f;
+ }
+ p_da->list_dir_end();
+ return "";
+}
+
class NewProjectDialog : public ConfirmationDialog {
GDCLASS(NewProjectDialog, ConfirmationDialog);
@@ -92,18 +105,18 @@ private:
if (mode != MODE_IMPORT) {
- if (d->file_exists("godot.cfg")) {
+ if (_find_project_file(d) != "") {
- error->set_text(TTR("Invalid project path, godot.cfg must not exist."));
+ error->set_text(TTR("Invalid project path, *.godot must not exist."));
memdelete(d);
return "";
}
} else {
- if (valid_path != "" && !d->file_exists("godot.cfg")) {
+ if (valid_path != "" && _find_project_file(d) == "") {
- error->set_text(TTR("Invalid project path, godot.cfg must exist."));
+ error->set_text(TTR("Invalid project path, *.godot must exist."));
memdelete(d);
return "";
}
@@ -136,7 +149,7 @@ private:
String p = p_path;
if (mode == MODE_IMPORT) {
- if (p.ends_with("godot.cfg")) {
+ if (p.get_extension() == "godot") {
p = p.get_base_dir();
}
@@ -162,7 +175,7 @@ private:
fdialog->set_mode(FileDialog::MODE_OPEN_FILE);
fdialog->clear_filters();
- fdialog->add_filter("godot.cfg ; " _MKSTR(VERSION_NAME) " Project");
+ fdialog->add_filter("*.godot ; " _MKSTR(VERSION_NAME) " Project");
} else {
fdialog->set_mode(FileDialog::MODE_OPEN_DIR);
}
@@ -186,9 +199,9 @@ private:
} else {
if (mode == MODE_NEW) {
- FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"), FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(dir.plus_file("/" + project_name->get_text().replace(" ", "_") + ".godot"), FileAccess::WRITE);
if (!f) {
- error->set_text(TTR("Couldn't create godot.cfg in project path."));
+ error->set_text(TTR("Couldn't create *.godot project file in project path."));
} else {
f->store_line("; Engine configuration file.");
@@ -741,10 +754,17 @@ void ProjectManager::_load_recent_projects() {
continue;
String project = _name.get_slice("/", 1);
- String conf = path.plus_file("godot.cfg");
+ DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ if (dir_access->change_dir(path) != OK) {
+ EditorSettings::get_singleton()->erase(_name);
+ continue;
+ }
+ String conf = _find_project_file(dir_access);
+ memdelete(dir_access);
bool favorite = (_name.begins_with("favorite_projects/")) ? true : false;
uint64_t last_modified = 0;
+
if (FileAccess::exists(conf)) {
last_modified = FileAccess::get_modified_time(conf);
@@ -1006,7 +1026,7 @@ void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<Strin
while (n != String()) {
if (da->current_is_dir() && !n.begins_with(".")) {
subdirs.push_front(n);
- } else if (n == "godot.cfg") {
+ } else if (n.get_extension() == "godot") {
r_projects->push_back(da->get_current_dir());
}
n = da->get_next();
@@ -1117,7 +1137,7 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) {
dir->list_dir_begin();
String file = dir->get_next();
while (confirm && file != String()) {
- if (!dir->current_is_dir() && file.ends_with("godot.cfg")) {
+ if (!dir->current_is_dir() && file.get_extension() == "godot") {
confirm = false;
}
file = dir->get_next();