summaryrefslogtreecommitdiff
path: root/editor/script_create_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/script_create_dialog.cpp')
-rw-r--r--editor/script_create_dialog.cpp97
1 files changed, 54 insertions, 43 deletions
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index eb133abcd5..12b21d871b 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -40,36 +40,38 @@
#include "editor/editor_scale.h"
#include "editor_file_system.h"
-void ScriptCreateDialog::_notification(int p_what) {
+void ScriptCreateDialog::_theme_changed() {
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
+ String lang = ScriptServer::get_language(i)->get_type();
+ Ref<Texture2D> lang_icon = gc->get_theme_icon(lang, "EditorIcons");
+ if (lang_icon.is_valid()) {
+ language_menu->set_item_icon(i, lang_icon);
+ }
+ }
- switch (p_what) {
- case NOTIFICATION_THEME_CHANGED:
- case NOTIFICATION_ENTER_TREE: {
- for (int i = 0; i < ScriptServer::get_language_count(); i++) {
- String lang = ScriptServer::get_language(i)->get_type();
- Ref<Texture2D> lang_icon = get_icon(lang, "EditorIcons");
- if (lang_icon.is_valid()) {
- language_menu->set_item_icon(i, lang_icon);
- }
+ String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
+ if (!last_lang.empty()) {
+ for (int i = 0; i < language_menu->get_item_count(); i++) {
+ if (language_menu->get_item_text(i) == last_lang) {
+ language_menu->select(i);
+ current_language = i;
+ break;
}
+ }
+ } else {
+ language_menu->select(default_language);
+ }
- String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
- if (!last_lang.empty()) {
- for (int i = 0; i < language_menu->get_item_count(); i++) {
- if (language_menu->get_item_text(i) == last_lang) {
- language_menu->select(i);
- current_language = i;
- break;
- }
- }
- } else {
- language_menu->select(default_language);
- }
+ path_button->set_icon(gc->get_theme_icon("Folder", "EditorIcons"));
+ parent_browse_button->set_icon(gc->get_theme_icon("Folder", "EditorIcons"));
+ parent_search_button->set_icon(gc->get_theme_icon("ClassList", "EditorIcons"));
+ status_panel->add_theme_style_override("panel", gc->get_theme_stylebox("bg", "Tree"));
+}
+void ScriptCreateDialog::_notification(int p_what) {
- path_button->set_icon(get_icon("Folder", "EditorIcons"));
- parent_browse_button->set_icon(get_icon("Folder", "EditorIcons"));
- parent_search_button->set_icon(get_icon("ClassList", "EditorIcons"));
- status_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ _theme_changed();
} break;
}
}
@@ -419,7 +421,7 @@ void ScriptCreateDialog::_lang_changed(int l) {
templates[i].id = new_id;
}
// Disable overridden
- for (Map<String, Vector<int> >::Element *E = template_overrides.front(); E; E = E->next()) {
+ for (Map<String, Vector<int>>::Element *E = template_overrides.front(); E; E = E->next()) {
const Vector<int> &overrides = E->get();
if (overrides.size() == 1) {
@@ -442,7 +444,7 @@ void ScriptCreateDialog::_lang_changed(int l) {
override_info += ", ";
}
}
- template_menu->set_item_icon(extended.id, get_icon("Override", "EditorIcons"));
+ template_menu->set_item_icon(extended.id, gc->get_theme_icon("Override", "EditorIcons"));
template_menu->get_popup()->set_item_tooltip(extended.id, override_info.as_string());
}
// Reselect last selected template
@@ -517,11 +519,11 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) {
is_browsing_parent = browse_parent;
if (p_save) {
- file_browse->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_browse->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
file_browse->set_title(TTR("Open Script / Choose Location"));
file_browse->get_ok()->set_text(TTR("Open"));
} else {
- file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
file_browse->set_title(TTR("Open Script"));
}
@@ -607,9 +609,9 @@ void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) {
error_label->set_text("- " + TTR(p_msg));
if (valid) {
- error_label->add_color_override("font_color", get_color("success_color", "Editor"));
+ error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor"));
} else {
- error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ error_label->add_theme_color_override("font_color", gc->get_theme_color("error_color", "Editor"));
}
}
@@ -617,9 +619,9 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) {
path_error_label->set_text("- " + TTR(p_msg));
if (valid) {
- path_error_label->add_color_override("font_color", get_color("success_color", "Editor"));
+ path_error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor"));
} else {
- path_error_label->add_color_override("font_color", get_color("error_color", "Editor"));
+ path_error_label->add_theme_color_override("font_color", gc->get_theme_color("error_color", "Editor"));
}
}
@@ -687,6 +689,8 @@ void ScriptCreateDialog::_update_dialog() {
// Is Script created or loaded from existing file?
+ builtin_warning_label->set_visible(is_built_in);
+
if (is_built_in) {
get_ok()->set_text(TTR("Create"));
parent_name->set_editable(true);
@@ -739,9 +743,11 @@ ScriptCreateDialog::ScriptCreateDialog() {
/* Main Controls */
- GridContainer *gc = memnew(GridContainer);
+ gc = memnew(GridContainer);
gc->set_columns(2);
+ gc->connect("theme_changed", callable_mp(this, &ScriptCreateDialog::_theme_changed));
+
/* Error Messages Field */
VBoxContainer *vb = memnew(VBoxContainer);
@@ -752,6 +758,13 @@ ScriptCreateDialog::ScriptCreateDialog() {
path_error_label = memnew(Label);
vb->add_child(path_error_label);
+ builtin_warning_label = memnew(Label);
+ builtin_warning_label->set_text(
+ TTR("Note: Built-in scripts have some limitations and can't be edited using an external editor."));
+ vb->add_child(builtin_warning_label);
+ builtin_warning_label->set_autowrap(true);
+ builtin_warning_label->hide();
+
status_panel = memnew(PanelContainer);
status_panel->set_h_size_flags(Control::SIZE_FILL);
status_panel->add_child(vb);
@@ -774,7 +787,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
language_menu = memnew(OptionButton);
language_menu->set_custom_minimum_size(Size2(250, 0) * EDSCALE);
- language_menu->set_h_size_flags(SIZE_EXPAND_FILL);
+ language_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL);
gc->add_child(memnew(Label(TTR("Language:"))));
gc->add_child(language_menu);
@@ -798,10 +811,10 @@ ScriptCreateDialog::ScriptCreateDialog() {
base_type = "Object";
hb = memnew(HBoxContainer);
- hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
parent_name = memnew(LineEdit);
parent_name->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_parent_name_changed));
- parent_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ parent_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(parent_name);
parent_search_button = memnew(Button);
parent_search_button->set_flat(true);
@@ -819,7 +832,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
class_name = memnew(LineEdit);
class_name->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_class_name_changed));
- class_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ class_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
gc->add_child(memnew(Label(TTR("Class Name:"))));
gc->add_child(class_name);
@@ -845,7 +858,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
file_path = memnew(LineEdit);
file_path->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_path_changed));
file_path->connect("text_entered", callable_mp(this, &ScriptCreateDialog::_path_entered));
- file_path->set_h_size_flags(SIZE_EXPAND_FILL);
+ file_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(file_path);
path_button = memnew(Button);
path_button->set_flat(true);
@@ -863,18 +876,16 @@ ScriptCreateDialog::ScriptCreateDialog() {
file_browse = memnew(EditorFileDialog);
file_browse->connect("file_selected", callable_mp(this, &ScriptCreateDialog::_file_selected));
- file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
add_child(file_browse);
get_ok()->set_text(TTR("Create"));
alert = memnew(AcceptDialog);
- alert->set_as_minsize();
alert->get_label()->set_autowrap(true);
alert->get_label()->set_align(Label::ALIGN_CENTER);
alert->get_label()->set_valign(Label::VALIGN_CENTER);
alert->get_label()->set_custom_minimum_size(Size2(325, 60) * EDSCALE);
add_child(alert);
- set_as_minsize();
set_hide_on_ok(false);
set_title(TTR("Attach Node Script"));