summaryrefslogtreecommitdiff
path: root/core/project_settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/project_settings.cpp')
-rw-r--r--core/project_settings.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 407bb78375..e325c828b8 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,8 +43,6 @@
#include <zlib.h>
-#define FORMAT_VERSION 4
-
ProjectSettings *ProjectSettings::singleton = NULL;
ProjectSettings *ProjectSettings::get_singleton() {
@@ -271,9 +269,9 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack) {
return true;
}
-void ProjectSettings::_convert_to_last_version() {
- if (!has_setting("config_version") || (int)get_setting("config_version") <= 3) {
+void ProjectSettings::_convert_to_last_version(int p_from_version) {
+ if (p_from_version <= 3) {
// Converts the actions from array to dictionary (array of events to dictionary with deadzone + events)
for (Map<StringName, ProjectSettings::VariantContainer>::Element *E = props.front(); E; E = E->next()) {
Variant value = E->get().variant;
@@ -307,7 +305,7 @@ void ProjectSettings::_convert_to_last_version() {
* If a project file is found, load it or fail.
* If nothing was found, error out.
*/
-Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
+Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
// If looking for files in a network client, use it directly
@@ -396,7 +394,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo
// Optional, we don't mind if it fails
_load_settings_text("res://override.cfg");
}
-
return err;
}
@@ -443,13 +440,21 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo
if (resource_path.length() && resource_path[resource_path.length() - 1] == '/')
resource_path = resource_path.substr(0, resource_path.length() - 1); // chop end
- // If we're loading a project.godot from source code, we can operate some
- // ProjectSettings conversions if need be.
- _convert_to_last_version();
-
return OK;
}
+Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
+ Error err = _setup(p_path, p_main_pack, p_upwards);
+ if (err == OK) {
+ String custom_settings = GLOBAL_DEF("application/config/project_settings_override", "");
+ if (custom_settings != "") {
+ _load_settings_text(custom_settings);
+ }
+ }
+
+ return err;
+}
+
bool ProjectSettings::has_setting(String p_var) const {
_THREAD_SAFE_METHOD_
@@ -525,8 +530,8 @@ Error ProjectSettings::_load_settings_text(const String p_path) {
int lines = 0;
String error_text;
-
String section;
+ int config_version = 0;
while (true) {
@@ -537,6 +542,9 @@ Error ProjectSettings::_load_settings_text(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);
+ // If we're loading a project.godot from source code, we can operate some
+ // ProjectSettings conversions if need be.
+ _convert_to_last_version(config_version);
return OK;
} else if (err != OK) {
ERR_PRINTS("Error parsing " + p_path + " at line " + itos(lines) + ": " + error_text + " File might be corrupted.");
@@ -546,13 +554,13 @@ Error ProjectSettings::_load_settings_text(const String p_path) {
if (assign != String()) {
if (section == String() && assign == "config_version") {
- int config_version = value;
- if (config_version > FORMAT_VERSION) {
+ config_version = value;
+ if (config_version > CONFIG_VERSION) {
memdelete(f);
- ERR_FAIL_COND_V(config_version > FORMAT_VERSION, ERR_FILE_CANT_OPEN);
+ ERR_EXPLAIN(vformat("Can't open project at '%s', its `config_version` (%d) is from a more recent and incompatible version of the engine. Expected config version: %d.", p_path, config_version, CONFIG_VERSION));
+ ERR_FAIL_COND_V(config_version > CONFIG_VERSION, ERR_FILE_CANT_OPEN);
}
} else {
- // config_version is checked and dropped
if (section == String()) {
set(assign, value);
} else {
@@ -728,7 +736,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
file->store_line("; param=value ; assign values to parameters");
file->store_line("");
- file->store_string("config_version=" + itos(FORMAT_VERSION) + "\n");
+ file->store_string("config_version=" + itos(CONFIG_VERSION) + "\n");
if (p_custom_features != String())
file->store_string("custom_features=\"" + p_custom_features + "\"\n");
file->store_string("\n");
@@ -995,6 +1003,7 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("application/run/disable_stderr", false);
GLOBAL_DEF("application/config/use_custom_user_dir", false);
GLOBAL_DEF("application/config/custom_user_dir_name", "");
+ GLOBAL_DEF("application/config/project_settings_override", "");
action = Dictionary();
action["deadzone"] = Variant(0.5f);