diff options
Diffstat (limited to 'core')
-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/resource_loader.cpp | 1 | ||||
-rw-r--r-- | core/string/ustring.cpp | 29 | ||||
-rw-r--r-- | core/string/ustring.h | 2 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 1 |
10 files changed, 74 insertions, 3 deletions
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/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/string/ustring.cpp b/core/string/ustring.cpp index 6a59942a56..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)); diff --git a/core/string/ustring.h b/core/string/ustring.h index 28e3af92c5..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; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index ae15158836..13e9da37f2 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1734,6 +1734,7 @@ 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()); |