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.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 20d91e7940..ac4a4b7d15 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -42,7 +42,7 @@
#include "variant_parser.h"
#include <zlib.h>
-#define FORMAT_VERSION 3
+#define FORMAT_VERSION 4
ProjectSettings *ProjectSettings::singleton = NULL;
@@ -262,6 +262,23 @@ 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) {
+
+ // 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;
+ if (String(E->key()).begins_with("input/") && value.get_type() == Variant::ARRAY) {
+ Array array = value;
+ Dictionary action;
+ action["deadzone"] = Variant(0.5f);
+ action["events"] = array;
+ E->get().variant = action;
+ }
+ }
+ }
+}
+
Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
//If looking for files in network, just use network!
@@ -390,6 +407,8 @@ 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
+ _convert_to_last_version();
+
return OK;
}
@@ -797,12 +816,11 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) {
Variant ret;
- if (ProjectSettings::get_singleton()->has_setting(p_var)) {
- ret = ProjectSettings::get_singleton()->get(p_var);
- } else {
+ if (!ProjectSettings::get_singleton()->has_setting(p_var)) {
ProjectSettings::get_singleton()->set(p_var, p_default);
- ret = p_default;
}
+ ret = ProjectSettings::get_singleton()->get(p_var);
+
ProjectSettings::get_singleton()->set_initial_value(p_var, p_default);
ProjectSettings::get_singleton()->set_builtin_order(p_var);
return ret;