C#: Disable "Activate now" when creating addons

Since C# is a compiled language and doesn't support activating the plugin immediately after creating it, the "Activate now" option is disabled and a warning explains why.
This commit is contained in:
Raul Santos 2023-10-18 21:30:26 +02:00
parent dce1aab174
commit cd05b3de19
No known key found for this signature in database
GPG key ID: B532473AE3A803E4
2 changed files with 13 additions and 2 deletions

View file

@ -100,7 +100,8 @@ void PluginConfigDialog::_on_canceled() {
void PluginConfigDialog::_on_required_text_changed() {
int lang_idx = script_option_edit->get_selected();
String ext = ScriptServer::get_language(lang_idx)->get_extension();
ScriptLanguage *language = ScriptServer::get_language(lang_idx);
String ext = language->get_extension();
if (name_edit->get_text().is_empty()) {
validation_panel->set_message(MSG_ID_PLUGIN, TTR("Plugin name cannot be blank."), EditorValidationPanel::MSG_ERROR);
@ -120,6 +121,15 @@ void PluginConfigDialog::_on_required_text_changed() {
} else {
validation_panel->set_message(MSG_ID_SUBFOLDER, "", EditorValidationPanel::MSG_OK);
}
if (active_edit->is_visible()) {
if (language->get_name() == "C#") {
active_edit->set_pressed(false);
active_edit->set_disabled(true);
validation_panel->set_message(MSG_ID_ACTIVE, TTR("C# doesn't support activating the plugin on creation because the project must be built first."), EditorValidationPanel::MSG_WARNING);
} else {
active_edit->set_disabled(false);
}
}
}
String PluginConfigDialog::_get_subfolder() {
@ -291,7 +301,6 @@ PluginConfigDialog::PluginConfigDialog() {
grid->add_child(script_edit);
// Activate now checkbox
// TODO Make this option work better with languages like C#. Right now, it does not work because the C# project must be compiled first.
Label *active_lb = memnew(Label);
active_lb->set_text(TTR("Activate now?"));
active_lb->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
@ -310,6 +319,7 @@ PluginConfigDialog::PluginConfigDialog() {
validation_panel->add_line(MSG_ID_PLUGIN, TTR("Plugin name is valid."));
validation_panel->add_line(MSG_ID_SCRIPT, TTR("Script extension is valid."));
validation_panel->add_line(MSG_ID_SUBFOLDER, TTR("Subfolder name is valid."));
validation_panel->add_line(MSG_ID_ACTIVE, "");
validation_panel->set_update_callback(callable_mp(this, &PluginConfigDialog::_on_required_text_changed));
validation_panel->set_accept_button(get_ok_button());

View file

@ -48,6 +48,7 @@ class PluginConfigDialog : public ConfirmationDialog {
MSG_ID_PLUGIN,
MSG_ID_SUBFOLDER,
MSG_ID_SCRIPT,
MSG_ID_ACTIVE,
};
LineEdit *name_edit = nullptr;