diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/global_config.cpp | 82 | ||||
-rw-r--r-- | core/global_config.h | 5 | ||||
-rw-r--r-- | core/io/compression.cpp | 9 | ||||
-rw-r--r-- | core/io/compression.h | 5 | ||||
-rw-r--r-- | core/io/packet_peer.cpp | 2 | ||||
-rw-r--r-- | core/message_queue.cpp | 2 | ||||
-rw-r--r-- | core/os/os.cpp | 2 | ||||
-rw-r--r-- | core/register_core_types.cpp | 2 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 4 |
9 files changed, 54 insertions, 59 deletions
diff --git a/core/global_config.cpp b/core/global_config.cpp index d8b88afd07..95f4ec5e22 100644 --- a/core/global_config.cpp +++ b/core/global_config.cpp @@ -130,33 +130,8 @@ bool GlobalConfig::_set(const StringName &p_name, const Variant &p_value) { if (!props[p_name].overrided) props[p_name].variant = p_value; - if (props[p_name].order >= NO_ORDER_BASE && registering_order) { - props[p_name].order = last_order++; - } } else { - props[p_name] = VariantContainer(p_value, last_order++ + (registering_order ? 0 : NO_ORDER_BASE)); - } - } - - if (!disable_platform_override) { - - String s = String(p_name); - int sl = s.find("/"); - int p = s.find("."); - if (p != -1 && sl != -1 && p < sl) { - - Vector<String> ps = s.substr(0, sl).split("."); - String prop = s.substr(sl, s.length() - sl); - for (int i = 1; i < ps.size(); i++) { - - if (ps[i] == OS::get_singleton()->get_name()) { - - String fullprop = ps[0] + prop; - - set(fullprop, p_value); - props[fullprop].overrided = true; - } - } + props[p_name] = VariantContainer(p_value, last_order++); } } @@ -372,8 +347,6 @@ Error GlobalConfig::_load_settings_binary(const String p_path) { ERR_FAIL_V(ERR_FILE_CORRUPT;) } - set_registering_order(false); - uint32_t count = f->get_32(); for (uint32_t i = 0; i < count; i++) { @@ -397,8 +370,6 @@ Error GlobalConfig::_load_settings_binary(const String p_path) { set(key, value); } - set_registering_order(true); - return OK; } Error GlobalConfig::_load_settings(const String p_path) { @@ -468,6 +439,14 @@ void GlobalConfig::set_order(const String &p_name, int p_order) { props[p_name].order = p_order; } +void GlobalConfig::set_builtin_order(const String &p_name) { + + ERR_FAIL_COND(!props.has(p_name)); + if (props[p_name].order >= NO_BUILTIN_ORDER_BASE) { + props[p_name].order = last_builtin_order++; + } +} + void GlobalConfig::clear(const String &p_name) { ERR_FAIL_COND(!props.has(p_name)); @@ -715,13 +694,16 @@ 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)) { - GlobalConfig::get_singleton()->set_initial_value(p_var, p_default); - return GlobalConfig::get_singleton()->get(p_var); + ret = GlobalConfig::get_singleton()->get(p_var); + } else { + GlobalConfig::get_singleton()->set(p_var, p_default); + ret = p_default; } - GlobalConfig::get_singleton()->set(p_var, p_default); GlobalConfig::get_singleton()->set_initial_value(p_var, p_default); - return p_default; + GlobalConfig::get_singleton()->set_builtin_order(p_var); + return ret; } void GlobalConfig::add_singleton(const Singleton &p_singleton) { @@ -843,7 +825,8 @@ void GlobalConfig::_bind_methods() { GlobalConfig::GlobalConfig() { singleton = this; - last_order = 0; + last_order = NO_BUILTIN_ORDER_BASE; + last_builtin_order = 0; disable_platform_override = false; registering_order = true; @@ -851,12 +834,12 @@ GlobalConfig::GlobalConfig() { Ref<InputEventKey> key; Ref<InputEventJoypadButton> joyb; - GLOBAL_DEF("application/name", ""); - GLOBAL_DEF("application/main_scene", ""); - custom_prop_info["application/main_scene"] = PropertyInfo(Variant::STRING, "application/main_scene", PROPERTY_HINT_FILE, "tscn,scn,xscn,xml,res"); - GLOBAL_DEF("application/disable_stdout", false); - GLOBAL_DEF("application/disable_stderr", false); - GLOBAL_DEF("application/use_shared_user_dir", true); + GLOBAL_DEF("application/config/name", ""); + GLOBAL_DEF("application/run/main_scene", ""); + custom_prop_info["application/run/main_scene"] = PropertyInfo(Variant::STRING, "application/run/main_scene", PROPERTY_HINT_FILE, "tscn,scn,res"); + GLOBAL_DEF("application/run/disable_stdout", false); + GLOBAL_DEF("application/run/disable_stderr", false); + GLOBAL_DEF("application/config/use_shared_user_dir", true); key.instance(); key->set_scancode(KEY_RETURN); @@ -964,18 +947,19 @@ GlobalConfig::GlobalConfig() { //GLOBAL_DEF("display/handheld/orientation", "landscape"); - custom_prop_info["display/handheld/orientation"] = PropertyInfo(Variant::STRING, "display/handheld/orientation", PROPERTY_HINT_ENUM, "landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor"); + 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"); - GLOBAL_DEF("debug/profiler/max_functions", 16384); + GLOBAL_DEF("debug/settings/profiler/max_functions", 16384); - GLOBAL_DEF("compression/zstd/compression_level", 3); - custom_prop_info["compression/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"); - GLOBAL_DEF("compression/zlib/compression_level", Z_DEFAULT_COMPRESSION); - custom_prop_info["compression/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); - GLOBAL_DEF("compression/gzip/compression_level", Z_DEFAULT_COMPRESSION); - custom_prop_info["compression/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); + //assigning here, because using GLOBAL_GET on every block for compressing can be slow + Compression::zstd_level = GLOBAL_DEF("compression/formats/zstd/compression_level", 3); + custom_prop_info["compression/formats/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"); + Compression::zlib_level = GLOBAL_DEF("compression/formats/zlib/compression_level", Z_DEFAULT_COMPRESSION); + custom_prop_info["compression/formats/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); + Compression::gzip_level = GLOBAL_DEF("compression/formats/gzip/compression_level", Z_DEFAULT_COMPRESSION); + custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); using_datapack = false; } diff --git a/core/global_config.h b/core/global_config.h index d0f64dc23c..30c77bbc27 100644 --- a/core/global_config.h +++ b/core/global_config.h @@ -56,7 +56,8 @@ public: protected: enum { - NO_ORDER_BASE = 1 << 18 + //properties that are not for built in values begin from this value, so builtin ones are displayed first + NO_BUILTIN_ORDER_BASE = 1 << 16 }; struct VariantContainer { @@ -83,6 +84,7 @@ protected: bool registering_order; int last_order; + int last_builtin_order; Map<StringName, VariantContainer> props; String resource_path; Map<StringName, PropertyInfo> custom_prop_info; @@ -130,6 +132,7 @@ public: void clear(const String &p_name); int get_order(const String &p_name) const; void set_order(const String &p_name, int p_order); + void set_builtin_order(const String &p_name); Error setup(const String &p_path, const String &p_main_pack); diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 8c8f0b3655..b0f5448b6c 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -61,7 +61,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, strm.zalloc = zipio_alloc; strm.zfree = zipio_free; strm.opaque = Z_NULL; - int level = p_mode == MODE_DEFLATE ? GLOBAL_GET("compression/zlib/compression_level") : GLOBAL_GET("compression/gzip/compression_level"); + int level = p_mode == MODE_DEFLATE ? zlib_level : gzip_level; int err = deflateInit2(&strm, level, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY); if (err != Z_OK) return -1; @@ -80,8 +80,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, case MODE_ZSTD: { int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD); - int level = GLOBAL_GET("compression/zstd/compression_level"); - return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, level); + return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level); } break; } @@ -173,3 +172,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p ERR_FAIL_V(-1); } + +int Compression::zlib_level = Z_DEFAULT_COMPRESSION; +int Compression::gzip_level = Z_DEFAULT_COMPRESSION; +int Compression::zstd_level = 3; diff --git a/core/io/compression.h b/core/io/compression.h index bc39fc4185..5eb7806d7b 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -33,7 +33,12 @@ #include "typedefs.h" class Compression { + public: + static int zlib_level; + static int gzip_level; + static int zstd_level; + enum Mode { MODE_FASTLZ, MODE_DEFLATE, diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index ac68d5240c..93682e6b8a 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -254,7 +254,7 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) { PacketPeerStream::PacketPeerStream() { - int rbsize = GLOBAL_GET("network/packets/packet_stream_peer_max_buffer_po2"); + int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2"); ring_buffer.resize(rbsize); temp_buffer.resize(1 << rbsize); diff --git a/core/message_queue.cpp b/core/message_queue.cpp index d7d31b6c1e..1c980a56e3 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -382,7 +382,7 @@ MessageQueue::MessageQueue() { buffer_end = 0; buffer_max_used = 0; - buffer_size = GLOBAL_DEF("memory/buffers/message_queue_max_size_kb", DEFAULT_QUEUE_SIZE_KB); + buffer_size = GLOBAL_DEF("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB); buffer_size *= 1024; buffer = memnew_arr(uint8_t, buffer_size); } diff --git a/core/os/os.cpp b/core/os/os.cpp index 8bee725813..48463722cf 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -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/name"); + String an = GlobalConfig::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], "-"); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index b089ba9129..d6a521a86f 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -172,7 +172,7 @@ void register_core_types() { void register_core_settings() { //since in register core types, globals may not e present - GLOBAL_DEF("network/packets/packet_stream_peer_max_buffer_po2", (16)); + GLOBAL_DEF("network/limits/packet_peer_stream/max_buffer_po2", (16)); } void register_core_singletons() { diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index f230a4bc95..7fc151d83f 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -957,7 +957,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() { poll_every = 0; request_scene_tree = NULL; live_edit_funcs = NULL; - max_cps = GLOBAL_DEF("network/debug/max_remote_stdout_chars_per_second", 2048); + max_cps = GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second"); char_count = 0; msec_count = 0; last_msec = 0; @@ -967,7 +967,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() { eh.userdata = this; add_error_handler(&eh); - profile_info.resize(CLAMP(int(GlobalConfig::get_singleton()->get("debug/profiler/max_functions")), 128, 65535)); + profile_info.resize(CLAMP(int(GlobalConfig::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535)); profile_info_ptrs.resize(profile_info.size()); profiling = false; max_frame_functions = 16; |