Rename project file to "project.godot"

Slimmed down variant from the reverted #8375.
The rationale behind the name change is to give Godot's project file a unique
extension (".godot") that can be registered on the OS to be associated with
the Godot binary (OS registration not implemented here).

This PR also adds the possibility to start the game or editor if launched
with the project.godot passed as argument, which paves the way for allowing
a similar behaviour on a double-click in the OS file manager (code originally
by @Hinsbart).

Closes #6915.
This commit is contained in:
Rémi Verschelde 2017-05-01 17:44:52 +02:00
parent de7eba887e
commit 7ce8342ac5
11 changed files with 62 additions and 45 deletions

View file

@ -242,7 +242,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
if (FileAccessNetworkClient::get_singleton()) {
if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) {
if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
_load_settings("res://override.cfg");
}
@ -259,7 +259,7 @@ 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);
if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) {
if (_load_settings("res://project.godot") == 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"));
}
@ -272,7 +272,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
if (_load_resource_pack(exec_path.get_basename() + ".pck")) {
if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) {
if (_load_settings("res://project.godot") == 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"));
}
@ -293,14 +293,14 @@ 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
if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) {
if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
_load_settings("res://override.cfg");
}
return OK;
}
//Nothing was found, try to find a godot.cfg somewhere!
//Nothing was found, try to find a project.godot somewhere!
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
ERR_FAIL_COND_V(!d, ERR_CANT_CREATE);
@ -314,7 +314,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
while (true) {
//try to load settings in ascending through dirs shape!
if (_load_settings(current_dir + "/godot.cfg") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) {
if (_load_settings(current_dir + "/project.godot") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) {
_load_settings(current_dir + "/override.cfg");
candidate = current_dir;
@ -474,7 +474,7 @@ void GlobalConfig::clear(const String &p_name) {
Error GlobalConfig::save() {
return save_custom(get_resource_path() + "/godot.cfg");
return save_custom(get_resource_path() + "/project.godot");
}
Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom) {
@ -483,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("Coudln't save godot.cfb at " + p_file);
ERR_EXPLAIN("Couldn't save godot.cfb at " + p_file);
ERR_FAIL_COND_V(err, err)
}
@ -548,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("Coudln't save godot.cfg - " + p_file);
ERR_EXPLAIN("Couldn't save project.godot - " + p_file);
ERR_FAIL_COND_V(err, err)
}
@ -674,7 +674,7 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom,
Error err = file->open(dst_file,FileAccess::WRITE);
if (err) {
memdelete(file);
ERR_EXPLAIN("Coudln't save godot.cfg");
ERR_EXPLAIN("Couldn't save project.godot");
ERR_FAIL_COND_V(err,err)
}

View file

@ -409,7 +409,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings,
Token token;
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
r_err_str = "Expected '(' in old-style godot.cfg construct";
r_err_str = "Expected '(' in old-style project.godot construct";
return ERR_PARSE_ERROR;
}
@ -420,7 +420,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings,
CharType c = p_stream->get_char();
if (p_stream->is_eof()) {
r_err_str = "Unexpected EOF while parsing old-style godot.cfg construct";
r_err_str = "Unexpected EOF while parsing old-style project.godot construct";
return ERR_PARSE_ERROR;
}
@ -1273,7 +1273,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = arr;
return OK;
} else if (id == "key") { // compatibility with godot.cfg
} else if (id == "key") { // compatibility with project.godot
Vector<String> params;
Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
@ -1309,7 +1309,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = ie;
return OK;
} else if (id == "mbutton") { // compatibility with godot.cfg
} else if (id == "mbutton") { // compatibility with project.godot
Vector<String> params;
Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
@ -1324,7 +1324,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = ie;
return OK;
} else if (id == "jbutton") { // compatibility with godot.cfg
} else if (id == "jbutton") { // compatibility with project.godot
Vector<String> params;
Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
@ -1339,7 +1339,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = ie;
return OK;
} else if (id == "jaxis") { // compatibility with godot.cfg
} else if (id == "jaxis") { // compatibility with project.godot
Vector<String> params;
Error err = _parse_enginecfg(p_stream, params, line, r_err_str);
@ -1357,19 +1357,19 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = ie;
return OK;
} else if (id == "img") { // compatibility with godot.cfg
} else if (id == "img") { // compatibility with project.godot
Token token; // FIXME: no need for this declaration? the first argument in line 509 is a Token& token.
get_token(p_stream, token, line, r_err_str);
if (token.type != TK_PARENTHESIS_OPEN) {
r_err_str = "Expected '(' in old-style godot.cfg construct";
r_err_str = "Expected '(' in old-style project.godot construct";
return ERR_PARSE_ERROR;
}
while (true) {
CharType c = p_stream->get_char();
if (p_stream->is_eof()) {
r_err_str = "Unexpected EOF in old style godot.cfg img()";
r_err_str = "Unexpected EOF in old style project.godot img()";
return ERR_PARSE_ERROR;
}
if (c == ')')