diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 73 | ||||
-rw-r--r-- | core/core_constants.cpp | 83 | ||||
-rw-r--r-- | core/error/error_macros.cpp | 4 | ||||
-rw-r--r-- | core/error/error_macros.h | 48 | ||||
-rw-r--r-- | core/input/input.cpp | 18 | ||||
-rw-r--r-- | core/input/input.h | 2 | ||||
-rw-r--r-- | core/input/input_event.cpp | 114 | ||||
-rw-r--r-- | core/input/input_event.h | 8 | ||||
-rw-r--r-- | core/io/marshalls.h | 2 | ||||
-rw-r--r-- | core/io/resource.cpp | 2 | ||||
-rw-r--r-- | core/math/a_star.cpp | 38 | ||||
-rw-r--r-- | core/math/a_star.h | 2 | ||||
-rw-r--r-- | core/math/a_star_grid_2d.cpp | 2 | ||||
-rw-r--r-- | core/math/bvh_abb.h | 2 | ||||
-rw-r--r-- | core/math/bvh_split.inc | 8 | ||||
-rw-r--r-- | core/math/color.cpp | 2 | ||||
-rw-r--r-- | core/math/expression.cpp | 9 | ||||
-rw-r--r-- | core/math/geometry_3d.cpp | 2 | ||||
-rw-r--r-- | core/object/object.cpp | 2 | ||||
-rw-r--r-- | core/object/object.h | 19 | ||||
-rw-r--r-- | core/os/keyboard.cpp | 119 | ||||
-rw-r--r-- | core/os/keyboard.h | 89 | ||||
-rw-r--r-- | core/variant/variant.cpp | 40 | ||||
-rw-r--r-- | core/variant/variant.h | 1 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 2 | ||||
-rw-r--r-- | core/variant/variant_utility.cpp | 7 |
26 files changed, 325 insertions, 373 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index ed89bc15d3..00e74a7cce 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1232,12 +1232,9 @@ ProjectSettings::ProjectSettings() { singleton = this; GLOBAL_DEF_BASIC("application/config/name", ""); - GLOBAL_DEF_BASIC("application/config/name_localized", Dictionary()); - custom_prop_info["application/config/name_localized"] = PropertyInfo(Variant::DICTIONARY, "application/config/name_localized", PROPERTY_HINT_LOCALIZABLE_STRING); - GLOBAL_DEF_BASIC("application/config/description", ""); - custom_prop_info["application/config/description"] = PropertyInfo(Variant::STRING, "application/config/description", PROPERTY_HINT_MULTILINE_TEXT); - GLOBAL_DEF_BASIC("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_BASIC(PropertyInfo(Variant::DICTIONARY, "application/config/name_localized", PROPERTY_HINT_LOCALIZABLE_STRING), Dictionary()); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/config/description", PROPERTY_HINT_MULTILINE_TEXT), ""); + GLOBAL_DEF_BASIC(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_RST("application/config/use_hidden_project_data_directory", true); @@ -1249,22 +1246,15 @@ ProjectSettings::ProjectSettings() { // - Have a 16:9 aspect ratio, // - Have both dimensions divisible by 8 to better play along with video recording, // - Be displayable correctly in windowed mode on a 1366×768 display (tested on Windows 10 with default settings). - GLOBAL_DEF_BASIC("display/window/size/viewport_width", 1152); - custom_prop_info["display/window/size/viewport_width"] = PropertyInfo(Variant::INT, "display/window/size/viewport_width", PROPERTY_HINT_RANGE, "0,7680,1,or_greater"); // 8K resolution + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/viewport_width", PROPERTY_HINT_RANGE, "0,7680,1,or_greater"), 1152); // 8K resolution + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/viewport_height", PROPERTY_HINT_RANGE, "0,4320,1,or_greater"), 648); // 8K resolution - GLOBAL_DEF_BASIC("display/window/size/viewport_height", 648); - custom_prop_info["display/window/size/viewport_height"] = PropertyInfo(Variant::INT, "display/window/size/viewport_height", PROPERTY_HINT_RANGE, "0,4320,1,or_greater"); // 8K resolution - - GLOBAL_DEF_BASIC("display/window/size/mode", 0); - custom_prop_info["display/window/size/mode"] = PropertyInfo(Variant::INT, "display/window/size/mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,Fullscreen,Exclusive Fullscreen"); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/mode", PROPERTY_HINT_ENUM, "Windowed,Minimized,Maximized,Fullscreen,Exclusive Fullscreen"), 0); // Keep the enum values in sync with the `DisplayServer::SCREEN_` enum. - GLOBAL_DEF_BASIC("display/window/size/initial_screen", -2); - String screen_hints = "Primary Monitor:-2"; // Note: Main Window Monitor:-1 is not used for the main window, skip it. - for (int i = 0; i < 64; i++) { - screen_hints += ",Monitor " + itos(i + 1) + ":" + itos(i); - } - custom_prop_info["display/window/size/initial_screen"] = PropertyInfo(Variant::INT, "display/window/size/initial_screen", PROPERTY_HINT_ENUM, screen_hints); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_position_type", PROPERTY_HINT_ENUM, "Absolute,Primary Screen Center,Other Screen Center"), 1); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::VECTOR2I, "display/window/size/initial_position"), Vector2i()); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "display/window/size/initial_screen", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), 0); GLOBAL_DEF_BASIC("display/window/size/resizable", true); GLOBAL_DEF_BASIC("display/window/size/borderless", false); @@ -1273,20 +1263,15 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("display/window/size/extend_to_title", false); GLOBAL_DEF("display/window/size/no_focus", false); - GLOBAL_DEF("display/window/size/window_width_override", 0); - custom_prop_info["display/window/size/window_width_override"] = PropertyInfo(Variant::INT, "display/window/size/window_width_override", PROPERTY_HINT_RANGE, "0,7680,1,or_greater"); // 8K resolution - GLOBAL_DEF("display/window/size/window_height_override", 0); - custom_prop_info["display/window/size/window_height_override"] = PropertyInfo(Variant::INT, "display/window/size/window_height_override", PROPERTY_HINT_RANGE, "0,4320,1,or_greater"); // 8K resolution + GLOBAL_DEF(PropertyInfo(Variant::INT, "display/window/size/window_width_override", PROPERTY_HINT_RANGE, "0,7680,1,or_greater"), 0); // 8K resolution + GLOBAL_DEF(PropertyInfo(Variant::INT, "display/window/size/window_height_override", PROPERTY_HINT_RANGE, "0,4320,1,or_greater"), 0); // 8K resolution GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true); GLOBAL_DEF("display/window/energy_saving/keep_screen_on.editor", false); - GLOBAL_DEF_BASIC("audio/buses/default_bus_layout", "res://default_bus_layout.tres"); - custom_prop_info["audio/buses/default_bus_layout"] = PropertyInfo(Variant::STRING, "audio/buses/default_bus_layout", PROPERTY_HINT_FILE, "*.tres"); - GLOBAL_DEF_RST("audio/general/2d_panning_strength", 0.5f); - custom_prop_info["audio/general/2d_panning_strength"] = PropertyInfo(Variant::FLOAT, "audio/general/2d_panning_strength", PROPERTY_HINT_RANGE, "0,2,0.01"); - GLOBAL_DEF_RST("audio/general/3d_panning_strength", 0.5f); - custom_prop_info["audio/general/3d_panning_strength"] = PropertyInfo(Variant::FLOAT, "audio/general/3d_panning_strength", PROPERTY_HINT_RANGE, "0,2,0.01"); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "audio/buses/default_bus_layout", PROPERTY_HINT_FILE, "*.tres"), "res://default_bus_layout.tres"); + GLOBAL_DEF_RST(PropertyInfo(Variant::FLOAT, "audio/general/2d_panning_strength", PROPERTY_HINT_RANGE, "0,2,0.01"), 0.5f); + GLOBAL_DEF_RST(PropertyInfo(Variant::FLOAT, "audio/general/3d_panning_strength", PROPERTY_HINT_RANGE, "0,2,0.01"), 0.5f); PackedStringArray extensions; extensions.push_back("gd"); @@ -1297,11 +1282,13 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("editor/run/main_run_args", ""); - GLOBAL_DEF("editor/script/search_in_file_extensions", extensions); - custom_prop_info["editor/script/search_in_file_extensions"] = PropertyInfo(Variant::PACKED_STRING_ARRAY, "editor/script/search_in_file_extensions"); + GLOBAL_DEF(PropertyInfo(Variant::PACKED_STRING_ARRAY, "editor/script/search_in_file_extensions"), extensions); + + GLOBAL_DEF(PropertyInfo(Variant::STRING, "editor/script/templates_search_path", PROPERTY_HINT_DIR), "res://script_templates"); - GLOBAL_DEF("editor/script/templates_search_path", "res://script_templates"); - custom_prop_info["editor/script/templates_search_path"] = PropertyInfo(Variant::STRING, "editor/script/templates_search_path", PROPERTY_HINT_DIR); + // For correct doc generation. + GLOBAL_DEF("editor/naming/default_signal_callback_name", "_on_{node_name}_{signal_name}"); + GLOBAL_DEF("editor/naming/default_signal_callback_to_self_name", "_on_{signal_name}"); _add_builtin_input_map(); @@ -1313,21 +1300,13 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("physics/2d/run_on_separate_thread", false); GLOBAL_DEF("physics/3d/run_on_separate_thread", false); - GLOBAL_DEF("debug/settings/profiler/max_functions", 16384); - custom_prop_info["debug/settings/profiler/max_functions"] = PropertyInfo(Variant::INT, "debug/settings/profiler/max_functions", PROPERTY_HINT_RANGE, "128,65535,1"); - - GLOBAL_DEF("compression/formats/zstd/long_distance_matching", Compression::zstd_long_distance_matching); - custom_prop_info["compression/formats/zstd/long_distance_matching"] = PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching"); - GLOBAL_DEF("compression/formats/zstd/compression_level", Compression::zstd_level); - custom_prop_info["compression/formats/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"); - GLOBAL_DEF("compression/formats/zstd/window_log_size", Compression::zstd_window_log_size); - custom_prop_info["compression/formats/zstd/window_log_size"] = PropertyInfo(Variant::INT, "compression/formats/zstd/window_log_size", PROPERTY_HINT_RANGE, "10,30,1"); - - GLOBAL_DEF("compression/formats/zlib/compression_level", Compression::zlib_level); - custom_prop_info["compression/formats/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); + GLOBAL_DEF(PropertyInfo(Variant::INT, "debug/settings/profiler/max_functions", PROPERTY_HINT_RANGE, "128,65535,1"), 16384); - GLOBAL_DEF("compression/formats/gzip/compression_level", Compression::gzip_level); - custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); + GLOBAL_DEF(PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching"), Compression::zstd_long_distance_matching); + GLOBAL_DEF(PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"), Compression::zstd_level); + GLOBAL_DEF(PropertyInfo(Variant::INT, "compression/formats/zstd/window_log_size", PROPERTY_HINT_RANGE, "10,30,1"), Compression::zstd_window_log_size); + GLOBAL_DEF(PropertyInfo(Variant::INT, "compression/formats/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"), Compression::zlib_level); + GLOBAL_DEF(PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"), Compression::gzip_level); GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug to the project developer.")); diff --git a/core/core_constants.cpp b/core/core_constants.cpp index edb72f73cb..b1f56539e5 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -274,14 +274,9 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KP_7); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KP_8); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KP_9); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SUPER_L); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SUPER_R); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MENU); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPER_L); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPER_R); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPER); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HELP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIRECTION_L); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIRECTION_R); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BACK); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, FORWARD); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, STOP); @@ -289,11 +284,6 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, VOLUMEDOWN); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, VOLUMEMUTE); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, VOLUMEUP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BASSBOOST); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BASSUP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BASSDOWN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TREBLEUP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TREBLEDOWN); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MEDIAPLAY); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MEDIASTOP); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MEDIAPREVIOUS); @@ -392,72 +382,12 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BAR); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BRACERIGHT); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ASCIITILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NOBREAKSPACE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EXCLAMDOWN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CENT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, STERLING); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CURRENCY); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, YEN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BROKENBAR); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SECTION); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, COPYRIGHT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ORDFEMININE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, GUILLEMOTLEFT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NOTSIGN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPHEN); - BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(Key, KEY_REGISTERED, KEY_REGISTERED); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MACRON); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DEGREE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, PLUSMINUS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TWOSUPERIOR); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, THREESUPERIOR); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MU); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, PARAGRAPH); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, PERIODCENTERED); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CEDILLA); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ONESUPERIOR); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MASCULINE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, GUILLEMOTRIGHT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ONEQUARTER); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ONEHALF); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, THREEQUARTERS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, QUESTIONDOWN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, AGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, AACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ACIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ATILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ADIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ARING); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, AE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CCEDILLA); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ECIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EDIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, IGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, IACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ICIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, IDIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ETH); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NTILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OCIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OTILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ODIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MULTIPLY); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OOBLIQUE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UCIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UDIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, YACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, THORN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SSHARP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIVISION); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, YDIAERESIS); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, GLOBE); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KEYBOARD); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, JIS_EISU); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, JIS_KANA); BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(KeyModifierMask, KEY_CODE_MASK, CODE_MASK); BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(KeyModifierMask, KEY_MODIFIER_MASK, MODIFIER_MASK); @@ -656,7 +586,8 @@ void register_global_constants() { BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_CLASS_IS_ENUM); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NIL_IS_VARIANT); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_ARRAY); - BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE); + BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_ALWAYS_DUPLICATE); + BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NEVER_DUPLICATE); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_HIGH_END_GFX); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT); BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT); diff --git a/core/error/error_macros.cpp b/core/error/error_macros.cpp index ddfee3fc5d..8376c0aaf8 100644 --- a/core/error/error_macros.cpp +++ b/core/error/error_macros.cpp @@ -118,11 +118,11 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const char *p_message, bool p_editor_notify, bool p_fatal) { String fstr(p_fatal ? "FATAL: " : ""); String err(fstr + "Index " + p_index_str + " = " + itos(p_index) + " is out of bounds (" + p_size_str + " = " + itos(p_size) + ")."); - _err_print_error(p_function, p_file, p_line, err.utf8().get_data(), p_message); + _err_print_error(p_function, p_file, p_line, err.utf8().get_data(), p_message, p_editor_notify, ERR_HANDLER_ERROR); } void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, const String &p_message, bool p_editor_notify, bool p_fatal) { - _err_print_index_error(p_function, p_file, p_line, p_index, p_size, p_index_str, p_size_str, p_message.utf8().get_data(), p_fatal); + _err_print_index_error(p_function, p_file, p_line, p_index, p_size, p_index_str, p_size_str, p_message.utf8().get_data(), p_editor_notify, p_fatal); } void _err_flush_stdout() { diff --git a/core/error/error_macros.h b/core/error/error_macros.h index 63a2d22416..65804b7796 100644 --- a/core/error/error_macros.h +++ b/core/error/error_macros.h @@ -189,12 +189,12 @@ void _err_flush_stdout(); * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, the application crashes. */ -#define CRASH_BAD_INDEX(m_index, m_size) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ - _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ +#define CRASH_BAD_INDEX(m_index, m_size) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", false, true); \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) /** @@ -204,12 +204,12 @@ void _err_flush_stdout(); * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, prints `m_msg` and the application crashes. */ -#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ - _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ +#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, false, true); \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) // Unsigned integer index out of bounds error macros. @@ -292,12 +292,12 @@ void _err_flush_stdout(); * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, the application crashes. */ -#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \ - if (unlikely((m_index) >= (m_size))) { \ - _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ +#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \ + if (unlikely((m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", false, true); \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) /** @@ -307,12 +307,12 @@ void _err_flush_stdout(); * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, prints `m_msg` and the application crashes. */ -#define CRASH_BAD_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) >= (m_size))) { \ - _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ +#define CRASH_BAD_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, false, true); \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) // Null reference error macros. diff --git a/core/input/input.cpp b/core/input/input.cpp index 0afa004515..3cf83fd64b 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -93,6 +93,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("is_anything_pressed"), &Input::is_anything_pressed); ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed); ClassDB::bind_method(D_METHOD("is_physical_key_pressed", "keycode"), &Input::is_physical_key_pressed); + ClassDB::bind_method(D_METHOD("is_key_label_pressed", "keycode"), &Input::is_key_label_pressed); ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed); ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed); ClassDB::bind_method(D_METHOD("is_action_pressed", "action", "exact_match"), &Input::is_action_pressed, DEFVAL(false)); @@ -250,6 +251,11 @@ bool Input::is_physical_key_pressed(Key p_keycode) const { return physical_keys_pressed.has(p_keycode); } +bool Input::is_key_label_pressed(Key p_keycode) const { + _THREAD_SAFE_METHOD_ + return key_label_pressed.has(p_keycode); +} + bool Input::is_mouse_button_pressed(MouseButton p_button) const { _THREAD_SAFE_METHOD_ return mouse_button_mask.has_flag(mouse_button_to_mask(p_button)); @@ -343,8 +349,8 @@ float Input::get_axis(const StringName &p_negative_action, const StringName &p_p Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_positive_x, const StringName &p_negative_y, const StringName &p_positive_y, float p_deadzone) const { Vector2 vector = Vector2( - get_action_raw_strength(p_positive_x) - get_action_raw_strength(p_negative_x), - get_action_raw_strength(p_positive_y) - get_action_raw_strength(p_negative_y)); + get_action_strength(p_positive_x) - get_action_strength(p_negative_x), + get_action_strength(p_positive_y) - get_action_strength(p_negative_y)); if (p_deadzone < 0.0f) { // If the deadzone isn't specified, get it from the average of the actions. @@ -499,6 +505,13 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em physical_keys_pressed.erase(k->get_physical_keycode()); } } + if (k.is_valid() && !k->is_echo() && k->get_key_label() != Key::NONE) { + if (k->is_pressed()) { + key_label_pressed.insert(k->get_key_label()); + } else { + key_label_pressed.erase(k->get_key_label()); + } + } Ref<InputEventMouseButton> mb = p_event; @@ -919,6 +932,7 @@ void Input::release_pressed_events() { keys_pressed.clear(); physical_keys_pressed.clear(); + key_label_pressed.clear(); joy_buttons_pressed.clear(); _joy_axis.clear(); diff --git a/core/input/input.h b/core/input/input.h index 0915588700..f2de56b6b9 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -84,6 +84,7 @@ public: private: BitField<MouseButtonMask> mouse_button_mask; + RBSet<Key> key_label_pressed; RBSet<Key> physical_keys_pressed; RBSet<Key> keys_pressed; RBSet<JoyButton> joy_buttons_pressed; @@ -247,6 +248,7 @@ public: bool is_anything_pressed() const; bool is_key_pressed(Key p_keycode) const; bool is_physical_key_pressed(Key p_keycode) const; + bool is_key_label_pressed(Key p_keycode) const; bool is_mouse_button_pressed(MouseButton p_button) const; bool is_joy_button_pressed(int p_device, JoyButton p_button) const; bool is_action_pressed(const StringName &p_action, bool p_exact = false) const; diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 0dd7fdc19b..74c0812f43 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -285,6 +285,8 @@ void InputEventWithModifiers::_bind_methods() { ClassDB::bind_method(D_METHOD("set_meta_pressed", "pressed"), &InputEventWithModifiers::set_meta_pressed); ClassDB::bind_method(D_METHOD("is_meta_pressed"), &InputEventWithModifiers::is_meta_pressed); + ClassDB::bind_method(D_METHOD("get_modifiers_mask"), &InputEventWithModifiers::get_modifiers_mask); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "command_or_control_autoremap"), "set_command_or_control_autoremap", "is_command_or_control_autoremap"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "alt_pressed"), "set_alt_pressed", "is_alt_pressed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shift_pressed"), "set_shift_pressed", "is_shift_pressed"); @@ -328,6 +330,15 @@ Key InputEventKey::get_keycode() const { return keycode; } +void InputEventKey::set_key_label(Key p_key_label) { + key_label = p_key_label; + emit_changed(); +} + +Key InputEventKey::get_key_label() const { + return key_label; +} + void InputEventKey::set_physical_keycode(Key p_keycode) { physical_keycode = p_keycode; emit_changed(); @@ -363,13 +374,72 @@ Key InputEventKey::get_physical_keycode_with_modifiers() const { return physical_keycode | (int64_t)get_modifiers_mask(); } +Key InputEventKey::get_key_label_with_modifiers() const { + return key_label | get_modifiers_mask(); +} + +String InputEventKey::as_text_physical_keycode() const { + String kc; + + if (physical_keycode != Key::NONE) { + kc = keycode_get_string(physical_keycode); + } else { + kc = "(" + RTR("Unset") + ")"; + } + + if (kc.is_empty()) { + return kc; + } + + String mods_text = InputEventWithModifiers::as_text(); + return mods_text.is_empty() ? kc : mods_text + "+" + kc; +} + +String InputEventKey::as_text_keycode() const { + String kc; + + if (keycode != Key::NONE) { + kc = keycode_get_string(keycode); + } else { + kc = "(" + RTR("Unset") + ")"; + } + + if (kc.is_empty()) { + return kc; + } + + String mods_text = InputEventWithModifiers::as_text(); + return mods_text.is_empty() ? kc : mods_text + "+" + kc; +} + +String InputEventKey::as_text_key_label() const { + String kc; + + if (key_label != Key::NONE) { + kc = keycode_get_string(key_label); + } else { + kc = "(" + RTR("Unset") + ")"; + } + + if (kc.is_empty()) { + return kc; + } + + String mods_text = InputEventWithModifiers::as_text(); + return mods_text.is_empty() ? kc : mods_text + "+" + kc; +} + String InputEventKey::as_text() const { String kc; - if (keycode == Key::NONE) { + if (keycode == Key::NONE && physical_keycode == Key::NONE && key_label != Key::NONE) { + kc = keycode_get_string(key_label) + " (Unicode)"; + } else if (keycode != Key::NONE) { + kc = keycode_get_string(keycode); + } else if (physical_keycode != Key::NONE) { kc = keycode_get_string(physical_keycode) + " (" + RTR("Physical") + ")"; } else { - kc = keycode_get_string(keycode); + kc = "(" + RTR("Unset") + ")"; } if (kc.is_empty()) { @@ -386,11 +456,16 @@ String InputEventKey::to_string() { String kc = ""; String physical = "false"; - if (keycode == Key::NONE) { + + if (keycode == Key::NONE && physical_keycode == Key::NONE && unicode != 0) { + kc = "U+" + String::num_uint64(unicode, 16) + " (" + String::chr(unicode) + ")"; + } else if (keycode != Key::NONE) { + kc = itos((int64_t)keycode) + " (" + keycode_get_string(keycode) + ")"; + } else if (physical_keycode != Key::NONE) { kc = itos((int64_t)physical_keycode) + " (" + keycode_get_string(physical_keycode) + ")"; physical = "true"; } else { - kc = itos((int64_t)keycode) + " (" + keycode_get_string(keycode) + ")"; + kc = "(" + RTR("Unset") + ")"; } String mods = InputEventWithModifiers::as_text(); @@ -435,11 +510,16 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_ma } bool match; - if (keycode != Key::NONE) { + if (keycode == Key::NONE && physical_keycode == Key::NONE && key_label != Key::NONE) { + match = key_label == key->key_label; + } else if (keycode != Key::NONE) { match = keycode == key->keycode; + } else if (physical_keycode != Key::NONE) { + match = physical_keycode == key->physical_keycode; } else { - match = get_physical_keycode() == key->get_physical_keycode(); + match = false; } + Key action_mask = (Key)(int64_t)get_modifiers_mask(); Key key_mask = (Key)(int64_t)key->get_modifiers_mask(); if (key->is_pressed()) { @@ -470,12 +550,17 @@ bool InputEventKey::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) return false; } - if (keycode == Key::NONE) { - return physical_keycode == key->physical_keycode && + if (keycode == Key::NONE && physical_keycode == Key::NONE && key_label != Key::NONE) { + return (key_label == key->key_label) && (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask()); - } else { - return keycode == key->keycode && + } else if (keycode != Key::NONE) { + return (keycode == key->keycode) && (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask()); + } else if (physical_keycode != Key::NONE) { + return (physical_keycode == key->physical_keycode) && + (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask()); + } else { + return false; } } @@ -488,6 +573,9 @@ void InputEventKey::_bind_methods() { ClassDB::bind_method(D_METHOD("set_physical_keycode", "physical_keycode"), &InputEventKey::set_physical_keycode); ClassDB::bind_method(D_METHOD("get_physical_keycode"), &InputEventKey::get_physical_keycode); + ClassDB::bind_method(D_METHOD("set_key_label", "key_label"), &InputEventKey::set_key_label); + ClassDB::bind_method(D_METHOD("get_key_label"), &InputEventKey::get_key_label); + ClassDB::bind_method(D_METHOD("set_unicode", "unicode"), &InputEventKey::set_unicode); ClassDB::bind_method(D_METHOD("get_unicode"), &InputEventKey::get_unicode); @@ -495,10 +583,16 @@ void InputEventKey::_bind_methods() { ClassDB::bind_method(D_METHOD("get_keycode_with_modifiers"), &InputEventKey::get_keycode_with_modifiers); ClassDB::bind_method(D_METHOD("get_physical_keycode_with_modifiers"), &InputEventKey::get_physical_keycode_with_modifiers); + ClassDB::bind_method(D_METHOD("get_key_label_with_modifiers"), &InputEventKey::get_key_label_with_modifiers); + + ClassDB::bind_method(D_METHOD("as_text_keycode"), &InputEventKey::as_text_keycode); + ClassDB::bind_method(D_METHOD("as_text_physical_keycode"), &InputEventKey::as_text_physical_keycode); + ClassDB::bind_method(D_METHOD("as_text_key_label"), &InputEventKey::as_text_key_label); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); ADD_PROPERTY(PropertyInfo(Variant::INT, "keycode"), "set_keycode", "get_keycode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "physical_keycode"), "set_physical_keycode", "get_physical_keycode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "key_label"), "set_key_label", "get_key_label"); ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "is_echo"); } diff --git a/core/input/input_event.h b/core/input/input_event.h index 2d7a72e327..797761b208 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -153,6 +153,7 @@ class InputEventKey : public InputEventWithModifiers { Key keycode = Key::NONE; // Key enum, without modifier masks. Key physical_keycode = Key::NONE; + Key key_label = Key::NONE; uint32_t unicode = 0; ///unicode bool echo = false; /// true if this is an echo key @@ -170,6 +171,9 @@ public: void set_physical_keycode(Key p_keycode); Key get_physical_keycode() const; + void set_key_label(Key p_key_label); + Key get_key_label() const; + void set_unicode(char32_t p_unicode); char32_t get_unicode() const; @@ -178,12 +182,16 @@ public: Key get_keycode_with_modifiers() const; Key get_physical_keycode_with_modifiers() const; + Key get_key_label_with_modifiers() const; virtual bool action_match(const Ref<InputEvent> &p_event, bool p_exact_match, float p_deadzone, bool *r_pressed, float *r_strength, float *r_raw_strength) const override; virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override; virtual bool is_action_type() const override { return true; } + virtual String as_text_physical_keycode() const; + virtual String as_text_keycode() const; + virtual String as_text_key_label() const; virtual String as_text() const override; virtual String to_string() override; diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 5e760c7565..6f015ac386 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -44,7 +44,7 @@ typedef uint32_t uintr_t; #endif /** - * Miscellaneous helpers for marshalling data types, and encoding + * Miscellaneous helpers for marshaling data types, and encoding * in an endian independent way */ diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 6d3575b9fa..e44bbc246b 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -262,7 +262,7 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const { if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) { r->set(E.name, p.duplicate(p_subresources)); - } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E.usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { + } else if (p.get_type() == Variant::OBJECT && !(E.usage & PROPERTY_USAGE_NEVER_DUPLICATE) && (p_subresources || (E.usage & PROPERTY_USAGE_ALWAYS_DUPLICATE))) { Ref<Resource> sr = p; if (sr.is_valid()) { r->set(E.name, sr->duplicate(p_subresources)); diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index a54804c5dc..646bdea758 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -106,11 +106,11 @@ void AStar3D::remove_point(int64_t p_id) { bool p_exists = points.lookup(p_id, p); ERR_FAIL_COND_MSG(!p_exists, vformat("Can't remove point. Point with id: %d doesn't exist.", p_id)); - for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { + for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { Segment s(p_id, (*it.key)); segments.erase(s); - (*it.value)->neighbours.remove(p->id); + (*it.value)->neighbors.remove(p->id); (*it.value)->unlinked_neighbours.remove(p->id); } @@ -118,7 +118,7 @@ void AStar3D::remove_point(int64_t p_id) { Segment s(p_id, (*it.key)); segments.erase(s); - (*it.value)->neighbours.remove(p->id); + (*it.value)->neighbors.remove(p->id); (*it.value)->unlinked_neighbours.remove(p->id); } @@ -138,10 +138,10 @@ void AStar3D::connect_points(int64_t p_id, int64_t p_with_id, bool bidirectional bool to_exists = points.lookup(p_with_id, b); ERR_FAIL_COND_MSG(!to_exists, vformat("Can't connect points. Point with id: %d doesn't exist.", p_with_id)); - a->neighbours.set(b->id, b); + a->neighbors.set(b->id, b); if (bidirectional) { - b->neighbours.set(a->id, a); + b->neighbors.set(a->id, a); } else { b->unlinked_neighbours.set(a->id, a); } @@ -155,7 +155,7 @@ void AStar3D::connect_points(int64_t p_id, int64_t p_with_id, bool bidirectional if (element) { s.direction |= element->direction; if (s.direction == Segment::BIDIRECTIONAL) { - // Both are neighbours of each other now + // Both are neighbors of each other now a->unlinked_neighbours.remove(b->id); b->unlinked_neighbours.remove(a->id); } @@ -183,9 +183,9 @@ void AStar3D::disconnect_points(int64_t p_id, int64_t p_with_id, bool bidirectio // Erase the directions to be removed s.direction = (element->direction & ~remove_direction); - a->neighbours.remove(b->id); + a->neighbors.remove(b->id); if (bidirectional) { - b->neighbours.remove(a->id); + b->neighbors.remove(a->id); if (element->direction != Segment::BIDIRECTIONAL) { a->unlinked_neighbours.remove(b->id); b->unlinked_neighbours.remove(a->id); @@ -226,7 +226,7 @@ Vector<int64_t> AStar3D::get_point_connections(int64_t p_id) { Vector<int64_t> point_list; - for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { + for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { point_list.push_back((*it.key)); } @@ -346,8 +346,8 @@ bool AStar3D::_solve(Point *begin_point, Point *end_point) { open_list.remove_at(open_list.size() - 1); p->closed_pass = pass; // Mark the point as closed - for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { - Point *e = *(it.value); // The neighbour point + for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { + Point *e = *(it.value); // The neighbor point if (!e->enabled || e->closed_pass == pass) { continue; @@ -794,7 +794,7 @@ bool AStar2D::_solve(AStar3D::Point *begin_point, AStar3D::Point *end_point) { bool found_route = false; - Vector<AStar3D::Point *> open_list; + LocalVector<AStar3D::Point *> open_list; SortArray<AStar3D::Point *, AStar3D::SortPoints> sorter; begin_point->g_score = 0; @@ -802,19 +802,19 @@ bool AStar2D::_solve(AStar3D::Point *begin_point, AStar3D::Point *end_point) { open_list.push_back(begin_point); while (!open_list.is_empty()) { - AStar3D::Point *p = open_list[0]; // The currently processed point + AStar3D::Point *p = open_list[0]; // The currently processed point. if (p == end_point) { found_route = true; break; } - sorter.pop_heap(0, open_list.size(), open_list.ptrw()); // Remove the current point from the open list + sorter.pop_heap(0, open_list.size(), open_list.ptr()); // Remove the current point from the open list. open_list.remove_at(open_list.size() - 1); - p->closed_pass = astar.pass; // Mark the point as closed + p->closed_pass = astar.pass; // Mark the point as closed. - for (OAHashMap<int64_t, AStar3D::Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { - AStar3D::Point *e = *(it.value); // The neighbour point + for (OAHashMap<int64_t, AStar3D::Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { + AStar3D::Point *e = *(it.value); // The neighbor point. if (!e->enabled || e->closed_pass == astar.pass) { continue; @@ -837,9 +837,9 @@ bool AStar2D::_solve(AStar3D::Point *begin_point, AStar3D::Point *end_point) { e->f_score = e->g_score + _estimate_cost(e->id, end_point->id); if (new_point) { // The position of the new points is already known. - sorter.push_heap(0, open_list.size() - 1, 0, e, open_list.ptrw()); + sorter.push_heap(0, open_list.size() - 1, 0, e, open_list.ptr()); } else { - sorter.push_heap(0, open_list.find(e), 0, e, open_list.ptrw()); + sorter.push_heap(0, open_list.find(e), 0, e, open_list.ptr()); } } } diff --git a/core/math/a_star.h b/core/math/a_star.h index a475e4f2fc..fc4bb09f03 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -52,7 +52,7 @@ class AStar3D : public RefCounted { real_t weight_scale = 0; bool enabled = false; - OAHashMap<int64_t, Point *> neighbours = 4u; + OAHashMap<int64_t, Point *> neighbors = 4u; OAHashMap<int64_t, Point *> unlinked_neighbours = 4u; // Used for pathfinding. diff --git a/core/math/a_star_grid_2d.cpp b/core/math/a_star_grid_2d.cpp index 30d50073d7..677e609763 100644 --- a/core/math/a_star_grid_2d.cpp +++ b/core/math/a_star_grid_2d.cpp @@ -401,7 +401,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point) { List<Point *> nbors; _get_nbors(p, nbors); for (List<Point *>::Element *E = nbors.front(); E; E = E->next()) { - Point *e = E->get(); // The neighbour point. + Point *e = E->get(); // The neighbor point. real_t weight_scale = 1.0; if (jumping_enabled) { diff --git a/core/math/bvh_abb.h b/core/math/bvh_abb.h index 32b011bd3b..fb0207e0bd 100644 --- a/core/math/bvh_abb.h +++ b/core/math/bvh_abb.h @@ -87,7 +87,7 @@ struct BVH_ABB { return -neg_max - min; } - POINT calculate_centre() const { + POINT calculate_center() const { return POINT((calculate_size() * 0.5) + min); } diff --git a/core/math/bvh_split.inc b/core/math/bvh_split.inc index 180bbfb511..875abedb70 100644 --- a/core/math/bvh_split.inc +++ b/core/math/bvh_split.inc @@ -25,7 +25,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u return; } - POINT centre = full_bound.calculate_centre(); + POINT center = full_bound.calculate_center(); POINT size = full_bound.calculate_size(); int order[POINT::AXIS_COUNT]; @@ -43,7 +43,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u for (int a = 0; a < num_a; a++) { uint32_t ind = group_a[a]; - if (temp_bounds[ind].min.coord[split_axis] > centre.coord[split_axis]) { + if (temp_bounds[ind].min.coord[split_axis] > center.coord[split_axis]) { // add to b group_b[num_b++] = ind; @@ -75,7 +75,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u for (int a = 0; a < num_a; a++) { uint32_t ind = group_a[a]; - if (temp_bounds[ind].min.coord[split_axis] > centre.coord[split_axis]) { + if (temp_bounds[ind].min.coord[split_axis] > center.coord[split_axis]) { count++; } } @@ -100,7 +100,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u for (int a = 0; a < num_a; a++) { uint32_t ind = group_a[a]; - if (temp_bounds[ind].min.coord[split_axis] > centre.coord[split_axis]) { + if (temp_bounds[ind].min.coord[split_axis] > center.coord[split_axis]) { // add to b group_b[num_b++] = ind; diff --git a/core/math/color.cpp b/core/math/color.cpp index 5bae8d25d6..3e5fa7b402 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -194,7 +194,7 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) { a = p_alpha; if (p_s == 0.0f) { - // Achromatic (grey) + // Achromatic (gray) r = g = b = p_v; return; } diff --git a/core/math/expression.cpp b/core/math/expression.cpp index da52bb9465..d1ec987d56 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -434,14 +434,13 @@ Error Expression::_get_token(Token &r_token) { } return OK; - } else if (is_ascii_char(cchar) || is_underscore(cchar)) { - String id; - bool first = true; + } else if (is_unicode_identifier_start(cchar)) { + String id = String::chr(cchar); + cchar = GET_CHAR(); - while (is_ascii_char(cchar) || is_underscore(cchar) || (!first && is_digit(cchar))) { + while (is_unicode_identifier_continue(cchar)) { id += String::chr(cchar); cchar = GET_CHAR(); - first = false; } str_ofs--; //go back one diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index 4786110054..590483bf20 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -151,7 +151,7 @@ void Geometry3D::MeshData::optimize_vertices() { } } - for (MeshData::Edge edge : edges) { + for (MeshData::Edge &edge : edges) { int a = edge.vertex_a; int b = edge.vertex_b; diff --git a/core/object/object.cpp b/core/object/object.cpp index 2cb56dfe6c..a8b9e00c96 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -499,7 +499,7 @@ void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) cons _get_property_listv(p_list, p_reversed); if (!is_class("Script")) { // can still be set, but this is for user-friendliness - p_list->push_back(PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_DEFAULT)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NEVER_DUPLICATE)); } if (script_instance && !p_reversed) { diff --git a/core/object/object.h b/core/object/object.h index f78c7c34fd..ec77da4ee1 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -109,15 +109,16 @@ enum PropertyUsageFlags { PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 16, PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 17, PROPERTY_USAGE_ARRAY = 1 << 18, // Used in the inspector to group properties as elements of an array. - PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE = 1 << 19, // If the object is duplicated also this property will be duplicated. - PROPERTY_USAGE_HIGH_END_GFX = 1 << 20, - PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 1 << 21, - PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 1 << 22, - PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 23, // Used in inspector to increment property when keyed in animation player. - PROPERTY_USAGE_DEFERRED_SET_RESOURCE = 1 << 24, // when loading, the resource for this property can be set at the end of loading. - PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT = 1 << 25, // For Object properties, instantiate them when creating in editor. - PROPERTY_USAGE_EDITOR_BASIC_SETTING = 1 << 26, //for project or editor settings, show when basic settings are selected. - PROPERTY_USAGE_READ_ONLY = 1 << 27, // Mark a property as read-only in the inspector. + PROPERTY_USAGE_ALWAYS_DUPLICATE = 1 << 19, // When duplicating a resource, always duplicate, even with subresource duplication disabled. + PROPERTY_USAGE_NEVER_DUPLICATE = 1 << 20, // When duplicating a resource, never duplicate, even with subresource duplication enabled. + PROPERTY_USAGE_HIGH_END_GFX = 1 << 21, + PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 1 << 22, + PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 1 << 23, + PROPERTY_USAGE_KEYING_INCREMENTS = 1 << 24, // Used in inspector to increment property when keyed in animation player. + PROPERTY_USAGE_DEFERRED_SET_RESOURCE = 1 << 25, // when loading, the resource for this property can be set at the end of loading. + PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT = 1 << 26, // For Object properties, instantiate them when creating in editor. + PROPERTY_USAGE_EDITOR_BASIC_SETTING = 1 << 27, //for project or editor settings, show when basic settings are selected. + PROPERTY_USAGE_READ_ONLY = 1 << 28, // Mark a property as read-only in the inspector. PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR, PROPERTY_USAGE_NO_EDITOR = PROPERTY_USAGE_STORAGE, diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 5183b77cb1..25a4b320cd 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -127,14 +127,9 @@ static const _KeyCodeText _keycodes[] = { {Key::KP_7 ,"Kp 7"}, {Key::KP_8 ,"Kp 8"}, {Key::KP_9 ,"Kp 9"}, - {Key::SUPER_L ,"Super L"}, - {Key::SUPER_R ,"Super R"}, {Key::MENU ,"Menu"}, - {Key::HYPER_L ,"Hyper L"}, - {Key::HYPER_R ,"Hyper R"}, + {Key::HYPER ,"Hyper"}, {Key::HELP ,"Help"}, - {Key::DIRECTION_L ,"Direction L"}, - {Key::DIRECTION_R ,"Direction R"}, {Key::BACK ,"Back"}, {Key::FORWARD ,"Forward"}, {Key::STOP ,"Stop"}, @@ -142,11 +137,6 @@ static const _KeyCodeText _keycodes[] = { {Key::VOLUMEDOWN ,"VolumeDown"}, {Key::VOLUMEMUTE ,"VolumeMute"}, {Key::VOLUMEUP ,"VolumeUp"}, - {Key::BASSBOOST ,"BassBoost"}, - {Key::BASSUP ,"BassUp"}, - {Key::BASSDOWN ,"BassDown"}, - {Key::TREBLEUP ,"TrebleUp"}, - {Key::TREBLEDOWN ,"TrebleDown"}, {Key::MEDIAPLAY ,"MediaPlay"}, {Key::MEDIASTOP ,"MediaStop"}, {Key::MEDIAPREVIOUS ,"MediaPrevious"}, @@ -174,6 +164,10 @@ static const _KeyCodeText _keycodes[] = { {Key::LAUNCHD ,"LaunchD"}, {Key::LAUNCHE ,"LaunchE"}, {Key::LAUNCHF ,"LaunchF"}, + {Key::GLOBE ,"Globe"}, + {Key::KEYBOARD ,"On-screen keyboard"}, + {Key::JIS_EISU ,"JIS Eisu"}, + {Key::JIS_KANA ,"JIS Kana"}, {Key::UNKNOWN ,"Unknown"}, {Key::SPACE ,"Space"}, {Key::EXCLAM ,"Exclam"}, @@ -244,72 +238,6 @@ static const _KeyCodeText _keycodes[] = { {Key::BAR ,"Bar"}, {Key::BRACERIGHT ,"BraceRight"}, {Key::ASCIITILDE ,"AsciiTilde"}, - {Key::NOBREAKSPACE ,"NoBreakSpace"}, - {Key::EXCLAMDOWN ,"ExclamDown"}, - {Key::CENT ,"Cent"}, - {Key::STERLING ,"Sterling"}, - {Key::CURRENCY ,"Currency"}, - {Key::YEN ,"Yen"}, - {Key::BROKENBAR ,"BrokenBar"}, - {Key::SECTION ,"Section"}, - {Key::DIAERESIS ,"Diaeresis"}, - {Key::COPYRIGHT ,"Copyright"}, - {Key::ORDFEMININE ,"Ordfeminine"}, - {Key::GUILLEMOTLEFT ,"GuillemotLeft"}, - {Key::NOTSIGN ,"NotSign"}, - {Key::HYPHEN ,"Hyphen"}, - {Key::KEY_REGISTERED ,"Registered"}, - {Key::MACRON ,"Macron"}, - {Key::DEGREE ,"Degree"}, - {Key::PLUSMINUS ,"PlusMinus"}, - {Key::TWOSUPERIOR ,"TwoSuperior"}, - {Key::THREESUPERIOR ,"ThreeSuperior"}, - {Key::ACUTE ,"Acute"}, - {Key::MU ,"Mu"}, - {Key::PARAGRAPH ,"Paragraph"}, - {Key::PERIODCENTERED ,"PeriodCentered"}, - {Key::CEDILLA ,"Cedilla"}, - {Key::ONESUPERIOR ,"OneSuperior"}, - {Key::MASCULINE ,"Masculine"}, - {Key::GUILLEMOTRIGHT ,"GuillemotRight"}, - {Key::ONEQUARTER ,"OneQuarter"}, - {Key::ONEHALF ,"OneHalf"}, - {Key::THREEQUARTERS ,"ThreeQuarters"}, - {Key::QUESTIONDOWN ,"QuestionDown"}, - {Key::AGRAVE ,"Agrave"}, - {Key::AACUTE ,"Aacute"}, - {Key::ACIRCUMFLEX ,"AcircumFlex"}, - {Key::ATILDE ,"Atilde"}, - {Key::ADIAERESIS ,"Adiaeresis"}, - {Key::ARING ,"Aring"}, - {Key::AE ,"Ae"}, - {Key::CCEDILLA ,"Ccedilla"}, - {Key::EGRAVE ,"Egrave"}, - {Key::EACUTE ,"Eacute"}, - {Key::ECIRCUMFLEX ,"Ecircumflex"}, - {Key::EDIAERESIS ,"Ediaeresis"}, - {Key::IGRAVE ,"Igrave"}, - {Key::IACUTE ,"Iacute"}, - {Key::ICIRCUMFLEX ,"Icircumflex"}, - {Key::IDIAERESIS ,"Idiaeresis"}, - {Key::ETH ,"Eth"}, - {Key::NTILDE ,"Ntilde"}, - {Key::OGRAVE ,"Ograve"}, - {Key::OACUTE ,"Oacute"}, - {Key::OCIRCUMFLEX ,"Ocircumflex"}, - {Key::OTILDE ,"Otilde"}, - {Key::ODIAERESIS ,"Odiaeresis"}, - {Key::MULTIPLY ,"Multiply"}, - {Key::OOBLIQUE ,"Ooblique"}, - {Key::UGRAVE ,"Ugrave"}, - {Key::UACUTE ,"Uacute"}, - {Key::UCIRCUMFLEX ,"Ucircumflex"}, - {Key::UDIAERESIS ,"Udiaeresis"}, - {Key::YACUTE ,"Yacute"}, - {Key::THORN ,"Thorn"}, - {Key::SSHARP ,"Ssharp"}, - {Key::DIVISION ,"Division"}, - {Key::YDIAERESIS ,"Ydiaeresis"}, {Key::NONE ,nullptr} /* clang-format on */ }; @@ -378,14 +306,9 @@ bool keycode_has_unicode(Key p_keycode) { case Key::F33: case Key::F34: case Key::F35: - case Key::SUPER_L: - case Key::SUPER_R: case Key::MENU: - case Key::HYPER_L: - case Key::HYPER_R: + case Key::HYPER: case Key::HELP: - case Key::DIRECTION_L: - case Key::DIRECTION_R: case Key::BACK: case Key::FORWARD: case Key::STOP: @@ -393,11 +316,6 @@ bool keycode_has_unicode(Key p_keycode) { case Key::VOLUMEDOWN: case Key::VOLUMEMUTE: case Key::VOLUMEUP: - case Key::BASSBOOST: - case Key::BASSUP: - case Key::BASSDOWN: - case Key::TREBLEUP: - case Key::TREBLEDOWN: case Key::MEDIAPLAY: case Key::MEDIASTOP: case Key::MEDIAPREVIOUS: @@ -426,6 +344,10 @@ bool keycode_has_unicode(Key p_keycode) { case Key::LAUNCHD: case Key::LAUNCHE: case Key::LAUNCHF: + case Key::GLOBE: + case Key::KEYBOARD: + case Key::JIS_EISU: + case Key::JIS_KANA: return false; default: { } @@ -522,3 +444,24 @@ int keycode_get_value_by_index(int p_index) { const char *keycode_get_name_by_index(int p_index) { return _keycodes[p_index].text; } + +char32_t fix_unicode(char32_t p_char) { + if (p_char >= 0x20 && p_char != 0x7F) { + return p_char; + } + return 0; +} + +Key fix_keycode(char32_t p_char, Key p_key) { + if (p_char >= 0x20 && p_char <= 0x7E) { + return (Key)String::char_uppercase(p_char); + } + return p_key; +} + +Key fix_key_label(char32_t p_char, Key p_key) { + if (p_char >= 0x20 && p_char != 0x7F) { + return (Key)String::char_uppercase(p_char); + } + return p_key; +} diff --git a/core/os/keyboard.h b/core/os/keyboard.h index c78fa2a631..84017e89a6 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -124,14 +124,9 @@ enum class Key { KP_7 = SPECIAL | 0x8D, KP_8 = SPECIAL | 0x8E, KP_9 = SPECIAL | 0x8F, - SUPER_L = SPECIAL | 0x40, - SUPER_R = SPECIAL | 0x41, MENU = SPECIAL | 0x42, - HYPER_L = SPECIAL | 0x43, - HYPER_R = SPECIAL | 0x44, + HYPER = SPECIAL | 0x43, HELP = SPECIAL | 0x45, - DIRECTION_L = SPECIAL | 0x46, - DIRECTION_R = SPECIAL | 0x47, BACK = SPECIAL | 0x48, FORWARD = SPECIAL | 0x49, STOP = SPECIAL | 0x4A, @@ -139,11 +134,6 @@ enum class Key { VOLUMEDOWN = SPECIAL | 0x4C, VOLUMEMUTE = SPECIAL | 0x4D, VOLUMEUP = SPECIAL | 0x4E, - BASSBOOST = SPECIAL | 0x4F, - BASSUP = SPECIAL | 0x50, - BASSDOWN = SPECIAL | 0x51, - TREBLEUP = SPECIAL | 0x52, - TREBLEDOWN = SPECIAL | 0x53, MEDIAPLAY = SPECIAL | 0x54, MEDIASTOP = SPECIAL | 0x55, MEDIAPREVIOUS = SPECIAL | 0x56, @@ -173,7 +163,12 @@ enum class Key { LAUNCHE = SPECIAL | 0x6E, LAUNCHF = SPECIAL | 0x6F, - UNKNOWN = SPECIAL | 0xFFFFFF, + GLOBE = SPECIAL | 0x70, + KEYBOARD = SPECIAL | 0x71, + JIS_EISU = SPECIAL | 0x72, + JIS_KANA = SPECIAL | 0x73, + + UNKNOWN = SPECIAL | 0x7FFFFF, /* PRINTABLE LATIN 1 CODES */ @@ -246,74 +241,8 @@ enum class Key { BAR = 0x007C, BRACERIGHT = 0x007D, ASCIITILDE = 0x007E, - NOBREAKSPACE = 0x00A0, - EXCLAMDOWN = 0x00A1, - CENT = 0x00A2, - STERLING = 0x00A3, - CURRENCY = 0x00A4, YEN = 0x00A5, - BROKENBAR = 0x00A6, SECTION = 0x00A7, - DIAERESIS = 0x00A8, - COPYRIGHT = 0x00A9, - ORDFEMININE = 0x00AA, - GUILLEMOTLEFT = 0x00AB, - NOTSIGN = 0x00AC, - HYPHEN = 0x00AD, - KEY_REGISTERED = 0x00AE, // "REGISTERED" is a reserved word on Windows. - MACRON = 0x00AF, - DEGREE = 0x00B0, - PLUSMINUS = 0x00B1, - TWOSUPERIOR = 0x00B2, - THREESUPERIOR = 0x00B3, - ACUTE = 0x00B4, - MU = 0x00B5, - PARAGRAPH = 0x00B6, - PERIODCENTERED = 0x00B7, - CEDILLA = 0x00B8, - ONESUPERIOR = 0x00B9, - MASCULINE = 0x00BA, - GUILLEMOTRIGHT = 0x00BB, - ONEQUARTER = 0x00BC, - ONEHALF = 0x00BD, - THREEQUARTERS = 0x00BE, - QUESTIONDOWN = 0x00BF, - AGRAVE = 0x00C0, - AACUTE = 0x00C1, - ACIRCUMFLEX = 0x00C2, - ATILDE = 0x00C3, - ADIAERESIS = 0x00C4, - ARING = 0x00C5, - AE = 0x00C6, - CCEDILLA = 0x00C7, - EGRAVE = 0x00C8, - EACUTE = 0x00C9, - ECIRCUMFLEX = 0x00CA, - EDIAERESIS = 0x00CB, - IGRAVE = 0x00CC, - IACUTE = 0x00CD, - ICIRCUMFLEX = 0x00CE, - IDIAERESIS = 0x00CF, - ETH = 0x00D0, - NTILDE = 0x00D1, - OGRAVE = 0x00D2, - OACUTE = 0x00D3, - OCIRCUMFLEX = 0x00D4, - OTILDE = 0x00D5, - ODIAERESIS = 0x00D6, - MULTIPLY = 0x00D7, - OOBLIQUE = 0x00D8, - UGRAVE = 0x00D9, - UACUTE = 0x00DA, - UCIRCUMFLEX = 0x00DB, - UDIAERESIS = 0x00DC, - YACUTE = 0x00DD, - THORN = 0x00DE, - SSHARP = 0x00DF, - - DIVISION = 0x00F7, - YDIAERESIS = 0x00FF, - END_LATIN1 = 0x0100, }; enum class KeyModifierMask { @@ -407,4 +336,8 @@ int keycode_get_count(); int keycode_get_value_by_index(int p_index); const char *keycode_get_name_by_index(int p_index); +char32_t fix_unicode(char32_t p_char); +Key fix_keycode(char32_t p_char, Key p_key); +Key fix_key_label(char32_t p_char, Key p_key); + #endif // KEYBOARD_H diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index ca42738b05..672b030806 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -3492,6 +3492,46 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const } } +bool Variant::identity_compare(const Variant &p_variant) const { + if (type != p_variant.type) { + return false; + } + + switch (type) { + case OBJECT: { + return _get_obj().obj == p_variant._get_obj().obj; + } break; + + case DICTIONARY: { + const Dictionary &l = *(reinterpret_cast<const Dictionary *>(_data._mem)); + const Dictionary &r = *(reinterpret_cast<const Dictionary *>(p_variant._data._mem)); + return l.id() == r.id(); + } break; + + case ARRAY: { + const Array &l = *(reinterpret_cast<const Array *>(_data._mem)); + const Array &r = *(reinterpret_cast<const Array *>(p_variant._data._mem)); + return l.id() == r.id(); + } break; + + case PACKED_BYTE_ARRAY: + case PACKED_INT32_ARRAY: + case PACKED_INT64_ARRAY: + case PACKED_FLOAT32_ARRAY: + case PACKED_FLOAT64_ARRAY: + case PACKED_STRING_ARRAY: + case PACKED_VECTOR2_ARRAY: + case PACKED_VECTOR3_ARRAY: + case PACKED_COLOR_ARRAY: { + return _data.packed_array == p_variant._data.packed_array; + } break; + + default: { + return hash_compare(p_variant); + } + } +} + bool StringLikeVariantComparator::compare(const Variant &p_lhs, const Variant &p_rhs) { if (p_lhs.hash_compare(p_rhs)) { return true; diff --git a/core/variant/variant.h b/core/variant/variant.h index b9294de77d..b2f31a6d57 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -748,6 +748,7 @@ public: uint32_t recursive_hash(int recursion_count) const; bool hash_compare(const Variant &p_variant, int recursion_count = 0) const; + bool identity_compare(const Variant &p_variant) const; bool booleanize() const; String stringify(int recursion_count = 0) const; String to_json_string() const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 2cc0b3a8d7..9e8c6fccb3 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -2135,7 +2135,7 @@ static void _register_variant_builtin_methods() { bind_static_method(Projection, create_depth_correction, sarray("flip_y"), varray()); bind_static_method(Projection, create_light_atlas_rect, sarray("rect"), varray()); bind_static_method(Projection, create_perspective, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov"), varray(false)); - bind_static_method(Projection, create_perspective_hmd, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov", "eye", "intraocular_dist", " convergence_dist"), varray()); + bind_static_method(Projection, create_perspective_hmd, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov", "eye", "intraocular_dist", "convergence_dist"), varray()); bind_static_method(Projection, create_for_hmd, sarray("eye", "aspect", "intraocular_dist", "display_width", "display_to_lens", "oversample", "z_near", "z_far"), varray()); bind_static_method(Projection, create_orthogonal, sarray("left", "right", "bottom", "top", "z_near", "z_far"), varray()); bind_static_method(Projection, create_orthogonal_aspect, sarray("size", "aspect", "z_near", "z_far", "flip_fov"), varray(false)); diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index fe7150bca9..042ebe368a 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -1007,9 +1007,14 @@ struct VariantUtilityFunctions { static inline uint64_t rid_allocate_id() { return RID_AllocBase::_gen_id(); } + static inline RID rid_from_int64(uint64_t p_base) { return RID::from_uint64(p_base); } + + static inline bool is_same(const Variant &p_a, const Variant &p_b) { + return p_a.identity_compare(p_b); + } }; #ifdef DEBUG_METHODS_ENABLED @@ -1601,6 +1606,8 @@ void Variant::_register_variant_utility_functions() { FUNCBINDR(rid_allocate_id, Vector<String>(), Variant::UTILITY_FUNC_TYPE_GENERAL); FUNCBINDR(rid_from_int64, sarray("base"), Variant::UTILITY_FUNC_TYPE_GENERAL); + + FUNCBINDR(is_same, sarray("a", "b"), Variant::UTILITY_FUNC_TYPE_GENERAL); } void Variant::_unregister_variant_utility_functions() { |