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 /core/global_config.cpp | |
parent | abe09919bf5664353bea904116c6bc5bb856cd7f (diff) |
Revert "Use .godot as file extension for project files."
Diffstat (limited to 'core/global_config.cpp')
-rw-r--r-- | core/global_config.cpp | 72 |
1 files changed, 14 insertions, 58 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); |