diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 15 | ||||
-rw-r--r-- | core/extension/gdextension.cpp | 9 | ||||
-rw-r--r-- | core/extension/gdextension.h | 2 | ||||
-rw-r--r-- | core/extension/gdextension_manager.cpp | 23 | ||||
-rw-r--r-- | core/extension/gdextension_manager.h | 4 | ||||
-rw-r--r-- | core/input/godotcontrollerdb.txt | 2 | ||||
-rw-r--r-- | core/io/file_access_memory.cpp | 4 | ||||
-rw-r--r-- | core/io/pck_packer.cpp | 4 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 1 | ||||
-rw-r--r-- | core/object/object.cpp | 14 | ||||
-rw-r--r-- | core/string/ustring.cpp | 37 | ||||
-rw-r--r-- | core/string/ustring.h | 3 | ||||
-rw-r--r-- | core/variant/array.cpp | 2 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 16 | ||||
-rw-r--r-- | core/variant/variant_utility.cpp | 12 |
15 files changed, 136 insertions, 12 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 123e01860e..ac5499d709 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1270,6 +1270,10 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("application/config/custom_user_dir_name", ""); GLOBAL_DEF("application/config/project_settings_override", ""); + GLOBAL_DEF("application/run/main_loop_type", "SceneTree"); + GLOBAL_DEF("application/config/auto_accept_quit", true); + GLOBAL_DEF("application/config/quit_on_go_back", true); + // The default window size is tuned to: // - Have a 16:9 aspect ratio, // - Have both dimensions divisible by 8 to better play along with video recording, @@ -1314,12 +1318,17 @@ ProjectSettings::ProjectSettings() { // Keep the enum values in sync with the `DisplayServer::ScreenOrientation` enum. custom_prop_info["display/window/handheld/orientation"] = PropertyInfo(Variant::INT, "display/window/handheld/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait,Reverse Landscape,Reverse Portrait,Sensor Landscape,Sensor Portrait,Sensor"); + GLOBAL_DEF("display/window/subwindows/embed_subwindows", true); // Keep the enum values in sync with the `DisplayServer::VSyncMode` enum. custom_prop_info["display/window/vsync/vsync_mode"] = PropertyInfo(Variant::INT, "display/window/vsync/vsync_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Adaptive,Mailbox"); custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded"); GLOBAL_DEF("physics/2d/run_on_separate_thread", false); GLOBAL_DEF("physics/3d/run_on_separate_thread", false); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,canvas_items,viewport"), "disabled"); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/window/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height,expand"), "keep"); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "display/window/stretch/scale", PROPERTY_HINT_RANGE, "0.5,8.0,0.01"), 1.0); + GLOBAL_DEF(PropertyInfo(Variant::INT, "debug/settings/profiler/max_functions", PROPERTY_HINT_RANGE, "128,65535,1"), 16384); GLOBAL_DEF(PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching"), Compression::zstd_long_distance_matching); @@ -1339,11 +1348,17 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF(PropertyInfo(Variant::INT, "gui/timers/incremental_search_max_interval_msec", PROPERTY_HINT_RANGE, "0,10000,1,or_greater"), 2000); + GLOBAL_DEF_BASIC("gui/common/snap_controls_to_pixels", true); + GLOBAL_DEF_BASIC("gui/fonts/dynamic_fonts/use_oversampling", true); + GLOBAL_DEF("rendering/rendering_device/staging_buffer/block_size_kb", 256); GLOBAL_DEF("rendering/rendering_device/staging_buffer/max_size_mb", 128); GLOBAL_DEF("rendering/rendering_device/staging_buffer/texture_upload_region_size_px", 64); GLOBAL_DEF("rendering/rendering_device/vulkan/max_descriptors_per_pool", 64); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/textures/canvas_textures/default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,Linear Mipmap,Nearest Mipmap"), 1); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/textures/canvas_textures/default_texture_repeat", PROPERTY_HINT_ENUM, "Disable,Enable,Mirror"), 0); + // These properties will not show up in the dialog nor in the documentation. If you want to exclude whole groups, see _get_property_list() method. GLOBAL_DEF_INTERNAL("application/config/features", PackedStringArray()); GLOBAL_DEF_INTERNAL("internationalization/locale/translation_remaps", PackedStringArray()); diff --git a/core/extension/gdextension.cpp b/core/extension/gdextension.cpp index 829e1d8e5b..f158755a85 100644 --- a/core/extension/gdextension.cpp +++ b/core/extension/gdextension.cpp @@ -549,6 +549,15 @@ Ref<Resource> GDExtensionResourceLoader::load(const String &p_path, const String return Ref<Resource>(); } + // Handle icons if any are specified. + if (config->has_section("icons")) { + List<String> keys; + config->get_section_keys("icons", &keys); + for (const String &key : keys) { + lib->class_icon_paths[key] = config->get_value("icons", key); + } + } + return lib; } diff --git a/core/extension/gdextension.h b/core/extension/gdextension.h index 39523a142f..9d946ca7ba 100644 --- a/core/extension/gdextension.h +++ b/core/extension/gdextension.h @@ -67,6 +67,8 @@ protected: static void _bind_methods(); public: + HashMap<String, String> class_icon_paths; + static String get_extension_list_config_file(); static String find_extension_library(const String &p_path, Ref<ConfigFile> p_config, std::function<bool(String)> p_has_feature, PackedStringArray *r_tags = nullptr); diff --git a/core/extension/gdextension_manager.cpp b/core/extension/gdextension_manager.cpp index 8701e6d77b..63e809bc7c 100644 --- a/core/extension/gdextension_manager.cpp +++ b/core/extension/gdextension_manager.cpp @@ -50,6 +50,11 @@ GDExtensionManager::LoadStatus GDExtensionManager::load_extension(const String & extension->initialize_library(GDExtension::InitializationLevel(i)); } } + + for (const KeyValue<String, String> &kv : extension->class_icon_paths) { + gdextension_class_icon_paths[kv.key] = kv.value; + } + gdextension_map[p_path] = extension; return LOAD_STATUS_OK; } @@ -74,6 +79,11 @@ GDExtensionManager::LoadStatus GDExtensionManager::unload_extension(const String extension->deinitialize_library(GDExtension::InitializationLevel(i)); } } + + for (const KeyValue<String, String> &kv : extension->class_icon_paths) { + gdextension_class_icon_paths.erase(kv.key); + } + gdextension_map.erase(p_path); return LOAD_STATUS_OK; } @@ -95,6 +105,19 @@ Ref<GDExtension> GDExtensionManager::get_extension(const String &p_path) { return E->value; } +bool GDExtensionManager::class_has_icon_path(const String &p_class) const { + // TODO: Check that the icon belongs to a registered class somehow. + return gdextension_class_icon_paths.has(p_class); +} + +String GDExtensionManager::class_get_icon_path(const String &p_class) const { + // TODO: Check that the icon belongs to a registered class somehow. + if (gdextension_class_icon_paths.has(p_class)) { + return gdextension_class_icon_paths[p_class]; + } + return ""; +} + void GDExtensionManager::initialize_extensions(GDExtension::InitializationLevel p_level) { ERR_FAIL_COND(int32_t(p_level) - 1 != level); for (KeyValue<String, Ref<GDExtension>> &E : gdextension_map) { diff --git a/core/extension/gdextension_manager.h b/core/extension/gdextension_manager.h index 456942af0d..3643f043d8 100644 --- a/core/extension/gdextension_manager.h +++ b/core/extension/gdextension_manager.h @@ -38,6 +38,7 @@ class GDExtensionManager : public Object { int32_t level = -1; HashMap<String, Ref<GDExtension>> gdextension_map; + HashMap<String, String> gdextension_class_icon_paths; static void _bind_methods(); @@ -59,6 +60,9 @@ public: Vector<String> get_loaded_extensions() const; Ref<GDExtension> get_extension(const String &p_path); + bool class_has_icon_path(const String &p_class) const; + String class_get_icon_path(const String &p_class) const; + void initialize_extensions(GDExtension::InitializationLevel p_level); void deinitialize_extensions(GDExtension::InitializationLevel p_level); diff --git a/core/input/godotcontrollerdb.txt b/core/input/godotcontrollerdb.txt index 6ead872149..7c51e20b4c 100644 --- a/core/input/godotcontrollerdb.txt +++ b/core/input/godotcontrollerdb.txt @@ -2,7 +2,7 @@ # Source: https://github.com/godotengine/godot # Windows -__XINPUT_DEVICE__,XInput Gamepad,a:b12,b:b13,x:b14,y:b15,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpdown:b1,dpleft:b2,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Windows, +__XINPUT_DEVICE__,XInput Gamepad,a:b12,b:b13,x:b14,y:b15,start:b4,guide:b10,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpdown:b1,dpleft:b2,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Windows, # Android Default Android Gamepad,Default Controller,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b8,rightshoulder:b10,rightx:a2,start:b6,righty:a3,dpleft:h0.8,lefttrigger:a4,x:b2,dpup:h0.1,back:b4,leftstick:b7,leftshoulder:b9,y:b3,a:b0,dpright:h0.2,righttrigger:a5,b:b1,platform:Android, diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 1052170f3c..14ec0be092 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -144,7 +144,7 @@ uint64_t FileAccessMemory::get_buffer(uint8_t *p_dst, uint64_t p_length) const { } memcpy(p_dst, &data[pos], read); - pos += p_length; + pos += read; return read; } @@ -172,5 +172,5 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, uint64_t p_length) { } memcpy(&data[pos], p_src, write); - pos += p_length; + pos += write; } diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 15bc29e908..e7f4980e94 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -252,10 +252,6 @@ Error PCKPacker::flush(bool p_verbose) { } } - if (p_verbose) { - printf("\n"); - } - file.unref(); memdelete_arr(buf); diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index a46fac4e7a..9af3a7daed 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -1090,6 +1090,7 @@ void ResourceLoader::initialize() { } void ResourceLoader::finalize() { + clear_thread_load_tasks(); memdelete(thread_load_mutex); memdelete(thread_load_semaphore); } diff --git a/core/object/object.cpp b/core/object/object.cpp index 57aa1339ec..c324eab9bb 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -1378,7 +1378,12 @@ String Object::tr(const StringName &p_message, const StringName &p_context) cons if (!_can_translate || !TranslationServer::get_singleton()) { return p_message; } - return TranslationServer::get_singleton()->translate(p_message, p_context); + + if (Engine::get_singleton()->is_editor_hint()) { + return TranslationServer::get_singleton()->tool_translate(p_message, p_context); + } else { + return TranslationServer::get_singleton()->translate(p_message, p_context); + } } String Object::tr_n(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context) const { @@ -1389,7 +1394,12 @@ String Object::tr_n(const StringName &p_message, const StringName &p_message_plu } return p_message_plural; } - return TranslationServer::get_singleton()->translate_plural(p_message, p_message_plural, p_n, p_context); + + if (Engine::get_singleton()->is_editor_hint()) { + return TranslationServer::get_singleton()->tool_translate_plural(p_message, p_message_plural, p_n, p_context); + } else { + return TranslationServer::get_singleton()->translate_plural(p_message, p_message_plural, p_n, p_context); + } } void Object::_clear_internal_resource_paths(const Variant &p_var) { diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 1b3b070592..773445edb6 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1644,6 +1644,35 @@ String String::hex_encode_buffer(const uint8_t *p_buffer, int p_len) { return ret; } +Vector<uint8_t> String::hex_decode() const { + ERR_FAIL_COND_V_MSG(length() % 2 != 0, Vector<uint8_t>(), "Hexadecimal string of uneven length."); + +#define HEX_TO_BYTE(m_output, m_index) \ + uint8_t m_output; \ + c = operator[](m_index); \ + if (is_digit(c)) { \ + m_output = c - '0'; \ + } else if (c >= 'a' && c <= 'f') { \ + m_output = c - 'a' + 10; \ + } else if (c >= 'A' && c <= 'F') { \ + m_output = c - 'A' + 10; \ + } else { \ + ERR_FAIL_V_MSG(Vector<uint8_t>(), "Invalid hexadecimal character \"" + chr(c) + "\" at index " + m_index + "."); \ + } + + Vector<uint8_t> out; + int len = length() / 2; + out.resize(len); + for (int i = 0; i < len; i++) { + char32_t c; + HEX_TO_BYTE(first, i * 2); + HEX_TO_BYTE(second, i * 2 + 1); + out.write[i] = first * 16 + second; + } + return out; +#undef HEX_TO_BYTE +} + void String::print_unicode_error(const String &p_message, bool p_critical) const { if (p_critical) { print_error(vformat("Unicode parsing error, some characters were replaced with spaces: %s", p_message)); @@ -5034,6 +5063,14 @@ Vector<uint8_t> String::to_utf32_buffer() const { return retval; } +Vector<uint8_t> String::to_wchar_buffer() const { +#ifdef WINDOWS_ENABLED + return to_utf16_buffer(); +#else + return to_utf32_buffer(); +#endif +} + #ifdef TOOLS_ENABLED /** * "Tools TRanslate". Performs string replacement for internationalization diff --git a/core/string/ustring.h b/core/string/ustring.h index 1582504c57..90034b1b07 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -321,6 +321,8 @@ public: static String chr(char32_t p_char); static String md5(const uint8_t *p_md5); static String hex_encode_buffer(const uint8_t *p_buffer, int p_len); + Vector<uint8_t> hex_decode() const; + bool is_numeric() const; double to_float() const; @@ -455,6 +457,7 @@ public: Vector<uint8_t> to_utf8_buffer() const; Vector<uint8_t> to_utf16_buffer() const; Vector<uint8_t> to_utf32_buffer() const; + Vector<uint8_t> to_wchar_buffer() const; String(const char *p_str); String(const wchar_t *p_str); diff --git a/core/variant/array.cpp b/core/variant/array.cpp index d156c35343..5215142dd3 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -466,7 +466,7 @@ Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { ERR_FAIL_COND_V_MSG(p_step > 0 && begin > end, result, "Slice is positive, but bounds is decreasing."); ERR_FAIL_COND_V_MSG(p_step < 0 && begin < end, result, "Slice is negative, but bounds is increasing."); - int result_size = (end - begin) / p_step; + int result_size = (end - begin) / p_step + (((end - begin) % p_step != 0) ? 1 : 0); result.resize(result_size); for (int src_idx = begin, dest_idx = 0; dest_idx < result_size; ++dest_idx) { diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 0c0c8f657a..13e9da37f2 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -700,6 +700,19 @@ struct _VariantCall { return s; } + static String func_PackedByteArray_get_string_from_wchar(PackedByteArray *p_instance) { + String s; + if (p_instance->size() > 0) { + const uint8_t *r = p_instance->ptr(); +#ifdef WINDOWS_ENABLED + s.parse_utf16((const char16_t *)r, floor((double)p_instance->size() / (double)sizeof(char16_t))); +#else + s = String((const char32_t *)r, floor((double)p_instance->size() / (double)sizeof(char32_t))); +#endif + } + return s; + } + static PackedByteArray func_PackedByteArray_compress(PackedByteArray *p_instance, int p_mode) { PackedByteArray compressed; @@ -1721,6 +1734,8 @@ static void _register_variant_builtin_methods() { bind_string_method(to_utf8_buffer, sarray(), varray()); bind_string_method(to_utf16_buffer, sarray(), varray()); bind_string_method(to_utf32_buffer, sarray(), varray()); + bind_string_method(hex_decode, sarray(), varray()); + bind_string_method(to_wchar_buffer, sarray(), varray()); bind_static_method(String, num_scientific, sarray("number"), varray()); bind_static_method(String, num, sarray("number", "decimals"), varray(-1)); @@ -2258,6 +2273,7 @@ static void _register_variant_builtin_methods() { bind_function(PackedByteArray, get_string_from_utf8, _VariantCall::func_PackedByteArray_get_string_from_utf8, sarray(), varray()); bind_function(PackedByteArray, get_string_from_utf16, _VariantCall::func_PackedByteArray_get_string_from_utf16, sarray(), varray()); bind_function(PackedByteArray, get_string_from_utf32, _VariantCall::func_PackedByteArray_get_string_from_utf32, sarray(), varray()); + bind_function(PackedByteArray, get_string_from_wchar, _VariantCall::func_PackedByteArray_get_string_from_wchar, sarray(), varray()); bind_function(PackedByteArray, hex_encode, _VariantCall::func_PackedByteArray_hex_encode, sarray(), varray()); bind_function(PackedByteArray, compress, _VariantCall::func_PackedByteArray_compress, sarray("compression_mode"), varray(0)); bind_function(PackedByteArray, decompress, _VariantCall::func_PackedByteArray_decompress, sarray("buffer_size", "compression_mode"), varray(0)); diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index 8f3ae65b9c..a6363039ba 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -542,7 +542,8 @@ struct VariantUtilityFunctions { } Variant base = *p_args[0]; Variant ret; - for (int i = 1; i < p_argcount; i++) { + + for (int i = 0; i < p_argcount; i++) { Variant::Type arg_type = p_args[i]->get_type(); if (arg_type != Variant::INT && arg_type != Variant::FLOAT) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; @@ -550,6 +551,9 @@ struct VariantUtilityFunctions { r_error.argument = i; return Variant(); } + if (i == 0) { + continue; + } bool valid; Variant::evaluate(Variant::OP_LESS, base, *p_args[i], ret, valid); if (!valid) { @@ -582,7 +586,8 @@ struct VariantUtilityFunctions { } Variant base = *p_args[0]; Variant ret; - for (int i = 1; i < p_argcount; i++) { + + for (int i = 0; i < p_argcount; i++) { Variant::Type arg_type = p_args[i]->get_type(); if (arg_type != Variant::INT && arg_type != Variant::FLOAT) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; @@ -590,6 +595,9 @@ struct VariantUtilityFunctions { r_error.argument = i; return Variant(); } + if (i == 0) { + continue; + } bool valid; Variant::evaluate(Variant::OP_GREATER, base, *p_args[i], ret, valid); if (!valid) { |