diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 77 | ||||
-rw-r--r-- | core/config/project_settings.h | 14 | ||||
-rw-r--r-- | core/io/marshalls.cpp | 4 | ||||
-rw-r--r-- | core/object/script_language.h | 2 | ||||
-rw-r--r-- | core/object/script_language_extension.cpp | 1 | ||||
-rw-r--r-- | core/object/script_language_extension.h | 1 | ||||
-rw-r--r-- | core/variant/variant.h | 1 |
7 files changed, 100 insertions, 0 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 4e3196dec3..8096407430 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -281,6 +281,11 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { if (autoloads.has(node_name)) { remove_autoload(node_name); } + } else if (p_name.operator String().begins_with("global_group/")) { + String group_name = p_name.operator String().get_slice("/", 1); + if (global_groups.has(group_name)) { + remove_global_group(group_name); + } } } else { if (p_name == CoreStringNames::get_singleton()->_custom_features) { @@ -327,6 +332,9 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { autoload.path = path; } add_autoload(autoload); + } else if (p_name.operator String().begins_with("global_group/")) { + String group_name = p_name.operator String().get_slice("/", 1); + add_global_group(group_name, p_value); } } @@ -674,6 +682,8 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo Compression::gzip_level = GLOBAL_GET("compression/formats/gzip/compression_level"); + load_scene_groups_cache(); + project_loaded = err == OK; return err; } @@ -1241,6 +1251,73 @@ ProjectSettings::AutoloadInfo ProjectSettings::get_autoload(const StringName &p_ return autoloads[p_name]; } +const HashMap<StringName, String> &ProjectSettings::get_global_groups_list() const { + return global_groups; +} + +void ProjectSettings::add_global_group(const StringName &p_name, const String &p_description) { + ERR_FAIL_COND_MSG(p_name == StringName(), "Trying to add global group with no name."); + global_groups[p_name] = p_description; +} + +void ProjectSettings::remove_global_group(const StringName &p_name) { + ERR_FAIL_COND_MSG(!global_groups.has(p_name), "Trying to remove non-existent global group."); + global_groups.erase(p_name); +} + +bool ProjectSettings::has_global_group(const StringName &p_name) const { + return global_groups.has(p_name); +} + +void ProjectSettings::remove_scene_groups_cache(const StringName &p_path) { + scene_groups_cache.erase(p_path); +} + +void ProjectSettings::add_scene_groups_cache(const StringName &p_path, const HashSet<StringName> &p_cache) { + scene_groups_cache[p_path] = p_cache; +} + +void ProjectSettings::save_scene_groups_cache() { + Ref<ConfigFile> cf; + cf.instantiate(); + for (const KeyValue<StringName, HashSet<StringName>> &E : scene_groups_cache) { + if (E.value.is_empty()) { + continue; + } + Array list; + for (const StringName &group : E.value) { + list.push_back(group); + } + cf->set_value(E.key, "groups", list); + } + cf->save(get_scene_groups_cache_path()); +} + +String ProjectSettings::get_scene_groups_cache_path() const { + return get_project_data_path().path_join("scene_groups_cache.cfg"); +} + +void ProjectSettings::load_scene_groups_cache() { + Ref<ConfigFile> cf; + cf.instantiate(); + if (cf->load(get_scene_groups_cache_path()) == OK) { + List<String> scene_paths; + cf->get_sections(&scene_paths); + for (const String &E : scene_paths) { + Array scene_groups = cf->get_value(E, "groups", Array()); + HashSet<StringName> cache; + for (int i = 0; i < scene_groups.size(); ++i) { + cache.insert(scene_groups[i]); + } + add_scene_groups_cache(E, cache); + } + } +} + +const HashMap<StringName, HashSet<StringName>> &ProjectSettings::get_scene_groups_cache() const { + return scene_groups_cache; +} + void ProjectSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("has_setting", "name"), &ProjectSettings::has_setting); ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &ProjectSettings::set_setting); diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 302df7e8d0..55d5957ad1 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -106,6 +106,8 @@ protected: LocalVector<String> hidden_prefixes; HashMap<StringName, AutoloadInfo> autoloads; + HashMap<StringName, String> global_groups; + HashMap<StringName, HashSet<StringName>> scene_groups_cache; Array global_class_list; bool is_global_class_list_loaded = false; @@ -208,6 +210,18 @@ public: bool has_autoload(const StringName &p_autoload) const; AutoloadInfo get_autoload(const StringName &p_name) const; + const HashMap<StringName, String> &get_global_groups_list() const; + void add_global_group(const StringName &p_name, const String &p_description); + void remove_global_group(const StringName &p_name); + bool has_global_group(const StringName &p_name) const; + + const HashMap<StringName, HashSet<StringName>> &get_scene_groups_cache() const; + void add_scene_groups_cache(const StringName &p_path, const HashSet<StringName> &p_cache); + void remove_scene_groups_cache(const StringName &p_path); + void save_scene_groups_cache(); + String get_scene_groups_cache_path() const; + void load_scene_groups_cache(); + ProjectSettings(); ~ProjectSettings(); }; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 3d384d9345..bc2493d360 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -638,6 +638,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int if (str.is_empty()) { r_variant = (Object *)nullptr; } else { + ERR_FAIL_COND_V(!ClassDB::can_instantiate(str), ERR_INVALID_DATA); + Object *obj = ClassDB::instantiate(str); ERR_FAIL_NULL_V(obj, ERR_UNAVAILABLE); @@ -1492,6 +1494,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4; } else { + ERR_FAIL_COND_V(!ClassDB::can_instantiate(obj->get_class()), ERR_INVALID_PARAMETER); + _encode_string(obj->get_class(), buf, r_len); List<PropertyInfo> props; diff --git a/core/object/script_language.h b/core/object/script_language.h index 85e64c8d62..69da50f074 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -384,10 +384,12 @@ public: uint64_t call_count; uint64_t total_time; uint64_t self_time; + uint64_t internal_time; }; virtual void profiling_start() = 0; virtual void profiling_stop() = 0; + virtual void profiling_set_save_native_calls(bool p_enable) = 0; virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) = 0; virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) = 0; diff --git a/core/object/script_language_extension.cpp b/core/object/script_language_extension.cpp index e326baf7eb..79f39cb626 100644 --- a/core/object/script_language_extension.cpp +++ b/core/object/script_language_extension.cpp @@ -145,6 +145,7 @@ void ScriptLanguageExtension::_bind_methods() { GDVIRTUAL_BIND(_profiling_start); GDVIRTUAL_BIND(_profiling_stop); + GDVIRTUAL_BIND(_profiling_set_save_native_calls, "enable"); GDVIRTUAL_BIND(_profiling_get_accumulated_data, "info_array", "info_max"); GDVIRTUAL_BIND(_profiling_get_frame_data, "info_array", "info_max"); diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index 00ab1cd6c0..852b2aebd8 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -607,6 +607,7 @@ public: EXBIND0(profiling_start) EXBIND0(profiling_stop) + EXBIND1(profiling_set_save_native_calls, bool) GDVIRTUAL2R(int, _profiling_get_accumulated_data, GDExtensionPtr<ScriptLanguageExtensionProfilingInfo>, int) diff --git a/core/variant/variant.h b/core/variant/variant.h index 17e701cf66..480f21df98 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -70,6 +70,7 @@ typedef Vector<int32_t> PackedInt32Array; typedef Vector<int64_t> PackedInt64Array; typedef Vector<float> PackedFloat32Array; typedef Vector<double> PackedFloat64Array; +typedef Vector<real_t> PackedRealArray; typedef Vector<String> PackedStringArray; typedef Vector<Vector2> PackedVector2Array; typedef Vector<Vector3> PackedVector3Array; |