summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/classes/EditorExportPlugin.xml8
-rw-r--r--doc/classes/EditorSettings.xml4
-rw-r--r--editor/animation_track_editor.cpp16
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/export/editor_export_platform.cpp191
-rw-r--r--editor/plugins/font_config_plugin.cpp47
-rw-r--r--editor/plugins/font_config_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp67
-rw-r--r--misc/dist/html/editor.html1
-rw-r--r--modules/gdscript/gdscript_lambda_callable.cpp4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd18
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out3
-rw-r--r--modules/gltf/doc_classes/GLTFAccessor.xml27
-rw-r--r--modules/gltf/gltf_document.cpp78
-rw-r--r--modules/gltf/gltf_document.h8
-rw-r--r--modules/gltf/structures/gltf_accessor.cpp28
-rw-r--r--modules/gltf/structures/gltf_accessor.h30
-rw-r--r--modules/jpg/image_loader_jpegd.cpp2
-rw-r--r--platform/web/web_main.cpp1
-rw-r--r--scene/gui/text_edit.cpp30
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/resources/font.cpp1
22 files changed, 333 insertions, 235 deletions
diff --git a/doc/classes/EditorExportPlugin.xml b/doc/classes/EditorExportPlugin.xml
index 4d304cf5fd..9ef911a68d 100644
--- a/doc/classes/EditorExportPlugin.xml
+++ b/doc/classes/EditorExportPlugin.xml
@@ -36,7 +36,6 @@
<description>
Customize a resource. If changes are made to it, return the same or a new resource. Otherwise, return [code]null[/code].
The [i]path[/i] argument is only used when customizing an actual file, otherwise this means that this resource is part of another one and it will be empty.
- Calling [method skip] inside this callback will make the file not included in the export.
Implementing this method is required if [method _begin_customize_resources] returns [code]true[/code].
</description>
</method>
@@ -46,7 +45,6 @@
<param index="1" name="path" type="String" />
<description>
Customize a scene. If changes are made to it, return the same or a new scene. Otherwise, return [code]null[/code]. If a new scene is returned, it is up to you to dispose of the old one.
- Calling [method skip] inside this callback will make the file not included in the export.
Implementing this method is required if [method _begin_customize_scenes] returns [code]true[/code].
</description>
</method>
@@ -84,9 +82,8 @@
<param index="1" name="type" type="String" />
<param index="2" name="features" type="PackedStringArray" />
<description>
- Virtual method to be overridden by the user. Called for each exported file, except for imported resources (resources that have an associated [code].import[/code] file). The arguments can be used to identify the file. [param path] is the path of the file, [param type] is the [Resource] represented by the file (e.g. [PackedScene]), and [param features] is the list of features for the export.
+ Virtual method to be overridden by the user. Called for each exported file before [method _customize_resource] and [method _customize_scene]. The arguments can be used to identify the file. [param path] is the path of the file, [param type] is the [Resource] represented by the file (e.g. [PackedScene]), and [param features] is the list of features for the export.
Calling [method skip] inside this callback will make the file not included in the export.
- Use [method _customize_resource] for imported resources that are not handled by this function.
</description>
</method>
<method name="_get_android_dependencies" qualifiers="virtual const">
@@ -235,6 +232,7 @@
<description>
Adds a custom file to be exported. [param path] is the virtual path that can be used to load the file, [param file] is the binary data of the file.
When called inside [method _export_file] and [param remap] is [code]true[/code], the current file will not be exported, but instead remapped to this custom file. [param remap] is ignored when called in other places.
+ [param file] will not be imported, so consider using [method _customize_resource] to remap imported resources.
</description>
</method>
<method name="add_ios_bundle_file">
@@ -317,7 +315,7 @@
<method name="skip">
<return type="void" />
<description>
- To be called inside [method _export_file], [method _customize_resource], or [method _customize_scene]. Skips the current file, so it's not included in the export.
+ To be called inside [method _export_file]. Skips the current file, so it's not included in the export.
</description>
</method>
</methods>
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index c97ae197d9..c7ff543b66 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -396,6 +396,10 @@
<member name="editors/animation/autorename_animation_tracks" type="bool" setter="" getter="">
If [code]true[/code], automatically updates animation tracks' target paths when renaming or reparenting nodes in the Scene tree dock.
</member>
+ <member name="editors/animation/confirm_insert_track" type="bool" setter="" getter="">
+ If [code]true[/code], display a confirmation dialog when adding a new track to an animation by pressing the "key" icon next to a property. Holding Shift will bypass the dialog.
+ If [code]false[/code], the behavior is reversed, i.e. the dialog only appears when Shift is held.
+ </member>
<member name="editors/animation/default_create_bezier_tracks" type="bool" setter="" getter="">
If [code]true[/code], create a Bezier track instead of a standard track when pressing the "key" icon next to a property. Bezier tracks provide more control over animation curves, but are more difficult to adjust quickly.
</member>
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 9c7c275053..6810b802a1 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -3867,15 +3867,23 @@ void AnimationTrackEditor::commit_insert_queue() {
}
// Skip the confirmation dialog if the user holds Shift while clicking the key icon.
- if (!Input::get_singleton()->is_key_pressed(Key::SHIFT) && num_tracks > 0) {
- String shortcut_hint = TTR("Hold Shift when clicking the key icon to skip this dialog.");
+ // If `confirm_insert_track` editor setting is disabled, the behavior is reversed.
+ bool confirm_insert = EDITOR_GET("editors/animation/confirm_insert_track");
+ if ((Input::get_singleton()->is_key_pressed(Key::SHIFT) != confirm_insert) && num_tracks > 0) {
+ String dialog_text;
+
// Potentially a new key, does not exist.
if (num_tracks == 1) {
// TRANSLATORS: %s will be replaced by a phrase describing the target of track.
- insert_confirm_text->set_text(vformat(TTR("Create new track for %s and insert key?") + "\n\n" + shortcut_hint, last_track_query));
+ dialog_text = vformat(TTR("Create new track for %s and insert key?"), last_track_query);
} else {
- insert_confirm_text->set_text(vformat(TTR("Create %d new tracks and insert keys?") + "\n\n" + shortcut_hint, num_tracks));
+ dialog_text = vformat(TTR("Create %d new tracks and insert keys?"), num_tracks);
+ }
+
+ if (confirm_insert) {
+ dialog_text += +"\n\n" + TTR("Hold Shift when clicking the key icon to skip this dialog.");
}
+ insert_confirm_text->set_text(dialog_text);
insert_confirm_bezier->set_visible(all_bezier);
insert_confirm_reset->set_visible(reset_allowed);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 85e60df1dd..5d3cc80da9 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -786,6 +786,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Animation
_initial_set("editors/animation/autorename_animation_tracks", true);
+ _initial_set("editors/animation/confirm_insert_track", true);
_initial_set("editors/animation/default_create_bezier_tracks", false);
_initial_set("editors/animation/default_create_reset_tracks", true);
_initial_set("editors/animation/onion_layers_past_color", Color(1, 0, 0));
diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp
index 527544fea3..c0646dc572 100644
--- a/editor/export/editor_export_platform.cpp
+++ b/editor/export/editor_export_platform.cpp
@@ -797,10 +797,6 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector
if (!customize_scenes_plugins.is_empty()) {
for (Ref<EditorExportPlugin> &plugin : customize_scenes_plugins) {
Node *customized = plugin->_customize_scene(node, p_path);
- if (plugin->skipped) {
- plugin->_clear();
- return String();
- }
if (customized != nullptr) {
node = customized;
modified = true;
@@ -834,10 +830,6 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector
if (!customize_resources_plugins.is_empty()) {
for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
Ref<Resource> new_res = plugin->_customize_resource(res, p_path);
- if (plugin->skipped) {
- plugin->_clear();
- return String();
- }
if (new_res.is_valid()) {
modified = true;
if (new_res != res) {
@@ -1132,33 +1124,97 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
//store everything in the export medium
- int idx = 0;
int total = paths.size();
+ // idx is incremented at the beginning of the paths loop to easily allow
+ // for continue statements without accidentally skipping an increment.
+ int idx = total > 0 ? -1 : 0;
for (const String &E : paths) {
+ idx++;
String path = E;
String type = ResourceLoader::get_resource_type(path);
- if (FileAccess::exists(path + ".import")) {
- // Before doing this, try to see if it can be customized.
+ bool has_import_file = FileAccess::exists(path + ".import");
+ Ref<ConfigFile> config;
+ if (has_import_file) {
+ config.instantiate();
+ err = config->load(path + ".import");
+ if (err != OK) {
+ ERR_PRINT("Could not parse: '" + path + "', not exported.");
+ continue;
+ }
+
+ String importer_type = config->get_value("remap", "importer");
+
+ if (importer_type == "skip") {
+ // Skip file.
+ continue;
+ }
+ }
+
+ bool do_export = true;
+ for (int i = 0; i < export_plugins.size(); i++) {
+ if (GDVIRTUAL_IS_OVERRIDDEN_PTR(export_plugins[i], _export_file)) {
+ export_plugins.write[i]->_export_file_script(path, type, features_psa);
+ } else {
+ export_plugins.write[i]->_export_file(path, type, features);
+ }
+ if (p_so_func) {
+ for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) {
+ err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]);
+ if (err != OK) {
+ return err;
+ }
+ }
+ }
+
+ for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) {
+ err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key);
+ if (err != OK) {
+ return err;
+ }
+ if (export_plugins[i]->extra_files[j].remap) {
+ do_export = false; // If remap, do not.
+ path_remaps.push_back(path);
+ path_remaps.push_back(export_plugins[i]->extra_files[j].path);
+ }
+ }
+
+ if (export_plugins[i]->skipped) {
+ do_export = false;
+ }
+ export_plugins.write[i]->_clear();
+
+ if (!do_export) {
+ break;
+ }
+ }
+ if (!do_export) {
+ continue;
+ }
+
+ if (has_import_file) {
+ String importer_type = config->get_value("remap", "importer");
+
+ if (importer_type == "keep") {
+ // Just keep file as-is.
+ Vector<uint8_t> array = FileAccess::get_file_as_bytes(path);
+ err = p_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key);
+
+ if (err != OK) {
+ return err;
+ }
- String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, false);
- if (export_path.is_empty()) {
- // Skipped from plugin.
continue;
}
+ // Before doing this, try to see if it can be customized.
+ String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, false);
+
if (export_path != path) {
// It was actually customized.
// Since the original file is likely not recognized, just use the import system.
- Ref<ConfigFile> config;
- config.instantiate();
- err = config->load(path + ".import");
- if (err != OK) {
- ERR_PRINT("Could not parse: '" + path + "', not exported.");
- continue;
- }
config->set_value("remap", "type", ResourceLoader::get_resource_type(export_path));
// Erase all Paths.
@@ -1194,33 +1250,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
} else {
// File is imported and not customized, replace by what it imports.
- Ref<ConfigFile> config;
- config.instantiate();
- err = config->load(path + ".import");
- if (err != OK) {
- ERR_PRINT("Could not parse: '" + path + "', not exported.");
- continue;
- }
-
- String importer_type = config->get_value("remap", "importer");
-
- if (importer_type == "skip") {
- // Skip file.
- continue;
- }
-
- if (importer_type == "keep") {
- // Just keep file as-is.
- Vector<uint8_t> array = FileAccess::get_file_as_bytes(path);
- err = p_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key);
-
- if (err != OK) {
- return err;
- }
-
- continue;
- }
-
List<String> remaps;
config->get_section_keys("remap", &remaps);
@@ -1282,66 +1311,24 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
} else {
- // Customize.
+ // Just store it as it comes.
- bool do_export = true;
- for (int i = 0; i < export_plugins.size(); i++) {
- if (GDVIRTUAL_IS_OVERRIDDEN_PTR(export_plugins[i], _export_file)) {
- export_plugins.write[i]->_export_file_script(path, type, features_psa);
- } else {
- export_plugins.write[i]->_export_file(path, type, features);
- }
- if (p_so_func) {
- for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) {
- err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]);
- if (err != OK) {
- return err;
- }
- }
- }
-
- for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) {
- err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key);
- if (err != OK) {
- return err;
- }
- if (export_plugins[i]->extra_files[j].remap) {
- do_export = false; //if remap, do not
- path_remaps.push_back(path);
- path_remaps.push_back(export_plugins[i]->extra_files[j].path);
- }
- }
+ // Customization only happens if plugins did not take care of it before.
+ bool force_binary = convert_text_to_binary && (path.get_extension().to_lower() == "tres" || path.get_extension().to_lower() == "tscn");
+ String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, force_binary);
- if (export_plugins[i]->skipped) {
- do_export = false;
- }
- export_plugins.write[i]->_clear();
-
- if (!do_export) {
- break; //apologies, not exporting
- }
+ if (export_path != path) {
+ // Add a remap entry.
+ path_remaps.push_back(path);
+ path_remaps.push_back(export_path);
}
- //just store it as it comes
- if (do_export) {
- // Customization only happens if plugins did not take care of it before
- bool force_binary = convert_text_to_binary && (path.get_extension().to_lower() == "tres" || path.get_extension().to_lower() == "tscn");
- String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, force_binary);
-
- if (export_path != path) {
- // Add a remap entry
- path_remaps.push_back(path);
- path_remaps.push_back(export_path);
- }
- Vector<uint8_t> array = FileAccess::get_file_as_bytes(export_path);
- err = p_func(p_udata, export_path, array, idx, total, enc_in_filters, enc_ex_filters, key);
- if (err != OK) {
- return err;
- }
+ Vector<uint8_t> array = FileAccess::get_file_as_bytes(export_path);
+ err = p_func(p_udata, export_path, array, idx, total, enc_in_filters, enc_ex_filters, key);
+ if (err != OK) {
+ return err;
}
}
-
- idx++;
}
if (convert_text_to_binary || !customize_resources_plugins.is_empty() || !customize_scenes_plugins.is_empty()) {
diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp
index 15b268337f..e6ce63fe36 100644
--- a/editor/plugins/font_config_plugin.cpp
+++ b/editor/plugins/font_config_plugin.cpp
@@ -386,15 +386,8 @@ EditorPropertyFontMetaOverride::EditorPropertyFontMetaOverride(bool p_script) {
void EditorPropertyOTVariation::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) {
if (p_property.begins_with("keys")) {
Dictionary dict = object->get_dict();
- Dictionary defaults_dict = object->get_defaults();
int key = p_property.get_slice("/", 1).to_int();
dict[key] = (int)p_value;
- if (defaults_dict.has(key)) {
- Vector3i range = defaults_dict[key];
- if (range.z == (int)p_value) {
- dict.erase(key);
- }
- }
emit_changed(get_edited_property(), dict, "", true);
@@ -422,6 +415,14 @@ void EditorPropertyOTVariation::update_property() {
Dictionary supported = (fd.is_valid()) ? fd->get_supported_variation_list() : Dictionary();
+ for (int i = 0; i < supported.size(); i++) {
+ int name_tag = supported.get_key_at_index(i);
+ Vector3i range = supported.get_value_at_index(i);
+ if ((dict.has(name_tag) && dict[name_tag].get_type() == Variant::NIL) || !dict.has(name_tag)) {
+ dict[name_tag] = range.z;
+ }
+ }
+
edit->set_text(vformat(TTR("Variation Coordinates (%d)"), supported.size()));
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
@@ -481,7 +482,21 @@ void EditorPropertyOTVariation::update_property() {
prop->set_object_and_property(object.ptr(), "keys/" + itos(name_tag));
String name = TS->tag_to_name(name_tag);
- prop->set_label(name.capitalize());
+ String name_cap;
+ {
+ String aux = name.replace("_", " ").strip_edges();
+ for (int j = 0; j < aux.get_slice_count(" "); j++) {
+ String slice = aux.get_slicec(' ', j);
+ if (slice.length() > 0) {
+ slice[0] = String::char_uppercase(slice[0]);
+ if (i > 0) {
+ name_cap += " ";
+ }
+ name_cap += slice;
+ }
+ }
+ }
+ prop->set_label(name_cap);
prop->set_tooltip_text(name);
prop->set_selectable(false);
@@ -935,6 +950,12 @@ void FontPreview::_notification(int p_what) {
font->draw_string(get_canvas_item(), Point2(0, font->get_height(font_size) + 2 * EDSCALE), TTR("Unable to preview font"), HORIZONTAL_ALIGNMENT_CENTER, get_size().x, font_size, text_color);
}
} break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ if (prev_font.is_valid()) {
+ prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
+ } break;
}
}
@@ -945,7 +966,17 @@ Size2 FontPreview::get_minimum_size() const {
}
void FontPreview::set_data(const Ref<Font> &p_f) {
+ if (prev_font.is_valid()) {
+ prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
prev_font = p_f;
+ if (prev_font.is_valid()) {
+ prev_font->connect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
+ queue_redraw();
+}
+
+void FontPreview::_preview_changed() {
queue_redraw();
}
diff --git a/editor/plugins/font_config_plugin.h b/editor/plugins/font_config_plugin.h
index 7b2d26da4a..4e798fc3e8 100644
--- a/editor/plugins/font_config_plugin.h
+++ b/editor/plugins/font_config_plugin.h
@@ -225,6 +225,8 @@ protected:
Ref<Font> prev_font;
+ void _preview_changed();
+
public:
virtual Size2 get_minimum_size() const override;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 059e177874..96127ec93e 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1819,15 +1819,25 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
CodeEdit *te = code_editor->get_text_editor();
Point2i pos = te->get_line_column_at_pos(p_point);
- int row = pos.y;
- int col = pos.x;
+ int drop_at_line = pos.y;
+ int drop_at_column = pos.x;
+ int selection_index = te->get_selection_at_line_column(drop_at_line, drop_at_column);
+
+ bool line_will_be_empty = false;
+ if (selection_index >= 0) {
+ // Dropped on a selection, it will be replaced.
+ drop_at_line = te->get_selection_from_line(selection_index);
+ drop_at_column = te->get_selection_from_column(selection_index);
+ line_will_be_empty = drop_at_column <= te->get_first_non_whitespace_column(drop_at_line) && te->get_selection_to_column(selection_index) == te->get_line(te->get_selection_to_line(selection_index)).length();
+ }
+
+ String text_to_drop;
const bool drop_modifier_pressed = Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL);
- const String &line = te->get_line(row);
- const bool is_empty_line = line.is_empty() || te->get_first_non_whitespace_column(row) == line.length();
+ const String &line = te->get_line(drop_at_line);
+ const bool is_empty_line = line_will_be_empty || line.is_empty() || te->get_first_non_whitespace_column(drop_at_line) == line.length();
if (d.has("type") && String(d["type"]) == "resource") {
- te->remove_secondary_carets();
Ref<Resource> resource = d["resource"];
if (resource.is_null()) {
return;
@@ -1840,7 +1850,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
return;
}
- String text_to_drop;
if (drop_modifier_pressed) {
if (resource->is_built_in()) {
String warning = TTR("Preloading internal resources is not supported.");
@@ -1851,19 +1860,10 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
} else {
text_to_drop = _quote_drop_data(path);
}
-
- te->set_caret_line(row);
- te->set_caret_column(col);
- te->insert_text_at_caret(text_to_drop);
- te->grab_focus();
}
if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) {
- te->remove_secondary_carets();
-
Array files = d["files"];
- String text_to_drop;
-
for (int i = 0; i < files.size(); i++) {
const String &path = String(files[i]);
@@ -1883,15 +1883,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
text_to_drop += is_empty_line ? "\n" : ", ";
}
}
-
- te->set_caret_line(row);
- te->set_caret_column(col);
- te->insert_text_at_caret(text_to_drop);
- te->grab_focus();
}
if (d.has("type") && String(d["type"]) == "nodes") {
- te->remove_secondary_carets();
Node *scene_root = get_tree()->get_edited_scene_root();
if (!scene_root) {
EditorNode::get_singleton()->show_warning(TTR("Can't drop nodes without an open scene."));
@@ -1909,7 +1903,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
Array nodes = d["nodes"];
- String text_to_drop;
if (drop_modifier_pressed) {
const bool use_type = EDITOR_GET("text_editor/completion/add_type_hints");
@@ -1981,27 +1974,33 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
text_to_drop += (is_unique ? "%" : "$") + path;
}
}
-
- te->set_caret_line(row);
- te->set_caret_column(col);
- te->insert_text_at_caret(text_to_drop);
- te->grab_focus();
}
if (d.has("type") && String(d["type"]) == "obj_property") {
- te->remove_secondary_carets();
-
bool add_literal = EDITOR_GET("text_editor/completion/add_node_path_literals");
- String text_to_drop = add_literal ? "^" : "";
+ text_to_drop = add_literal ? "^" : "";
// It is unclear whether properties may contain single or double quotes.
// Assume here that double-quotes may not exist. We are escaping single-quotes if necessary.
text_to_drop += _quote_drop_data(String(d["property"]));
+ }
+
+ if (text_to_drop.is_empty()) {
+ return;
+ }
- te->set_caret_line(row);
- te->set_caret_column(col);
- te->insert_text_at_caret(text_to_drop);
- te->grab_focus();
+ // Remove drag caret before any actions so it is not included in undo.
+ te->remove_drag_caret();
+ te->begin_complex_operation();
+ if (selection_index >= 0) {
+ te->delete_selection(selection_index);
}
+ te->remove_secondary_carets();
+ te->deselect();
+ te->set_caret_line(drop_at_line);
+ te->set_caret_column(drop_at_column);
+ te->insert_text_at_caret(text_to_drop);
+ te->end_complex_operation();
+ te->grab_focus();
}
void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
diff --git a/misc/dist/html/editor.html b/misc/dist/html/editor.html
index 5959b7b664..3a22055546 100644
--- a/misc/dist/html/editor.html
+++ b/misc/dist/html/editor.html
@@ -227,7 +227,6 @@ a:active {
line-height: 1.3;
visibility: visible;
padding: 4px 6px;
- visibility: visible;
}
</style>
</head>
diff --git a/modules/gdscript/gdscript_lambda_callable.cpp b/modules/gdscript/gdscript_lambda_callable.cpp
index 626ef6ccb0..42b0b066e1 100644
--- a/modules/gdscript/gdscript_lambda_callable.cpp
+++ b/modules/gdscript/gdscript_lambda_callable.cpp
@@ -84,7 +84,7 @@ int GDScriptLambdaCallable::get_argument_count(bool &r_is_valid) const {
return 0;
}
r_is_valid = true;
- return function->get_argument_count();
+ return function->get_argument_count() - captures.size();
}
void GDScriptLambdaCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
@@ -204,7 +204,7 @@ int GDScriptLambdaSelfCallable::get_argument_count(bool &r_is_valid) const {
return 0;
}
r_is_valid = true;
- return function->get_argument_count();
+ return function->get_argument_count() - captures.size();
}
void GDScriptLambdaSelfCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd
new file mode 100644
index 0000000000..67225cad6a
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd
@@ -0,0 +1,18 @@
+# https://github.com/godotengine/godot/issues/93952
+
+func foo():
+ pass
+
+func test():
+ var a: int
+
+ var lambda_self := func (x: int) -> void:
+ foo()
+ print(a, x)
+
+ print(lambda_self.get_argument_count()) # Should print 1.
+
+ var lambda_non_self := func (x: int) -> void:
+ print(a, x)
+
+ print(lambda_non_self.get_argument_count()) # Should print 1.
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out
new file mode 100644
index 0000000000..04b4638adf
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out
@@ -0,0 +1,3 @@
+GDTEST_OK
+1
+1
diff --git a/modules/gltf/doc_classes/GLTFAccessor.xml b/modules/gltf/doc_classes/GLTFAccessor.xml
index 54762faed7..dd059e6b79 100644
--- a/modules/gltf/doc_classes/GLTFAccessor.xml
+++ b/modules/gltf/doc_classes/GLTFAccessor.xml
@@ -12,7 +12,7 @@
<link title="Runtime file loading and saving">$DOCS_URL/tutorials/io/runtime_file_loading_and_saving.html</link>
</tutorials>
<members>
- <member name="accessor_type" type="int" setter="set_accessor_type" getter="get_accessor_type" default="0">
+ <member name="accessor_type" type="int" setter="set_accessor_type" getter="get_accessor_type" enum="GLTFAccessor.GLTFAccessorType" default="0">
The GLTF accessor type as an enum. Possible values are 0 for "SCALAR", 1 for "VEC2", 2 for "VEC3", 3 for "VEC4", 4 for "MAT2", 5 for "MAT3", and 6 for "MAT4".
</member>
<member name="buffer_view" type="int" setter="set_buffer_view" getter="get_buffer_view" default="-1">
@@ -54,8 +54,31 @@
<member name="sparse_values_byte_offset" type="int" setter="set_sparse_values_byte_offset" getter="get_sparse_values_byte_offset" default="0">
The offset relative to the start of the bufferView in bytes.
</member>
- <member name="type" type="int" setter="set_type" getter="get_type" default="0" deprecated="Use [member accessor_type] instead.">
+ <member name="type" type="int" setter="set_type" getter="get_type" deprecated="Use [member accessor_type] instead.">
The GLTF accessor type as an enum. Use [member accessor_type] instead.
</member>
</members>
+ <constants>
+ <constant name="TYPE_SCALAR" value="0" enum="GLTFAccessorType">
+ Accessor type "SCALAR". For the glTF object model, this can be used to map to a single float, int, or bool value, or a float array.
+ </constant>
+ <constant name="TYPE_VEC2" value="1" enum="GLTFAccessorType">
+ Accessor type "VEC2". For the glTF object model, this maps to "float2", represented in the glTF JSON as an array of two floats.
+ </constant>
+ <constant name="TYPE_VEC3" value="2" enum="GLTFAccessorType">
+ Accessor type "VEC3". For the glTF object model, this maps to "float3", represented in the glTF JSON as an array of three floats.
+ </constant>
+ <constant name="TYPE_VEC4" value="3" enum="GLTFAccessorType">
+ Accessor type "VEC4". For the glTF object model, this maps to "float4", represented in the glTF JSON as an array of four floats.
+ </constant>
+ <constant name="TYPE_MAT2" value="4" enum="GLTFAccessorType">
+ Accessor type "MAT2". For the glTF object model, this maps to "float2x2", represented in the glTF JSON as an array of four floats.
+ </constant>
+ <constant name="TYPE_MAT3" value="5" enum="GLTFAccessorType">
+ Accessor type "MAT3". For the glTF object model, this maps to "float3x3", represented in the glTF JSON as an array of nine floats.
+ </constant>
+ <constant name="TYPE_MAT4" value="6" enum="GLTFAccessorType">
+ Accessor type "MAT4". For the glTF object model, this maps to "float4x4", represented in the glTF JSON as an array of sixteen floats.
+ </constant>
+ </constants>
</class>
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index e0bdd4cf33..c0232e6d0c 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -934,58 +934,58 @@ Error GLTFDocument::_encode_accessors(Ref<GLTFState> p_state) {
return OK;
}
-String GLTFDocument::_get_accessor_type_name(const GLTFAccessorType p_accessor_type) {
- if (p_accessor_type == GLTFAccessorType::TYPE_SCALAR) {
+String GLTFDocument::_get_accessor_type_name(const GLTFAccessor::GLTFAccessorType p_accessor_type) {
+ if (p_accessor_type == GLTFAccessor::TYPE_SCALAR) {
return "SCALAR";
}
- if (p_accessor_type == GLTFAccessorType::TYPE_VEC2) {
+ if (p_accessor_type == GLTFAccessor::TYPE_VEC2) {
return "VEC2";
}
- if (p_accessor_type == GLTFAccessorType::TYPE_VEC3) {
+ if (p_accessor_type == GLTFAccessor::TYPE_VEC3) {
return "VEC3";
}
- if (p_accessor_type == GLTFAccessorType::TYPE_VEC4) {
+ if (p_accessor_type == GLTFAccessor::TYPE_VEC4) {
return "VEC4";
}
- if (p_accessor_type == GLTFAccessorType::TYPE_MAT2) {
+ if (p_accessor_type == GLTFAccessor::TYPE_MAT2) {
return "MAT2";
}
- if (p_accessor_type == GLTFAccessorType::TYPE_MAT3) {
+ if (p_accessor_type == GLTFAccessor::TYPE_MAT3) {
return "MAT3";
}
- if (p_accessor_type == GLTFAccessorType::TYPE_MAT4) {
+ if (p_accessor_type == GLTFAccessor::TYPE_MAT4) {
return "MAT4";
}
ERR_FAIL_V("SCALAR");
}
-GLTFAccessorType GLTFDocument::_get_accessor_type_from_str(const String &p_string) {
+GLTFAccessor::GLTFAccessorType GLTFDocument::_get_accessor_type_from_str(const String &p_string) {
if (p_string == "SCALAR") {
- return GLTFAccessorType::TYPE_SCALAR;
+ return GLTFAccessor::TYPE_SCALAR;
}
if (p_string == "VEC2") {
- return GLTFAccessorType::TYPE_VEC2;
+ return GLTFAccessor::TYPE_VEC2;
}
if (p_string == "VEC3") {
- return GLTFAccessorType::TYPE_VEC3;
+ return GLTFAccessor::TYPE_VEC3;
}
if (p_string == "VEC4") {
- return GLTFAccessorType::TYPE_VEC4;
+ return GLTFAccessor::TYPE_VEC4;
}
if (p_string == "MAT2") {
- return GLTFAccessorType::TYPE_MAT2;
+ return GLTFAccessor::TYPE_MAT2;
}
if (p_string == "MAT3") {
- return GLTFAccessorType::TYPE_MAT3;
+ return GLTFAccessor::TYPE_MAT3;
}
if (p_string == "MAT4") {
- return GLTFAccessorType::TYPE_MAT4;
+ return GLTFAccessor::TYPE_MAT4;
}
- ERR_FAIL_V(GLTFAccessorType::TYPE_SCALAR);
+ ERR_FAIL_V(GLTFAccessor::TYPE_SCALAR);
}
Error GLTFDocument::_parse_accessors(Ref<GLTFState> p_state) {
@@ -1088,7 +1088,7 @@ String GLTFDocument::_get_component_type_name(const uint32_t p_component) {
return "<Error>";
}
-Error GLTFDocument::_encode_buffer_view(Ref<GLTFState> p_state, const double *p_src, const int p_count, const GLTFAccessorType p_accessor_type, const int p_component_type, const bool p_normalized, const int p_byte_offset, const bool p_for_vertex, GLTFBufferViewIndex &r_accessor, const bool p_for_vertex_indices) {
+Error GLTFDocument::_encode_buffer_view(Ref<GLTFState> p_state, const double *p_src, const int p_count, const GLTFAccessor::GLTFAccessorType p_accessor_type, const int p_component_type, const bool p_normalized, const int p_byte_offset, const bool p_for_vertex, GLTFBufferViewIndex &r_accessor, const bool p_for_vertex_indices) {
const int component_count_for_type[7] = {
1, 2, 3, 4, 4, 9, 16
};
@@ -1103,18 +1103,18 @@ Error GLTFDocument::_encode_buffer_view(Ref<GLTFState> p_state, const double *p_
switch (p_component_type) {
case COMPONENT_TYPE_BYTE:
case COMPONENT_TYPE_UNSIGNED_BYTE: {
- if (p_accessor_type == TYPE_MAT2) {
+ if (p_accessor_type == GLTFAccessor::TYPE_MAT2) {
skip_every = 2;
skip_bytes = 2;
}
- if (p_accessor_type == TYPE_MAT3) {
+ if (p_accessor_type == GLTFAccessor::TYPE_MAT3) {
skip_every = 3;
skip_bytes = 1;
}
} break;
case COMPONENT_TYPE_SHORT:
case COMPONENT_TYPE_UNSIGNED_SHORT: {
- if (p_accessor_type == TYPE_MAT3) {
+ if (p_accessor_type == GLTFAccessor::TYPE_MAT3) {
skip_every = 6;
skip_bytes = 4;
}
@@ -1296,7 +1296,7 @@ Error GLTFDocument::_encode_buffer_view(Ref<GLTFState> p_state, const double *p_
return OK;
}
-Error GLTFDocument::_decode_buffer_view(Ref<GLTFState> p_state, double *p_dst, const GLTFBufferViewIndex p_buffer_view, const int p_skip_every, const int p_skip_bytes, const int p_element_size, const int p_count, const GLTFAccessorType p_accessor_type, const int p_component_count, const int p_component_type, const int p_component_size, const bool p_normalized, const int p_byte_offset, const bool p_for_vertex) {
+Error GLTFDocument::_decode_buffer_view(Ref<GLTFState> p_state, double *p_dst, const GLTFBufferViewIndex p_buffer_view, const int p_skip_every, const int p_skip_bytes, const int p_element_size, const int p_count, const GLTFAccessor::GLTFAccessorType p_accessor_type, const int p_component_count, const int p_component_type, const int p_component_size, const bool p_normalized, const int p_byte_offset, const bool p_for_vertex) {
const Ref<GLTFBufferView> bv = p_state->buffer_views[p_buffer_view];
int stride = p_element_size;
@@ -1427,12 +1427,12 @@ Vector<double> GLTFDocument::_decode_accessor(Ref<GLTFState> p_state, const GLTF
switch (a->component_type) {
case COMPONENT_TYPE_BYTE:
case COMPONENT_TYPE_UNSIGNED_BYTE: {
- if (a->accessor_type == TYPE_MAT2) {
+ if (a->accessor_type == GLTFAccessor::TYPE_MAT2) {
skip_every = 2;
skip_bytes = 2;
element_size = 8; //override for this case
}
- if (a->accessor_type == TYPE_MAT3) {
+ if (a->accessor_type == GLTFAccessor::TYPE_MAT3) {
skip_every = 3;
skip_bytes = 1;
element_size = 12; //override for this case
@@ -1440,7 +1440,7 @@ Vector<double> GLTFDocument::_decode_accessor(Ref<GLTFState> p_state, const GLTF
} break;
case COMPONENT_TYPE_SHORT:
case COMPONENT_TYPE_UNSIGNED_SHORT: {
- if (a->accessor_type == TYPE_MAT3) {
+ if (a->accessor_type == GLTFAccessor::TYPE_MAT3) {
skip_every = 6;
skip_bytes = 4;
element_size = 16; //override for this case
@@ -1474,7 +1474,7 @@ Vector<double> GLTFDocument::_decode_accessor(Ref<GLTFState> p_state, const GLTF
indices.resize(a->sparse_count);
const int indices_component_size = _get_component_type_size(a->sparse_indices_component_type);
- Error err = _decode_buffer_view(p_state, indices.ptrw(), a->sparse_indices_buffer_view, 0, 0, indices_component_size, a->sparse_count, TYPE_SCALAR, 1, a->sparse_indices_component_type, indices_component_size, false, a->sparse_indices_byte_offset, false);
+ Error err = _decode_buffer_view(p_state, indices.ptrw(), a->sparse_indices_buffer_view, 0, 0, indices_component_size, a->sparse_count, GLTFAccessor::TYPE_SCALAR, 1, a->sparse_indices_component_type, indices_component_size, false, a->sparse_indices_byte_offset, false);
if (err != OK) {
return Vector<double>();
}
@@ -1536,7 +1536,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref<GLTFState> p_state,
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_SCALAR;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_SCALAR;
int component_type;
if (max_index > 65535 || p_for_vertex) {
component_type = GLTFDocument::COMPONENT_TYPE_INT;
@@ -1650,7 +1650,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec2(Ref<GLTFState> p_state,
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_VEC2;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_VEC2;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
accessor->max = type_max;
@@ -1703,7 +1703,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_color(Ref<GLTFState> p_state
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_VEC4;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_VEC4;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
accessor->max = type_max;
@@ -1770,7 +1770,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_weights(Ref<GLTFState> p_sta
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_VEC4;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_VEC4;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
accessor->max = type_max;
@@ -1821,7 +1821,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_joints(Ref<GLTFState> p_stat
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_VEC4;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_VEC4;
const int component_type = GLTFDocument::COMPONENT_TYPE_UNSIGNED_SHORT;
accessor->max = type_max;
@@ -1874,7 +1874,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_quaternions(Ref<GLTFState> p
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_VEC4;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_VEC4;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
accessor->max = type_max;
@@ -1949,7 +1949,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> p_stat
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_SCALAR;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_SCALAR;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
accessor->max = type_max;
@@ -1999,7 +1999,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_vec3(Ref<GLTFState> p_state,
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_VEC3;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_VEC3;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
accessor->max = type_max;
@@ -2075,7 +2075,7 @@ GLTFAccessorIndex GLTFDocument::_encode_sparse_accessor_as_vec3(Ref<GLTFState> p
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_VEC3;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_VEC3;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
sparse_accessor->normalized = false;
@@ -2103,7 +2103,7 @@ GLTFAccessorIndex GLTFDocument::_encode_sparse_accessor_as_vec3(Ref<GLTFState> p
} else {
sparse_accessor->sparse_indices_component_type = GLTFDocument::COMPONENT_TYPE_UNSIGNED_SHORT;
}
- if (_encode_buffer_view(p_state, changed_indices.ptr(), changed_indices.size(), GLTFAccessorType::TYPE_SCALAR, sparse_accessor->sparse_indices_component_type, sparse_accessor->normalized, sparse_accessor->sparse_indices_byte_offset, false, buffer_view_i_indices) != OK) {
+ if (_encode_buffer_view(p_state, changed_indices.ptr(), changed_indices.size(), GLTFAccessor::TYPE_SCALAR, sparse_accessor->sparse_indices_component_type, sparse_accessor->normalized, sparse_accessor->sparse_indices_byte_offset, false, buffer_view_i_indices) != OK) {
return -1;
}
// We use changed_indices.size() here, because we must pass the number of vec3 values rather than the number of components.
@@ -2180,7 +2180,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_xform(Ref<GLTFState> p_state
p_state->buffers.push_back(Vector<uint8_t>());
}
int64_t size = p_state->buffers[0].size();
- const GLTFAccessorType accessor_type = GLTFAccessorType::TYPE_MAT4;
+ const GLTFAccessor::GLTFAccessorType accessor_type = GLTFAccessor::TYPE_MAT4;
const int component_type = GLTFDocument::COMPONENT_TYPE_FLOAT;
accessor->max = type_max;
@@ -2234,9 +2234,9 @@ Vector<Color> GLTFDocument::_decode_accessor_as_color(Ref<GLTFState> p_state, co
}
const int accessor_type = p_state->accessors[p_accessor]->accessor_type;
- ERR_FAIL_COND_V(!(accessor_type == TYPE_VEC3 || accessor_type == TYPE_VEC4), ret);
+ ERR_FAIL_COND_V(!(accessor_type == GLTFAccessor::TYPE_VEC3 || accessor_type == GLTFAccessor::TYPE_VEC4), ret);
int vec_len = 3;
- if (accessor_type == TYPE_VEC4) {
+ if (accessor_type == GLTFAccessor::TYPE_VEC4) {
vec_len = 4;
}
diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h
index 4f92ceccca..d37544750d 100644
--- a/modules/gltf/gltf_document.h
+++ b/modules/gltf/gltf_document.h
@@ -111,7 +111,7 @@ private:
int _get_component_type_size(const int p_component_type);
Error _parse_scenes(Ref<GLTFState> p_state);
Error _parse_nodes(Ref<GLTFState> p_state);
- String _get_accessor_type_name(const GLTFAccessorType p_accessor_type);
+ String _get_accessor_type_name(const GLTFAccessor::GLTFAccessorType p_accessor_type);
String _sanitize_animation_name(const String &p_name);
String _gen_unique_animation_name(Ref<GLTFState> p_state, const String &p_name);
String _sanitize_bone_name(const String &p_name);
@@ -131,13 +131,13 @@ private:
void _compute_node_heights(Ref<GLTFState> p_state);
Error _parse_buffers(Ref<GLTFState> p_state, const String &p_base_path);
Error _parse_buffer_views(Ref<GLTFState> p_state);
- GLTFAccessorType _get_accessor_type_from_str(const String &p_string);
+ GLTFAccessor::GLTFAccessorType _get_accessor_type_from_str(const String &p_string);
Error _parse_accessors(Ref<GLTFState> p_state);
Error _decode_buffer_view(Ref<GLTFState> p_state, double *p_dst,
const GLTFBufferViewIndex p_buffer_view,
const int p_skip_every, const int p_skip_bytes,
const int p_element_size, const int p_count,
- const GLTFAccessorType p_accessor_type, const int p_component_count,
+ const GLTFAccessor::GLTFAccessorType p_accessor_type, const int p_component_count,
const int p_component_type, const int p_component_size,
const bool p_normalized, const int p_byte_offset,
const bool p_for_vertex);
@@ -266,7 +266,7 @@ private:
const Vector<Transform3D> p_attribs,
const bool p_for_vertex);
Error _encode_buffer_view(Ref<GLTFState> p_state, const double *p_src,
- const int p_count, const GLTFAccessorType p_accessor_type,
+ const int p_count, const GLTFAccessor::GLTFAccessorType p_accessor_type,
const int p_component_type, const bool p_normalized,
const int p_byte_offset, const bool p_for_vertex,
GLTFBufferViewIndex &r_accessor, const bool p_for_indices = false);
diff --git a/modules/gltf/structures/gltf_accessor.cpp b/modules/gltf/structures/gltf_accessor.cpp
index 602f0d9dc4..1ebc00a514 100644
--- a/modules/gltf/structures/gltf_accessor.cpp
+++ b/modules/gltf/structures/gltf_accessor.cpp
@@ -31,6 +31,14 @@
#include "gltf_accessor.h"
void GLTFAccessor::_bind_methods() {
+ BIND_ENUM_CONSTANT(TYPE_SCALAR);
+ BIND_ENUM_CONSTANT(TYPE_VEC2);
+ BIND_ENUM_CONSTANT(TYPE_VEC3);
+ BIND_ENUM_CONSTANT(TYPE_VEC4);
+ BIND_ENUM_CONSTANT(TYPE_MAT2);
+ BIND_ENUM_CONSTANT(TYPE_MAT3);
+ BIND_ENUM_CONSTANT(TYPE_MAT4);
+
ClassDB::bind_method(D_METHOD("get_buffer_view"), &GLTFAccessor::get_buffer_view);
ClassDB::bind_method(D_METHOD("set_buffer_view", "buffer_view"), &GLTFAccessor::set_buffer_view);
ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFAccessor::get_byte_offset);
@@ -43,8 +51,8 @@ void GLTFAccessor::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_count", "count"), &GLTFAccessor::set_count);
ClassDB::bind_method(D_METHOD("get_accessor_type"), &GLTFAccessor::get_accessor_type);
ClassDB::bind_method(D_METHOD("set_accessor_type", "accessor_type"), &GLTFAccessor::set_accessor_type);
- ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_accessor_type);
- ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_accessor_type);
+ ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_type);
+ ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_type);
ClassDB::bind_method(D_METHOD("get_min"), &GLTFAccessor::get_min);
ClassDB::bind_method(D_METHOD("set_min", "min"), &GLTFAccessor::set_min);
ClassDB::bind_method(D_METHOD("get_max"), &GLTFAccessor::get_max);
@@ -67,8 +75,8 @@ void GLTFAccessor::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int
- ADD_PROPERTY(PropertyInfo(Variant::INT, "accessor_type"), "set_accessor_type", "get_accessor_type"); // GLTFAccessorType
- ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type"); // Deprecated, GLTFAccessorType
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "accessor_type"), "set_accessor_type", "get_accessor_type"); // GLTFAccessor::GLTFAccessorType
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_type", "get_type"); // Deprecated, int for GLTFAccessor::GLTFAccessorType
ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "min"), "set_min", "get_min"); // Vector<real_t>
ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "max"), "set_max", "get_max"); // Vector<real_t>
ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int
@@ -119,11 +127,19 @@ void GLTFAccessor::set_count(int p_count) {
count = p_count;
}
-int GLTFAccessor::get_accessor_type() {
+GLTFAccessor::GLTFAccessorType GLTFAccessor::get_accessor_type() {
+ return accessor_type;
+}
+
+void GLTFAccessor::set_accessor_type(GLTFAccessorType p_accessor_type) {
+ accessor_type = p_accessor_type;
+}
+
+int GLTFAccessor::get_type() {
return (int)accessor_type;
}
-void GLTFAccessor::set_accessor_type(int p_accessor_type) {
+void GLTFAccessor::set_type(int p_accessor_type) {
accessor_type = (GLTFAccessorType)p_accessor_type; // TODO: Register enum
}
diff --git a/modules/gltf/structures/gltf_accessor.h b/modules/gltf/structures/gltf_accessor.h
index 51ca282630..1a3a2cb494 100644
--- a/modules/gltf/structures/gltf_accessor.h
+++ b/modules/gltf/structures/gltf_accessor.h
@@ -35,20 +35,21 @@
#include "core/io/resource.h"
-enum GLTFAccessorType {
- TYPE_SCALAR,
- TYPE_VEC2,
- TYPE_VEC3,
- TYPE_VEC4,
- TYPE_MAT2,
- TYPE_MAT3,
- TYPE_MAT4,
-};
-
struct GLTFAccessor : public Resource {
GDCLASS(GLTFAccessor, Resource);
friend class GLTFDocument;
+public:
+ enum GLTFAccessorType {
+ TYPE_SCALAR,
+ TYPE_VEC2,
+ TYPE_VEC3,
+ TYPE_VEC4,
+ TYPE_MAT2,
+ TYPE_MAT3,
+ TYPE_MAT4,
+ };
+
private:
GLTFBufferViewIndex buffer_view = -1;
int byte_offset = 0;
@@ -84,8 +85,11 @@ public:
int get_count();
void set_count(int p_count);
- int get_accessor_type();
- void set_accessor_type(int p_accessor_type);
+ GLTFAccessorType get_accessor_type();
+ void set_accessor_type(GLTFAccessorType p_accessor_type);
+
+ int get_type();
+ void set_type(int p_accessor_type);
Vector<double> get_min();
void set_min(Vector<double> p_min);
@@ -112,4 +116,6 @@ public:
void set_sparse_values_byte_offset(int p_sparse_values_byte_offset);
};
+VARIANT_ENUM_CAST(GLTFAccessor::GLTFAccessorType);
+
#endif // GLTF_ACCESSOR_H
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index ada0cd01fa..53046de740 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -162,7 +162,7 @@ static Error _jpgd_save_to_output_stream(jpge::output_stream *p_output_stream, c
ERR_FAIL_COND_V_MSG(error != OK, error, "Couldn't decompress image.");
}
if (image->get_format() != Image::FORMAT_RGB8) {
- image = p_img->duplicate();
+ image = image->duplicate();
image->convert(Image::FORMAT_RGB8);
}
diff --git a/platform/web/web_main.cpp b/platform/web/web_main.cpp
index eb61644066..d0c3bd7c0e 100644
--- a/platform/web/web_main.cpp
+++ b/platform/web/web_main.cpp
@@ -36,6 +36,7 @@
#include "core/io/resource_loader.h"
#include "main/main.h"
#include "scene/main/scene_tree.h"
+#include "scene/main/window.h" // SceneTree only forward declares it.
#include <emscripten/emscripten.h>
#include <stdlib.h>
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 7b682daa83..9cc59f1def 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1643,21 +1643,14 @@ void TextEdit::_notification(int p_what) {
} break;
case NOTIFICATION_DRAG_END: {
- if (is_drag_successful()) {
- if (selection_drag_attempt) {
- // Dropped elsewhere.
- if (is_editable() && !Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL)) {
- delete_selection();
- } else if (deselect_on_focus_loss_enabled) {
- deselect();
- }
- }
- }
- if (drag_caret_index >= 0) {
- if (drag_caret_index < carets.size()) {
- remove_caret(drag_caret_index);
+ remove_drag_caret();
+ if (selection_drag_attempt && is_drag_successful()) {
+ // Dropped elsewhere.
+ if (is_editable() && !Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL)) {
+ delete_selection();
+ } else if (deselect_on_focus_loss_enabled) {
+ deselect();
}
- drag_caret_index = -1;
}
selection_drag_attempt = false;
drag_action = false;
@@ -4606,6 +4599,15 @@ void TextEdit::remove_caret(int p_caret) {
}
}
+void TextEdit::remove_drag_caret() {
+ if (drag_caret_index >= 0) {
+ if (drag_caret_index < carets.size()) {
+ remove_caret(drag_caret_index);
+ }
+ drag_caret_index = -1;
+ }
+}
+
void TextEdit::remove_secondary_carets() {
if (carets.size() == 1) {
return;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 6ed5cf4bdc..4d9d169c1c 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -881,6 +881,7 @@ public:
int add_caret(int p_line, int p_column);
void remove_caret(int p_caret);
+ void remove_drag_caret();
void remove_secondary_carets();
int get_caret_count() const;
void add_caret_at_carets(bool p_below);
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index bc8e0b9015..37d9d57722 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -3213,7 +3213,6 @@ void SystemFont::_update_base_font() {
}
_invalidate_rids();
- notify_property_list_changed();
}
void SystemFont::reset_state() {