diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2023-01-06 22:59:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-06 22:59:29 +0100 |
commit | 163f6f5fe87d11645e94cd49f41226ab03063e53 (patch) | |
tree | fe8fd83df75c4f498986f51c6853f11cdd68f49f /core | |
parent | 670405905d40280294e5b8100c10294f54e9b6c9 (diff) | |
parent | 7c6b659bd799080ca3a84110b112313a8cd12b1f (diff) |
Merge pull request #68429 from KoBeWi/PropertySettings
Add PropertyInfo overload for GLOBAL_DEF
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 23 | ||||
-rw-r--r-- | core/config/project_settings.h | 4 | ||||
-rw-r--r-- | core/io/file_access_network.cpp | 6 | ||||
-rw-r--r-- | core/object/message_queue.cpp | 3 | ||||
-rw-r--r-- | core/register_core_types.cpp | 9 | ||||
-rw-r--r-- | core/string/translation.cpp | 2 |
6 files changed, 24 insertions, 23 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 5733827124..2ce3ce2678 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1048,6 +1048,12 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restar return ret; } +Variant _GLOBAL_DEF(const PropertyInfo &p_info, const Variant &p_default, bool p_restart_if_changed, bool p_ignore_value_in_docs, bool p_basic, bool p_internal) { + Variant ret = _GLOBAL_DEF(p_info.name, p_default, p_restart_if_changed, p_ignore_value_in_docs, p_basic, p_internal); + ProjectSettings::get_singleton()->set_custom_property_info(p_info); + return ret; +} + Vector<String> ProjectSettings::get_optimizer_presets() const { List<PropertyInfo> pi; ProjectSettings::get_singleton()->get_property_list(&pi); @@ -1082,13 +1088,13 @@ void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) { pinfo.hint_string = p_info["hint_string"]; } - set_custom_property_info(pinfo.name, pinfo); + set_custom_property_info(pinfo); } -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 ProjectSettings::set_custom_property_info(const PropertyInfo &p_info) { + const String &prop_name = p_info.name; + ERR_FAIL_COND(!props.has(prop_name)); + custom_prop_info[prop_name] = p_info; } const HashMap<StringName, PropertyInfo> &ProjectSettings::get_custom_property_info() const { @@ -1301,12 +1307,11 @@ ProjectSettings::ProjectSettings() { String("Please include this when reporting the bug to the project developer.")); GLOBAL_DEF("debug/settings/crash_handler/message.editor", String("Please include this when reporting the bug on: https://github.com/godotengine/godot/issues")); - GLOBAL_DEF_RST("rendering/occlusion_culling/bvh_build_quality", 2); - GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60); + GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/occlusion_culling/bvh_build_quality", PROPERTY_HINT_ENUM, "Low,Medium,High"), 2); + GLOBAL_DEF(PropertyInfo(Variant::INT, "memory/limits/multithreaded_server/rid_pool_prealloc", PROPERTY_HINT_RANGE, "0,500,1"), 60); // No negative and limit to 500 due to crashes. GLOBAL_DEF_RST("internationalization/rendering/force_right_to_left_layout_direction", false); - GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000); - ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/incremental_search_max_interval_msec", PropertyInfo(Variant::INT, "gui/timers/incremental_search_max_interval_msec", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); // No negative numbers. + GLOBAL_DEF(PropertyInfo(Variant::INT, "gui/timers/incremental_search_max_interval_msec", PROPERTY_HINT_RANGE, "0,10000,1,or_greater"), 2000); GLOBAL_DEF("rendering/rendering_device/staging_buffer/block_size_kb", 256); GLOBAL_DEF("rendering/rendering_device/staging_buffer/max_size_mb", 128); diff --git a/core/config/project_settings.h b/core/config/project_settings.h index aa03b0523f..2aca1e7691 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -173,7 +173,7 @@ public: Error load_custom(const String &p_path); Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true); Error save(); - void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); + void set_custom_property_info(const PropertyInfo &p_info); const HashMap<StringName, PropertyInfo> &get_custom_property_info() const; uint64_t get_last_saved_time() { return last_save_time; } @@ -199,6 +199,8 @@ public: // Not a macro any longer. Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed = false, bool p_ignore_value_in_docs = false, bool p_basic = false, bool p_internal = false); +Variant _GLOBAL_DEF(const PropertyInfo &p_info, const Variant &p_default, bool p_restart_if_changed = false, bool p_ignore_value_in_docs = false, bool p_basic = false, bool p_internal = false); + #define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value) #define GLOBAL_DEF_RST(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true) #define GLOBAL_DEF_NOVAL(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, true) diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index c442cd04ca..e765eb2d42 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -465,10 +465,8 @@ Error FileAccessNetwork::_set_unix_permissions(const String &p_file, uint32_t p_ } void FileAccessNetwork::configure() { - GLOBAL_DEF("network/remote_fs/page_size", 65536); - ProjectSettings::get_singleton()->set_custom_property_info("network/remote_fs/page_size", PropertyInfo(Variant::INT, "network/remote_fs/page_size", PROPERTY_HINT_RANGE, "1,65536,1,or_greater")); //is used as denominator and can't be zero - GLOBAL_DEF("network/remote_fs/page_read_ahead", 4); - ProjectSettings::get_singleton()->set_custom_property_info("network/remote_fs/page_read_ahead", PropertyInfo(Variant::INT, "network/remote_fs/page_read_ahead", PROPERTY_HINT_RANGE, "0,8,1,or_greater")); + GLOBAL_DEF(PropertyInfo(Variant::INT, "network/remote_fs/page_size", PROPERTY_HINT_RANGE, "1,65536,1,or_greater"), 65536); // Is used as denominator and can't be zero + GLOBAL_DEF(PropertyInfo(Variant::INT, "network/remote_fs/page_read_ahead", PROPERTY_HINT_RANGE, "0,8,1,or_greater"), 4); } FileAccessNetwork::FileAccessNetwork() { diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp index 4d8279de58..ebed6c21e9 100644 --- a/core/object/message_queue.cpp +++ b/core/object/message_queue.cpp @@ -314,8 +314,7 @@ MessageQueue::MessageQueue() { ERR_FAIL_COND_MSG(singleton != nullptr, "A MessageQueue singleton already exists."); singleton = this; - buffer_size = GLOBAL_DEF_RST("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB); - ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/message_queue/max_size_kb", PropertyInfo(Variant::INT, "memory/limits/message_queue/max_size_kb", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater")); + buffer_size = GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "memory/limits/message_queue/max_size_kb", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater"), DEFAULT_QUEUE_SIZE_KB); buffer_size *= 1024; buffer = memnew_arr(uint8_t, buffer_size); } diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index b614dca971..81866ee7e4 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -293,12 +293,9 @@ void register_core_types() { void register_core_settings() { // Since in register core types, globals may not be present. - GLOBAL_DEF("network/limits/tcp/connect_timeout_seconds", (30)); - ProjectSettings::get_singleton()->set_custom_property_info("network/limits/tcp/connect_timeout_seconds", PropertyInfo(Variant::INT, "network/limits/tcp/connect_timeout_seconds", PROPERTY_HINT_RANGE, "1,1800,1")); - GLOBAL_DEF_RST("network/limits/packet_peer_stream/max_buffer_po2", (16)); - ProjectSettings::get_singleton()->set_custom_property_info("network/limits/packet_peer_stream/max_buffer_po2", PropertyInfo(Variant::INT, "network/limits/packet_peer_stream/max_buffer_po2", PROPERTY_HINT_RANGE, "0,64,1,or_greater")); - GLOBAL_DEF("network/tls/certificate_bundle_override", ""); - ProjectSettings::get_singleton()->set_custom_property_info("network/tls/certificate_bundle_override", PropertyInfo(Variant::STRING, "network/tls/certificate_bundle_override", PROPERTY_HINT_FILE, "*.crt")); + GLOBAL_DEF(PropertyInfo(Variant::INT, "network/limits/tcp/connect_timeout_seconds", PROPERTY_HINT_RANGE, "1,1800,1"), (30)); + GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "network/limits/packet_peer_stream/max_buffer_po2", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), (16)); + GLOBAL_DEF(PropertyInfo(Variant::STRING, "network/tls/certificate_bundle_override", PROPERTY_HINT_FILE, "*.crt"), ""); int worker_threads = GLOBAL_DEF("threading/worker_pool/max_threads", -1); bool low_priority_use_system_threads = GLOBAL_DEF("threading/worker_pool/use_system_threads_for_low_priority_tasks", true); diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 9a4f1dae29..60dca8ebc6 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -688,7 +688,7 @@ void TranslationServer::setup() { pseudolocalization_skip_placeholders_enabled = GLOBAL_DEF("internationalization/pseudolocalization/skip_placeholders", true); #ifdef TOOLS_ENABLED - ProjectSettings::get_singleton()->set_custom_property_info("internationalization/locale/fallback", PropertyInfo(Variant::STRING, "internationalization/locale/fallback", PROPERTY_HINT_LOCALE_ID, "")); + ProjectSettings::get_singleton()->set_custom_property_info(PropertyInfo(Variant::STRING, "internationalization/locale/fallback", PROPERTY_HINT_LOCALE_ID, "")); #endif } |