summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/create_dialog.cpp31
-rw-r--r--editor/editor_data.cpp45
-rw-r--r--editor/editor_data.h8
-rw-r--r--editor/editor_file_system.cpp27
-rw-r--r--editor/editor_file_system.h5
-rw-r--r--editor/editor_node.cpp21
-rw-r--r--editor/editor_node.h5
-rw-r--r--editor/editor_plugin.cpp6
-rw-r--r--editor/editor_plugin.h5
-rw-r--r--editor/editor_plugin_settings.cpp36
-rw-r--r--editor/editor_plugin_settings.h9
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/filesystem_dock.cpp175
-rw-r--r--editor/filesystem_dock.h23
-rw-r--r--editor/plugin_config_dialog.cpp230
-rw-r--r--editor/plugin_config_dialog.h71
-rw-r--r--editor/plugins/script_editor_plugin.cpp18
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp9
-rw-r--r--editor/plugins/spatial_editor_plugin.h2
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp21
-rw-r--r--editor/plugins/texture_region_editor_plugin.h1
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp54
-rw-r--r--editor/plugins/tile_set_editor_plugin.h7
-rw-r--r--editor/project_settings_editor.cpp4
-rw-r--r--editor/project_settings_editor.h1
-rw-r--r--editor/property_editor.cpp18
-rw-r--r--editor/scene_tree_dock.cpp30
27 files changed, 703 insertions, 161 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index aa70c5aa15..ab7a7054eb 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -157,6 +157,15 @@ Ref<Texture> CreateDialog::_get_editor_icon(const String &p_type) const {
return get_icon(p_type, "EditorIcons");
}
+ if (ScriptServer::is_global_class(p_type)) {
+ RES icon = ResourceLoader::load(EditorNode::get_editor_data().script_class_get_icon_path(p_type));
+ if (icon.is_valid())
+ return icon;
+ icon = get_icon(ScriptServer::get_global_class_base(p_type), "EditorIcons");
+ if (icon.is_valid())
+ return icon;
+ }
+
const Map<String, Vector<EditorData::CustomType> > &p_map = EditorNode::get_editor_data().get_custom_types();
for (const Map<String, Vector<EditorData::CustomType> >::Element *E = p_map.front(); E; E = E->next()) {
const Vector<EditorData::CustomType> &ct = E->value();
@@ -180,7 +189,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
return;
bool cpp_type = ClassDB::class_exists(p_type);
- EditorData &ed = EditorNode::get_singleton()->get_editor_data();
+ EditorData &ed = EditorNode::get_editor_data();
if (p_type == base_type)
return;
@@ -262,13 +271,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description;
item->set_tooltip(0, description);
- if (cpp_type && has_icon(p_type, "EditorIcons")) {
-
- item->set_icon(0, get_icon(p_type, "EditorIcons"));
- } else if (!cpp_type && has_icon(ScriptServer::get_global_class_base(p_type), "EditorIcons")) {
-
- item->set_icon(0, get_icon(ScriptServer::get_global_class_base(p_type), "EditorIcons"));
- }
+ item->set_icon(0, _get_editor_icon(p_type));
p_types[p_type] = item;
}
@@ -287,7 +290,7 @@ void CreateDialog::_update_search() {
HashMap<String, TreeItem *> types;
TreeItem *root = search_options->create_item();
- EditorData &ed = EditorNode::get_singleton()->get_editor_data();
+ EditorData &ed = EditorNode::get_editor_data();
root->set_text(0, base_type);
if (has_icon(base_type, "EditorIcons")) {
@@ -490,16 +493,8 @@ Object *CreateDialog::instance_selected() {
custom = md;
if (custom != String()) {
-
if (ScriptServer::is_global_class(custom)) {
- RES script = ResourceLoader::load(ScriptServer::get_global_class_path(custom));
- ERR_FAIL_COND_V(!script.is_valid(), NULL);
-
- Object *obj = ClassDB::instance(ScriptServer::get_global_class_base(custom));
- ERR_FAIL_COND_V(!obj, NULL);
-
- obj->set_script(script.get_ref_ptr());
- return obj;
+ return EditorNode::get_editor_data().script_class_instance(custom);
}
return EditorNode::get_editor_data().instance_custom_type(selected->get_text(0), custom);
} else {
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index f4ef11eb36..69c120bb3c 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -888,11 +888,56 @@ StringName EditorData::script_class_get_base(const String &p_class) {
return script->get_language()->get_global_class_name(base_script->get_path());
}
+Object *EditorData::script_class_instance(const String &p_class) {
+ if (ScriptServer::is_global_class(p_class)) {
+ Object *obj = ClassDB::instance(ScriptServer::get_global_class_base(p_class));
+ if (obj) {
+ RES script = ResourceLoader::load(ScriptServer::get_global_class_path(p_class));
+ if (script.is_valid())
+ obj->set_script(script.get_ref_ptr());
+
+ RES icon = ResourceLoader::load(script_class_get_icon_path(p_class));
+ if (icon.is_valid())
+ obj->set_meta("_editor_icon", icon);
+
+ return obj;
+ }
+ }
+ return NULL;
+}
+
+void EditorData::script_class_save_icon_paths() {
+ List<StringName> keys;
+ _script_class_icon_paths.get_key_list(&keys);
+
+ Dictionary d;
+ for (List<StringName>::Element *E = keys.front(); E; E = E->next()) {
+ d[E->get()] = _script_class_icon_paths[E->get()];
+ }
+
+ ProjectSettings::get_singleton()->set("_global_script_class_icons", d);
+ ProjectSettings::get_singleton()->save();
+}
+
+void EditorData::script_class_load_icon_paths() {
+ script_class_clear_icon_paths();
+
+ Dictionary d = ProjectSettings::get_singleton()->get("_global_script_class_icons");
+ List<Variant> keys;
+ d.get_key_list(&keys);
+
+ for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
+ String key = E->get().operator String();
+ _script_class_icon_paths[key] = d[key];
+ }
+}
+
EditorData::EditorData() {
current_edited_scene = -1;
//load_imported_scenes_from_globals();
+ script_class_load_icon_paths();
}
///////////
diff --git a/editor/editor_data.h b/editor/editor_data.h
index fac6635cd2..285769aa78 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -146,6 +146,8 @@ private:
bool _find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths);
+ HashMap<StringName, String> _script_class_icon_paths;
+
public:
EditorPlugin *get_editor(Object *p_object);
EditorPlugin *get_subeditor(Object *p_object);
@@ -213,6 +215,12 @@ public:
bool script_class_is_parent(const String &p_class, const String &p_inherits);
StringName script_class_get_base(const String &p_class);
+ Object *script_class_instance(const String &p_class);
+ String script_class_get_icon_path(const String &p_class) const { return _script_class_icon_paths.has(p_class) ? _script_class_icon_paths[p_class] : String(); }
+ void script_class_set_icon_path(const String &p_class, const String &p_icon_path) { _script_class_icon_paths[p_class] = p_icon_path; }
+ void script_class_clear_icon_paths() { _script_class_icon_paths.clear(); }
+ void script_class_save_icon_paths();
+ void script_class_load_icon_paths();
EditorData();
};
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 671ac755b2..9562a8c63c 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -133,6 +133,10 @@ String EditorFileSystemDirectory::get_file_script_class_extends(int p_idx) const
return files[p_idx]->script_class_extends;
}
+String EditorFileSystemDirectory::get_file_script_class_icon_path(int p_idx) const {
+ return files[p_idx]->script_class_icon_path;
+}
+
StringName EditorFileSystemDirectory::get_file_type(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, files.size(), "");
@@ -233,6 +237,7 @@ void EditorFileSystem::_scan_filesystem() {
fc.import_valid = split[4].to_int64() != 0;
fc.script_class_name = split[5].get_slice("<>", 0);
fc.script_class_extends = split[5].get_slice("<>", 1);
+ fc.script_class_icon_path = split[5].get_slice("<>", 2);
String deps = split[6].strip_edges();
if (deps.length()) {
@@ -721,6 +726,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
fi->import_valid = fc->import_valid;
fi->script_class_name = fc->script_class_name;
fi->script_class_extends = fc->script_class_extends;
+ fi->script_class_icon_path = fc->script_class_icon_path;
if (fc->type == String()) {
fi->type = ResourceLoader::get_resource_type(path);
@@ -731,7 +737,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
} else {
fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path);
- fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends);
+ fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path);
fi->modified_time = 0;
fi->import_modified_time = 0;
fi->import_valid = ResourceLoader::is_import_valid(path);
@@ -753,10 +759,11 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
fi->import_valid = true;
fi->script_class_name = fc->script_class_name;
fi->script_class_extends = fc->script_class_extends;
+ fi->script_class_icon_path = fc->script_class_icon_path;
} else {
//new or modified time
fi->type = ResourceLoader::get_resource_type(path);
- fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends);
+ fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path);
fi->deps = _get_dependencies(path);
fi->modified_time = mt;
fi->import_modified_time = 0;
@@ -855,7 +862,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
fi->modified_time = FileAccess::get_modified_time(path);
fi->import_modified_time = 0;
fi->type = ResourceLoader::get_resource_type(path);
- fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends);
+ fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path);
fi->import_valid = ResourceLoader::is_import_valid(path);
{
@@ -1110,7 +1117,7 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir,
for (int i = 0; i < p_dir->files.size(); i++) {
- String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends;
+ String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path;
s += "::";
for (int j = 0; j < p_dir->files[i]->deps.size(); j++) {
@@ -1316,19 +1323,22 @@ Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) {
return ret;
}
-String EditorFileSystem::_get_global_script_class(const String &p_type, const String &p_path, String *r_extends) const {
+String EditorFileSystem::_get_global_script_class(const String &p_type, const String &p_path, String *r_extends, String *r_icon_path) const {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
if (ScriptServer::get_language(i)->handles_global_class_type(p_type)) {
String global_name;
String extends;
+ String icon_path;
- global_name = ScriptServer::get_language(i)->get_global_class_name(p_path, &extends);
+ global_name = ScriptServer::get_language(i)->get_global_class_name(p_path, &extends, &icon_path);
*r_extends = extends;
+ *r_icon_path = icon_path;
return global_name;
}
}
*r_extends = String();
+ *r_icon_path = String();
return String();
}
@@ -1346,8 +1356,8 @@ void EditorFileSystem::_scan_script_classes(EditorFileSystemDirectory *p_dir) {
lang = ScriptServer::get_language(j)->get_name();
}
}
-
ScriptServer::add_global_class(files[i]->script_class_name, files[i]->script_class_extends, lang, p_dir->get_file_path(i));
+ EditorNode::get_editor_data().script_class_set_icon_path(files[i]->script_class_name, files[i]->script_class_icon_path);
}
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
_scan_script_classes(p_dir->get_subdir(i));
@@ -1366,6 +1376,7 @@ void EditorFileSystem::update_script_classes() {
}
ScriptServer::save_global_classes();
+ EditorNode::get_editor_data().script_class_save_icon_paths();
emit_signal("script_classes_updated");
}
@@ -1438,7 +1449,7 @@ void EditorFileSystem::update_file(const String &p_file) {
}
fs->files[cpos]->type = type;
- fs->files[cpos]->script_class_name = _get_global_script_class(type, p_file, &fs->files[cpos]->script_class_extends);
+ fs->files[cpos]->script_class_name = _get_global_script_class(type, p_file, &fs->files[cpos]->script_class_extends, &fs->files[cpos]->script_class_icon_path);
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
fs->files[cpos]->deps = _get_dependencies(p_file);
fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file);
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 1aa35f4782..75ca79932f 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -60,6 +60,7 @@ class EditorFileSystemDirectory : public Object {
bool verified; //used for checking changes
String script_class_name;
String script_class_extends;
+ String script_class_icon_path;
};
struct FileInfoSort {
@@ -90,6 +91,7 @@ public:
bool get_file_import_is_valid(int p_idx) const;
String get_file_script_class_name(int p_idx) const; //used for scripts
String get_file_script_class_extends(int p_idx) const; //used for scripts
+ String get_file_script_class_icon_path(int p_idx) const; //used for scripts
EditorFileSystemDirectory *get_parent();
@@ -163,6 +165,7 @@ class EditorFileSystem : public Node {
bool import_valid;
String script_class_name;
String script_class_extends;
+ String script_class_icon_path;
};
HashMap<String, FileCache> file_cache;
@@ -225,7 +228,7 @@ class EditorFileSystem : public Node {
volatile bool update_script_classes_queued;
void _queue_update_script_classes();
- String _get_global_script_class(const String &p_type, const String &p_path, String *r_extends) const;
+ String _get_global_script_class(const String &p_type, const String &p_path, String *r_extends, String *r_icon_path) const;
protected:
void _notification(int p_what);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 4e6f3853c6..0be6ee8759 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -411,6 +411,18 @@ void EditorNode::_notification(int p_what) {
}
}
+void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_name) {
+ Ref<Script> script = Object::cast_to<Script>(p_script);
+ if (script.is_null())
+ return;
+ if (p_activate_name.length()) {
+ set_addon_plugin_enabled(p_activate_name, true);
+ }
+ project_settings->update_plugins();
+ project_settings->hide();
+ push_item(script.operator->());
+}
+
void EditorNode::_fs_changed() {
for (Set<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) {
@@ -2547,6 +2559,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled)
EditorPlugin *ep = memnew(EditorPlugin);
ep->set_script(script.get_ref_ptr());
+ ep->set_dir_cache(p_addon);
plugin_addons[p_addon] = ep;
add_editor_plugin(ep);
@@ -4548,6 +4561,8 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_resources_reimported"), &EditorNode::_resources_reimported);
ClassDB::bind_method(D_METHOD("_bottom_panel_raise_toggled"), &EditorNode::_bottom_panel_raise_toggled);
+ ClassDB::bind_method(D_METHOD("_on_plugin_ready"), &EditorNode::_on_plugin_ready);
+
ClassDB::bind_method(D_METHOD("_video_driver_selected"), &EditorNode::_video_driver_selected);
ADD_SIGNAL(MethodInfo("play_pressed"));
@@ -5134,6 +5149,10 @@ EditorNode::EditorNode() {
p->connect("id_pressed", this, "_menu_option");
p->add_item(TTR("Export"), FILE_EXPORT_PROJECT);
+ plugin_config_dialog = memnew(PluginConfigDialog);
+ plugin_config_dialog->connect("plugin_ready", this, "_on_plugin_ready");
+ gui_base->add_child(plugin_config_dialog);
+
tool_menu = memnew(PopupMenu);
tool_menu->set_name("Tools");
tool_menu->connect("index_pressed", this, "_tool_menu_option");
@@ -5409,7 +5428,7 @@ EditorNode::EditorNode() {
}
filesystem_dock = memnew(FileSystemDock(this));
- filesystem_dock->set_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
+ filesystem_dock->set_file_list_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
if (use_single_dock_column) {
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(filesystem_dock);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 85aa37ec7e..5a17ab6ca0 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -56,6 +56,7 @@
#include "editor/inspector_dock.h"
#include "editor/node_dock.h"
#include "editor/pane_drag.h"
+#include "editor/plugin_config_dialog.h"
#include "editor/progress_dialog.h"
#include "editor/project_export.h"
#include "editor/project_settings_editor.h"
@@ -257,6 +258,8 @@ private:
ToolButton *search_button;
TextureProgress *audio_vu;
+ PluginConfigDialog *plugin_config_dialog;
+
RichTextLabel *load_errors;
AcceptDialog *load_error_dialog;
@@ -416,6 +419,8 @@ private:
void _tool_menu_option(int p_idx);
void _update_debug_options();
+ void _on_plugin_ready(Object *p_script, const String &p_activate_name);
+
void _fs_changed();
void _resources_reimported(const Vector<String> &p_resources);
void _sources_changed(bool p_exist);
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index a926401558..137e710c5c 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -309,6 +309,12 @@ void EditorPlugin::remove_autoload_singleton(const String &p_name) {
EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name);
}
+Ref<ConfigFile> EditorPlugin::get_config() {
+ Ref<ConfigFile> cf = memnew(ConfigFile);
+ cf->load(_dir_cache.plus_file("plugin.cfg"));
+ return cf;
+}
+
ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
ERR_FAIL_NULL_V(p_control, NULL);
return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control);
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index c417f487dc..903b82937f 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -114,6 +114,7 @@ class EditorPlugin : public Node {
bool force_draw_over_forwarding_enabled;
String last_main_screen_name;
+ String _dir_cache;
protected:
static void _bind_methods();
@@ -221,6 +222,10 @@ public:
void add_autoload_singleton(const String &p_name, const String &p_path);
void remove_autoload_singleton(const String &p_name);
+ void set_dir_cache(const String &p_dir) { _dir_cache = p_dir; }
+ String get_dir_cache() { return _dir_cache; }
+ Ref<ConfigFile> get_config();
+
EditorPlugin();
virtual ~EditorPlugin();
};
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index ea1e0fe99e..68f8ed6d94 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -41,6 +41,9 @@ void EditorPluginSettings::_notification(int p_what) {
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
update_plugins();
+ } else if (p_what == Node::NOTIFICATION_READY) {
+ plugin_config_dialog->connect("plugin_ready", EditorNode::get_singleton(), "_on_plugin_ready");
+ plugin_list->connect("button_pressed", this, "_cell_button_pressed");
}
}
@@ -124,6 +127,7 @@ void EditorPluginSettings::update_plugins() {
item->set_range_config(3, 0, 1, 1);
item->set_text(3, "Inactive,Active");
item->set_editable(3, true);
+ item->add_button(4, get_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin"));
if (EditorNode::get_singleton()->is_addon_plugin_enabled(d)) {
item->set_custom_color(3, get_color("success_color", "Editor"));
@@ -164,17 +168,44 @@ void EditorPluginSettings::_plugin_activity_changed() {
ti->set_custom_color(3, get_color("disabled_font_color", "Editor"));
}
+void EditorPluginSettings::_create_clicked() {
+ plugin_config_dialog->config("");
+ plugin_config_dialog->popup_centered();
+}
+
+void EditorPluginSettings::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
+ TreeItem *item = Object::cast_to<TreeItem>(p_item);
+ if (!item)
+ return;
+ if (p_id == BUTTON_PLUGIN_EDIT) {
+ if (p_column == 4) {
+ String dir = item->get_metadata(0);
+ plugin_config_dialog->config("res://addons/" + dir + "/plugin.cfg");
+ plugin_config_dialog->popup_centered();
+ }
+ }
+}
+
void EditorPluginSettings::_bind_methods() {
ClassDB::bind_method("update_plugins", &EditorPluginSettings::update_plugins);
+ ClassDB::bind_method("_create_clicked", &EditorPluginSettings::_create_clicked);
ClassDB::bind_method("_plugin_activity_changed", &EditorPluginSettings::_plugin_activity_changed);
+ ClassDB::bind_method("_cell_button_pressed", &EditorPluginSettings::_cell_button_pressed);
}
EditorPluginSettings::EditorPluginSettings() {
+ plugin_config_dialog = memnew(PluginConfigDialog);
+ plugin_config_dialog->config("");
+ add_child(plugin_config_dialog);
+
HBoxContainer *title_hb = memnew(HBoxContainer);
title_hb->add_child(memnew(Label(TTR("Installed Plugins:"))));
title_hb->add_spacer();
+ create_plugin = memnew(Button(TTR("Create")));
+ create_plugin->connect("pressed", this, "_create_clicked");
+ title_hb->add_child(create_plugin);
update_list = memnew(Button(TTR("Update")));
update_list->connect("pressed", this, "update_plugins");
title_hb->add_child(update_list);
@@ -182,19 +213,22 @@ EditorPluginSettings::EditorPluginSettings() {
plugin_list = memnew(Tree);
plugin_list->set_v_size_flags(SIZE_EXPAND_FILL);
- plugin_list->set_columns(4);
+ plugin_list->set_columns(5);
plugin_list->set_column_titles_visible(true);
plugin_list->set_column_title(0, TTR("Name:"));
plugin_list->set_column_title(1, TTR("Version:"));
plugin_list->set_column_title(2, TTR("Author:"));
plugin_list->set_column_title(3, TTR("Status:"));
+ plugin_list->set_column_title(4, TTR("Edit:"));
plugin_list->set_column_expand(0, true);
plugin_list->set_column_expand(1, false);
plugin_list->set_column_expand(2, false);
plugin_list->set_column_expand(3, false);
+ plugin_list->set_column_expand(4, false);
plugin_list->set_column_min_width(1, 100 * EDSCALE);
plugin_list->set_column_min_width(2, 250 * EDSCALE);
plugin_list->set_column_min_width(3, 80 * EDSCALE);
+ plugin_list->set_column_min_width(4, 40 * EDSCALE);
plugin_list->set_hide_root(true);
plugin_list->connect("item_edited", this, "_plugin_activity_changed");
diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h
index aacbd05dd4..310cab699f 100644
--- a/editor/editor_plugin_settings.h
+++ b/editor/editor_plugin_settings.h
@@ -31,6 +31,7 @@
#ifndef EDITORPLUGINSETTINGS_H
#define EDITORPLUGINSETTINGS_H
+#include "editor/plugin_config_dialog.h";
#include "editor_data.h"
#include "property_editor.h"
#include "scene/gui/dialogs.h"
@@ -40,11 +41,19 @@ class EditorPluginSettings : public VBoxContainer {
GDCLASS(EditorPluginSettings, VBoxContainer);
+ enum {
+ BUTTON_PLUGIN_EDIT
+ };
+
+ PluginConfigDialog *plugin_config_dialog;
+ Button *create_plugin;
Button *update_list;
Tree *plugin_list;
bool updating;
void _plugin_activity_changed();
+ void _create_clicked();
+ void _cell_button_pressed(Object *p_item, int p_column, int p_id);
protected:
void _notification(int p_what);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 8e079b1f67..d24816ee02 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -511,6 +511,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("filesystem/file_dialog/thumbnail_size", 64);
hints["filesystem/file_dialog/thumbnail_size"] = PropertyInfo(Variant::INT, "filesystem/file_dialog/thumbnail_size", PROPERTY_HINT_RANGE, "32,128,16");
+ _initial_set("docks/filesystem/disable_split", false);
+ _initial_set("docks/filesystem/split_mode_minimum_height", 600);
_initial_set("docks/filesystem/display_mode", 0);
hints["docks/filesystem/display_mode"] = PropertyInfo(Variant::INT, "docks/filesystem/display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List");
_initial_set("docks/filesystem/thumbnail_size", 64);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index f2c8cde151..ec1153a015 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -139,41 +139,56 @@ void FileSystemDock::_update_tree(bool keep_collapse_state, bool p_uncollapse_ro
updating_tree = false;
}
-void FileSystemDock::_notification(int p_what) {
+void FileSystemDock::_update_display_mode() {
- switch (p_what) {
+ bool disable_split = bool(EditorSettings::get_singleton()->get("docks/filesystem/disable_split"));
+ bool compact_mode = get_size().height < int(EditorSettings::get_singleton()->get("docks/filesystem/split_mode_minimum_height"));
+ DisplayMode new_mode;
+ if (disable_split || compact_mode) {
+ new_mode = file_list_view ? DISPLAY_FILE_LIST_ONLY : DISPLAY_TREE_ONLY;
+ } else {
+ new_mode = DISPLAY_SPLIT;
+ }
- case NOTIFICATION_RESIZED: {
+ if (new_mode != display_mode) {
+ switch (new_mode) {
+ case DISPLAY_TREE_ONLY:
+ tree->show();
+ tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ _update_tree(true);
- bool new_mode = get_size().height < get_viewport_rect().size.height / 2;
+ file_list_vb->hide();
+ break;
- if (new_mode != low_height_mode) {
+ case DISPLAY_FILE_LIST_ONLY:
+ tree->hide();
+ button_tree->show();
- low_height_mode = new_mode;
+ file_list_vb->show();
+ _update_files(true);
+ break;
- if (low_height_mode) {
+ case DISPLAY_SPLIT:
+ tree->show();
+ tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ button_tree->hide();
+ tree->ensure_cursor_is_visible();
+ _update_tree(true);
- tree->hide();
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
- button_tree->show();
- } else {
+ file_list_vb->show();
+ _update_files(true);
+ break;
+ }
+ display_mode = new_mode;
+ }
+}
- tree->set_v_size_flags(SIZE_FILL);
- button_tree->hide();
- if (!tree->is_visible()) {
- tree->show();
- button_favorite->show();
- _update_tree(true);
- }
- tree->ensure_cursor_is_visible();
+void FileSystemDock::_notification(int p_what) {
- if (!file_list_vb->is_visible()) {
- file_list_vb->show();
- _update_files(true);
- }
- }
- }
+ switch (p_what) {
+ case NOTIFICATION_RESIZED: {
+ _update_display_mode();
} break;
case NOTIFICATION_ENTER_TREE: {
@@ -190,8 +205,8 @@ void FileSystemDock::_notification(int p_what) {
//button_instance->set_icon(get_icon("Add", ei));
//button_open->set_icon(get_icon("Folder", ei));
button_tree->set_icon(get_icon("Filesystem", ei));
- _update_file_display_toggle_button();
- button_display_mode->connect("pressed", this, "_change_file_display");
+ _update_file_list_display_mode_button();
+ button_file_list_display_mode->connect("pressed", this, "_change_file_display");
//file_options->set_icon( get_icon("Tools","ei"));
files->connect("item_activated", this, "_select_file");
button_hist_next->connect("pressed", this, "_fw_history");
@@ -208,6 +223,8 @@ void FileSystemDock::_notification(int p_what) {
button_tree->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
current_path->connect("text_entered", this, "navigate_to_path");
+ _update_display_mode();
+
if (EditorFileSystem::get_singleton()->is_scanning()) {
_set_scanning_mode();
} else {
@@ -241,12 +258,8 @@ void FileSystemDock::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
-
+ // Update icons
String ei = "EditorIcons";
- int new_mode = int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"));
-
- //_update_icons
-
button_reload->set_icon(get_icon("Reload", ei));
button_favorite->set_icon(get_icon("Favorites", ei));
button_tree->set_icon(get_icon("Filesystem", ei));
@@ -256,14 +269,18 @@ void FileSystemDock::_notification(int p_what) {
search_box->set_right_icon(get_icon("Search", ei));
search_box->set_clear_button_enabled(true);
- if (new_mode != display_mode) {
- set_display_mode(new_mode);
+ // Change size mode
+ int new_file_list_mode = int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"));
+ if (new_file_list_mode != file_list_display_mode) {
+ set_file_list_display_mode(new_file_list_mode);
} else {
- _update_file_display_toggle_button();
+ _update_file_list_display_mode_button();
_update_files(true);
}
- _update_tree(true);
+ // Change full tree mode
+ _update_display_mode();
+
} break;
}
}
@@ -289,7 +306,7 @@ void FileSystemDock::_dir_selected() {
current_path->set_text(path);
_push_to_history();
- if (!low_height_mode) {
+ if (display_mode == DISPLAY_SPLIT) {
_update_files(false);
}
}
@@ -360,7 +377,7 @@ void FileSystemDock::navigate_to_path(const String &p_path) {
current_path->set_text(path);
_push_to_history();
- if (!low_height_mode) {
+ if (display_mode == DISPLAY_SPLIT) {
_update_tree(true);
_update_files(false);
} else {
@@ -390,24 +407,24 @@ void FileSystemDock::_thumbnail_done(const String &p_path, const Ref<Texture> &p
}
}
-void FileSystemDock::_update_file_display_toggle_button() {
+void FileSystemDock::_update_file_list_display_mode_button() {
- if (button_display_mode->is_pressed()) {
- display_mode = DISPLAY_LIST;
- button_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
- button_display_mode->set_tooltip(TTR("View items as a grid of thumbnails."));
+ if (button_file_list_display_mode->is_pressed()) {
+ file_list_display_mode = FILE_LIST_DISPLAY_LIST;
+ button_file_list_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
+ button_file_list_display_mode->set_tooltip(TTR("View items as a grid of thumbnails."));
} else {
- display_mode = DISPLAY_THUMBNAILS;
- button_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
- button_display_mode->set_tooltip(TTR("View items as a list."));
+ file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
+ button_file_list_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
+ button_file_list_display_mode->set_tooltip(TTR("View items as a list."));
}
}
void FileSystemDock::_change_file_display() {
- _update_file_display_toggle_button();
+ _update_file_list_display_mode_button();
- EditorSettings::get_singleton()->set("docks/filesystem/display_mode", display_mode);
+ EditorSettings::get_singleton()->set("docks/filesystem/display_mode", file_list_display_mode);
_update_files(true);
}
@@ -472,8 +489,8 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
bool always_show_folders = EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders");
- bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS);
- bool use_folders = search_box->get_text().length() == 0 && (low_height_mode || always_show_folders);
+ bool use_thumbnails = (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS);
+ bool use_folders = search_box->get_text().length() == 0 && ((display_mode == DISPLAY_FILE_LIST_ONLY || display_mode == DISPLAY_TREE_ONLY) || always_show_folders);
if (use_thumbnails) {
@@ -617,24 +634,28 @@ void FileSystemDock::_select_file(int p_idx) {
}
}
-void FileSystemDock::_go_to_tree() {
+void FileSystemDock::_go_to_file_list() {
- if (low_height_mode) {
- tree->show();
- button_favorite->show();
- file_list_vb->hide();
+ if (display_mode == DISPLAY_TREE_ONLY) {
+ file_list_view = true;
+ _update_display_mode();
+ } else {
+ bool collapsed = tree->get_selected()->is_collapsed();
+ tree->get_selected()->set_collapsed(!collapsed);
+ _update_files(false);
}
+}
+void FileSystemDock::_go_to_tree() {
- _update_tree(true);
+ file_list_view = false;
tree->grab_focus();
+ _update_display_mode();
tree->ensure_cursor_is_visible();
- //button_open->hide();
- //file_options->hide();
}
void FileSystemDock::_preview_invalidated(const String &p_path) {
- if (display_mode == DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
+ if (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
for (int i = 0; i < files->get_item_count(); i++) {
@@ -1413,24 +1434,6 @@ void FileSystemDock::_resource_created() const {
editor->save_resource_as(current_res, path);
}
-void FileSystemDock::_go_to_file_list() {
-
- if (low_height_mode) {
- tree->hide();
- file_list_vb->show();
- button_favorite->hide();
- } else {
- bool collapsed = tree->get_selected()->is_collapsed();
- tree->get_selected()->set_collapsed(!collapsed);
- }
-
- //file_options->show();
-
- _update_files(false);
-
- //emit_signal("open",path);
-}
-
void FileSystemDock::_dir_rmb_pressed(const Vector2 &p_pos) {
folder_options->clear();
folder_options->set_size(Size2(1, 1));
@@ -1474,7 +1477,7 @@ void FileSystemDock::fix_dependencies(const String &p_for_file) {
void FileSystemDock::focus_on_filter() {
- if (low_height_mode && tree->is_visible()) {
+ if (display_mode == DISPLAY_FILE_LIST_ONLY && tree->is_visible()) {
// Tree mode, switch to files list with search box
tree->hide();
file_list_vb->show();
@@ -1484,12 +1487,12 @@ void FileSystemDock::focus_on_filter() {
search_box->grab_focus();
}
-void FileSystemDock::set_display_mode(int p_mode) {
+void FileSystemDock::set_file_list_display_mode(int p_mode) {
- if (p_mode == display_mode)
+ if (p_mode == file_list_display_mode)
return;
- button_display_mode->set_pressed(p_mode == DISPLAY_LIST);
+ button_file_list_display_mode->set_pressed(p_mode == FILE_LIST_DISPLAY_LIST);
_change_file_display();
}
@@ -2030,9 +2033,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
search_box->connect("text_changed", this, "_search_changed");
path_hb->add_child(search_box);
- button_display_mode = memnew(ToolButton);
- button_display_mode->set_toggle_mode(true);
- path_hb->add_child(button_display_mode);
+ button_file_list_display_mode = memnew(ToolButton);
+ button_file_list_display_mode->set_toggle_mode(true);
+ path_hb->add_child(button_file_list_display_mode);
files = memnew(ItemList);
files->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -2128,8 +2131,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
history_max_size = 20;
history.push_back("res://");
- low_height_mode = false;
- display_mode = DISPLAY_THUMBNAILS;
+ display_mode = DISPLAY_SPLIT;
+ file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
}
FileSystemDock::~FileSystemDock() {
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 6a0c73d52e..fbbe87fc16 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -60,12 +60,18 @@ class FileSystemDock : public VBoxContainer {
GDCLASS(FileSystemDock, VBoxContainer);
public:
- enum DisplayMode {
- DISPLAY_THUMBNAILS,
- DISPLAY_LIST
+ enum FileListDisplayMode {
+ FILE_LIST_DISPLAY_THUMBNAILS,
+ FILE_LIST_DISPLAY_LIST
};
private:
+ enum DisplayMode {
+ DISPLAY_TREE_ONLY,
+ DISPLAY_FILE_LIST_ONLY,
+ DISPLAY_SPLIT,
+ };
+
enum FileMenu {
FILE_OPEN,
FILE_INSTANCE,
@@ -106,7 +112,7 @@ private:
Button *button_reload;
Button *button_favorite;
Button *button_tree;
- Button *button_display_mode;
+ Button *button_file_list_display_mode;
Button *button_hist_next;
Button *button_hist_prev;
Button *button_show;
@@ -115,8 +121,9 @@ private:
TextureRect *search_icon;
HBoxContainer *path_hb;
- bool low_height_mode;
+ FileListDisplayMode file_list_display_mode;
DisplayMode display_mode;
+ bool file_list_view;
PopupMenu *file_options;
PopupMenu *folder_options;
@@ -172,7 +179,7 @@ private:
void _files_gui_input(Ref<InputEvent> p_event);
void _update_files(bool p_keep_selection);
- void _update_file_display_toggle_button();
+ void _update_file_list_display_mode_button();
void _change_file_display();
void _fs_changed();
@@ -245,6 +252,8 @@ private:
void _preview_invalidated(const String &p_path);
void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
+ void _update_display_mode();
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -258,7 +267,7 @@ public:
void fix_dependencies(const String &p_for_file);
- void set_display_mode(int p_mode);
+ void set_file_list_display_mode(int p_mode);
int get_split_offset() { return split_box->get_split_offset(); }
void set_split_offset(int p_offset) { split_box->set_split_offset(p_offset); }
diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp
new file mode 100644
index 0000000000..418936ac9f
--- /dev/null
+++ b/editor/plugin_config_dialog.cpp
@@ -0,0 +1,230 @@
+/*************************************************************************/
+/* plugin_config_dialog.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "plugin_config_dialog.h"
+#include "core/io/config_file.h"
+#include "core/os/dir_access.h"
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "modules/gdscript/gdscript.h"
+#include "scene/gui/grid_container.h"
+
+void PluginConfigDialog::_clear_fields() {
+ name_edit->set_text("");
+ subfolder_edit->set_text("");
+ desc_edit->set_text("");
+ author_edit->set_text("");
+ version_edit->set_text("");
+ script_edit->set_text("");
+}
+
+void PluginConfigDialog::_on_confirmed() {
+
+ String path = "res://addons/" + subfolder_edit->get_text();
+
+ if (!_edit_mode) {
+ DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ if (!d || d->make_dir_recursive(path) != OK)
+ return;
+ }
+
+ Ref<ConfigFile> cf = memnew(ConfigFile);
+ cf->set_value("plugin", "name", name_edit->get_text());
+ cf->set_value("plugin", "description", desc_edit->get_text());
+ cf->set_value("plugin", "author", author_edit->get_text());
+ cf->set_value("plugin", "version", version_edit->get_text());
+ cf->set_value("plugin", "script", script_edit->get_text());
+
+ cf->save(path.plus_file("plugin.cfg"));
+
+ if (!_edit_mode) {
+ String type = script_option_edit->get_item_text(script_option_edit->get_selected());
+
+ Ref<Script> script;
+
+ if (type == GDScriptLanguage::get_singleton()->get_name()) {
+ Ref<GDScript> gdscript = memnew(GDScript);
+ gdscript->set_source_code(
+ "tool\n"
+ "extends EditorPlugin\n"
+ "\n"
+ "func _enter_tree():\n"
+ "\tpass");
+ String script_path = path.plus_file(script_edit->get_text());
+ gdscript->set_path(script_path);
+ ResourceSaver::save(script_path, gdscript);
+ script = gdscript;
+ }
+ //TODO: other languages
+
+ emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? name_edit->get_text() : "");
+ } else {
+ EditorNode::get_singleton()->get_project_settings()->update_plugins();
+ }
+ _clear_fields();
+}
+
+void PluginConfigDialog::_on_cancelled() {
+ _clear_fields();
+}
+
+void PluginConfigDialog::_on_required_text_changed(const String &p_text) {
+ String ext = script_option_edit->get_item_metadata(script_option_edit->get_selected());
+ get_ok()->set_disabled(script_edit->get_text().get_basename().empty() || script_edit->get_text().get_extension() != ext || name_edit->get_text().empty());
+}
+
+void PluginConfigDialog::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ connect("confirmed", this, "_on_confirmed");
+ get_cancel()->connect("pressed", this, "_on_cancelled");
+ } break;
+ }
+}
+
+void PluginConfigDialog::config(const String &p_config_path) {
+ if (p_config_path.length()) {
+ Ref<ConfigFile> cf = memnew(ConfigFile);
+ print_line(p_config_path);
+ cf->load(p_config_path);
+
+ name_edit->set_text(cf->get_value("plugin", "name", ""));
+ subfolder_edit->set_text(p_config_path.get_base_dir().get_basename().get_file());
+ desc_edit->set_text(cf->get_value("plugin", "description", ""));
+ author_edit->set_text(cf->get_value("plugin", "author", ""));
+ version_edit->set_text(cf->get_value("plugin", "version", ""));
+ script_edit->set_text(cf->get_value("plugin", "script", ""));
+
+ _edit_mode = true;
+ active_edit->hide();
+ Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->hide();
+ subfolder_edit->hide();
+ Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->hide();
+ set_title(TTR("Edit a Plugin"));
+ } else {
+ _clear_fields();
+ _edit_mode = false;
+ active_edit->show();
+ Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->show();
+ subfolder_edit->show();
+ Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->show();
+ set_title(TTR("Create a Plugin"));
+ }
+ get_ok()->set_disabled(!_edit_mode);
+ get_ok()->set_text(_edit_mode ? TTR("Update") : TTR("Create"));
+}
+
+void PluginConfigDialog::_bind_methods() {
+ ClassDB::bind_method("_on_required_text_changed", &PluginConfigDialog::_on_required_text_changed);
+ ClassDB::bind_method("_on_confirmed", &PluginConfigDialog::_on_confirmed);
+ ClassDB::bind_method("_on_cancelled", &PluginConfigDialog::_on_cancelled);
+ ADD_SIGNAL(MethodInfo("plugin_ready", PropertyInfo(Variant::STRING, "script_path", PROPERTY_HINT_NONE, ""), PropertyInfo(Variant::STRING, "activate_name")));
+}
+
+PluginConfigDialog::PluginConfigDialog() {
+ get_ok()->set_disabled(true);
+ set_hide_on_ok(true);
+
+ GridContainer *grid = memnew(GridContainer);
+ grid->set_columns(2);
+ add_child(grid);
+
+ Label *name_lb = memnew(Label);
+ name_lb->set_text(TTR("Plugin Name:"));
+ grid->add_child(name_lb);
+
+ name_edit = memnew(LineEdit);
+ name_edit->connect("text_changed", this, "_on_required_text_changed");
+ name_edit->set_placeholder("MyPlugin");
+ grid->add_child(name_edit);
+
+ Label *subfolder_lb = memnew(Label);
+ subfolder_lb->set_text(TTR("Subfolder:"));
+ grid->add_child(subfolder_lb);
+
+ subfolder_edit = memnew(LineEdit);
+ subfolder_edit->set_placeholder("\"my_plugin\" -> res://addons/my_plugin");
+ grid->add_child(subfolder_edit);
+
+ Label *desc_lb = memnew(Label);
+ desc_lb->set_text(TTR("Description:"));
+ grid->add_child(desc_lb);
+
+ desc_edit = memnew(TextEdit);
+ desc_edit->set_custom_minimum_size(Size2(400.0f, 50.0f));
+ grid->add_child(desc_edit);
+
+ Label *author_lb = memnew(Label);
+ author_lb->set_text(TTR("Author:"));
+ grid->add_child(author_lb);
+
+ author_edit = memnew(LineEdit);
+ author_edit->set_placeholder("Godette");
+ grid->add_child(author_edit);
+
+ Label *version_lb = memnew(Label);
+ version_lb->set_text(TTR("Version:"));
+ grid->add_child(version_lb);
+
+ version_edit = memnew(LineEdit);
+ version_edit->set_placeholder("1.0");
+ grid->add_child(version_edit);
+
+ Label *script_option_lb = memnew(Label);
+ script_option_lb->set_text(TTR("Language:"));
+ grid->add_child(script_option_lb);
+
+ script_option_edit = memnew(OptionButton);
+ script_option_edit->add_item(GDScriptLanguage::get_singleton()->get_name());
+ script_option_edit->set_item_metadata(0, GDScriptLanguage::get_singleton()->get_extension());
+ script_option_edit->select(0);
+ //TODO: add other languages
+ grid->add_child(script_option_edit);
+
+ Label *script_lb = memnew(Label);
+ script_lb->set_text(TTR("Script Name:"));
+ grid->add_child(script_lb);
+
+ script_edit = memnew(LineEdit);
+ script_edit->connect("text_changed", this, "_on_required_text_changed");
+ script_edit->set_placeholder("\"plugin.gd\" -> res://addons/my_plugin/plugin.gd");
+ grid->add_child(script_edit);
+
+ Label *active_lb = memnew(Label);
+ active_lb->set_text(TTR("Activate now?"));
+ grid->add_child(active_lb);
+
+ active_edit = memnew(CheckBox);
+ active_edit->set_pressed(true);
+ grid->add_child(active_edit);
+}
+
+PluginConfigDialog::~PluginConfigDialog() {
+}
diff --git a/editor/plugin_config_dialog.h b/editor/plugin_config_dialog.h
new file mode 100644
index 0000000000..2d321a479d
--- /dev/null
+++ b/editor/plugin_config_dialog.h
@@ -0,0 +1,71 @@
+/*************************************************************************/
+/* plugin_config_dialog.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef PLUGIN_CONFIG_DIALOG_H
+#define PLUGIN_CONFIG_DIALOG_H
+
+#include "scene/gui/check_box.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/text_edit.h"
+
+class PluginConfigDialog : public ConfirmationDialog {
+
+ GDCLASS(PluginConfigDialog, ConfirmationDialog);
+
+ LineEdit *name_edit;
+ LineEdit *subfolder_edit;
+ TextEdit *desc_edit;
+ LineEdit *author_edit;
+ LineEdit *version_edit;
+ OptionButton *script_option_edit;
+ LineEdit *script_edit;
+ CheckBox *active_edit;
+
+ bool _edit_mode;
+
+ void _clear_fields();
+ void _on_confirmed();
+ void _on_cancelled();
+ void _on_required_text_changed(const String &p_text);
+
+protected:
+ virtual void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ void config(const String &p_plugin_dir_name);
+
+ PluginConfigDialog();
+ ~PluginConfigDialog();
+};
+
+#endif // PLUGIN_CONFIG_DIALOG_H
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 7d72537e32..b90cfb479d 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -2387,9 +2387,23 @@ void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) {
Ref<InputEventMouseButton> mb = ev;
- if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
+ if (mb.is_valid() && mb->is_pressed()) {
+ switch (mb->get_button_index()) {
+
+ case BUTTON_MIDDLE: {
+ // Right-click selects automatically; middle-click does not.
+ int idx = script_list->get_item_at_position(mb->get_position(), true);
+ if (idx >= 0) {
+ script_list->select(idx);
+ _script_selected(idx);
+ _menu_option(FILE_CLOSE);
+ }
+ } break;
- _make_script_list_context_menu();
+ case BUTTON_RIGHT: {
+ _make_script_list_context_menu();
+ } break;
+ }
}
}
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index c3d48d498c..9782b9d1f4 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -2081,6 +2081,15 @@ void SpatialEditorViewport::set_message(String p_message, float p_time) {
message_time = p_time;
}
+void SpatialEditorPlugin::edited_scene_changed() {
+ for (int i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
+ SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(i);
+ if (viewport->is_visible()) {
+ viewport->notification(Control::NOTIFICATION_VISIBILITY_CHANGED);
+ }
+ }
+}
+
void SpatialEditorViewport::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 0ebc11e5df..4057145c2f 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -741,6 +741,8 @@ public:
virtual void set_state(const Dictionary &p_state);
virtual void clear() { spatial_editor->clear(); }
+ virtual void edited_scene_changed();
+
SpatialEditorPlugin(EditorNode *p_node);
~SpatialEditorPlugin();
};
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 0419c3d4b1..d13e01dc1e 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -603,7 +603,6 @@ void TextureRegionEditor::_notification(int p_what) {
zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons"));
zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons"));
zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons"));
- icon_zoom->set_texture(get_icon("Zoom", "EditorIcons"));
} break;
}
}
@@ -865,7 +864,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
hb_grid->add_child(sb_step_y);
hb_grid->add_child(memnew(VSeparator));
- hb_grid->add_child(memnew(Label(TTR("Separation:"))));
+ hb_grid->add_child(memnew(Label(TTR("Sep.:"))));
sb_sep_x = memnew(SpinBox);
sb_sep_x->set_min(0);
@@ -898,10 +897,6 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
separator->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb_tools->add_child(separator);
- icon_zoom = memnew(TextureRect);
- icon_zoom->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
- hb_tools->add_child(icon_zoom);
-
zoom_out = memnew(ToolButton);
zoom_out->connect("pressed", this, "_zoom_out");
hb_tools->add_child(zoom_out);
@@ -940,16 +935,15 @@ bool TextureRegionEditorPlugin::handles(Object *p_object) const {
void TextureRegionEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
texture_region_button->show();
- if (region_editor->is_stylebox() || region_editor->is_atlas_texture() || region_editor->is_ninepatch() || (region_editor->get_sprite() && region_editor->get_sprite()->is_region())) {
+ if (region_editor->is_stylebox() || region_editor->is_atlas_texture() || region_editor->is_ninepatch() || (region_editor->get_sprite() && region_editor->get_sprite()->is_region()) || texture_region_button->is_pressed()) {
editor->make_bottom_panel_item_visible(region_editor);
- } else {
- if (texture_region_button->is_pressed())
- region_editor->show();
}
} else {
+ if (region_editor->is_visible_in_tree()) {
+ editor->hide_bottom_panel();
+ }
texture_region_button->hide();
region_editor->edit(NULL);
- region_editor->hide();
}
}
@@ -1001,10 +995,9 @@ TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node) {
editor = p_node;
region_editor = memnew(TextureRegionEditor(p_node));
- texture_region_button = p_node->add_bottom_panel_item(TTR("TextureRegion"), region_editor);
- texture_region_button->set_tooltip(TTR("Texture Region Editor"));
-
region_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
region_editor->hide();
+
+ texture_region_button = p_node->add_bottom_panel_item(TTR("TextureRegion"), region_editor);
texture_region_button->hide();
}
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index bd93be9267..670cc86bbb 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -56,7 +56,6 @@ class TextureRegionEditor : public Control {
friend class TextureRegionEditorPlugin;
MenuButton *snap_mode_button;
- TextureRect *icon_zoom;
ToolButton *zoom_in;
ToolButton *zoom_reset;
ToolButton *zoom_out;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 8d1db5de8f..490ebeca26 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -307,6 +307,11 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_workspacemode[i]->connect("pressed", this, "_on_workspace_mode_changed", p);
tool_hb->add_child(tool_workspacemode[i]);
}
+ Control *spacer = memnew(Control);
+ spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ tool_hb->add_child(spacer);
+ tool_hb->move_child(spacer, (int)WORKSPACE_CREATE_SINGLE);
+
tool_workspacemode[WORKSPACE_EDIT]->set_pressed(true);
workspace_mode = WORKSPACE_EDIT;
@@ -314,9 +319,6 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
main_vb->add_child(memnew(HSeparator));
tool_hb = memnew(HBoxContainer);
- Control *spacer = memnew(Control);
- spacer->set_custom_minimum_size(Size2(30, 0));
- tool_hb->add_child(spacer);
g = Ref<ButtonGroup>(memnew(ButtonGroup));
String label[EDITMODE_MAX] = { "Region", "Collision", "Occlusion", "Navigation", "Bitmask", "Priority", "Icon" };
@@ -335,7 +337,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
edit_mode = EDITMODE_COLLISION;
main_vb->add_child(tool_hb);
- main_vb->add_child(memnew(HSeparator));
+ separator_editmode = memnew(HSeparator);
+ main_vb->add_child(separator_editmode);
toolbar = memnew(HBoxContainer);
Ref<ButtonGroup> tg(memnew(ButtonGroup));
@@ -369,13 +372,17 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
toolbar->add_child(tools[SHAPE_NEW_POLYGON]);
tools[SHAPE_NEW_POLYGON]->set_toggle_mode(true);
tools[SHAPE_NEW_POLYGON]->set_button_group(tg);
- toolbar->add_child(memnew(VSeparator));
+
+ separator_delete = memnew(VSeparator);
+ toolbar->add_child(separator_delete);
tools[SHAPE_DELETE] = memnew(ToolButton);
p = Vector<Variant>();
p.push_back((int)SHAPE_DELETE);
tools[SHAPE_DELETE]->connect("pressed", this, "_on_tool_clicked", p);
toolbar->add_child(tools[SHAPE_DELETE]);
- toolbar->add_child(memnew(VSeparator));
+
+ separator_grid = memnew(VSeparator);
+ toolbar->add_child(separator_grid);
tools[SHAPE_KEEP_INSIDE_TILE] = memnew(ToolButton);
tools[SHAPE_KEEP_INSIDE_TILE]->set_toggle_mode(true);
tools[SHAPE_KEEP_INSIDE_TILE]->set_pressed(true);
@@ -588,10 +595,16 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) {
tools[BITMASK_PASTE]->hide();
tools[BITMASK_CLEAR]->hide();
tools[SHAPE_NEW_POLYGON]->hide();
- if (workspace_mode == WORKSPACE_EDIT)
+
+ if (workspace_mode == WORKSPACE_EDIT) {
+ separator_delete->show();
tools[SHAPE_DELETE]->show();
- else
+ } else {
+ separator_delete->hide();
tools[SHAPE_DELETE]->hide();
+ }
+
+ separator_grid->show();
tools[SHAPE_KEEP_INSIDE_TILE]->hide();
tools[TOOL_GRID_SNAP]->show();
@@ -605,7 +618,11 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) {
tools[BITMASK_PASTE]->show();
tools[BITMASK_CLEAR]->show();
tools[SHAPE_NEW_POLYGON]->hide();
+
+ separator_delete->hide();
tools[SHAPE_DELETE]->hide();
+
+ separator_grid->hide();
tools[SHAPE_KEEP_INSIDE_TILE]->hide();
tools[TOOL_GRID_SNAP]->hide();
@@ -621,7 +638,11 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) {
tools[BITMASK_PASTE]->hide();
tools[BITMASK_CLEAR]->hide();
tools[SHAPE_NEW_POLYGON]->show();
+
+ separator_delete->show();
tools[SHAPE_DELETE]->show();
+
+ separator_grid->show();
tools[SHAPE_KEEP_INSIDE_TILE]->show();
tools[TOOL_GRID_SNAP]->show();
@@ -635,9 +656,14 @@ void TileSetEditor::_on_edit_mode_changed(int p_edit_mode) {
tools[BITMASK_PASTE]->hide();
tools[BITMASK_CLEAR]->hide();
tools[SHAPE_NEW_POLYGON]->hide();
+
+ separator_delete->hide();
tools[SHAPE_DELETE]->hide();
+
+ separator_grid->show();
tools[SHAPE_KEEP_INSIDE_TILE]->hide();
tools[TOOL_GRID_SNAP]->show();
+
if (edit_mode == EDITMODE_ICON) {
tools[TOOL_SELECT]->set_tooltip(TTR("Select sub-tile to use as icon, this will be also used on invalid autotile bindings.\nClick on another Tile to edit it."));
spin_priority->hide();
@@ -661,6 +687,7 @@ void TileSetEditor::_on_workspace_mode_changed(int p_workspace_mode) {
tool_editmode[EDITMODE_REGION]->show();
tool_editmode[EDITMODE_REGION]->set_pressed(true);
_on_edit_mode_changed(EDITMODE_REGION);
+ separator_editmode->show();
}
}
@@ -2076,6 +2103,7 @@ void TileSetEditor::update_workspace_tile_mode() {
tool_editmode[EDITMODE_REGION]->show();
tool_editmode[EDITMODE_REGION]->set_pressed(true);
_on_edit_mode_changed(EDITMODE_REGION);
+ separator_editmode->show();
return;
}
@@ -2086,12 +2114,16 @@ void TileSetEditor::update_workspace_tile_mode() {
for (int i = 0; i < ZOOM_OUT; i++) {
tools[i]->hide();
}
+ separator_editmode->hide();
+ separator_delete->hide();
+ separator_grid->hide();
return;
}
for (int i = 0; i < EDITMODE_MAX; i++) {
tool_editmode[i]->show();
}
+ separator_editmode->show();
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
if (tool_editmode[EDITMODE_ICON]->is_pressed() || tool_editmode[EDITMODE_PRIORITY]->is_pressed() || tool_editmode[EDITMODE_BITMASK]->is_pressed()) {
@@ -2336,12 +2368,10 @@ bool TileSetEditorPlugin::handles(Object *p_node) const {
void TileSetEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
tileset_editor_button->show();
- if (tileset_editor_button->is_pressed()) {
- tileset_editor->show();
- }
+ editor->make_bottom_panel_item_visible(tileset_editor);
get_tree()->connect("idle_frame", tileset_editor, "_on_workspace_process");
} else {
- tileset_editor->hide();
+ editor->hide_bottom_panel();
tileset_editor_button->hide();
get_tree()->disconnect("idle_frame", tileset_editor, "_on_workspace_process");
}
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index 0c175e718c..23bf68b90f 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -40,12 +40,12 @@
#define WORKSPACE_MARGIN Vector2(10, 10)
class TilesetEditorContext;
-class TileSetEditor : public Panel {
+class TileSetEditor : public Control {
friend class TileSetEditorPlugin;
friend class TilesetEditorContext;
- GDCLASS(TileSetEditor, Panel)
+ GDCLASS(TileSetEditor, Control)
enum TextureToolButtons {
TOOL_TILESET_ADD_TEXTURE,
@@ -131,8 +131,11 @@ class TileSetEditor : public Panel {
Control *workspace;
Button *tool_workspacemode[WORKSPACE_MODE_MAX];
Button *tool_editmode[EDITMODE_MAX];
+ HSeparator *separator_editmode;
HBoxContainer *toolbar;
ToolButton *tools[TOOL_MAX];
+ VSeparator *separator_delete;
+ VSeparator *separator_grid;
SpinBox *spin_priority;
WorkspaceMode workspace_mode;
EditMode edit_mode;
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index ea697f5da2..970302e058 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -806,6 +806,10 @@ void ProjectSettingsEditor::popup_project_settings() {
plugin_settings->update_plugins();
}
+void ProjectSettingsEditor::update_plugins() {
+ plugin_settings->update_plugins();
+}
+
void ProjectSettingsEditor::_item_selected(const String &p_path) {
String selected_path = p_path;
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index b738c4ae20..1344da1de7 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -186,6 +186,7 @@ public:
static ProjectSettingsEditor *get_singleton() { return singleton; }
void popup_project_settings();
void set_plugins_page();
+ void update_plugins();
EditorAutoloadSettings *get_autoload_settings() { return autoload_settings; }
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index b370a711e3..408e67149a 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -287,7 +287,11 @@ void CustomPropertyEditor::_menu_option(int p_which) {
Object *obj = ClassDB::instance(intype);
if (!obj) {
- obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
+ if (ScriptServer::is_global_class(intype)) {
+ obj = EditorNode::get_editor_data().script_class_instance(intype);
+ } else {
+ obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
+ }
}
ERR_BREAK(!obj);
@@ -1132,7 +1136,11 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
Object *obj = ClassDB::instance(intype);
if (!obj) {
- obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
+ if (ScriptServer::is_global_class(intype)) {
+ obj = EditorNode::get_editor_data().script_class_instance(intype);
+ } else {
+ obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
+ }
}
ERR_FAIL_COND(!obj);
@@ -1334,7 +1342,11 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
Object *obj = ClassDB::instance(intype);
if (!obj) {
- obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
+ if (ScriptServer::is_global_class(intype)) {
+ obj = EditorNode::get_editor_data().script_class_instance(intype);
+ } else {
+ obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
+ }
}
ERR_BREAK(!obj);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index d17bcef92b..607d974025 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -365,10 +365,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptLanguage *l = ScriptServer::get_language(i);
if (l->get_type() == existing->get_class()) {
- if (EDITOR_GET("interface/editors/derive_script_globals_by_name").operator bool()) {
- String name = l->get_global_class_name(existing->get_path(), NULL);
- inherits = editor->get_editor_data().script_class_get_base(name);
- } else if (l->can_inherit_from_file()) {
+ String name = l->get_global_class_name(existing->get_path());
+ if (ScriptServer::is_global_class(name)) {
+ if (EDITOR_GET("interface/editors/derive_script_globals_by_name").operator bool()) {
+ inherits = editor->get_editor_data().script_class_get_base(name);
+ } else if (l->can_inherit_from_file()) {
+ inherits = "\"" + existing->get_path() + "\"";
+ }
+ } else {
inherits = "\"" + existing->get_path() + "\"";
}
}
@@ -395,6 +399,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
const RefPtr empty;
editor_data->get_undo_redo().add_do_method(E->get(), "set_script", empty);
editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing);
+
+ editor_data->get_undo_redo().add_do_method(E->get(), "set_meta", "_editor_icon", get_icon(E->get()->get_class(), "EditorIcons"));
+ editor_data->get_undo_redo().add_undo_method(E->get(), "set_meta", "_editor_icon", E->get()->get_meta("_editor_icon"));
}
}
@@ -402,7 +409,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_undo_method(this, "_update_script_button");
editor_data->get_undo_redo().commit_action();
-
} break;
case TOOL_MOVE_UP:
case TOOL_MOVE_DOWN: {
@@ -1490,9 +1496,23 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) {
Ref<Script> existing = E->get()->get_script();
editor_data->get_undo_redo().add_do_method(E->get(), "set_script", p_script.get_ref_ptr());
editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing);
+
+ String icon_path;
+ String name = p_script->get_language()->get_global_class_name(p_script->get_path(), NULL, &icon_path);
+ if (ScriptServer::is_global_class(name)) {
+ RES icon = ResourceLoader::load(icon_path);
+ editor_data->get_undo_redo().add_do_method(E->get(), "set_meta", "_editor_icon", icon);
+ String existing_name = existing.is_valid() ? existing->get_language()->get_global_class_name(existing->get_path()) : String();
+ if (existing.is_null() || !ScriptServer::is_global_class(existing_name)) {
+ editor_data->get_undo_redo().add_undo_method(E->get(), "set_meta", "_editor_icon", get_icon(E->get()->get_class(), "EditorIcons"));
+ } else {
+ editor_data->get_undo_redo().add_undo_method(E->get(), "set_meta", "_editor_icon", editor_data->script_class_get_icon_path(existing_name));
+ }
+ }
}
editor_data->get_undo_redo().commit_action();
+ print_line("test: " + String(Variant(selected.front()->get()->get_meta("_editor_icon"))));
editor->push_item(p_script.operator->());
}