summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-07-19 17:00:46 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-07-19 17:06:03 -0300
commit25678b1876816b9ccb14b2c92aef62f3b009f88f (patch)
tree189f082d788f78e16f620b056d21249118883fc5 /core
parent89588d43349e496a9e05756d42ae87323d31269e (diff)
-Renamed GlobalConfig to ProjectSettings, makes more sense.
-Added system for feature overrides, it's pretty cool :)
Diffstat (limited to 'core')
-rw-r--r--core/SCsub6
-rw-r--r--core/bind/core_bind.cpp4
-rw-r--r--core/core_string_names.cpp1
-rw-r--r--core/core_string_names.h1
-rw-r--r--core/input_map.cpp6
-rw-r--r--core/io/compression.cpp2
-rw-r--r--core/io/file_access_memory.cpp6
-rw-r--r--core/io/file_access_network.cpp2
-rw-r--r--core/io/packet_peer.cpp2
-rw-r--r--core/io/resource_format_binary.cpp16
-rw-r--r--core/io/resource_import.cpp7
-rw-r--r--core/io/resource_loader.cpp14
-rw-r--r--core/io/resource_saver.cpp4
-rw-r--r--core/message_queue.cpp2
-rw-r--r--core/os/dir_access.cpp8
-rw-r--r--core/os/file_access.cpp6
-rw-r--r--core/os/input.cpp4
-rw-r--r--core/os/input_event.cpp2
-rw-r--r--core/os/os.cpp24
-rw-r--r--core/os/os.h3
-rw-r--r--core/project_settings.cpp (renamed from core/global_config.cpp)258
-rw-r--r--core/project_settings.h (renamed from core/global_config.h)30
-rw-r--r--core/register_core_types.cpp26
-rw-r--r--core/script_debugger_remote.cpp8
-rw-r--r--core/translation.cpp8
25 files changed, 272 insertions, 178 deletions
diff --git a/core/SCsub b/core/SCsub
index 02abaa2bb6..4c541d7269 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -14,9 +14,9 @@ for x in env.global_defaults:
gd_inc += '#include "platform/' + x + '/globals/global_defaults.h"\n'
gd_call += "\tregister_" + x + "_global_defaults();\n"
-gd_cpp = '#include "global_config.h"\n'
+gd_cpp = '#include "project_settings.h"\n'
gd_cpp += gd_inc
-gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n"
+gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n"
f = open("global_defaults.gen.cpp", "wb")
f.write(gd_cpp)
@@ -48,7 +48,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
print("Invalid AES256 encryption key, not 64 bits hex: " + e)
f = open("script_encryption_key.gen.cpp", "wb")
-f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
+f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 694e077f48..69d0ba7851 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "core_bind.h"
-#include "core/global_config.h"
+#include "core/project_settings.h"
#include "geometry.h"
#include "io/file_access_compressed.h"
#include "io/file_access_encrypted.h"
@@ -106,7 +106,7 @@ PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {
bool _ResourceLoader::has(const String &p_path) {
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
};
diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp
index 0ed44b0cb7..2adc15447a 100644
--- a/core/core_string_names.cpp
+++ b/core/core_string_names.cpp
@@ -44,6 +44,7 @@ CoreStringNames::CoreStringNames() {
_iter_next = StaticCString::create("_iter_next");
_iter_get = StaticCString::create("_iter_get");
get_rid = StaticCString::create("get_rid");
+ _custom_features = StaticCString::create("_custom_features");
#ifdef TOOLS_ENABLED
_sections_unfolded = StaticCString::create("_sections_unfolded");
#endif
diff --git a/core/core_string_names.h b/core/core_string_names.h
index 4b4f87a8f0..501185f5b7 100644
--- a/core/core_string_names.h
+++ b/core/core_string_names.h
@@ -61,6 +61,7 @@ public:
StringName _iter_next;
StringName _iter_get;
StringName get_rid;
+ StringName _custom_features;
#ifdef TOOLS_ENABLED
StringName _sections_unfolded;
#endif
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 422ebd2956..1abe019167 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "input_map.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "os/keyboard.h"
InputMap *InputMap::singleton = NULL;
@@ -189,7 +189,7 @@ void InputMap::load_from_globals() {
input_map.clear();
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
@@ -201,7 +201,7 @@ void InputMap::load_from_globals() {
add_action(name);
- Array va = GlobalConfig::get_singleton()->get(pi.name);
+ Array va = ProjectSettings::get_singleton()->get(pi.name);
for (int i = 0; i < va.size(); i++) {
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index b0f5448b6c..ca35ece8f5 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "compression.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "os/copymem.h"
#include "zip_io.h"
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index 32ea4ce096..2197b187eb 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "file_access_memory.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "map.h"
#include "os/copymem.h"
#include "os/dir_access.h"
@@ -43,8 +43,8 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
}
String name;
- if (GlobalConfig::get_singleton())
- name = GlobalConfig::get_singleton()->globalize_path(p_name);
+ if (ProjectSettings::get_singleton())
+ name = ProjectSettings::get_singleton()->globalize_path(p_name);
else
name = p_name;
//name = DirAccess::normalize_path(name);
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 50e78899fb..46457d1425 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_access_network.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/ip.h"
#include "marshalls.h"
#include "os/os.h"
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 93682e6b8a..81446a3886 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "packet_peer.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/marshalls.h"
/* helpers / binders */
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 728cd5d4ff..602cbe6f30 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_binary.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "image.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
@@ -317,7 +317,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
if (remaps.find(path)) {
@@ -346,7 +346,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
RES res = ResourceLoader::load(path, type);
@@ -1017,7 +1017,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
@@ -1065,7 +1065,7 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<Str
ERR_FAIL_COND(!f);
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f, p_dependencies, p_add_types);
@@ -1152,7 +1152,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
ria->remaps = p_map;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
@@ -1281,7 +1281,7 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
@@ -1984,7 +1984,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Error ResourceFormatSaverBinary::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ResourceFormatSaverBinaryInstance saver;
return saver.save(local_path, p_resource, p_flags);
}
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index ffb27bc26a..61da4f3350 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -49,6 +49,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
int lines = 0;
String error_text;
+ bool path_found = false; //first match must have priority
while (true) {
assign = Variant();
@@ -66,14 +67,16 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
}
if (assign != String()) {
- if (assign.begins_with("path.") && r_path_and_type.path == String()) {
+ if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) {
String feature = assign.get_slicec('.', 1);
if (OS::get_singleton()->check_feature_support(feature)) {
r_path_and_type.path = value;
+ path_found = true; //first match must have priority
}
- } else if (assign == "path") {
+ } else if (!path_found && assign == "path") {
r_path_and_type.path = value;
+ path_found = true; //first match must have priority
} else if (assign == "type") {
r_path_and_type.type = value;
}
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index bb7be38413..57acb6c754 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_loader.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/resource_import.h"
#include "os/file_access.h"
#include "os/os.h"
@@ -166,7 +166,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -233,7 +233,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -304,7 +304,7 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
if (path.is_rel_path())
local_path = "res://" + path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(path);
+ local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
@@ -327,7 +327,7 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
if (path.is_rel_path())
local_path = "res://" + path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(path);
+ local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
@@ -350,7 +350,7 @@ String ResourceLoader::get_resource_type(const String &p_path) {
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
for (int i = 0; i < loader_count; i++) {
@@ -430,7 +430,7 @@ void ResourceLoader::reload_translation_remaps() {
void ResourceLoader::load_translation_remaps() {
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 8592346a72..58913b80cc 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_saver.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "os/file_access.h"
#include "resource_loader.h"
#include "script_language.h"
@@ -64,7 +64,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
String old_path = p_resource->get_path();
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
RES rwcopy = p_resource;
if (p_flags & FLAG_CHANGE_PATH)
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index 1c980a56e3..93d0b0730a 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "message_queue.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "script_language.h"
MessageQueue *MessageQueue::singleton = NULL;
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index aa03b764ef..484942bad5 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dir_access.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "os/file_access.h"
#include "os/memory.h"
#include "os/os.h"
@@ -37,7 +37,7 @@ String DirAccess::_get_root_path() const {
switch (_access_type) {
- case ACCESS_RESOURCES: return GlobalConfig::get_singleton()->get_resource_path();
+ case ACCESS_RESOURCES: return ProjectSettings::get_singleton()->get_resource_path();
case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir();
default: return "";
}
@@ -200,10 +200,10 @@ String DirAccess::fix_path(String p_path) const {
case ACCESS_RESOURCES: {
- if (GlobalConfig::get_singleton()) {
+ if (ProjectSettings::get_singleton()) {
if (p_path.begins_with("res://")) {
- String resource_path = GlobalConfig::get_singleton()->get_resource_path();
+ String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
return p_path.replace_first("res:/", resource_path);
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 805b66b983..2bb676381f 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -31,7 +31,7 @@
#include "core/io/file_access_pack.h"
#include "core/io/marshalls.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "os/os.h"
#include "thirdparty/misc/md5.h"
@@ -135,10 +135,10 @@ String FileAccess::fix_path(const String &p_path) const {
case ACCESS_RESOURCES: {
- if (GlobalConfig::get_singleton()) {
+ if (ProjectSettings::get_singleton()) {
if (r_path.begins_with("res://")) {
- String resource_path = GlobalConfig::get_singleton()->get_resource_path();
+ String resource_path = ProjectSettings::get_singleton()->get_resource_path();
if (resource_path != "") {
return r_path.replace("res:/", resource_path);
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 587340fe91..18d644668c 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "input.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "input_map.h"
#include "os/os.h"
Input *Input::singleton = NULL;
@@ -101,7 +101,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released")) {
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 1c575aa970..0a07b6b2b7 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -103,7 +103,7 @@ bool InputEvent::is_action_type() const {
if (String(p_method) == "is_action" && p_argidx == 0) {
List<PropertyInfo> pinfo;
- GlobalConfig::get_singleton()->get_property_list(&pinfo);
+ ProjectSettings::get_singleton()->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
const PropertyInfo &pi = E->get();
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 48463722cf..5a9766891d 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -30,9 +30,9 @@
#include "os.h"
#include "dir_access.h"
-#include "global_config.h"
#include "input.h"
#include "os/file_access.h"
+#include "project_settings.h"
#include <stdarg.h>
@@ -260,7 +260,7 @@ String OS::get_locale() const {
String OS::get_resource_dir() const {
- return GlobalConfig::get_singleton()->get_resource_path();
+ return ProjectSettings::get_singleton()->get_resource_path();
}
String OS::get_system_dir(SystemDir p_dir) const {
@@ -269,7 +269,7 @@ String OS::get_system_dir(SystemDir p_dir) const {
}
String OS::get_safe_application_name() const {
- String an = GlobalConfig::get_singleton()->get("application/config/name");
+ String an = ProjectSettings::get_singleton()->get("application/config/name");
Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" ");
for (int i = 0; i < invalid_char.size(); i++) {
an = an.replace(invalid_char[i], "-");
@@ -494,6 +494,24 @@ int OS::get_power_percent_left() {
return -1;
}
+bool OS::check_feature_support(const String &p_feature) {
+
+ if (p_feature == get_name())
+ return true;
+#ifdef DEBUG_ENABLED
+ if (p_feature == "debug")
+ return true;
+#else
+ if (p_feature == "release")
+ return true;
+#endif
+
+ if (_check_internal_feature_support(p_feature))
+ return true;
+
+ return false;
+}
+
OS::OS() {
last_error = NULL;
singleton = this;
diff --git a/core/os/os.h b/core/os/os.h
index cafd1f4e14..362fec8a9e 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -109,6 +109,7 @@ protected:
virtual void set_cmdline(const char *p_execpath, const List<String> &p_args);
void _ensure_data_dir();
+ virtual bool _check_internal_feature_support(const String &p_feature) = 0;
public:
typedef int64_t ProcessID;
@@ -408,7 +409,7 @@ public:
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
- virtual bool check_feature_support(const String &p_feature) = 0;
+ bool check_feature_support(const String &p_feature);
bool is_hidpi_allowed() const { return _allow_hidpi; }
OS();
diff --git a/core/global_config.cpp b/core/project_settings.cpp
index 76572df2a7..1a0a50a10f 100644
--- a/core/global_config.cpp
+++ b/core/project_settings.cpp
@@ -27,9 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "global_config.h"
+#include "project_settings.h"
#include "bind/core_bind.h"
+#include "core_string_names.h"
#include "io/file_access_network.h"
#include "io/file_access_pack.h"
#include "io/marshalls.h"
@@ -38,24 +39,23 @@
#include "os/keyboard.h"
#include "os/os.h"
#include "variant_parser.h"
-
#include <zlib.h>
#define FORMAT_VERSION 3
-GlobalConfig *GlobalConfig::singleton = NULL;
+ProjectSettings *ProjectSettings::singleton = NULL;
-GlobalConfig *GlobalConfig::get_singleton() {
+ProjectSettings *ProjectSettings::get_singleton() {
return singleton;
}
-String GlobalConfig::get_resource_path() const {
+String ProjectSettings::get_resource_path() const {
return resource_path;
};
-String GlobalConfig::localize_path(const String &p_path) const {
+String ProjectSettings::localize_path(const String &p_path) const {
if (resource_path == "")
return p_path; //not initialied yet
@@ -99,13 +99,13 @@ String GlobalConfig::localize_path(const String &p_path) const {
};
}
-void GlobalConfig::set_initial_value(const String &p_name, const Variant &p_value) {
+void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_value) {
ERR_FAIL_COND(!props.has(p_name));
props[p_name].initial = p_value;
}
-String GlobalConfig::globalize_path(const String &p_path) const {
+String ProjectSettings::globalize_path(const String &p_path) const {
if (p_path.begins_with("res://")) {
@@ -119,13 +119,44 @@ String GlobalConfig::globalize_path(const String &p_path) const {
return p_path;
}
-bool GlobalConfig::_set(const StringName &p_name, const Variant &p_value) {
+bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
_THREAD_SAFE_METHOD_
if (p_value.get_type() == Variant::NIL)
props.erase(p_name);
else {
+
+ if (p_name == CoreStringNames::get_singleton()->_custom_features) {
+ Vector<String> custom_feature_array = p_value;
+ for (int i = 0; i < custom_feature_array.size(); i++) {
+
+ custom_features.insert(custom_feature_array[i]);
+ }
+ return true;
+ }
+
+ if (!disable_feature_overrides) {
+ int dot = p_name.operator String().find(".");
+ if (dot != -1) {
+ Vector<String> s = p_name.operator String().split(".");
+
+ bool override_valid = false;
+ for (int i = 1; i < s.size(); i++) {
+ String feature = s[i].strip_edges();
+ if (OS::get_singleton()->check_feature_support(feature) || custom_features.has(feature)) {
+ override_valid = true;
+ break;
+ }
+ }
+
+ if (override_valid) {
+
+ feature_overrides[s[0]] = p_name;
+ }
+ }
+ }
+
if (props.has(p_name)) {
if (!props[p_name].overrided)
props[p_name].variant = p_value;
@@ -137,15 +168,19 @@ bool GlobalConfig::_set(const StringName &p_name, const Variant &p_value) {
return true;
}
-bool GlobalConfig::_get(const StringName &p_name, Variant &r_ret) const {
+bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const {
_THREAD_SAFE_METHOD_
- if (!props.has(p_name)) {
- print_line("WARNING: not found: " + String(p_name));
+ StringName name = p_name;
+ if (!disable_feature_overrides && feature_overrides.has(name)) {
+ name = feature_overrides[name];
+ }
+ if (!props.has(name)) {
+ print_line("WARNING: not found: " + String(name));
return false;
}
- r_ret = props[p_name].variant;
+ r_ret = props[name].variant;
return true;
}
@@ -159,7 +194,7 @@ struct _VCSort {
bool operator<(const _VCSort &p_vcs) const { return order == p_vcs.order ? name < p_vcs.name : order < p_vcs.order; }
};
-void GlobalConfig::_get_property_list(List<PropertyInfo> *p_list) const {
+void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
_THREAD_SAFE_METHOD_
@@ -186,8 +221,13 @@ void GlobalConfig::_get_property_list(List<PropertyInfo> *p_list) const {
for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) {
- if (custom_prop_info.has(E->get().name)) {
- PropertyInfo pi = custom_prop_info[E->get().name];
+ String prop_info_name = E->get().name;
+ int dot = prop_info_name.find(".");
+ if (dot != -1)
+ prop_info_name = prop_info_name.substr(0, dot);
+
+ if (custom_prop_info.has(prop_info_name)) {
+ PropertyInfo pi = custom_prop_info[prop_info_name];
pi.name = E->get().name;
pi.usage = E->get().flags;
p_list->push_back(pi);
@@ -196,7 +236,7 @@ void GlobalConfig::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-bool GlobalConfig::_load_resource_pack(const String &p_pack) {
+bool ProjectSettings::_load_resource_pack(const String &p_pack) {
if (PackedData::get_singleton()->is_disabled())
return false;
@@ -213,13 +253,13 @@ bool GlobalConfig::_load_resource_pack(const String &p_pack) {
return true;
}
-Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
+Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
//If looking for files in network, just use network!
if (FileAccessNetworkClient::get_singleton()) {
- if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
_load_settings("res://override.cfg");
}
@@ -236,7 +276,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://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
//load override from location of the main pack
_load_settings(p_main_pack.get_base_dir().plus_file("override.cfg"));
}
@@ -249,7 +289,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://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
//load override from location of executable
_load_settings(exec_path.get_base_dir().plus_file("override.cfg"));
}
@@ -270,7 +310,7 @@ 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://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) {
+ if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
_load_settings("res://override.cfg");
}
@@ -291,7 +331,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 + "/project.godot") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) {
+ if (_load_settings(current_dir + "/project.godot") == OK || _load_settings_binary(current_dir + "/project.binary") == OK) {
_load_settings(current_dir + "/override.cfg");
candidate = current_dir;
@@ -318,19 +358,19 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) {
return OK;
}
-bool GlobalConfig::has(String p_var) const {
+bool ProjectSettings::has(String p_var) const {
_THREAD_SAFE_METHOD_
return props.has(p_var);
}
-void GlobalConfig::set_registering_order(bool p_enable) {
+void ProjectSettings::set_registering_order(bool p_enable) {
registering_order = p_enable;
}
-Error GlobalConfig::_load_settings_binary(const String p_path) {
+Error ProjectSettings::_load_settings_binary(const String p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -343,7 +383,7 @@ Error GlobalConfig::_load_settings_binary(const String p_path) {
if (hdr[0] != 'E' || hdr[1] != 'C' || hdr[2] != 'F' || hdr[3] != 'G') {
memdelete(f);
- ERR_EXPLAIN("Corrupted header in binary godot.cfb (not ECFG)");
+ ERR_EXPLAIN("Corrupted header in binary project.binary (not ECFG)");
ERR_FAIL_V(ERR_FILE_CORRUPT;)
}
@@ -372,7 +412,7 @@ Error GlobalConfig::_load_settings_binary(const String p_path) {
return OK;
}
-Error GlobalConfig::_load_settings(const String p_path) {
+Error ProjectSettings::_load_settings(const String p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -403,7 +443,7 @@ Error GlobalConfig::_load_settings(const String p_path) {
memdelete(f);
return OK;
} else if (err != OK) {
- ERR_PRINTS("GlobalConfig::load - " + p_path + ":" + itos(lines) + " error: " + error_text);
+ ERR_PRINTS("ProjectSettings::load - " + p_path + ":" + itos(lines) + " error: " + error_text);
memdelete(f);
return err;
}
@@ -427,19 +467,19 @@ Error GlobalConfig::_load_settings(const String p_path) {
return OK;
}
-int GlobalConfig::get_order(const String &p_name) const {
+int ProjectSettings::get_order(const String &p_name) const {
ERR_FAIL_COND_V(!props.has(p_name), -1);
return props[p_name].order;
}
-void GlobalConfig::set_order(const String &p_name, int p_order) {
+void ProjectSettings::set_order(const String &p_name, int p_order) {
ERR_FAIL_COND(!props.has(p_name));
props[p_name].order = p_order;
}
-void GlobalConfig::set_builtin_order(const String &p_name) {
+void ProjectSettings::set_builtin_order(const String &p_name) {
ERR_FAIL_COND(!props.has(p_name));
if (props[p_name].order >= NO_BUILTIN_ORDER_BASE) {
@@ -447,24 +487,24 @@ void GlobalConfig::set_builtin_order(const String &p_name) {
}
}
-void GlobalConfig::clear(const String &p_name) {
+void ProjectSettings::clear(const String &p_name) {
ERR_FAIL_COND(!props.has(p_name));
props.erase(p_name);
}
-Error GlobalConfig::save() {
+Error ProjectSettings::save() {
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) {
+Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom, const String &p_custom_features) {
Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
- ERR_EXPLAIN("Couldn't save godot.cfb at " + p_file);
+ ERR_EXPLAIN("Couldn't save project.binary at " + p_file);
ERR_FAIL_COND_V(err, err)
}
@@ -481,7 +521,34 @@ Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String
}
}
- file->store_32(count); //store how many properties are saved
+ if (p_custom_features != String()) {
+ file->store_32(count + 1);
+ //store how many properties are saved, add one for custom featuers, which must always go first
+ String key = CoreStringNames::get_singleton()->_custom_features;
+ file->store_32(key.length());
+ file->store_string(key);
+
+ int len;
+ Error err = encode_variant(p_custom_features, NULL, len);
+ if (err != OK) {
+ memdelete(file);
+ ERR_FAIL_V(err);
+ }
+
+ Vector<uint8_t> buff;
+ buff.resize(len);
+
+ err = encode_variant(p_custom_features, &buff[0], len);
+ if (err != OK) {
+ memdelete(file);
+ ERR_FAIL_V(err);
+ }
+ file->store_32(len);
+ file->store_buffer(buff.ptr(), buff.size());
+
+ } else {
+ file->store_32(count); //store how many properties are saved
+ }
for (Map<String, List<String> >::Element *E = props.front(); E; E = E->next()) {
@@ -523,7 +590,7 @@ Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String
return OK;
}
-Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom) {
+Error ProjectSettings::_save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom, const String &p_custom_features) {
Error err;
FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
@@ -534,6 +601,8 @@ Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String,
}
file->store_string("config_version=" + itos(FORMAT_VERSION) + "\n");
+ if (p_custom_features != String())
+ file->store_string("_custom_featores=\"" + p_custom_features + "\"\n");
for (Map<String, List<String> >::Element *E = props.front(); E; E = E->next()) {
@@ -565,12 +634,12 @@ Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String,
return OK;
}
-Error GlobalConfig::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array?
+Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other params as dictionary and array?
return save_custom(p_file);
};
-Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom, const Set<String> &p_ignore_masks) {
+Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector<String> &p_custom_features) {
ERR_FAIL_COND_V(p_path == "", ERR_INVALID_PARAMETER);
@@ -586,19 +655,6 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom,
if (p_custom.has(G->key()))
continue;
- bool discard = false;
-
- for (const Set<String>::Element *E = p_ignore_masks.front(); E; E = E->next()) {
-
- if (String(G->key()).match(E->get())) {
- discard = true;
- break;
- }
- }
-
- if (discard)
- continue;
-
_VCSort vc;
vc.name = G->key(); //*k;
vc.order = v->order;
@@ -639,10 +695,20 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom,
props[category].push_back(name);
}
+ String custom_features;
+
+ for (int i = 0; i < p_custom_features.size(); i++) {
+ if (i > 0)
+ custom_features += ",";
+
+ String f = p_custom_features[i].strip_edges().replace("\"", "");
+ custom_features += f;
+ }
+
if (p_path.ends_with(".godot"))
- return _save_settings_text(p_path, props, p_custom);
- else if (p_path.ends_with(".cfb"))
- return _save_settings_binary(p_path, props, p_custom);
+ return _save_settings_text(p_path, props, p_custom, custom_features);
+ else if (p_path.ends_with(".binary"))
+ return _save_settings_binary(p_path, props, p_custom, custom_features);
else {
ERR_EXPLAIN("Unknown config file format: " + p_path);
@@ -695,24 +761,24 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom,
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) {
Variant ret;
- if (GlobalConfig::get_singleton()->has(p_var)) {
- ret = GlobalConfig::get_singleton()->get(p_var);
+ if (ProjectSettings::get_singleton()->has(p_var)) {
+ ret = ProjectSettings::get_singleton()->get(p_var);
} else {
- GlobalConfig::get_singleton()->set(p_var, p_default);
+ ProjectSettings::get_singleton()->set(p_var, p_default);
ret = p_default;
}
- GlobalConfig::get_singleton()->set_initial_value(p_var, p_default);
- GlobalConfig::get_singleton()->set_builtin_order(p_var);
+ ProjectSettings::get_singleton()->set_initial_value(p_var, p_default);
+ ProjectSettings::get_singleton()->set_builtin_order(p_var);
return ret;
}
-void GlobalConfig::add_singleton(const Singleton &p_singleton) {
+void ProjectSettings::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
singleton_ptrs[p_singleton.name] = p_singleton.ptr;
}
-Object *GlobalConfig::get_singleton_object(const String &p_name) const {
+Object *ProjectSettings::get_singleton_object(const String &p_name) const {
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
if (!E)
@@ -721,21 +787,21 @@ Object *GlobalConfig::get_singleton_object(const String &p_name) const {
return E->get();
};
-bool GlobalConfig::has_singleton(const String &p_name) const {
+bool ProjectSettings::has_singleton(const String &p_name) const {
return get_singleton_object(p_name) != NULL;
};
-void GlobalConfig::get_singletons(List<Singleton> *p_singletons) {
+void ProjectSettings::get_singletons(List<Singleton> *p_singletons) {
for (List<Singleton>::Element *E = singletons.front(); E; E = E->next())
p_singletons->push_back(E->get());
}
-Vector<String> GlobalConfig::get_optimizer_presets() const {
+Vector<String> ProjectSettings::get_optimizer_presets() const {
List<PropertyInfo> pi;
- GlobalConfig::get_singleton()->get_property_list(&pi);
+ ProjectSettings::get_singleton()->get_property_list(&pi);
Vector<String> names;
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
@@ -750,7 +816,7 @@ Vector<String> GlobalConfig::get_optimizer_presets() const {
return names;
}
-void GlobalConfig::_add_property_info_bind(const Dictionary &p_info) {
+void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) {
ERR_FAIL_COND(!p_info.has("name"));
ERR_FAIL_COND(!p_info.has("type"));
@@ -769,24 +835,24 @@ void GlobalConfig::_add_property_info_bind(const Dictionary &p_info) {
set_custom_property_info(pinfo.name, pinfo);
}
-void GlobalConfig::set_custom_property_info(const String &p_prop, const PropertyInfo &p_info) {
+void ProjectSettings::set_custom_property_info(const String &p_prop, const PropertyInfo &p_info) {
ERR_FAIL_COND(!props.has(p_prop));
custom_prop_info[p_prop] = p_info;
custom_prop_info[p_prop].name = p_prop;
}
-void GlobalConfig::set_disable_platform_override(bool p_disable) {
+void ProjectSettings::set_disable_feature_overrides(bool p_disable) {
- disable_platform_override = p_disable;
+ disable_feature_overrides = p_disable;
}
-bool GlobalConfig::is_using_datapack() const {
+bool ProjectSettings::is_using_datapack() const {
return using_datapack;
}
-bool GlobalConfig::property_can_revert(const String &p_name) {
+bool ProjectSettings::property_can_revert(const String &p_name) {
if (!props.has(p_name))
return false;
@@ -794,7 +860,7 @@ bool GlobalConfig::property_can_revert(const String &p_name) {
return props[p_name].initial != props[p_name].variant;
}
-Variant GlobalConfig::property_get_revert(const String &p_name) {
+Variant ProjectSettings::property_get_revert(const String &p_name) {
if (!props.has(p_name))
return Variant();
@@ -802,32 +868,32 @@ Variant GlobalConfig::property_get_revert(const String &p_name) {
return props[p_name].initial;
}
-void GlobalConfig::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("has", "name"), &GlobalConfig::has);
- ClassDB::bind_method(D_METHOD("set_order", "name", "pos"), &GlobalConfig::set_order);
- ClassDB::bind_method(D_METHOD("get_order", "name"), &GlobalConfig::get_order);
- ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &GlobalConfig::set_initial_value);
- ClassDB::bind_method(D_METHOD("add_property_info", "hint"), &GlobalConfig::_add_property_info_bind);
- 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("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);
- ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &GlobalConfig::_load_resource_pack);
- ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &GlobalConfig::property_can_revert);
- ClassDB::bind_method(D_METHOD("property_get_revert:Variant", "name"), &GlobalConfig::property_get_revert);
-
- ClassDB::bind_method(D_METHOD("save_custom", "file"), &GlobalConfig::_save_custom_bnd);
+void ProjectSettings::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("has", "name"), &ProjectSettings::has);
+ ClassDB::bind_method(D_METHOD("set_order", "name", "pos"), &ProjectSettings::set_order);
+ ClassDB::bind_method(D_METHOD("get_order", "name"), &ProjectSettings::get_order);
+ ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &ProjectSettings::set_initial_value);
+ ClassDB::bind_method(D_METHOD("add_property_info", "hint"), &ProjectSettings::_add_property_info_bind);
+ ClassDB::bind_method(D_METHOD("clear", "name"), &ProjectSettings::clear);
+ ClassDB::bind_method(D_METHOD("localize_path", "path"), &ProjectSettings::localize_path);
+ ClassDB::bind_method(D_METHOD("globalize_path", "path"), &ProjectSettings::globalize_path);
+ ClassDB::bind_method(D_METHOD("save"), &ProjectSettings::save);
+ ClassDB::bind_method(D_METHOD("has_singleton", "name"), &ProjectSettings::has_singleton);
+ ClassDB::bind_method(D_METHOD("get_singleton", "name"), &ProjectSettings::get_singleton_object);
+ ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &ProjectSettings::_load_resource_pack);
+ ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert);
+ ClassDB::bind_method(D_METHOD("property_get_revert:Variant", "name"), &ProjectSettings::property_get_revert);
+
+ ClassDB::bind_method(D_METHOD("save_custom", "file"), &ProjectSettings::_save_custom_bnd);
}
-GlobalConfig::GlobalConfig() {
+ProjectSettings::ProjectSettings() {
singleton = this;
last_order = NO_BUILTIN_ORDER_BASE;
last_builtin_order = 0;
- disable_platform_override = false;
+ disable_feature_overrides = false;
registering_order = true;
Array va;
@@ -950,6 +1016,8 @@ GlobalConfig::GlobalConfig() {
custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::STRING, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor");
custom_prop_info["rendering/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
custom_prop_info["physics/2d/thread_model"] = PropertyInfo(Variant::INT, "physics/2d/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
+ custom_prop_info["rendering/quality/intended_usage/framebuffer_allocation"] = PropertyInfo(Variant::INT, "rendering/quality/intended_usage/framebuffer_allocation", PROPERTY_HINT_ENUM, "2D,2D Without Sampling,3D,3D Without Effects");
+ GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_mode", 2);
GLOBAL_DEF("debug/settings/profiler/max_functions", 16384);
@@ -964,7 +1032,7 @@ GlobalConfig::GlobalConfig() {
using_datapack = false;
}
-GlobalConfig::~GlobalConfig() {
+ProjectSettings::~ProjectSettings() {
singleton = NULL;
}
diff --git a/core/global_config.h b/core/project_settings.h
index 30c77bbc27..278d4b8132 100644
--- a/core/global_config.h
+++ b/core/project_settings.h
@@ -37,9 +37,9 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-class GlobalConfig : public Object {
+class ProjectSettings : public Object {
- GDCLASS(GlobalConfig, Object);
+ GDCLASS(ProjectSettings, Object);
_THREAD_SAFE_CLASS_
public:
@@ -53,13 +53,12 @@ public:
ptr = p_ptr;
}
};
-
-protected:
enum {
//properties that are not for built in values begin from this value, so builtin ones are displayed first
NO_BUILTIN_ORDER_BASE = 1 << 16
};
+protected:
struct VariantContainer {
int order;
bool persist;
@@ -88,21 +87,24 @@ protected:
Map<StringName, VariantContainer> props;
String resource_path;
Map<StringName, PropertyInfo> custom_prop_info;
- bool disable_platform_override;
+ bool disable_feature_overrides;
bool using_datapack;
List<String> input_presets;
+ Set<String> custom_features;
+ Map<StringName, StringName> feature_overrides;
+
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
- static GlobalConfig *singleton;
+ static ProjectSettings *singleton;
Error _load_settings(const String p_path);
Error _load_settings_binary(const String p_path);
- Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap());
- Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap());
+ Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
+ Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
List<Singleton> singletons;
Map<StringName, Object *> singleton_ptrs;
@@ -127,7 +129,7 @@ public:
String get_resource_path() const;
- static GlobalConfig *get_singleton();
+ static ProjectSettings *get_singleton();
void clear(const String &p_name);
int get_order(const String &p_name) const;
@@ -136,7 +138,7 @@ public:
Error setup(const String &p_path, const String &p_main_pack);
- Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Set<String> &p_ignore_masks = Set<String>());
+ Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>());
Error save();
void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info);
@@ -149,7 +151,7 @@ public:
List<String> get_input_presets() const { return input_presets; }
- void set_disable_platform_override(bool p_disable);
+ void set_disable_feature_overrides(bool p_disable);
Object *get_singleton_object(const String &p_name) const;
void register_global_defaults();
@@ -158,13 +160,13 @@ public:
void set_registering_order(bool p_registering);
- GlobalConfig();
- ~GlobalConfig();
+ ProjectSettings();
+ ~ProjectSettings();
};
//not a macro any longer
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default);
#define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value)
-#define GLOBAL_GET(m_var) GlobalConfig::get_singleton()->get(m_var)
+#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var)
#endif
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index d6a521a86f..07715f9718 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -36,7 +36,7 @@
#include "core_string_names.h"
#include "func_ref.h"
#include "geometry.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "input_map.h"
#include "io/config_file.h"
#include "io/http_client.h"
@@ -177,18 +177,18 @@ void register_core_settings() {
void register_core_singletons() {
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("GlobalConfig", GlobalConfig::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("IP", IP::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Geometry", _Geometry::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("OS", _OS::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Engine", _Engine::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ClassDB", _classdb));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Marshalls", _Marshalls::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("TranslationServer", TranslationServer::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Input", Input::get_singleton()));
- GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("InputMap", InputMap::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("IP", IP::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Geometry", _Geometry::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("OS", _OS::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Engine", _Engine::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ClassDB", _classdb));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Marshalls", _Marshalls::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("TranslationServer", TranslationServer::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Input", Input::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("InputMap", InputMap::get_singleton()));
}
void unregister_core_types() {
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 7fc151d83f..a7b6f25590 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "script_debugger_remote.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/ip.h"
#include "os/input.h"
#include "os/os.h"
@@ -130,7 +130,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
ERR_FAIL();
}
- OS::get_singleton()->enable_for_stealing_focus(GlobalConfig::get_singleton()->get("editor_pid"));
+ OS::get_singleton()->enable_for_stealing_focus(ProjectSettings::get_singleton()->get("editor_pid"));
packet_peer_stream->put_var("debug_enter");
packet_peer_stream->put_var(2);
@@ -952,7 +952,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
phl.userdata = this;
add_print_handler(&phl);
requested_quit = false;
- performance = GlobalConfig::get_singleton()->get_singleton_object("Performance");
+ performance = ProjectSettings::get_singleton()->get_singleton_object("Performance");
last_perf_time = 0;
poll_every = 0;
request_scene_tree = NULL;
@@ -967,7 +967,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
eh.userdata = this;
add_error_handler(&eh);
- profile_info.resize(CLAMP(int(GlobalConfig::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535));
+ profile_info.resize(CLAMP(int(ProjectSettings::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535));
profile_info_ptrs.resize(profile_info.size());
profiling = false;
max_frame_functions = 16;
diff --git a/core/translation.cpp b/core/translation.cpp
index 72231ef295..d782006ddc 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "translation.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/resource_loader.h"
#include "os/os.h"
@@ -1053,8 +1053,8 @@ TranslationServer *TranslationServer::singleton = NULL;
bool TranslationServer::_load_translations(const String &p_from) {
- if (GlobalConfig::get_singleton()->has(p_from)) {
- PoolVector<String> translations = GlobalConfig::get_singleton()->get(p_from);
+ if (ProjectSettings::get_singleton()->has(p_from)) {
+ PoolVector<String> translations = ProjectSettings::get_singleton()->get(p_from);
int tcount = translations.size();
@@ -1095,7 +1095,7 @@ void TranslationServer::setup() {
options += locale_list[idx];
idx++;
}
- GlobalConfig::get_singleton()->set_custom_property_info("locale/fallback", PropertyInfo(Variant::STRING, "locale/fallback", PROPERTY_HINT_ENUM, options));
+ ProjectSettings::get_singleton()->set_custom_property_info("locale/fallback", PropertyInfo(Variant::STRING, "locale/fallback", PROPERTY_HINT_ENUM, options));
}
#endif
//load translations