Disable signal callback generation in C#

This commit is contained in:
Paul Joannon
2024-02-04 19:08:41 +01:00
parent d3352813ea
commit 9fa2355cef
10 changed files with 50 additions and 18 deletions

View File

@@ -178,6 +178,7 @@ void ConnectDialog::_tree_node_selected() {
set_dst_method(generate_method_callback_name(source, signal, current));
}
_update_method_tree();
_update_warning_label();
_update_ok_enabled();
}
@@ -433,6 +434,23 @@ void ConnectDialog::_update_ok_enabled() {
get_ok_button()->set_disabled(false);
}
void ConnectDialog::_update_warning_label() {
Ref<Script> scr = source->get_node(dst_path)->get_script();
if (scr.is_null()) {
warning_label->set_visible(false);
return;
}
ScriptLanguage *language = scr->get_language();
if (language->can_make_function()) {
warning_label->set_visible(false);
return;
}
warning_label->set_text(vformat(TTR("%s: Callback code won't be generated, please add it manually."), language->get_name()));
warning_label->set_visible(true);
}
void ConnectDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -617,6 +635,7 @@ void ConnectDialog::init(const ConnectionData &p_cd, const PackedStringArray &p_
void ConnectDialog::popup_dialog(const String p_for_signal) {
from_signal->set_text(p_for_signal);
warning_label->add_theme_color_override("font_color", warning_label->get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
error_label->add_theme_color_override("font_color", error_label->get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
filter_nodes->clear();
@@ -694,6 +713,10 @@ ConnectDialog::ConnectDialog() {
connect_to_label = Object::cast_to<Label>(vbc_left->get_child(mc->get_index() - 1));
vbc_left->add_child(tree);
warning_label = memnew(Label);
vbc_left->add_child(warning_label);
warning_label->hide();
error_label = memnew(Label);
error_label->set_text(TTR("Scene does not contain any script."));
vbc_left->add_child(error_label);