Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.3] Cherry-picks for the 4.3 (4.3.1) branch - 1st gdextension bugs batch #935

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/extension/gdextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class GDExtensionMethodBind : public MethodBind {
}

virtual bool is_vararg() const override {
return false;
return vararg;
}

#ifdef TOOLS_ENABLED
Expand Down
2 changes: 1 addition & 1 deletion core/io/stream_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ Error StreamPeerExtension::put_data(const uint8_t *p_data, int p_bytes) {

Error StreamPeerExtension::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
Error err;
if (GDVIRTUAL_CALL(_put_data, p_data, p_bytes, &r_sent, err)) {
if (GDVIRTUAL_CALL(_put_partial_data, p_data, p_bytes, &r_sent, err)) {
return err;
}
WARN_PRINT_ONCE("StreamPeerExtension::_put_partial_data is unimplemented!");
Expand Down
12 changes: 12 additions & 0 deletions doc/classes/AudioStream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<link title="Audio Spectrum Visualizer Demo">https://godotengine.org/asset-library/asset/2762</link>
</tutorials>
<methods>
<method name="_get_bar_beats" qualifiers="virtual const">
<return type="int" />
<description>
Override this method to return the bar beats of this stream.
</description>
</method>
<method name="_get_beat_count" qualifiers="virtual const">
<return type="int" />
<description>
Expand Down Expand Up @@ -45,6 +51,12 @@
Override this method to customize the name assigned to this audio stream. Unused by the engine.
</description>
</method>
<method name="_has_loop" qualifiers="virtual const">
<return type="bool" />
<description>
Override this method to return [code]true[/code] if this stream has a loop.
</description>
</method>
<method name="_instantiate_playback" qualifiers="virtual const">
<return type="AudioStreamPlayback" />
<description>
Expand Down
4 changes: 2 additions & 2 deletions editor/export/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
unzClose(pkg);

_update_template_status();
EditorSettings::get_singleton()->set_meta("export_template_download_directory", p_file.get_base_dir());
EditorSettings::get_singleton()->set("_export_template_download_directory", p_file.get_base_dir());
return true;
}

Expand Down Expand Up @@ -1059,7 +1059,7 @@ ExportTemplateManager::ExportTemplateManager() {
install_file_dialog->set_title(TTR("Select Template File"));
install_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);
install_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
install_file_dialog->set_current_dir(EditorSettings::get_singleton()->get_meta("export_template_download_directory", ""));
install_file_dialog->set_current_dir(EDITOR_DEF("_export_template_download_directory", ""));
install_file_dialog->add_filter("*.tpz", TTR("Redot Export Templates"));
install_file_dialog->connect("file_selected", callable_mp(this, &ExportTemplateManager::_install_file_selected).bind(false));
add_child(install_file_dialog);
Expand Down
56 changes: 34 additions & 22 deletions editor/script_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "editor/themes/editor_scale.h"
#include "scene/gui/grid_container.h"
#include "scene/gui/line_edit.h"
#include "scene/theme/theme_db.h"

static String _get_parent_class_of_script(const String &p_path) {
if (!ResourceLoader::exists(p_path, "Script")) {
Expand Down Expand Up @@ -113,15 +114,7 @@ static Vector<String> _get_hierarchy(const String &p_class_name) {

void ScriptCreateDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
Ref<Texture2D> language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type());
if (language_icon.is_valid()) {
language_menu->set_item_icon(i, language_icon);
}
}

case NOTIFICATION_ENTER_TREE: {
String last_language = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
if (!last_language.is_empty()) {
for (int i = 0; i < language_menu->get_item_count(); i++) {
Expand All @@ -133,9 +126,31 @@ void ScriptCreateDialog::_notification(int p_what) {
} else {
language_menu->select(default_language);
}
if (EditorSettings::get_singleton()->has_meta("script_setup_use_script_templates")) {
is_using_templates = bool(EditorSettings::get_singleton()->get_meta("script_setup_use_script_templates"));
use_templates->set_pressed(is_using_templates);
is_using_templates = EDITOR_DEF("_script_setup_use_script_templates", false);
use_templates->set_pressed(is_using_templates);
} break;

case NOTIFICATION_THEME_CHANGED: {
const int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor));

EditorData &ed = EditorNode::get_editor_data();

for (int i = 0; i < ScriptServer::get_language_count(); i++) {
// Check if the extension has an icon first.
String script_type = ScriptServer::get_language(i)->get_type();
Ref<Texture2D> language_icon = get_editor_theme_icon(script_type);
if (language_icon.is_null() || language_icon == ThemeDB::get_singleton()->get_fallback_icon()) {
// The theme doesn't have an icon for this language, ask the extensions.
Ref<Texture2D> extension_language_icon = ed.extension_class_get_icon(script_type);
if (extension_language_icon.is_valid()) {
language_menu->get_popup()->set_item_icon_max_width(i, icon_size);
language_icon = extension_language_icon;
}
}

if (language_icon.is_valid()) {
language_menu->set_item_icon(i, language_icon);
}
}

path_button->set_icon(get_editor_theme_icon(SNAME("Folder")));
Expand Down Expand Up @@ -299,12 +314,9 @@ void ScriptCreateDialog::_template_changed(int p_template) {
EditorSettings::get_singleton()->set_project_metadata("script_setup", "templates_dictionary", dic_templates_project);
} else {
// Save template info to editor dictionary (not a project template).
Dictionary dic_templates;
if (EditorSettings::get_singleton()->has_meta("script_setup_templates_dictionary")) {
dic_templates = (Dictionary)EditorSettings::get_singleton()->get_meta("script_setup_templates_dictionary");
}
Dictionary dic_templates = EDITOR_GET("_script_setup_templates_dictionary");
dic_templates[parent_name->get_text()] = sinfo.get_hash();
EditorSettings::get_singleton()->set_meta("script_setup_templates_dictionary", dic_templates);
EditorSettings::get_singleton()->set("_script_setup_templates_dictionary", dic_templates);
// Remove template from project dictionary as we last used an editor level template.
Dictionary dic_templates_project = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary());
if (dic_templates_project.has(parent_name->get_text())) {
Expand Down Expand Up @@ -417,7 +429,7 @@ void ScriptCreateDialog::_built_in_pressed() {

void ScriptCreateDialog::_use_template_pressed() {
is_using_templates = use_templates->is_pressed();
EditorSettings::get_singleton()->set_meta("script_setup_use_script_templates", is_using_templates);
EditorSettings::get_singleton()->set("_script_setup_use_script_templates", is_using_templates);
validation_panel->update();
}

Expand Down Expand Up @@ -511,10 +523,7 @@ void ScriptCreateDialog::_update_template_menu() {
if (is_language_using_templates) {
// Get the latest templates used for each type of node from project settings then global settings.
Dictionary last_local_templates = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary());
Dictionary last_global_templates;
if (EditorSettings::get_singleton()->has_meta("script_setup_templates_dictionary")) {
last_global_templates = (Dictionary)EditorSettings::get_singleton()->get_meta("script_setup_templates_dictionary");
}
Dictionary last_global_templates = EDITOR_GET("_script_setup_templates_dictionary");
String inherits_base_type = parent_name->get_text();

// If it inherits from a script, get its parent class first.
Expand Down Expand Up @@ -827,6 +836,8 @@ void ScriptCreateDialog::_bind_methods() {
}

ScriptCreateDialog::ScriptCreateDialog() {
EDITOR_DEF("_script_setup_templates_dictionary", Dictionary());

/* Main Controls */

GridContainer *gc = memnew(GridContainer);
Expand Down Expand Up @@ -857,6 +868,7 @@ ScriptCreateDialog::ScriptCreateDialog() {

language_menu = memnew(OptionButton);
language_menu->set_custom_minimum_size(Size2(350, 0) * EDSCALE);
language_menu->set_expand_icon(true);
language_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL);
gc->add_child(memnew(Label(TTR("Language:"))));
gc->add_child(language_menu);
Expand Down
6 changes: 5 additions & 1 deletion scene/resources/compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ void CompositorEffect::_validate_property(PropertyInfo &p_property) const {
}
}

void CompositorEffect::_call_render_callback(int p_effect_callback_type, const RenderData *p_render_data) {
GDVIRTUAL_CALL(_render_callback, p_effect_callback_type, p_render_data);
}

void CompositorEffect::set_enabled(bool p_enabled) {
enabled = p_enabled;
if (rid.is_valid()) {
Expand All @@ -107,7 +111,7 @@ void CompositorEffect::set_effect_callback_type(EffectCallbackType p_callback_ty
if (rid.is_valid()) {
RenderingServer *rs = RenderingServer::get_singleton();
ERR_FAIL_NULL(rs);
rs->compositor_effect_set_callback(rid, RenderingServer::CompositorEffectCallbackType(effect_callback_type), Callable(this, "_render_callback"));
rs->compositor_effect_set_callback(rid, RenderingServer::CompositorEffectCallbackType(effect_callback_type), callable_mp(this, &CompositorEffect::_call_render_callback));
}
}

Expand Down
2 changes: 2 additions & 0 deletions scene/resources/compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class CompositorEffect : public Resource {
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;

void _call_render_callback(int p_effect_callback_type, const RenderData *p_render_data);

GDVIRTUAL2(_render_callback, int, const RenderData *)

public:
Expand Down
2 changes: 2 additions & 0 deletions servers/audio/audio_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ void AudioStream::_bind_methods() {
GDVIRTUAL_BIND(_get_bpm)
GDVIRTUAL_BIND(_get_beat_count)
GDVIRTUAL_BIND(_get_parameter_list)
GDVIRTUAL_BIND(_has_loop);
GDVIRTUAL_BIND(_get_bar_beats);

ADD_SIGNAL(MethodInfo("parameter_list_changed"));
}
Expand Down