Fix build with GDScript support disabled

Fixes #41710.
This commit is contained in:
Rémi Verschelde 2020-09-08 09:14:25 +02:00
parent 48de626949
commit 8ae2a84fb6
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 10 additions and 1 deletions

View File

@ -35,9 +35,12 @@
#include "editor/editor_plugin.h" #include "editor/editor_plugin.h"
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#include "editor/project_settings_editor.h" #include "editor/project_settings_editor.h"
#include "modules/gdscript/gdscript.h"
#include "scene/gui/grid_container.h" #include "scene/gui/grid_container.h"
#ifdef GDSCRIPT_ENABLED
#include "modules/gdscript/gdscript.h"
#endif
void PluginConfigDialog::_clear_fields() { void PluginConfigDialog::_clear_fields() {
name_edit->set_text(""); name_edit->set_text("");
subfolder_edit->set_text(""); subfolder_edit->set_text("");
@ -75,6 +78,7 @@ void PluginConfigDialog::_on_confirmed() {
// TODO Use script templates. Right now, this code won't add the 'tool' annotation to other languages. // TODO Use script templates. Right now, this code won't add the 'tool' annotation to other languages.
// TODO Better support script languages with named classes (has_named_classes). // TODO Better support script languages with named classes (has_named_classes).
#ifdef GDSCRIPT_ENABLED
if (lang_name == GDScriptLanguage::get_singleton()->get_name()) { if (lang_name == GDScriptLanguage::get_singleton()->get_name()) {
// Hard-coded GDScript template to keep usability until we use script templates. // Hard-coded GDScript template to keep usability until we use script templates.
Ref<Script> gdscript = memnew(GDScript); Ref<Script> gdscript = memnew(GDScript);
@ -95,12 +99,15 @@ void PluginConfigDialog::_on_confirmed() {
ResourceSaver::save(script_path, gdscript); ResourceSaver::save(script_path, gdscript);
script = gdscript; script = gdscript;
} else { } else {
#endif
String script_path = path.plus_file(script_edit->get_text()); String script_path = path.plus_file(script_edit->get_text());
String class_name = script_path.get_file().get_basename(); String class_name = script_path.get_file().get_basename();
script = ScriptServer::get_language(lang_idx)->get_template(class_name, "EditorPlugin"); script = ScriptServer::get_language(lang_idx)->get_template(class_name, "EditorPlugin");
script->set_path(script_path); script->set_path(script_path);
ResourceSaver::save(script_path, script); ResourceSaver::save(script_path, script);
#ifdef GDSCRIPT_ENABLED
} }
#endif
emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? subfolder_edit->get_text() : ""); emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? subfolder_edit->get_text() : "");
} else { } else {
@ -229,9 +236,11 @@ PluginConfigDialog::PluginConfigDialog() {
for (int i = 0; i < ScriptServer::get_language_count(); i++) { for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptLanguage *lang = ScriptServer::get_language(i); ScriptLanguage *lang = ScriptServer::get_language(i);
script_option_edit->add_item(lang->get_name()); script_option_edit->add_item(lang->get_name());
#ifdef GDSCRIPT_ENABLED
if (lang == GDScriptLanguage::get_singleton()) { if (lang == GDScriptLanguage::get_singleton()) {
default_lang = i; default_lang = i;
} }
#endif
} }
script_option_edit->select(default_lang); script_option_edit->select(default_lang);
grid->add_child(script_option_edit); grid->add_child(script_option_edit);