summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/core_constants.cpp8
-rw-r--r--core/input/input_event.cpp22
-rw-r--r--core/io/image.cpp10
-rw-r--r--core/io/image.h2
-rw-r--r--core/object/class_db.cpp10
-rw-r--r--core/os/keyboard.cpp3
-rw-r--r--core/os/keyboard.h2
-rw-r--r--core/string/ustring.cpp8
-rw-r--r--core/variant/typed_array.h3
-rw-r--r--core/variant/variant.cpp18
10 files changed, 67 insertions, 19 deletions
diff --git a/core/core_constants.cpp b/core/core_constants.cpp
index 2332bc235b..33b3271495 100644
--- a/core/core_constants.cpp
+++ b/core/core_constants.cpp
@@ -420,6 +420,10 @@ void register_global_constants() {
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, LAUNCHD);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, LAUNCHE);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, LAUNCHF);
+ 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_ENUM_CLASS_CONSTANT(Key, KEY, UNKNOWN);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SPACE);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EXCLAM);
@@ -492,10 +496,6 @@ void register_global_constants() {
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ASCIITILDE);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, YEN);
BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SECTION);
- 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);
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index e37886cbe9..9e341b2157 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -1722,7 +1722,27 @@ String InputEventMIDI::as_text() const {
}
String InputEventMIDI::to_string() {
- return vformat("InputEventMIDI: channel=%d, message=%d, pitch=%d, velocity=%d, pressure=%d, controller_number=%d, controller_value=%d", channel, message, pitch, velocity, pressure, controller_number, controller_value);
+ String ret;
+ switch (message) {
+ case MIDIMessage::NOTE_ON:
+ ret = vformat("Note On: channel=%d, pitch=%d, velocity=%d", channel, pitch, velocity);
+ break;
+ case MIDIMessage::NOTE_OFF:
+ ret = vformat("Note Off: channel=%d, pitch=%d, velocity=%d", channel, pitch, velocity);
+ break;
+ case MIDIMessage::PITCH_BEND:
+ ret = vformat("Pitch Bend: channel=%d, pitch=%d", channel, pitch);
+ break;
+ case MIDIMessage::CHANNEL_PRESSURE:
+ ret = vformat("Channel Pressure: channel=%d, pressure=%d", channel, pressure);
+ break;
+ case MIDIMessage::CONTROL_CHANGE:
+ ret = vformat("Control Change: channel=%d, controller_number=%d, controller_value=%d", channel, controller_number, controller_value);
+ break;
+ default:
+ ret = vformat("channel=%d, message=%d, pitch=%d, velocity=%d, pressure=%d, controller_number=%d, controller_value=%d, instrument=%d", channel, message, pitch, velocity, pressure, controller_number, controller_value, instrument);
+ }
+ return "InputEventMIDI: " + ret;
}
void InputEventMIDI::_bind_methods() {
diff --git a/core/io/image.cpp b/core/io/image.cpp
index a5fea09113..3ca39f98c0 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -3018,6 +3018,7 @@ ImageMemLoadFunc Image::_tga_mem_loader_func = nullptr;
ImageMemLoadFunc Image::_bmp_mem_loader_func = nullptr;
ScalableImageMemLoadFunc Image::_svg_scalable_mem_loader_func = nullptr;
ImageMemLoadFunc Image::_dds_mem_loader_func = nullptr;
+ImageMemLoadFunc Image::_ktx_mem_loader_func = nullptr;
void (*Image::_image_compress_bc_func)(Image *, Image::UsedChannels) = nullptr;
void (*Image::_image_compress_bptc_func)(Image *, Image::UsedChannels) = nullptr;
@@ -3490,6 +3491,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("load_tga_from_buffer", "buffer"), &Image::load_tga_from_buffer);
ClassDB::bind_method(D_METHOD("load_bmp_from_buffer", "buffer"), &Image::load_bmp_from_buffer);
ClassDB::bind_method(D_METHOD("load_dds_from_buffer", "buffer"), &Image::load_dds_from_buffer);
+ ClassDB::bind_method(D_METHOD("load_ktx_from_buffer", "buffer"), &Image::load_ktx_from_buffer);
ClassDB::bind_method(D_METHOD("load_svg_from_buffer", "buffer", "scale"), &Image::load_svg_from_buffer, DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("load_svg_from_string", "svg_str", "scale"), &Image::load_svg_from_string, DEFVAL(1.0));
@@ -3873,6 +3875,14 @@ Error Image::load_dds_from_buffer(const Vector<uint8_t> &p_array) {
return _load_from_buffer(p_array, _dds_mem_loader_func);
}
+Error Image::load_ktx_from_buffer(const Vector<uint8_t> &p_array) {
+ ERR_FAIL_NULL_V_MSG(
+ _ktx_mem_loader_func,
+ ERR_UNAVAILABLE,
+ "The KTX module isn't enabled. Recompile the Godot editor or export template binary with the `module_ktx_enabled=yes` SCons option.");
+ return _load_from_buffer(p_array, _ktx_mem_loader_func);
+}
+
void Image::convert_rg_to_ra_rgba8() {
ERR_FAIL_COND(format != FORMAT_RGBA8);
ERR_FAIL_COND(!data.size());
diff --git a/core/io/image.h b/core/io/image.h
index f68543ba24..cb7c6bff52 100644
--- a/core/io/image.h
+++ b/core/io/image.h
@@ -151,6 +151,7 @@ public:
static ImageMemLoadFunc _bmp_mem_loader_func;
static ScalableImageMemLoadFunc _svg_scalable_mem_loader_func;
static ImageMemLoadFunc _dds_mem_loader_func;
+ static ImageMemLoadFunc _ktx_mem_loader_func;
static void (*_image_compress_bc_func)(Image *, UsedChannels p_channels);
static void (*_image_compress_bptc_func)(Image *, UsedChannels p_channels);
@@ -404,6 +405,7 @@ public:
Error load_tga_from_buffer(const Vector<uint8_t> &p_array);
Error load_bmp_from_buffer(const Vector<uint8_t> &p_array);
Error load_dds_from_buffer(const Vector<uint8_t> &p_array);
+ Error load_ktx_from_buffer(const Vector<uint8_t> &p_array);
Error load_svg_from_buffer(const Vector<uint8_t> &p_array, float scale = 1.0);
Error load_svg_from_string(const String &p_svg_str, float scale = 1.0);
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index c8c50fb957..e9fd8ad583 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -1661,7 +1661,15 @@ void ClassDB::register_extension_class(ObjectGDExtension *p_extension) {
c.name = p_extension->class_name;
c.is_virtual = p_extension->is_virtual;
if (!p_extension->is_abstract) {
- c.creation_func = parent->creation_func;
+ // Find the closest ancestor which is either non-abstract or native (or both).
+ ClassInfo *concrete_ancestor = parent;
+ while (concrete_ancestor->creation_func == nullptr &&
+ concrete_ancestor->inherits_ptr != nullptr &&
+ concrete_ancestor->gdextension != nullptr) {
+ concrete_ancestor = concrete_ancestor->inherits_ptr;
+ }
+ ERR_FAIL_NULL_MSG(concrete_ancestor->creation_func, "Extension class " + String(p_extension->class_name) + " cannot extend native abstract class " + String(concrete_ancestor->name));
+ c.creation_func = concrete_ancestor->creation_func;
}
c.inherits = parent->name;
c.class_ptr = parent->class_ptr;
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index 1a51624030..6078882839 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -146,6 +146,7 @@ static const _KeyCodeText _keycodes[] = {
{Key::FAVORITES ,"Favorites"},
{Key::SEARCH ,"Search"},
{Key::STANDBY ,"StandBy"},
+ {Key::OPENURL ,"OpenURL"},
{Key::LAUNCHMAIL ,"LaunchMail"},
{Key::LAUNCHMEDIA ,"LaunchMedia"},
{Key::LAUNCH0 ,"Launch0"},
@@ -238,6 +239,8 @@ static const _KeyCodeText _keycodes[] = {
{Key::BAR ,"Bar"},
{Key::BRACERIGHT ,"BraceRight"},
{Key::ASCIITILDE ,"AsciiTilde"},
+ {Key::YEN ,"Yen"},
+ {Key::SECTION ,"Section"},
{Key::NONE ,nullptr}
/* clang-format on */
};
diff --git a/core/os/keyboard.h b/core/os/keyboard.h
index cf276dc49f..785972d31d 100644
--- a/core/os/keyboard.h
+++ b/core/os/keyboard.h
@@ -33,6 +33,8 @@
#include "core/string/ustring.h"
+// Keep the values in this enum in sync with `_keycodes` in `keyboard.cpp`,
+// and the bindings in `core_constants.cpp`.
enum class Key {
NONE = 0,
// Special key: The strategy here is similar to the one used by toolkits,
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 80ca51573c..3f11459a1e 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -3665,7 +3665,9 @@ String String::left(int p_len) const {
return *this;
}
- return substr(0, p_len);
+ String s;
+ s.copy_from_unchecked(&get_data()[0], p_len);
+ return s;
}
String String::right(int p_len) const {
@@ -3681,7 +3683,9 @@ String String::right(int p_len) const {
return *this;
}
- return substr(length() - p_len);
+ String s;
+ s.copy_from_unchecked(&get_data()[length() - p_len], p_len);
+ return s;
}
char32_t String::unicode_at(int p_idx) const {
diff --git a/core/variant/typed_array.h b/core/variant/typed_array.h
index 98afc7e717..055c52aa63 100644
--- a/core/variant/typed_array.h
+++ b/core/variant/typed_array.h
@@ -230,4 +230,7 @@ MAKE_TYPED_ARRAY_INFO(Vector<Vector3>, Variant::PACKED_VECTOR3_ARRAY)
MAKE_TYPED_ARRAY_INFO(Vector<Color>, Variant::PACKED_COLOR_ARRAY)
MAKE_TYPED_ARRAY_INFO(IPAddress, Variant::STRING)
+#undef MAKE_TYPED_ARRAY
+#undef MAKE_TYPED_ARRAY_INFO
+
#endif // TYPED_ARRAY_H
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 10a267e5a9..8a0289898d 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -1754,11 +1754,10 @@ String Variant::stringify(int recursion_count) const {
case COLOR:
return operator Color();
case DICTIONARY: {
+ ERR_FAIL_COND_V_MSG(recursion_count > MAX_RECURSION, "{ ... }", "Maximum dictionary recursion reached!");
+ recursion_count++;
+
const Dictionary &d = *reinterpret_cast<const Dictionary *>(_data._mem);
- if (recursion_count > MAX_RECURSION) {
- ERR_PRINT("Maximum dictionary recursion reached!");
- return "{ ... }";
- }
// Add leading and trailing space to Dictionary printing. This distinguishes it
// from array printing on fonts that have similar-looking {} and [] characters.
@@ -1768,7 +1767,6 @@ String Variant::stringify(int recursion_count) const {
Vector<_VariantStrPair> pairs;
- recursion_count++;
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
_VariantStrPair sp;
sp.key = stringify_variant_clean(E->get(), recursion_count);
@@ -1787,6 +1785,7 @@ String Variant::stringify(int recursion_count) const {
return str;
}
+ // Packed arrays cannot contain recursive structures, the recursion_count increment is not needed.
case PACKED_VECTOR2_ARRAY: {
return stringify_vector(operator Vector<Vector2>(), recursion_count);
}
@@ -1815,13 +1814,10 @@ String Variant::stringify(int recursion_count) const {
return stringify_vector(operator Vector<double>(), recursion_count);
}
case ARRAY: {
- Array arr = operator Array();
- if (recursion_count > MAX_RECURSION) {
- ERR_PRINT("Maximum array recursion reached!");
- return "[...]";
- }
+ ERR_FAIL_COND_V_MSG(recursion_count > MAX_RECURSION, "[...]", "Maximum array recursion reached!");
+ recursion_count++;
- return stringify_vector(arr, recursion_count);
+ return stringify_vector(operator Array(), recursion_count);
}
case OBJECT: {
if (_get_obj().obj) {