diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-04-29 17:56:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-29 17:56:51 +0200 |
commit | 6d2f985db494432e6d5194d5f7c2c00e7f099c55 (patch) | |
tree | a5b1eb0bf609b1faa9b20ba32375323e15340216 | |
parent | abe09919bf5664353bea904116c6bc5bb856cd7f (diff) |
Revert "Use .godot as file extension for project files."
-rw-r--r-- | core/global_config.cpp | 72 | ||||
-rw-r--r-- | core/global_config.h | 3 | ||||
-rw-r--r-- | doc/base/classes.xml | 2 | ||||
-rw-r--r-- | editor/editor_file_system.cpp | 48 | ||||
-rw-r--r-- | editor/project_manager.cpp | 42 | ||||
-rw-r--r-- | editor/project_settings.cpp | 3 | ||||
-rw-r--r-- | main/main.cpp | 23 |
7 files changed, 45 insertions, 148 deletions
diff --git a/core/global_config.cpp b/core/global_config.cpp index f9a0877c23..5ce9a088b8 100644 --- a/core/global_config.cpp +++ b/core/global_config.cpp @@ -53,11 +53,6 @@ String GlobalConfig::get_resource_path() const { return resource_path; }; -String GlobalConfig::get_project_file_name() const { - - return project_file_name; -} - String GlobalConfig::localize_path(const String &p_path) const { if (resource_path == "") @@ -241,43 +236,13 @@ bool GlobalConfig::_load_resource_pack(const String &p_pack) { return true; } -static String _find_project_file(DirAccess *p_diraccess, bool p_res = false) { - p_diraccess->list_dir_begin(); - String ret = ""; - while (true) { - bool isdir; - String file = p_diraccess->get_next(&isdir); - if (file == "") - break; - - if (!isdir) { - if (file.get_extension() == "godot") { - - if (p_res) { - ret = "res://" + file; - } else { - ret = p_diraccess->get_current_dir() + "/" + file; - } - } - } - } - p_diraccess->list_dir_end(); - return ret; -} - -static String _find_project_file() { - DirAccess *dir = DirAccess::create(DirAccess::ACCESS_RESOURCES); - String ret = _find_project_file(dir, true); - memdelete(dir); - return ret; -} - Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { //If looking for files in network, just use network! + if (FileAccessNetworkClient::get_singleton()) { - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } @@ -293,8 +258,8 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { bool ok = _load_resource_pack(p_main_pack); ERR_FAIL_COND_V(!ok, ERR_CANT_OPEN); - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { //load override from location of the main pack _load_settings(p_main_pack.get_base_dir().plus_file("override.cfg")); } @@ -307,8 +272,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { if (_load_resource_pack(exec_path.get_basename() + ".pck")) { - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { //load override from location of executable _load_settings(exec_path.get_base_dir().plus_file("override.cfg")); } @@ -328,15 +292,15 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { // data.pck and data.zip are deprecated and no longer supported, apologies. // make sure this is loaded from the resource path - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } return OK; } - //Nothing was found, try to find a *.godot somewhere! + //Nothing was found, try to find a godot.cfg somewhere! DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_FAIL_COND_V(!d, ERR_CANT_CREATE); @@ -349,8 +313,8 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { while (true) { //try to load settings in ascending through dirs shape! - String gdproj = _find_project_file(d); - if (_load_settings(gdproj) == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { + + if (_load_settings(current_dir + "/godot.cfg") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { _load_settings(current_dir + "/override.cfg"); candidate = current_dir; @@ -464,7 +428,6 @@ Error GlobalConfig::_load_settings(const String p_path) { err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); if (err == ERR_FILE_EOF) { memdelete(f); - project_file_name = p_path.get_file(); return OK; } else if (err != OK) { ERR_PRINTS("GlobalConfig::load - " + p_path + ":" + itos(lines) + " error: " + error_text); @@ -486,7 +449,6 @@ Error GlobalConfig::_load_settings(const String p_path) { } } - project_file_name = p_path.get_file(); memdelete(f); return OK; @@ -512,12 +474,7 @@ void GlobalConfig::clear(const String &p_name) { Error GlobalConfig::save() { - if (project_file_name.empty()) { - String name = ((String)get("application/name")).replace(" ", "_"); - return save_custom(get_resource_path() + "/" + name + ".godot"); - } else { - return save_custom(get_resource_path() + "/" + project_file_name); - } + return save_custom(get_resource_path() + "/godot.cfg"); } Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom) { @@ -526,7 +483,7 @@ Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err != OK) { - ERR_EXPLAIN("Couldn't save godot.cfb at " + p_file); + ERR_EXPLAIN("Coudln't save godot.cfb at " + p_file); ERR_FAIL_COND_V(err, err) } @@ -591,7 +548,7 @@ Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String, FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err) { - ERR_EXPLAIN("Couldn't save project file - " + p_file); + ERR_EXPLAIN("Coudln't save godot.cfg - " + p_file); ERR_FAIL_COND_V(err, err) } @@ -871,7 +828,6 @@ void GlobalConfig::_bind_methods() { ClassDB::bind_method(D_METHOD("clear", "name"), &GlobalConfig::clear); ClassDB::bind_method(D_METHOD("localize_path", "path"), &GlobalConfig::localize_path); ClassDB::bind_method(D_METHOD("globalize_path", "path"), &GlobalConfig::globalize_path); - ClassDB::bind_method(D_METHOD("get_project_file_name"), &GlobalConfig::get_project_file_name); ClassDB::bind_method(D_METHOD("save"), &GlobalConfig::save); ClassDB::bind_method(D_METHOD("has_singleton", "name"), &GlobalConfig::has_singleton); ClassDB::bind_method(D_METHOD("get_singleton", "name"), &GlobalConfig::get_singleton_object); diff --git a/core/global_config.h b/core/global_config.h index 5148c4377e..d0f64dc23c 100644 --- a/core/global_config.h +++ b/core/global_config.h @@ -111,8 +111,6 @@ protected: void _add_property_info_bind(const Dictionary &p_info); - String project_file_name; - protected: static void _bind_methods(); @@ -126,7 +124,6 @@ public: Variant property_get_revert(const String &p_name); String get_resource_path() const; - String get_project_file_name() const; static GlobalConfig *get_singleton(); diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 6f6a094927..96b311e788 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -16455,7 +16455,7 @@ Contains global variables accessible from everywhere. </brief_description> <description> - Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in the project file (*.godot) are also loaded into globals, making this object very useful for reading custom game configuration options. + Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in godot.cfg are also loaded into globals, making this object very useful for reading custom game configuration options. </description> <methods> <method name="add_property_info"> diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 3fb2923696..2612a2af16 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -487,22 +487,6 @@ bool EditorFileSystem::_check_missing_imported_files(const String &p_path) { return true; } -static bool _find_project(const String &p_path) { - DirAccess *dir_access = DirAccess::create_for_path(p_path); - bool ret = false; - while (true) { - bool is_dir; - String file = dir_access->get_next(&is_dir); - if (file == "") - break; - if (file.ends_with(".godot")) { - ret = true; - } - } - memdelete(dir_access); - return ret; -} - void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) { List<String> dirs; @@ -525,9 +509,8 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (f.begins_with(".")) //ignore hidden and . / .. continue; - if (_find_project(cd.plus_file(f))) { + if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this continue; - } dirs.push_back(f); @@ -693,35 +676,34 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const while (true) { bool isdir; - String file = da->get_next(&isdir); - if (file == "") + String f = da->get_next(&isdir); + if (f == "") break; if (isdir) { - if (file.begins_with(".")) //ignore hidden and . / .. + if (f.begins_with(".")) //ignore hidden and . / .. continue; - int idx = p_dir->find_dir_index(file); + int idx = p_dir->find_dir_index(f); if (idx == -1) { - if (_find_project(cd.plus_file(file))) { + if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this continue; - } EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory); efd->parent = p_dir; - efd->name = file; + efd->name = f; DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); - d->change_dir(cd.plus_file(file)); + d->change_dir(cd.plus_file(f)); _scan_new_dir(efd, d, p_progress.get_sub(1, 1)); memdelete(d); ItemAction ia; ia.action = ItemAction::ACTION_DIR_ADD; ia.dir = p_dir; - ia.file = file; + ia.file = f; ia.new_dir = efd; scan_actions.push_back(ia); } else { @@ -729,16 +711,16 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } } else { - String ext = file.get_extension().to_lower(); + String ext = f.get_extension().to_lower(); if (!valid_extensions.has(ext)) continue; //invalid - int idx = p_dir->find_file_index(file); + int idx = p_dir->find_file_index(f); if (idx == -1) { //never seen this file, add actition to add it EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); - fi->file = file; + fi->file = f; String path = cd.plus_file(fi->file); fi->modified_time = FileAccess::get_modified_time(path); @@ -749,7 +731,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const ItemAction ia; ia.action = ItemAction::ACTION_FILE_ADD; ia.dir = p_dir; - ia.file = file; + ia.file = f; ia.new_file = fi; scan_actions.push_back(ia); } @@ -757,14 +739,14 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const if (import_extensions.has(ext)) { //if it can be imported, and it was added, it needs to be reimported print_line("REIMPORT: file was not found before, reimport"); - print_line("at dir: " + p_dir->get_path() + " file: " + file); + print_line("at dir: " + p_dir->get_path() + " file: " + f); for (int i = 0; i < p_dir->files.size(); i++) { print_line(itos(i) + ": " + p_dir->files[i]->file); } ItemAction ia; ia.action = ItemAction::ACTION_FILE_REIMPORT; ia.dir = p_dir; - ia.file = file; + ia.file = f; scan_actions.push_back(ia); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1a4a36fa18..f2c04fe785 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -50,19 +50,6 @@ #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); @@ -105,18 +92,18 @@ private: if (mode != MODE_IMPORT) { - if (_find_project_file(d) != "") { + if (d->file_exists("godot.cfg")) { - error->set_text(TTR("Invalid project path, *.godot must not exist.")); + error->set_text(TTR("Invalid project path, godot.cfg must not exist.")); memdelete(d); return ""; } } else { - if (valid_path != "" && _find_project_file(d) == "") { + if (valid_path != "" && !d->file_exists("godot.cfg")) { - error->set_text(TTR("Invalid project path, *.godot must exist.")); + error->set_text(TTR("Invalid project path, godot.cfg must exist.")); memdelete(d); return ""; } @@ -149,7 +136,7 @@ private: String p = p_path; if (mode == MODE_IMPORT) { - if (p.get_extension() == "godot") { + if (p.ends_with("godot.cfg")) { p = p.get_base_dir(); } @@ -175,7 +162,7 @@ private: fdialog->set_mode(FileDialog::MODE_OPEN_FILE); fdialog->clear_filters(); - fdialog->add_filter("*.godot ; " _MKSTR(VERSION_NAME) " Project"); + fdialog->add_filter("godot.cfg ; " _MKSTR(VERSION_NAME) " Project"); } else { fdialog->set_mode(FileDialog::MODE_OPEN_DIR); } @@ -199,9 +186,9 @@ private: } else { if (mode == MODE_NEW) { - FileAccess *f = FileAccess::open(dir.plus_file("/" + project_name->get_text().replace(" ", "_") + ".godot"), FileAccess::WRITE); + FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"), FileAccess::WRITE); if (!f) { - error->set_text(TTR("Couldn't create *.godot project file in project path.")); + error->set_text(TTR("Couldn't create godot.cfg in project path.")); } else { f->store_line("; Engine configuration file."); @@ -754,17 +741,10 @@ void ProjectManager::_load_recent_projects() { continue; String project = _name.get_slice("/", 1); - 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); + String conf = path.plus_file("godot.cfg"); 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); @@ -1026,7 +1006,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.get_extension() == "godot") { + } else if (n == "godot.cfg") { r_projects->push_back(da->get_current_dir()); } n = da->get_next(); @@ -1137,7 +1117,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.get_extension() == "godot") { + if (!dir->current_is_dir() && file.ends_with("godot.cfg")) { confirm = false; } file = dir->get_next(); diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp index 7d9ee91f35..858b9403a7 100644 --- a/editor/project_settings.cpp +++ b/editor/project_settings.cpp @@ -1168,8 +1168,7 @@ void ProjectSettings::_bind_methods() { ProjectSettings::ProjectSettings(EditorData *p_data) { singleton = this; - String project_file = "(" + GlobalConfig::get_singleton()->get_project_file_name() + ")"; - set_title(TTR("Project Settings " + project_file)); + set_title(TTR("Project Settings (godot.cfg)")); set_resizable(true); undo_redo = &p_data->get_undo_redo(); data = p_data; diff --git a/main/main.cpp b/main/main.cpp index 377d15f5f4..ad7ca84d6b 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -129,7 +129,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(VERSION_FULL_NAME " (c) 2008-2017 Juan Linietsky, Ariel Manzur.\n"); OS::get_singleton()->print("Usage: %s [options] [scene]\n", p_binary); OS::get_singleton()->print("Options:\n"); - OS::get_singleton()->print("\t-path [dir] : Path to a game, containing *.godot\n"); + OS::get_singleton()->print("\t-path [dir] : Path to a game, containing godot.cfg\n"); #ifdef TOOLS_ENABLED OS::get_singleton()->print("\t-e,-editor : Bring up the editor instead of running the scene.\n"); #endif @@ -447,23 +447,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else { goto error; } - } else if (I->get().ends_with(".godot")) { - String path; - String file = I->get(); - int sep = MAX(file.find_last("/"), file.find_last("\\")); - if (sep == -1) - path = "."; - else { - path = file.substr(0, sep); - } - if (OS::get_singleton()->set_cwd(path) == OK) { - - } else { - game_path = path; - } -#ifdef TOOLS_ENABLED - editor = true; -#endif } else if (I->get() == "-bp") { // /breakpoints if (I->next()) { @@ -690,7 +673,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph else input_map->load_from_globals(); //keys for game - if (video_driver == "") // specified in *.godot + if (video_driver == "") // specified in godot.cfg video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0))); if (!force_res && use_custom_res && globals->has("display/window/width")) @@ -742,7 +725,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph /* Determine Video Driver */ - if (audio_driver == "") { // specified in *.godot + if (audio_driver == "") { // specified in godot.cfg audio_driver = GLOBAL_DEF("audio/driver", OS::get_singleton()->get_audio_driver_name(0)); } |