summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_file_system.cpp8
-rw-r--r--editor/editor_node.cpp14
-rw-r--r--editor/editor_node.h6
-rw-r--r--editor/editor_plugin.cpp30
-rw-r--r--editor/editor_plugin.h3
-rw-r--r--editor/editor_plugin_settings.cpp2
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--editor/editor_themes.cpp16
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp2
-rw-r--r--editor/project_manager.cpp22
-rw-r--r--editor/project_manager.h1
-rw-r--r--editor/script_create_dialog.cpp2
12 files changed, 85 insertions, 24 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 94eb1a3399..37e2079b64 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1401,6 +1401,14 @@ void EditorFileSystem::update_script_classes() {
ScriptServer::save_global_classes();
EditorNode::get_editor_data().script_class_save_icon_paths();
+
+ // Rescan custom loaders and savers.
+ // Doing the following here because the `filesystem_changed` signal fires multiple times and isn't always followed by script classes update.
+ // So I thought it's better to do this when script classes really get updated
+ ResourceLoader::remove_custom_loaders();
+ ResourceLoader::add_custom_loaders();
+ ResourceSaver::remove_custom_savers();
+ ResourceSaver::add_custom_savers();
}
void EditorFileSystem::_queue_update_script_classes() {
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index d100d7f618..1063447376 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2471,7 +2471,7 @@ void EditorNode::_editor_select(int p_which) {
}
}
-void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
+void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
if (p_editor->has_main_screen()) {
@@ -2496,9 +2496,11 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
}
singleton->editor_data.add_editor_plugin(p_editor);
singleton->add_child(p_editor);
+ if (p_config_changed)
+ p_editor->enable_plugin();
}
-void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
+void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
if (p_editor->has_main_screen()) {
@@ -2521,6 +2523,8 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
}
p_editor->make_visible(false);
p_editor->clear();
+ if (p_config_changed)
+ p_editor->disable_plugin();
singleton->editor_plugins_over->get_plugins_list().erase(p_editor);
singleton->remove_child(p_editor);
singleton->editor_data.remove_editor_plugin(p_editor);
@@ -2546,7 +2550,7 @@ void EditorNode::_update_addon_config() {
project_settings->queue_save();
}
-void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled) {
+void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed) {
ERR_FAIL_COND(p_enabled && plugin_addons.has(p_addon));
ERR_FAIL_COND(!p_enabled && !plugin_addons.has(p_addon));
@@ -2554,7 +2558,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled)
if (!p_enabled) {
EditorPlugin *addon = plugin_addons[p_addon];
- remove_editor_plugin(addon);
+ remove_editor_plugin(addon, p_config_changed);
memdelete(addon); //bye
plugin_addons.erase(p_addon);
_update_addon_config();
@@ -2606,7 +2610,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled)
ep->set_script(script.get_ref_ptr());
ep->set_dir_cache(p_addon);
plugin_addons[p_addon] = ep;
- add_editor_plugin(ep);
+ add_editor_plugin(ep, p_config_changed);
_update_addon_config();
}
diff --git a/editor/editor_node.h b/editor/editor_node.h
index e5670e5e7c..f4c0375c2e 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -637,8 +637,8 @@ public:
ProjectSettingsEditor *get_project_settings() { return project_settings; }
- static void add_editor_plugin(EditorPlugin *p_editor);
- static void remove_editor_plugin(EditorPlugin *p_editor);
+ static void add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
+ static void remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
@@ -651,7 +651,7 @@ public:
void add_control_to_dock(DockSlot p_slot, Control *p_control);
void remove_control_from_dock(Control *p_control);
- void set_addon_plugin_enabled(const String &p_addon, bool p_enabled);
+ void set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed = false);
bool is_addon_plugin_enabled(const String &p_addon) const;
void edit_node(Node *p_node);
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index cd024ff870..403db4b8ba 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -698,6 +698,34 @@ void EditorPlugin::remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_
ResourceImporterScene::get_singleton()->remove_importer(p_importer);
}
+int find(const PoolStringArray &a, const String &v) {
+ PoolStringArray::Read r = a.read();
+ for (int j = 0; j < a.size(); ++j) {
+ if (r[j] == v) {
+ return j;
+ }
+ }
+ return -1;
+}
+
+void EditorPlugin::enable_plugin() {
+ // Called when the plugin gets enabled in project settings, after it's added to the tree.
+ // You can implement it to register autoloads.
+
+ if (get_script_instance() && get_script_instance()->has_method("enable_plugin")) {
+ get_script_instance()->call("enable_plugin");
+ }
+}
+
+void EditorPlugin::disable_plugin() {
+ // Last function called when the plugin gets disabled in project settings.
+ // Implement it to cleanup things from the project, such as unregister autoloads.
+
+ if (get_script_instance() && get_script_instance()->has_method("disable_plugin")) {
+ get_script_instance()->call("disable_plugin");
+ }
+}
+
void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) {
@@ -801,6 +829,8 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "build"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("enable_plugin"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("disable_plugin"));
ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index e03aeb5d30..5f060a4e96 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -232,6 +232,9 @@ public:
String get_dir_cache() { return _dir_cache; }
Ref<ConfigFile> get_config();
+ void enable_plugin();
+ void disable_plugin();
+
EditorPlugin();
virtual ~EditorPlugin();
};
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 30027c0c34..a4d543c567 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -152,7 +152,7 @@ void EditorPluginSettings::_plugin_activity_changed() {
bool active = ti->get_range(3);
String name = ti->get_metadata(0);
- EditorNode::get_singleton()->set_addon_plugin_enabled(name, active);
+ EditorNode::get_singleton()->set_addon_plugin_enabled(name, active, true);
bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(name);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 039ba22a77..fbcab3cbb6 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -581,6 +581,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
/* Extra config */
+ _initial_set("project_manager/sorting_order", 0);
+ hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Last Modified");
+
if (p_extra_config.is_valid()) {
if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 36053d7534..eacf2ee1b4 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -351,18 +351,18 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("mono_color", "Editor", mono_color);
- Color success_color = accent_color.linear_interpolate(Color(0.2, 1, 0.2), 0.6) * 1.2;
- Color warning_color = accent_color.linear_interpolate(Color(1, 1, 0), 0.7) * 1.0;
- Color error_color = accent_color.linear_interpolate(Color(1, 0, 0), 0.8) * 1.7;
+ Color success_color = Color(0.45, 0.95, 0.5);
+ Color warning_color = Color(1, 0.87, 0.4);
+ Color error_color = Color(1, 0.47, 0.42);
Color property_color = font_color.linear_interpolate(Color(0.5, 0.5, 0.5), 0.5);
if (!dark_theme) {
- // yellow on white themes is a P.I.T.A.
- warning_color = accent_color.linear_interpolate(Color(0.9, 0.7, 0), 0.9);
- warning_color = warning_color.linear_interpolate(mono_color, 0.2);
- success_color = success_color.linear_interpolate(mono_color, 0.2);
- error_color = error_color.linear_interpolate(mono_color, 0.2);
+ // Darken some colors to be readable on a light background
+ success_color = success_color.linear_interpolate(mono_color, 0.35);
+ warning_color = warning_color.linear_interpolate(mono_color, 0.35);
+ error_color = error_color.linear_interpolate(mono_color, 0.25);
}
+
theme->set_color("success_color", "Editor", success_color);
theme->set_color("warning_color", "Editor", warning_color);
theme->set_color("error_color", "Editor", error_color);
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index 990c77430f..17117e635f 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -1111,7 +1111,7 @@ void AnimationNodeStateMachineEditor::_erase_selected() {
updating = true;
undo_redo->create_action("Node Removed");
undo_redo->add_do_method(state_machine.ptr(), "remove_node", selected_node);
- undo_redo->add_undo_method(state_machine.ptr(), "add_node", selected_node, state_machine->get_node(selected_node));
+ undo_redo->add_undo_method(state_machine.ptr(), "add_node", selected_node, state_machine->get_node(selected_node), state_machine->get_node_position(selected_node));
for (int i = 0; i < state_machine->get_transition_count(); i++) {
String from = state_machine->get_transition_from(i);
String to = state_machine->get_transition_to(i);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 0e2e957333..ac728e8d7c 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1165,10 +1165,12 @@ void ProjectManager::_load_recent_projects() {
bool set_ordered_latest_modification;
ProjectListFilter::FilterOption filter_order_option = project_order_filter->get_filter_option();
- if (filter_order_option == ProjectListFilter::FILTER_NAME)
+ if (filter_order_option == ProjectListFilter::FILTER_NAME) {
set_ordered_latest_modification = false;
- else
+ } else {
set_ordered_latest_modification = true;
+ }
+ EditorSettings::get_singleton()->set("project_manager/sorting_order", (int)filter_order_option);
List<ProjectItem> projects;
List<ProjectItem> favorite_projects;
@@ -1838,16 +1840,19 @@ ProjectManager::ProjectManager() {
Label *sort_label = memnew(Label);
sort_label->set_text(TTR("Sort:"));
sort_filters->add_child(sort_label);
- Vector<String> vec1;
- vec1.push_back("Name");
- vec1.push_back("Last Modified");
+ Vector<String> sort_filter_titles;
+ sort_filter_titles.push_back("Name");
+ sort_filter_titles.push_back("Last Modified");
project_order_filter = memnew(ProjectListFilter);
- project_order_filter->_setup_filters(vec1);
+ project_order_filter->_setup_filters(sort_filter_titles);
project_order_filter->set_filter_size(150);
sort_filters->add_child(project_order_filter);
project_order_filter->connect("filter_changed", this, "_load_recent_projects");
project_order_filter->set_custom_minimum_size(Size2(180, 10) * EDSCALE);
+ int projects_sorting_order = (int)EditorSettings::get_singleton()->get("project_manager/sorting_order");
+ project_order_filter->set_filter_option((ProjectListFilter::FilterOption)projects_sorting_order);
+
sort_filters->add_spacer(true);
Label *search_label = memnew(Label);
search_label->set_text(TTR("Search:"));
@@ -2074,6 +2079,11 @@ ProjectListFilter::FilterOption ProjectListFilter::get_filter_option() {
return _current_filter;
}
+void ProjectListFilter::set_filter_option(FilterOption option) {
+ filter_option->select((int)option);
+ _filter_option_selected(0);
+}
+
void ProjectListFilter::_filter_option_selected(int p_idx) {
FilterOption selected = (FilterOption)(filter_option->get_selected());
if (_current_filter != selected) {
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 88fc081272..e0a0932cf8 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -152,6 +152,7 @@ public:
void set_filter_size(int h_size);
String get_search_term();
FilterOption get_filter_option();
+ void set_filter_option(FilterOption);
ProjectListFilter();
};
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index df704706af..e0c95e3bbc 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -308,8 +308,10 @@ void ScriptCreateDialog::_built_in_pressed() {
if (internal->is_pressed()) {
is_built_in = true;
+ is_new_script_created = true;
} else {
is_built_in = false;
+ _path_changed(file_path->get_text());
}
_update_dialog();
}