summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp179
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/editor_properties.cpp21
-rw-r--r--editor/editor_properties.h3
-rw-r--r--editor/editor_properties_array_dict.cpp82
-rw-r--r--editor/editor_properties_array_dict.h2
-rw-r--r--editor/export_template_manager.cpp8
-rw-r--r--editor/export_template_manager.h2
-rw-r--r--editor/filesystem_dock.cpp37
-rw-r--r--editor/filesystem_dock.h2
-rw-r--r--editor/groups_editor.cpp1
-rw-r--r--editor/icons/README.md4
-rw-r--r--editor/import/resource_importer_obj.cpp11
-rw-r--r--editor/import/resource_importer_scene.cpp50
-rw-r--r--editor/import/resource_importer_texture.cpp4
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp3
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp9
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp22
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp1
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp3
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/plugins/script_text_editor.cpp31
-rw-r--r--editor/plugins/script_text_editor.h2
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp178
-rw-r--r--editor/plugins/tile_map_editor_plugin.h7
-rw-r--r--editor/project_settings_editor.cpp160
-rw-r--r--editor/project_settings_editor.h2
-rw-r--r--editor/property_editor.cpp1
-rw-r--r--editor/scene_tree_editor.cpp25
-rw-r--r--editor/scene_tree_editor.h3
-rw-r--r--editor/settings_config_dialog.cpp2
31 files changed, 510 insertions, 348 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 52f356813a..6084332dfb 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -587,7 +587,6 @@ void EditorNode::edit_node(Node *p_node) {
void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) {
editor_data.apply_changes_in_editors();
-
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
@@ -596,9 +595,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
if (err != OK) {
- current_option = -1;
- accept->set_text(TTR("Error saving resource!"));
- accept->popup_centered_minsize();
+ show_accept(TTR("Error saving resource!"), TTR("I see..."));
return;
}
@@ -684,26 +681,21 @@ void EditorNode::_dialog_display_save_error(String p_file, Error p_error) {
if (p_error) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
-
switch (p_error) {
case ERR_FILE_CANT_WRITE: {
- accept->set_text(TTR("Can't open file for writing:") + " " + p_file.get_extension());
+ show_accept(TTR("Can't open file for writing:") + " " + p_file.get_extension(), TTR("I see..."));
} break;
case ERR_FILE_UNRECOGNIZED: {
- accept->set_text(TTR("Requested file format unknown:") + " " + p_file.get_extension());
+ show_accept(TTR("Requested file format unknown:") + " " + p_file.get_extension(), TTR("I see..."));
} break;
default: {
- accept->set_text(TTR("Error while saving."));
+ show_accept(TTR("Error while saving."), TTR("I see..."));
} break;
}
-
- accept->popup_centered_minsize();
}
}
@@ -711,34 +703,29 @@ void EditorNode::_dialog_display_load_error(String p_file, Error p_error) {
if (p_error) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
-
switch (p_error) {
case ERR_CANT_OPEN: {
- accept->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_file.get_file()));
+ show_accept(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_file.get_file()), TTR("I see..."));
} break;
case ERR_PARSE_ERROR: {
- accept->set_text(vformat(TTR("Error while parsing '%s'."), p_file.get_file()));
+ show_accept(vformat(TTR("Error while parsing '%s'."), p_file.get_file()), TTR("I see..."));
} break;
case ERR_FILE_CORRUPT: {
- accept->set_text(vformat(TTR("Unexpected end of file '%s'."), p_file.get_file()));
+ show_accept(vformat(TTR("Unexpected end of file '%s'."), p_file.get_file()), TTR("I see..."));
} break;
case ERR_FILE_NOT_FOUND: {
- accept->set_text(vformat(TTR("Missing '%s' or its dependencies."), p_file.get_file()));
+ show_accept(vformat(TTR("Missing '%s' or its dependencies."), p_file.get_file()), TTR("I see..."));
} break;
default: {
- accept->set_text(vformat(TTR("Error while loading '%s'."), p_file.get_file()));
+ show_accept(vformat(TTR("Error while loading '%s'."), p_file.get_file()), TTR("I see..."));
} break;
}
-
- accept->popup_centered_minsize();
}
}
@@ -999,10 +986,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
if (!scene) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("This operation can't be done without a tree root."));
- accept->popup_centered_minsize();
+ show_accept(TTR("This operation can't be done without a tree root."), TTR("I see..."));
return;
}
@@ -1030,10 +1014,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
if (err != OK) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."));
- accept->popup_centered_minsize();
+ show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("I see..."));
return;
}
@@ -1041,10 +1022,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
// (hacky but needed for the tree to update properly)
Node *dummy_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!dummy_scene) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."));
- accept->popup_centered_minsize();
+ show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("I see..."));
return;
}
memdelete(dummy_scene);
@@ -1055,8 +1033,23 @@ void EditorNode::_save_scene(String p_file, int idx) {
flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
err = ResourceSaver::save(p_file, sdata, flg);
- Map<RES, bool> processed;
- _save_edited_subresources(scene, processed, flg);
+ //Map<RES, bool> processed;
+ //this method is slow and not always works, deprecating
+ //_save_edited_subresources(scene, processed, flg);
+ { //instead, just find globally unsaved subresources and save them
+
+ List<Ref<Resource> > cached;
+ ResourceCache::get_cached_resources(&cached);
+ for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) {
+
+ Ref<Resource> res = E->get();
+ if (res->is_edited() && res->get_path().is_resource_file()) {
+ ResourceSaver::save(res->get_path(), res, flg);
+ res->set_edited(false);
+ }
+ }
+ }
+
editor_data.save_editor_external_data();
if (err == OK) {
scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file));
@@ -1074,8 +1067,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
void EditorNode::_save_all_scenes() {
- int i = _next_unsaved_scene(true, 0);
- while (i != -1) {
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *scene = editor_data.get_edited_scene_root(i);
if (scene && scene->get_filename() != "") {
if (i != editor_data.get_edited_scene())
@@ -1083,7 +1075,6 @@ void EditorNode::_save_all_scenes() {
else
_save_scene_with_preview(scene->get_filename());
} // else: ignore new scenes
- i = _next_unsaved_scene(true, ++i);
}
_save_default_environment();
@@ -1167,10 +1158,7 @@ void EditorNode::_dialog_action(String p_file) {
ml = ResourceLoader::load(p_file, "MeshLibrary");
if (ml.is_null()) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Can't load MeshLibrary for merging!"));
- accept->popup_centered_minsize();
+ show_accept(TTR("Can't load MeshLibrary for merging!"), TTR("I see..."));
return;
}
}
@@ -1183,11 +1171,7 @@ void EditorNode::_dialog_action(String p_file) {
Error err = ResourceSaver::save(p_file, ml);
if (err) {
-
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Error saving MeshLibrary!"));
- accept->popup_centered_minsize();
+ show_accept(TTR("Error saving MeshLibrary!"), TTR("I see..."));
return;
}
@@ -1199,10 +1183,7 @@ void EditorNode::_dialog_action(String p_file) {
tileset = ResourceLoader::load(p_file, "TileSet");
if (tileset.is_null()) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Can't load TileSet for merging!"));
- accept->popup_centered_minsize();
+ show_accept(TTR("Can't load TileSet for merging!"), TTR("I see..."));
return;
}
@@ -1215,10 +1196,7 @@ void EditorNode::_dialog_action(String p_file) {
Error err = ResourceSaver::save(p_file, tileset);
if (err) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Error saving TileSet!"));
- accept->popup_centered_minsize();
+ show_accept("Error saving TileSet!", "I see...");
return;
}
} break;
@@ -1359,8 +1337,7 @@ void EditorNode::_save_default_environment() {
if (fallback.is_valid() && fallback->get_path().is_resource_file()) {
Map<RES, bool> processed;
_find_and_save_edited_subresources(fallback.ptr(), processed, 0);
- if (fallback->get_last_modified_time() != fallback->get_import_last_modified_time())
- save_resource_in_path(fallback, fallback->get_path());
+ save_resource_in_path(fallback, fallback->get_path());
}
}
@@ -1573,10 +1550,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("There is no defined scene to run."));
- accept->popup_centered_minsize();
+ show_accept(TTR("There is no defined scene to run."), TTR("I see..."));
return;
}
@@ -1630,10 +1604,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (scene->get_filename() == "") {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Current scene was never saved, please save it prior to running."));
- accept->popup_centered_minsize();
+ show_accept(TTR("Current scene was never saved, please save it prior to running."), TTR("I see..."));
return;
}
@@ -1664,10 +1635,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
if (error != OK) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("Could not start subprocess!"));
- accept->popup_centered_minsize();
+ show_accept(TTR("Could not start subprocess!"), TTR("I see..."));
return;
}
@@ -1785,10 +1753,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (!scene) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("This operation can't be done without a tree root."));
- accept->popup_centered_minsize();
+ show_accept(TTR("This operation can't be done without a tree root."), TTR("I see..."));
break;
}
@@ -1851,10 +1816,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (!editor_data.get_edited_scene_root()) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("This operation can't be done without a scene."));
- accept->popup_centered_minsize();
+ show_accept(TTR("This operation can't be done without a scene."), TTR("I see..."));
break;
}
@@ -1874,10 +1836,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
//Make sure that the scene has a root before trying to convert to tileset
if (!editor_data.get_edited_scene_root()) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("This operation can't be done without a root node."));
- accept->popup_centered_minsize();
+ show_accept(TTR("This operation can't be done without a root node."), TTR("I see..."));
break;
}
@@ -1902,10 +1861,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (!editor_data.get_edited_scene_root()) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("This operation can't be done without a selected node."));
- accept->popup_centered_minsize();
+ show_accept(TTR("This operation can't be done without a selected node."), TTR("I see..."));
break;
}
@@ -1935,25 +1891,29 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case EDIT_UNDO: {
if (Input::get_singleton()->get_mouse_button_mask() & 0x7) {
- break; // can't undo while mouse buttons are pressed
- }
-
- String action = editor_data.get_undo_redo().get_current_action_name();
- if (action != "")
- log->add_message("UNDO: " + action);
+ log->add_message("Can't UNDO while mouse buttons are pressed.");
+ } else {
+ String action = editor_data.get_undo_redo().get_current_action_name();
- editor_data.get_undo_redo().undo();
+ if (!editor_data.get_undo_redo().undo()) {
+ log->add_message("There is nothing to UNDO.");
+ } else if (action != "") {
+ log->add_message("UNDO: " + action);
+ }
+ }
} break;
case EDIT_REDO: {
- if (Input::get_singleton()->get_mouse_button_mask() & 0x7)
- break; // can't redo while mouse buttons are pressed
-
- editor_data.get_undo_redo().redo();
- String action = editor_data.get_undo_redo().get_current_action_name();
- if (action != "")
- log->add_message("REDO: " + action);
-
+ if (Input::get_singleton()->get_mouse_button_mask() & 0x7) {
+ log->add_message("Can't REDO while mouse buttons are pressed.");
+ } else {
+ if (!editor_data.get_undo_redo().redo()) {
+ log->add_message("There is nothing to REDO.");
+ } else {
+ String action = editor_data.get_undo_redo().get_current_action_name();
+ log->add_message("REDO: " + action);
+ }
+ }
} break;
case EDIT_REVERT: {
@@ -2174,10 +2134,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
OS::get_singleton()->set_low_processor_usage_mode(false);
EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_always", true);
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see..."));
- accept->set_text(TTR("This option is deprecated. Situations where refresh must be forced are now considered a bug. Please report."));
- accept->popup_centered_minsize();
+ show_accept(TTR("This option is deprecated. Situations where refresh must be forced are now considered a bug. Please report."), TTR("I see..."));
} break;
case SETTINGS_UPDATE_CHANGES: {
@@ -2776,10 +2733,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
if (!lpath.begins_with("res://")) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."));
- accept->popup_centered_minsize();
+ show_accept(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."), TTR("Ugh"));
opening_prev = false;
return ERR_FILE_NOT_FOUND;
}
@@ -3193,6 +3147,13 @@ Error EditorNode::export_preset(const String &p_preset, const String &p_path, bo
return OK;
}
+void EditorNode::show_accept(const String &p_text, const String &p_title) {
+ current_option = -1;
+ accept->get_ok()->set_text(p_title);
+ accept->set_text(p_text);
+ accept->popup_centered_minsize();
+}
+
void EditorNode::show_warning(const String &p_text, const String &p_title) {
warning->set_text(p_text);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index dedd947633..4241520b30 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -685,6 +685,7 @@ public:
Ref<Theme> get_editor_theme() const { return theme; }
+ void show_accept(const String &p_text, const String &p_title);
void show_warning(const String &p_text, const String &p_title = "Warning!");
Error export_preset(const String &p_preset, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after = false);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 5abcae80e0..9902d8d3e7 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -1530,6 +1530,8 @@ void EditorPropertyNodePath::_node_selected(const NodePath &p_path) {
void EditorPropertyNodePath::_node_assign() {
if (!scene_tree) {
scene_tree = memnew(SceneTreeDialog);
+ scene_tree->get_scene_tree()->set_show_enabled_subscene(true);
+ scene_tree->get_scene_tree()->set_valid_types(valid_types);
add_child(scene_tree);
scene_tree->connect("selected", this, "_node_selected");
}
@@ -1584,9 +1586,10 @@ void EditorPropertyNodePath::update_property() {
assign->set_icon(icon);
}
-void EditorPropertyNodePath::setup(const NodePath &p_base_hint) {
+void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types) {
base_hint = p_base_hint;
+ valid_types = p_valid_types;
}
void EditorPropertyNodePath::_notification(int p_what) {
@@ -1779,6 +1782,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
if (!scene_tree) {
scene_tree = memnew(SceneTreeDialog);
+ scene_tree->get_scene_tree()->set_show_enabled_subscene(true);
add_child(scene_tree);
scene_tree->connect("selected", this, "_viewport_selected");
scene_tree->set_title(TTR("Pick a Viewport"));
@@ -2665,7 +2669,12 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
EditorPropertyNodePath *editor = memnew(EditorPropertyNodePath);
if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && p_hint_text != String()) {
- editor->setup(p_hint_text);
+ editor->setup(p_hint_text, Vector<StringName>());
+ }
+ if (p_hint == PROPERTY_HINT_NODE_PATH_VALID_TYPES && p_hint_text != String()) {
+ Vector<String> types = p_hint_text.split(",", false);
+ Vector<StringName> sn = Variant(types); //convert via variant
+ editor->setup(NodePath(), sn);
}
add_property_editor(p_path, editor);
@@ -2684,34 +2693,42 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
} break;
case Variant::ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::ARRAY);
add_property_editor(p_path, editor);
} break;
case Variant::POOL_BYTE_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_BYTE_ARRAY);
add_property_editor(p_path, editor);
} break; // 20
case Variant::POOL_INT_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_INT_ARRAY);
add_property_editor(p_path, editor);
} break;
case Variant::POOL_REAL_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_REAL_ARRAY);
add_property_editor(p_path, editor);
} break;
case Variant::POOL_STRING_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_STRING_ARRAY);
add_property_editor(p_path, editor);
} break;
case Variant::POOL_VECTOR2_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_VECTOR2_ARRAY);
add_property_editor(p_path, editor);
} break;
case Variant::POOL_VECTOR3_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_VECTOR3_ARRAY);
add_property_editor(p_path, editor);
} break; // 25
case Variant::POOL_COLOR_ARRAY: {
EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_COLOR_ARRAY);
add_property_editor(p_path, editor);
} break;
default: {}
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 734ca2de82..c67eccb60e 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -453,6 +453,7 @@ class EditorPropertyNodePath : public EditorProperty {
SceneTreeDialog *scene_tree;
NodePath base_hint;
+ Vector<StringName> valid_types;
void _node_selected(const NodePath &p_path);
void _node_assign();
void _node_clear();
@@ -463,7 +464,7 @@ protected:
public:
virtual void update_property();
- void setup(const NodePath &p_base_hint);
+ void setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types);
EditorPropertyNodePath();
};
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 90f8d0e157..2bd28170e7 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -172,28 +172,9 @@ void EditorPropertyArray::update_property() {
Variant array = get_edited_object()->get(get_edited_property());
- if ((!array.is_array()) != edit->is_disabled()) {
-
- if (array.is_array()) {
- edit->set_disabled(false);
- edit->set_pressed(false);
-
- } else {
- edit->set_disabled(true);
- if (vbox) {
- memdelete(vbox);
- }
- }
- }
-
- if (!array.is_array()) {
- return;
- }
-
- String arrtype;
- switch (array.get_type()) {
+ String arrtype = "";
+ switch (array_type) {
case Variant::ARRAY: {
-
arrtype = "Array";
} break;
@@ -229,6 +210,15 @@ void EditorPropertyArray::update_property() {
default: {}
}
+ if (!array.is_array()) {
+ edit->set_text(arrtype + "[" + Variant::get_type_name(array.get_type()) + "]");
+ edit->set_pressed(false);
+ if (vbox) {
+ memdelete(vbox);
+ }
+ return;
+ }
+
edit->set_text(arrtype + "[" + itos(array.call("size")) + "]");
#ifdef TOOLS_ENABLED
@@ -419,40 +409,55 @@ void EditorPropertyArray::update_property() {
prop = memnew(EditorPropertyDictionary);
} break;
- case Variant::ARRAY: {
- prop = memnew(EditorPropertyArray);
+ // arrays
+ case Variant::ARRAY: {
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::ARRAY);
+ prop = editor;
} break;
-
- // arrays
case Variant::POOL_BYTE_ARRAY: {
- prop = memnew(EditorPropertyArray);
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_BYTE_ARRAY);
+ prop = editor;
} break;
case Variant::POOL_INT_ARRAY: {
- prop = memnew(EditorPropertyArray);
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_INT_ARRAY);
+ prop = editor;
} break;
case Variant::POOL_REAL_ARRAY: {
- prop = memnew(EditorPropertyArray);
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_REAL_ARRAY);
+ prop = editor;
} break;
case Variant::POOL_STRING_ARRAY: {
- prop = memnew(EditorPropertyArray);
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_STRING_ARRAY);
+ prop = editor;
} break;
case Variant::POOL_VECTOR2_ARRAY: {
- prop = memnew(EditorPropertyArray);
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_VECTOR2_ARRAY);
+ prop = editor;
} break;
case Variant::POOL_VECTOR3_ARRAY: {
- prop = memnew(EditorPropertyArray);
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_VECTOR3_ARRAY);
+ prop = editor;
} break;
case Variant::POOL_COLOR_ARRAY: {
- prop = memnew(EditorPropertyArray);
+ EditorPropertyArray *editor = memnew(EditorPropertyArray);
+ editor->setup(Variant::POOL_COLOR_ARRAY);
+ prop = editor;
} break;
default: {}
}
@@ -496,6 +501,14 @@ void EditorPropertyArray::_notification(int p_what) {
}
void EditorPropertyArray::_edit_pressed() {
+ Variant array = get_edited_object()->get(get_edited_property());
+ if (!array.is_array()) {
+ Variant::CallError ce;
+ array = Variant::construct(array_type, NULL, 0, ce);
+
+ get_edited_object()->set(get_edited_property(), array);
+ }
+
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
update_property();
}
@@ -522,6 +535,11 @@ void EditorPropertyArray::_length_changed(double p_page) {
update_property();
}
+void EditorPropertyArray::setup(Variant::Type p_array_type) {
+
+ array_type = p_array_type;
+}
+
void EditorPropertyArray::_bind_methods() {
ClassDB::bind_method("_edit_pressed", &EditorPropertyArray::_edit_pressed);
ClassDB::bind_method("_page_changed", &EditorPropertyArray::_page_changed);
diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h
index 7f6203ee88..75c67d280d 100644
--- a/editor/editor_properties_array_dict.h
+++ b/editor/editor_properties_array_dict.h
@@ -62,6 +62,7 @@ class EditorPropertyArray : public EditorProperty {
EditorSpinSlider *length;
EditorSpinSlider *page;
HBoxContainer *page_hb;
+ Variant::Type array_type;
void _page_changed(double p_page);
void _length_changed(double p_page);
@@ -75,6 +76,7 @@ protected:
void _notification(int p_what);
public:
+ void setup(Variant::Type p_array_type);
virtual void update_property();
EditorPropertyArray();
};
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index a39c8b2209..541c848ca3 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -436,6 +436,10 @@ void ExportTemplateManager::_begin_template_download(const String &p_url) {
template_list_state->set_text(TTR("Connecting to Mirror..."));
}
+void ExportTemplateManager::_window_template_downloader_closed() {
+ download_templates->cancel_request();
+}
+
void ExportTemplateManager::_notification(int p_what) {
if (p_what == NOTIFICATION_PROCESS) {
@@ -496,7 +500,6 @@ void ExportTemplateManager::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (!is_visible_in_tree()) {
print_line("closed");
- download_templates->cancel_request();
set_process(false);
}
}
@@ -511,6 +514,7 @@ void ExportTemplateManager::_bind_methods() {
ClassDB::bind_method("_http_download_mirror_completed", &ExportTemplateManager::_http_download_mirror_completed);
ClassDB::bind_method("_http_download_templates_completed", &ExportTemplateManager::_http_download_templates_completed);
ClassDB::bind_method("_begin_template_download", &ExportTemplateManager::_begin_template_download);
+ ClassDB::bind_method("_window_template_downloader_closed", &ExportTemplateManager::_window_template_downloader_closed);
}
ExportTemplateManager::ExportTemplateManager() {
@@ -560,7 +564,9 @@ ExportTemplateManager::ExportTemplateManager() {
template_downloader = memnew(AcceptDialog);
template_downloader->set_title(TTR("Download Templates"));
template_downloader->get_ok()->set_text(TTR("Close"));
+ template_downloader->set_exclusive(true);
add_child(template_downloader);
+ template_downloader->connect("popup_hide", this, "_window_template_downloader_closed");
VBoxContainer *vbc = memnew(VBoxContainer);
template_downloader->add_child(vbc);
diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h
index 62336162fd..54a645c69f 100644
--- a/editor/export_template_manager.h
+++ b/editor/export_template_manager.h
@@ -77,6 +77,8 @@ class ExportTemplateManager : public ConfirmationDialog {
void _begin_template_download(const String &p_url);
+ void _window_template_downloader_closed();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 297373d299..9a0432ad58 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -200,6 +200,7 @@ void FileSystemDock::_notification(int p_what) {
button_hist_next->set_icon(get_icon("Forward", ei));
button_hist_prev->set_icon(get_icon("Back", ei));
+ button_show->set_icon(get_icon("GuiVisibilityVisible", "EditorIcons"));
file_options->connect("id_pressed", this, "_file_option");
folder_options->connect("id_pressed", this, "_folder_option");
@@ -317,6 +318,15 @@ void FileSystemDock::_favorites_pressed() {
_update_tree(true);
}
+void FileSystemDock::_show_current_scene_file() {
+
+ int index = EditorNode::get_editor_data().get_edited_scene();
+ String path = EditorNode::get_editor_data().get_scene_path(index);
+ if (path != String()) {
+ navigate_to_path(path);
+ }
+}
+
String FileSystemDock::get_selected_path() const {
TreeItem *sel = tree->get_selected();
@@ -1048,18 +1058,24 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path) {
Map<String, String> file_renames;
Map<String, String> folder_renames;
+ bool is_moved = false;
for (int i = 0; i < to_move.size(); i++) {
String old_path = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path;
String new_path = p_to_path.plus_file(old_path.get_file());
- _try_move_item(to_move[i], new_path, file_renames, folder_renames);
+ if (old_path != new_path) {
+ _try_move_item(to_move[i], new_path, file_renames, folder_renames);
+ is_moved = true;
+ }
}
- _update_dependencies_after_move(file_renames);
- _update_resource_paths_after_move(file_renames);
- _update_favorite_dirs_list_after_move(folder_renames);
+ if (is_moved) {
+ _update_dependencies_after_move(file_renames);
+ _update_resource_paths_after_move(file_renames);
+ _update_favorite_dirs_list_after_move(folder_renames);
- print_line("call rescan!");
- _rescan();
+ print_line("call rescan!");
+ _rescan();
+ }
}
void FileSystemDock::_file_option(int p_option) {
@@ -1779,6 +1795,7 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree);
ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan);
ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed);
+ ClassDB::bind_method(D_METHOD("_show_current_scene_file"), &FileSystemDock::_show_current_scene_file);
//ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
ClassDB::bind_method(D_METHOD("_go_to_file_list"), &FileSystemDock::_go_to_file_list);
ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"), &FileSystemDock::_dir_rmb_pressed);
@@ -1828,6 +1845,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
ED_SHORTCUT("filesystem_dock/rename", TTR("Rename"));
HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
+ toolbar_hbc->add_constant_override("separation", 0);
add_child(toolbar_hbc);
button_hist_prev = memnew(ToolButton);
@@ -1864,6 +1882,13 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
button_favorite->set_focus_mode(FOCUS_NONE);
toolbar_hbc->add_child(button_favorite);
+ button_show = memnew(Button);
+ button_show->set_flat(true);
+ button_show->connect("pressed", this, "_show_current_scene_file");
+ toolbar_hbc->add_child(button_show);
+ button_show->set_focus_mode(FOCUS_NONE);
+ button_show->set_tooltip(TTR("Show current scene file."));
+
//Control *spacer = memnew( Control);
/*
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index e59d4c96e1..53f77b64f9 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -106,6 +106,7 @@ private:
Button *button_display_mode;
Button *button_hist_next;
Button *button_hist_prev;
+ Button *button_show;
LineEdit *current_path;
LineEdit *search_box;
TextureRect *search_icon;
@@ -204,6 +205,7 @@ private:
void _rescan();
void _favorites_pressed();
+ void _show_current_scene_file();
void _search_changed(const String &p_text);
void _dir_rmb_pressed(const Vector2 &p_pos);
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index e42f9780a6..2bfd2eb5c3 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -444,6 +444,7 @@ GroupDialog::GroupDialog() {
set_title("Group Editor");
get_cancel()->hide();
set_as_toplevel(true);
+ set_resizable(true);
error = memnew(ConfirmationDialog);
add_child(error);
diff --git a/editor/icons/README.md b/editor/icons/README.md
index f3aaa23666..3a2aba5b07 100644
--- a/editor/icons/README.md
+++ b/editor/icons/README.md
@@ -2,11 +2,11 @@ The icons here are optimized SVGs, because the editor renders the svgs at runtim
to be small in size, so they can be efficiently parsed.
The original icons can be found at:
-https://github.com/djrm/godot-design/tree/master/assets/icons
+https://github.com/godotengine/godot-design/tree/master/engine/icons
There you can find the optimizer script.
If you add a new icon, please make a pull request to this repo:
-https://github.com/djrm/godot-design/
+https://github.com/godotengine/godot-design/
and store the the optimized SVG version here.
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 21803a2184..b8dd4a87b7 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -188,7 +188,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
return OK;
}
-static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, Vector3 p_scale_mesh, List<String> *r_missing_deps) {
+static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, List<String> *r_missing_deps) {
FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
@@ -200,6 +200,8 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
bool flip_faces = false;
+ int mesh_flags = p_optimize ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
+
//bool flip_faces = p_options["force/flip_faces"];
//bool force_smooth = p_options["force/smooth_shading"];
//bool weld_vertices = p_options["force/weld_vertices"];
@@ -331,7 +333,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
surf_tool->set_material(material_map[current_material_library][current_material]);
}
- mesh = surf_tool->commit(mesh);
+ mesh = surf_tool->commit(mesh, mesh_flags);
if (current_material != String()) {
mesh->surface_set_name(mesh->get_surface_count() - 1, current_material.get_basename());
@@ -402,7 +404,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
List<Ref<Mesh> > meshes;
- Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, Vector3(1, 1, 1), r_missing_deps);
+ Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & IMPORT_USE_COMPRESSION, Vector3(1, 1, 1), r_missing_deps);
if (err != OK) {
if (r_err) {
@@ -470,6 +472,7 @@ void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_tangents"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "scale_mesh"), Vector3(1, 1, 1)));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true));
}
bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
@@ -480,7 +483,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s
List<Ref<Mesh> > meshes;
- Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["scale_mesh"], NULL);
+ Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], NULL);
ERR_FAIL_COND_V(err != OK, err);
ERR_FAIL_COND_V(meshes.size() != 1, ERR_BUG);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index fdbf66f656..91644492c3 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -224,24 +224,42 @@ String ResourceImporterScene::get_preset_name(int p_idx) const {
static bool _teststr(const String &p_what, const String &p_str) {
- if (p_what.findn("$" + p_str) != -1) //blender and other stuff
+ String what = p_what;
+
+ //remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this
+ while (what.length() && ((what[what.length() - 1] >= '0' && what[what.length() - 1] <= '9') || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) {
+
+ what = what.substr(0, what.length() - 1);
+ }
+
+ if (what.findn("$" + p_str) != -1) //blender and other stuff
return true;
- if (p_what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
+ if (what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
return true;
- if (p_what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
+ if (what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
return true;
return false;
}
static String _fixstr(const String &p_what, const String &p_str) {
- if (p_what.findn("$" + p_str) != -1) //blender and other stuff
- return p_what.replace("$" + p_str, "");
- if (p_what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
- return p_what.substr(0, p_what.length() - (p_str.length() + 1));
- if (p_what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
- return p_what.substr(0, p_what.length() - (p_str.length() + 1));
- return p_what;
+ String what = p_what;
+
+ //remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this
+ while (what.length() && ((what[what.length() - 1] >= '0' && what[what.length() - 1] <= '9') || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) {
+
+ what = what.substr(0, what.length() - 1);
+ }
+
+ String end = p_what.substr(what.length(), p_what.length() - what.length());
+
+ if (what.findn("$" + p_str) != -1) //blender and other stuff
+ return what.replace("$" + p_str, "") + end;
+ if (what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
+ return what.substr(0, what.length() - (p_str.length() + 1)) + end;
+ if (what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
+ return what.substr(0, what.length() - (p_str.length() + 1)) + end;
+ return what;
}
Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map, LightBakeMode p_light_bake_mode) {
@@ -437,13 +455,19 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
Node *col;
if (_teststr(name, "col")) {
- mi->set_name(_fixstr(name, "col"));
+ String new_name = _fixstr(name, "col");
+ if (mi->get_parent() && !mi->get_parent()->has_node(new_name)) {
+ mi->set_name(new_name);
+ }
col = mi->create_trimesh_collision_node();
ERR_FAIL_COND_V(!col, NULL);
col->set_name("col");
} else {
- mi->set_name(_fixstr(name, "convcol"));
+ String new_name = _fixstr(name, "convcol");
+ if (mi->get_parent() && !mi->get_parent()->has_node(new_name)) {
+ mi->set_name(new_name);
+ }
col = mi->create_convex_collision_node();
ERR_FAIL_COND_V(!col, NULL);
@@ -893,7 +917,6 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
}
String ext_name = p_base_path.plus_file(_make_extname(E->get()) + ".anim");
-
if (FileAccess::exists(ext_name) && p_keep_animations) {
//try to keep custom animation tracks
Ref<Animation> old_anim = ResourceLoader::load(ext_name, "Animation", true);
@@ -907,6 +930,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
}
}
+ anim->set_path(ext_name, true); //if not set, then its never saved externally
ResourceSaver::save(ext_name, anim, ResourceSaver::FLAG_CHANGE_PATH);
p_animations[anim] = anim;
}
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index beaa8d9600..17a9394b51 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -395,6 +395,10 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC);
}
+
+ if (normal) {
+ image->normalize();
+ }
}
if (fix_alpha_border) {
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 7d0e2929bd..3efb2736b5 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -767,7 +767,8 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
add_options.push_back(AddOption("Animation", "AnimationNodeAnimation"));
add_options.push_back(AddOption("OneShot", "AnimationNodeOneShot"));
- add_options.push_back(AddOption("Add", "AnimationNodeAdd"));
+ add_options.push_back(AddOption("Add2", "AnimationNodeAdd2"));
+ add_options.push_back(AddOption("Add3", "AnimationNodeAdd3"));
add_options.push_back(AddOption("Blend2", "AnimationNodeBlend2"));
add_options.push_back(AddOption("Blend3", "AnimationNodeBlend3"));
add_options.push_back(AddOption("Seek", "AnimationNodeTimeSeek"));
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 3477a6ec30..b38ff239cc 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -144,6 +144,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
ITEM_ICON(TOOL_DUPLICATE_ANIM, "Duplicate");
ITEM_ICON(TOOL_RENAME_ANIM, "Rename");
ITEM_ICON(TOOL_EDIT_TRANSITIONS, "Blend");
+ ITEM_ICON(TOOL_EDIT_RESOURCE, "Edit");
ITEM_ICON(TOOL_REMOVE_ANIM, "Remove");
//ITEM_ICON(TOOL_COPY_ANIM, "Copy");
//ITEM_ICON(TOOL_PASTE_ANIM, "Paste");
@@ -1102,9 +1103,12 @@ void AnimationPlayerEditor::_animation_about_to_show_menu() {
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
- String current = animation->get_item_text(animation->get_selected());
+ String current;
+ if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count())
+ current = animation->get_item_text(animation->get_selected());
+
Ref<Animation> anim;
- if (current != "") {
+ if (current != String()) {
anim = player->get_animation(current);
}
@@ -1667,6 +1671,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
tool_anim->get_popup()->add_separator();
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/rename_animation", TTR("Rename...")), TOOL_RENAME_ANIM);
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/edit_transitions", TTR("Edit Transitions...")), TOOL_EDIT_TRANSITIONS);
+ tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/open_animation_in_inspector", TTR("Open in Inspector")), TOOL_EDIT_RESOURCE);
tool_anim->get_popup()->add_separator();
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove")), TOOL_REMOVE_ANIM);
hb->add_child(tool_anim);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 0f46f7f004..48ee011fc1 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -543,7 +543,6 @@ void CanvasItemEditor::_get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResu
for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from));
- Node2D *to_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().to));
Vector<Vector2> bone_shape;
if (!_get_bone_shape(&bone_shape, NULL, E))
@@ -719,16 +718,17 @@ Vector2 CanvasItemEditor::_anchor_to_position(const Control *p_control, Vector2
ERR_FAIL_COND_V(!p_control, Vector2());
Transform2D parent_transform = p_control->get_transform().affine_inverse();
- Size2 parent_size = p_control->get_parent_area_size();
+ Rect2 parent_rect = p_control->get_parent_anchorable_rect();
- return parent_transform.xform(Vector2(parent_size.x * anchor.x, parent_size.y * anchor.y));
+ return parent_transform.xform(parent_rect.position + Vector2(parent_rect.size.x * anchor.x, parent_rect.size.y * anchor.y));
}
Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2 position) {
ERR_FAIL_COND_V(!p_control, Vector2());
- Size2 parent_size = p_control->get_parent_area_size();
- return p_control->get_transform().xform(position) / parent_size;
+ Rect2 parent_rect = p_control->get_parent_anchorable_rect();
+
+ return (p_control->get_transform().xform(position) - parent_rect.position) / parent_rect.size;
}
void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items, bool save_bones) {
@@ -2491,10 +2491,12 @@ void CanvasItemEditor::_draw_selection() {
Transform2D parent_transform = xform * control->get_transform().affine_inverse();
float node_pos_in_parent[4];
- node_pos_in_parent[0] = control->get_anchor(MARGIN_LEFT) * control->get_parent_area_size().width + control->get_margin(MARGIN_LEFT);
- node_pos_in_parent[1] = control->get_anchor(MARGIN_TOP) * control->get_parent_area_size().height + control->get_margin(MARGIN_TOP);
- node_pos_in_parent[2] = control->get_anchor(MARGIN_RIGHT) * control->get_parent_area_size().width + control->get_margin(MARGIN_RIGHT);
- node_pos_in_parent[3] = control->get_anchor(MARGIN_BOTTOM) * control->get_parent_area_size().height + control->get_margin(MARGIN_BOTTOM);
+ Rect2 parent_rect = control->get_parent_anchorable_rect();
+
+ node_pos_in_parent[0] = control->get_anchor(MARGIN_LEFT) * parent_rect.size.width + control->get_margin(MARGIN_LEFT) + parent_rect.position.x;
+ node_pos_in_parent[1] = control->get_anchor(MARGIN_TOP) * parent_rect.size.height + control->get_margin(MARGIN_TOP) + parent_rect.position.y;
+ node_pos_in_parent[2] = control->get_anchor(MARGIN_RIGHT) * parent_rect.size.width + control->get_margin(MARGIN_RIGHT) + parent_rect.position.x;
+ node_pos_in_parent[3] = control->get_anchor(MARGIN_BOTTOM) * parent_rect.size.height + control->get_margin(MARGIN_BOTTOM) + parent_rect.position.y;
Point2 start, end;
switch (drag_type) {
@@ -4351,7 +4353,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
snap_button->set_toggle_mode(true);
snap_button->connect("toggled", this, "_button_toggle_snap");
snap_button->set_tooltip(TTR("Toggle snapping."));
- snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_snap", TTR("Use Snap"), KEY_S));
+ snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_snap", TTR("Use Snap"), KEY_MASK_SHIFT | KEY_S));
snap_config_menu = memnew(MenuButton);
hb->add_child(snap_config_menu);
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index ed41e1931e..4840b1899d 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -563,6 +563,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (uv_move_current == UV_MODE_REMOVE_SPLIT) {
+ splits_prev = node->get_splits();
for (int i = 0; i < splits_prev.size(); i += 2) {
if (splits_prev[i] < 0 || splits_prev[i] >= points_prev.size())
continue;
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index e316116b43..89c1b3a978 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -124,9 +124,10 @@ void EditorPropertyRootMotion::_node_assign() {
ti = filters->create_item(ti);
parenthood[accum] = ti;
ti->set_text(0, F->get());
- ti->set_selectable(0, false);
+ ti->set_selectable(0, true);
ti->set_editable(0, false);
ti->set_icon(0, get_icon("BoneAttachment", "EditorIcons"));
+ ti->set_metadata(0, accum);
} else {
ti = parenthood[accum];
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 9724017787..aa4673f41e 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -2884,7 +2884,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
error_dialog = memnew(AcceptDialog);
add_child(error_dialog);
- error_dialog->get_ok()->set_text(TTR("I see.."));
+ error_dialog->get_ok()->set_text(TTR("I see..."));
debugger = memnew(ScriptEditorDebugger(editor));
debugger->connect("goto_script_line", this, "_goto_script_line");
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index aef2a53dd1..345c7c06eb 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1289,16 +1289,26 @@ void ScriptTextEditor::_edit_option(int p_op) {
void ScriptTextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
highlighters[p_highlighter->get_name()] = p_highlighter;
- highlighter_menu->get_popup()->add_item(p_highlighter->get_name());
+ highlighter_menu->add_radio_check_item(p_highlighter->get_name());
}
void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
TextEdit *te = code_editor->get_text_edit();
te->_set_syntax_highlighting(p_highlighter);
+ if (p_highlighter != NULL)
+ highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true);
+ else
+ highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text("Standard"), true);
}
void ScriptTextEditor::_change_syntax_highlighter(int p_idx) {
- set_syntax_highlighter(highlighters[highlighter_menu->get_popup()->get_item_text(p_idx)]);
+ Map<String, SyntaxHighlighter *>::Element *el = highlighters.front();
+ while (el != NULL) {
+ highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(el->key()), false);
+ el = el->next();
+ }
+ // highlighter_menu->set_item_checked(p_idx, true);
+ set_syntax_highlighter(highlighters[highlighter_menu->get_item_text(p_idx)]);
}
void ScriptTextEditor::_bind_methods() {
@@ -1666,6 +1676,7 @@ ScriptTextEditor::ScriptTextEditor() {
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_breakpoint"), DEBUG_GOTO_NEXT_BREAKPOINT);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_breakpoint"), DEBUG_GOTO_PREV_BREAKPOINT);
edit_menu->get_popup()->add_separator();
+
PopupMenu *convert_case = memnew(PopupMenu);
convert_case->set_name("convert_case");
edit_menu->get_popup()->add_child(convert_case);
@@ -1675,6 +1686,14 @@ ScriptTextEditor::ScriptTextEditor() {
convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE);
convert_case->connect("id_pressed", this, "_edit_option");
+ highlighters["Standard"] = NULL;
+ highlighter_menu = memnew(PopupMenu);
+ highlighter_menu->set_name("highlighter_menu");
+ edit_menu->get_popup()->add_child(highlighter_menu);
+ edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu");
+ highlighter_menu->add_radio_check_item(TTR("Standard"));
+ highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter");
+
search_menu = memnew(MenuButton);
edit_hb->add_child(search_menu);
search_menu->set_text(TTR("Search"));
@@ -1694,14 +1713,6 @@ ScriptTextEditor::ScriptTextEditor() {
edit_hb->add_child(edit_menu);
- highlighters["Standard"] = NULL;
-
- highlighter_menu = memnew(MenuButton);
- highlighter_menu->set_text(TTR("Syntax Highlighter"));
- highlighter_menu->get_popup()->add_item("Standard");
- highlighter_menu->get_popup()->connect("id_pressed", this, "_change_syntax_highlighter");
- edit_hb->add_child(highlighter_menu);
-
quick_open = memnew(ScriptEditorQuickOpen);
add_child(quick_open);
quick_open->connect("goto_line", this, "_goto_line");
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index a93e1a6fa8..a415f478e8 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -49,8 +49,8 @@ class ScriptTextEditor : public ScriptEditorBase {
HBoxContainer *edit_hb;
MenuButton *edit_menu;
- MenuButton *highlighter_menu;
MenuButton *search_menu;
+ PopupMenu *highlighter_menu;
PopupMenu *context_menu;
GotoLineDialog *goto_line_dialog;
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 7264af3488..19646f37b5 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -137,7 +137,7 @@ void TileMapEditor::_menu_option(int p_option) {
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
- _set_cell(Point2i(j, i), TileMap::INVALID_CELL, false, false, false);
+ _set_cell(Point2i(j, i), invalid_cell, false, false, false);
}
}
_finish_undo();
@@ -186,24 +186,34 @@ void TileMapEditor::_canvas_mouse_exit() {
canvas_item_editor->update();
}
-int TileMapEditor::get_selected_tile() const {
+Vector<int> TileMapEditor::get_selected_tiles() const {
- int item = palette->get_current();
+ Vector<int> items = palette->get_selected_items();
- if (item == -1)
- return TileMap::INVALID_CELL;
+ if (items.size() == 0) {
+ items.push_back(TileMap::INVALID_CELL);
+ return items;
+ }
- return palette->get_item_metadata(item);
+ for (int i = items.size() - 1; i >= 0; i--) {
+ items[i] = palette->get_item_metadata(items[i]);
+ }
+ return items;
}
-void TileMapEditor::set_selected_tile(int p_tile) {
+void TileMapEditor::set_selected_tiles(Vector<int> p_tiles) {
- int idx = palette->find_metadata(p_tile);
+ palette->unselect_all();
- if (idx >= 0) {
- palette->select(idx, true);
- palette->ensure_current_is_visible();
+ for (int i = p_tiles.size() - 1; i >= 0; i--) {
+ int idx = palette->find_metadata(p_tiles[i]);
+
+ if (idx >= 0) {
+ palette->select(idx, false);
+ }
}
+
+ palette->ensure_current_is_visible();
}
void TileMapEditor::_create_set_cell_undo(const Vector2 &p_vec, const CellOp &p_cell_old, const CellOp &p_cell_new) {
@@ -246,10 +256,14 @@ void TileMapEditor::_finish_undo() {
undo_redo->commit_action();
}
-void TileMapEditor::_set_cell(const Point2i &p_pos, int p_value, bool p_flip_h, bool p_flip_v, bool p_transpose) {
+void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p_flip_h, bool p_flip_v, bool p_transpose) {
ERR_FAIL_COND(!node);
+ if (p_values.size() == 0)
+ return;
+
+ int p_value = p_values[Math::rand() % p_values.size()];
int prev_val = node->get_cell(p_pos.x, p_pos.y);
bool prev_flip_h = node->is_cell_x_flipped(p_pos.x, p_pos.y);
@@ -339,7 +353,7 @@ void TileMapEditor::_update_palette() {
if (!node)
return;
- int selected = get_selected_tile();
+ Vector<int> selected = get_selected_tiles();
palette->clear();
manual_palette->clear();
manual_palette->hide();
@@ -428,14 +442,17 @@ void TileMapEditor::_update_palette() {
palette->set_item_metadata(palette->get_item_count() - 1, entries[i].id);
}
- if (selected != -1)
- set_selected_tile(selected);
- else
+ int sel_tile = selected.get(0);
+ if (selected.get(0) != TileMap::INVALID_CELL) {
+ set_selected_tiles(selected);
+ sel_tile = selected.get(Math::rand() % selected.size());
+ } else {
palette->select(0);
+ }
- if (manual_autotile && tileset->tile_get_tile_mode(get_selected_tile()) == TileSet::AUTO_TILE) {
+ if (manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) {
- const Map<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(get_selected_tile());
+ const Map<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(sel_tile);
Vector<Vector2> entries;
for (const Map<Vector2, uint16_t>::Element *E = tiles.front(); E; E = E->next()) {
@@ -443,7 +460,7 @@ void TileMapEditor::_update_palette() {
}
entries.sort();
- Ref<Texture> tex = tileset->tile_get_texture(get_selected_tile());
+ Ref<Texture> tex = tileset->tile_get_texture(sel_tile);
for (int i = 0; i < entries.size(); i++) {
@@ -451,9 +468,9 @@ void TileMapEditor::_update_palette() {
if (tex.is_valid()) {
- Rect2 region = tileset->tile_get_region(get_selected_tile());
- int spacing = tileset->autotile_get_spacing(get_selected_tile());
- region.size = tileset->autotile_get_size(get_selected_tile());
+ Rect2 region = tileset->tile_get_region(sel_tile);
+ int spacing = tileset->autotile_get_spacing(sel_tile);
+ region.size = tileset->autotile_get_size(sel_tile); // !!
region.position += (region.size + Vector2(spacing, spacing)) * entries[i];
if (!region.has_no_area())
@@ -488,7 +505,10 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) {
_update_palette();
}
- set_selected_tile(id);
+ Vector<int> selected;
+
+ selected.push_back(id);
+ set_selected_tiles(selected);
mirror_x->set_pressed(node->is_cell_x_flipped(p_pos.x, p_pos.y));
mirror_y->set_pressed(node->is_cell_y_flipped(p_pos.x, p_pos.y));
@@ -501,18 +521,21 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) {
PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) {
int prev_id = node->get_cell(p_start.x, p_start.y);
- int id = TileMap::INVALID_CELL;
+ Vector<int> ids;
+ ids.push_back(TileMap::INVALID_CELL);
if (!erase) {
- id = get_selected_tile();
+ ids = get_selected_tiles();
- if (id == TileMap::INVALID_CELL)
+ if (ids.size() == 0 && ids[0] == TileMap::INVALID_CELL)
return PoolVector<Vector2>();
} else if (prev_id == TileMap::INVALID_CELL) {
return PoolVector<Vector2>();
}
- if (id == prev_id) {
- return PoolVector<Vector2>();
+ for (int i = ids.size() - 1; i >= 0; i--) {
+ if (ids[i] == prev_id) {
+ return PoolVector<Vector2>();
+ }
}
Rect2i r = node->_edit_get_rect();
@@ -602,13 +625,13 @@ void TileMapEditor::_fill_points(const PoolVector<Vector2> p_points, const Dicti
int len = p_points.size();
PoolVector<Vector2>::Read pr = p_points.read();
- int id = p_op["id"];
+ Vector<int> ids = p_op["id"];
bool xf = p_op["flip_h"];
bool yf = p_op["flip_v"];
bool tr = p_op["transpose"];
for (int i = 0; i < len; i++) {
- _set_cell(pr[i], id, xf, yf, tr);
+ _set_cell(pr[i], ids, xf, yf, tr);
node->make_bitmask_area_dirty(pr[i]);
}
node->update_dirty_bitmask();
@@ -621,7 +644,7 @@ void TileMapEditor::_erase_points(const PoolVector<Vector2> p_points) {
for (int i = 0; i < len; i++) {
- _set_cell(pr[i], TileMap::INVALID_CELL);
+ _set_cell(pr[i], invalid_cell);
}
}
@@ -885,9 +908,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_PAINTING) {
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
- if (id != TileMap::INVALID_CELL) {
+ if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
tool = TOOL_PAINTING;
@@ -910,25 +933,25 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_PAINTING) {
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
- if (id != TileMap::INVALID_CELL) {
+ if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
- _set_cell(over_tile, id, flip_h, flip_v, transpose);
+ _set_cell(over_tile, ids, flip_h, flip_v, transpose);
_finish_undo();
paint_undo.clear();
}
} else if (tool == TOOL_LINE_PAINT) {
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
- if (id != TileMap::INVALID_CELL) {
+ if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
_start_undo(TTR("Line Draw"));
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
- _set_cell(E->key(), id, flip_h, flip_v, transpose);
+ _set_cell(E->key(), ids, flip_h, flip_v, transpose);
}
_finish_undo();
@@ -938,15 +961,15 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
} else if (tool == TOOL_RECTANGLE_PAINT) {
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
- if (id != TileMap::INVALID_CELL) {
+ if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
_start_undo(TTR("Rectangle Paint"));
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
- _set_cell(Point2i(j, i), id, flip_h, flip_v, transpose);
+ _set_cell(Point2i(j, i), ids, flip_h, flip_v, transpose);
}
}
_finish_undo();
@@ -956,11 +979,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else if (tool == TOOL_DUPLICATING) {
Point2 ofs = over_tile - rectangle.position;
+ Vector<int> ids;
_start_undo(TTR("Duplicate"));
+ ids.push_back(0);
for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) {
- _set_cell(E->get().pos + ofs, E->get().cell, E->get().flip_h, E->get().flip_v, E->get().transpose);
+ ids[0] = E->get().cell;
+ _set_cell(E->get().pos + ofs, ids, E->get().flip_h, E->get().flip_v, E->get().transpose);
}
_finish_undo();
@@ -970,17 +996,20 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else if (tool == TOOL_MOVING) {
Point2 ofs = over_tile - rectangle.position;
+ Vector<int> ids;
_start_undo(TTR("Move"));
+ ids.push_back(TileMap::INVALID_CELL);
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
- _set_cell(Point2i(j, i), TileMap::INVALID_CELL, false, false, false);
+ _set_cell(Point2i(j, i), ids, false, false, false);
}
}
for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) {
- _set_cell(E->get().pos + ofs, E->get().cell, E->get().flip_h, E->get().flip_v, E->get().transpose);
+ ids[0] = E->get().cell;
+ _set_cell(E->get().pos + ofs, ids, E->get().flip_h, E->get().flip_v, E->get().transpose);
}
_finish_undo();
@@ -1003,7 +1032,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
undo_redo->create_action(TTR("Bucket Fill"));
Dictionary op;
- op["id"] = get_selected_tile();
+ op["id"] = get_selected_tiles();
op["flip_h"] = flip_h;
op["flip_v"] = flip_v;
op["transpose"] = transpose;
@@ -1079,7 +1108,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
tool = TOOL_ERASING;
- _set_cell(local, TileMap::INVALID_CELL);
+ _set_cell(local, invalid_cell);
}
return true;
@@ -1100,8 +1129,10 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
} else if (tool == TOOL_BUCKET) {
+ Vector<int> ids;
+ ids.push_back(node->get_cell(over_tile.x, over_tile.y));
Dictionary pop;
- pop["id"] = node->get_cell(over_tile.x, over_tile.y);
+ pop["id"] = ids;
pop["flip_h"] = node->is_cell_x_flipped(over_tile.x, over_tile.y);
pop["flip_v"] = node->is_cell_y_flipped(over_tile.x, over_tile.y);
pop["transpose"] = node->is_cell_transposed(over_tile.x, over_tile.y);
@@ -1149,7 +1180,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
// Paint using bresenham line to prevent holes in painting if the user moves fast
Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y);
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
for (int i = 0; i < points.size(); ++i) {
@@ -1159,7 +1190,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
paint_undo[pos] = _get_op_from_cell(pos);
}
- _set_cell(pos, id, flip_h, flip_v, transpose);
+ _set_cell(pos, ids, flip_h, flip_v, transpose);
}
return true;
@@ -1175,7 +1206,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Point2i pos = points[i];
- _set_cell(pos, TileMap::INVALID_CELL);
+ _set_cell(pos, invalid_cell);
}
return true;
@@ -1190,20 +1221,23 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (tool == TOOL_LINE_PAINT || tool == TOOL_LINE_ERASE) {
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
+ Vector<int> tmp_cell;
bool erasing = (tool == TOOL_LINE_ERASE);
+ tmp_cell.push_back(0);
if (erasing && paint_undo.size()) {
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
- _set_cell(E->key(), E->get().idx, E->get().xf, E->get().yf, E->get().tr);
+ tmp_cell[0] = E->get().idx;
+ _set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr);
}
}
paint_undo.clear();
- if (id != TileMap::INVALID_CELL) {
+ if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) {
Vector<Point2i> points = line(rectangle_begin.x, over_tile.x, rectangle_begin.y, over_tile.y);
@@ -1212,7 +1246,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
paint_undo[points[i]] = _get_op_from_cell(points[i]);
if (erasing)
- _set_cell(points[i], TileMap::INVALID_CELL);
+ _set_cell(points[i], invalid_cell);
}
canvas_item_editor->update();
@@ -1222,6 +1256,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
}
if (tool == TOOL_RECTANGLE_PAINT || tool == TOOL_RECTANGLE_ERASE) {
+ Vector<int> tmp_cell;
+ tmp_cell.push_back(0);
+
_select(rectangle_begin, over_tile);
if (tool == TOOL_RECTANGLE_ERASE) {
@@ -1230,7 +1267,8 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
- _set_cell(E->key(), E->get().idx, E->get().xf, E->get().yf, E->get().tr);
+ tmp_cell[0] = E->get().idx;
+ _set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr);
}
}
@@ -1242,7 +1280,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
Point2i tile = Point2i(j, i);
paint_undo[tile] = _get_op_from_cell(tile);
- _set_cell(tile, TileMap::INVALID_CELL);
+ _set_cell(tile, invalid_cell);
}
}
}
@@ -1499,27 +1537,27 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
if (paint_undo.empty())
return;
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
- if (id == TileMap::INVALID_CELL)
+ if (ids.size() == 1 && ids[0] == TileMap::INVALID_CELL)
return;
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
- _draw_cell(id, E->key(), flip_h, flip_v, transpose, xform);
+ _draw_cell(ids[0], E->key(), flip_h, flip_v, transpose, xform);
}
} else if (tool == TOOL_RECTANGLE_PAINT) {
- int id = get_selected_tile();
+ Vector<int> ids = get_selected_tiles();
- if (id == TileMap::INVALID_CELL)
+ if (ids.size() == 1 && ids[0] == TileMap::INVALID_CELL)
return;
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
- _draw_cell(id, Point2i(j, i), flip_h, flip_v, transpose, xform);
+ _draw_cell(ids[0], Point2i(j, i), flip_h, flip_v, transpose, xform);
}
}
} else if (tool == TOOL_DUPLICATING || tool == TOOL_MOVING) {
@@ -1557,17 +1595,17 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
} else if (tool == TOOL_BUCKET) {
- int tile = get_selected_tile();
- _draw_fill_preview(tile, over_tile, flip_h, flip_v, transpose, xform);
+ Vector<int> tiles = get_selected_tiles();
+ _draw_fill_preview(tiles[0], over_tile, flip_h, flip_v, transpose, xform);
} else {
- int st = get_selected_tile();
+ Vector<int> st = get_selected_tiles();
- if (st == TileMap::INVALID_CELL)
+ if (st.size() == 1 && st[0] == TileMap::INVALID_CELL)
return;
- _draw_cell(st, over_tile, flip_h, flip_v, transpose, xform);
+ _draw_cell(st[0], over_tile, flip_h, flip_v, transpose, xform);
}
}
}
@@ -1713,6 +1751,9 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
bucket_cache_tile = -1;
bucket_cache_visited = 0;
+ invalid_cell.resize(1);
+ invalid_cell[0] = TileMap::INVALID_CELL;
+
ED_SHORTCUT("tile_map_editor/erase_selection", TTR("Erase Selection"), KEY_DELETE);
ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find Tile"), KEY_MASK_CMD + KEY_F);
ED_SHORTCUT("tile_map_editor/transpose", TTR("Transpose"), KEY_T);
@@ -1759,6 +1800,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
palette->set_max_columns(0);
palette->set_icon_mode(ItemList::ICON_MODE_TOP);
palette->set_max_text_lines(2);
+ palette->set_select_mode(ItemList::SELECT_MULTI);
palette->connect("item_selected", this, "_palette_selected");
palette_container->add_child(palette);
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index 77e9a33892..b8443ca962 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -157,6 +157,7 @@ class TileMapEditor : public VBoxContainer {
List<TileData> copydata;
Map<Point2i, CellOp> undo_data;
+ Vector<int> invalid_cell;
void _pick_tile(const Point2 &p_pos);
@@ -173,8 +174,8 @@ class TileMapEditor : public VBoxContainer {
void _update_copydata();
- int get_selected_tile() const;
- void set_selected_tile(int p_tile);
+ Vector<int> get_selected_tiles() const;
+ void set_selected_tiles(Vector<int> p_tile);
void _manual_toggled(bool p_enabled);
void _text_entered(const String &p_text);
@@ -187,7 +188,7 @@ class TileMapEditor : public VBoxContainer {
void _start_undo(const String &p_action);
void _finish_undo();
void _create_set_cell_undo(const Vector2 &p_vec, const CellOp &p_cell_old, const CellOp &p_cell_new);
- void _set_cell(const Point2i &p_pos, int p_value, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false);
+ void _set_cell(const Point2i &p_pos, Vector<int> p_values, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false);
void _canvas_mouse_enter();
void _canvas_mouse_exit();
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 3e17385909..cf136a5e58 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -149,53 +149,71 @@ void ProjectSettingsEditor::_action_edited() {
if (!ti)
return;
- String new_name = ti->get_text(0);
- String old_name = add_at.substr(add_at.find("/") + 1, add_at.length());
+ if (input_editor->get_selected_column() == 0) {
- if (new_name == old_name)
- return;
+ String new_name = ti->get_text(0);
+ String old_name = add_at.substr(add_at.find("/") + 1, add_at.length());
- if (new_name == "" || !_validate_action_name(new_name)) {
+ if (new_name == old_name)
+ return;
- ti->set_text(0, old_name);
- add_at = "input/" + old_name;
+ if (new_name == "" || !_validate_action_name(new_name)) {
- message->set_text(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'."));
- message->popup_centered(Size2(300, 100) * EDSCALE);
- return;
- }
+ ti->set_text(0, old_name);
+ add_at = "input/" + old_name;
- String action_prop = "input/" + new_name;
+ message->set_text(TTR("Invalid action name. it cannot be empty nor contain '/', ':', '=', '\\' or '\"'"));
+ message->popup_centered(Size2(300, 100) * EDSCALE);
+ return;
+ }
- if (ProjectSettings::get_singleton()->has_setting(action_prop)) {
+ String action_prop = "input/" + new_name;
- ti->set_text(0, old_name);
- add_at = "input/" + old_name;
+ if (ProjectSettings::get_singleton()->has_setting(action_prop)) {
- message->set_text(vformat(TTR("Action '%s' already exists!"), new_name));
- message->popup_centered(Size2(300, 100) * EDSCALE);
- return;
- }
+ ti->set_text(0, old_name);
+ add_at = "input/" + old_name;
- int order = ProjectSettings::get_singleton()->get_order(add_at);
- Dictionary action = ProjectSettings::get_singleton()->get(add_at);
-
- setting = true;
- undo_redo->create_action(TTR("Rename Input Action Event"));
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", add_at);
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", action_prop, action);
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", action_prop, order);
- undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", action_prop);
- undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", add_at, action);
- undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", add_at, order);
- undo_redo->add_do_method(this, "_update_actions");
- undo_redo->add_undo_method(this, "_update_actions");
- undo_redo->add_do_method(this, "_settings_changed");
- undo_redo->add_undo_method(this, "_settings_changed");
- undo_redo->commit_action();
- setting = false;
+ message->set_text(vformat(TTR("Action '%s' already exists!"), new_name));
+ message->popup_centered(Size2(300, 100) * EDSCALE);
+ return;
+ }
- add_at = action_prop;
+ int order = ProjectSettings::get_singleton()->get_order(add_at);
+ Dictionary action = ProjectSettings::get_singleton()->get(add_at);
+
+ setting = true;
+ undo_redo->create_action(TTR("Rename Input Action Event"));
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", add_at);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", action_prop, action);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", action_prop, order);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", action_prop);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", add_at, action);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", add_at, order);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
+ undo_redo->commit_action();
+ setting = false;
+
+ add_at = action_prop;
+ } else if (input_editor->get_selected_column() == 1) {
+
+ String name = "input/" + ti->get_text(0);
+ Dictionary old_action = ProjectSettings::get_singleton()->get(name);
+ Dictionary new_action = old_action.duplicate();
+ new_action["deadzone"] = ti->get_range(1);
+
+ undo_redo->create_action(TTR("Change Action deadzone"));
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, new_action);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_action);
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_settings_changed");
+ undo_redo->commit_action();
+ }
}
void ProjectSettingsEditor::_device_input_add() {
@@ -237,24 +255,18 @@ void ProjectSettingsEditor::_device_input_add() {
jm->set_axis_value(device_index->get_selected() & 1 ? 1 : -1);
jm->set_device(_get_current_device());
- bool should_update_event = true;
- Variant deadzone = device_special_value->get_value();
for (int i = 0; i < events.size(); i++) {
Ref<InputEventJoypadMotion> aie = events[i];
if (aie.is_null())
continue;
+
if (aie->get_device() == jm->get_device() && aie->get_axis() == jm->get_axis() && aie->get_axis_value() == jm->get_axis_value()) {
- should_update_event = false;
- break;
+ return;
}
}
- if (!should_update_event && deadzone == action["deadzone"])
- return;
-
ie = jm;
- action["deadzone"] = deadzone;
} break;
case INPUT_JOY_BUTTON: {
@@ -430,8 +442,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
press_a_key->popup_centered(Size2(250, 80) * EDSCALE);
press_a_key->grab_focus();
- device_special_value_label->hide();
- device_special_value->hide();
} break;
case INPUT_MOUSE_BUTTON: {
@@ -458,8 +468,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_input->get_ok()->set_text(TTR("Add"));
}
- device_special_value_label->hide();
- device_special_value->hide();
} break;
case INPUT_JOY_MOTION: {
@@ -482,14 +490,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_input->get_ok()->set_text(TTR("Add"));
}
- device_special_value_label->set_text(TTR("Deadzone (global to the action):"));
- device_special_value_label->show();
- device_special_value->set_min(0.0f);
- device_special_value->set_max(1.0f);
- device_special_value->set_step(0.01f);
- Dictionary action = ProjectSettings::get_singleton()->get(add_at);
- device_special_value->set_value(action.has("deadzone") ? action["deadzone"] : Variant(0.5f));
- device_special_value->show();
} break;
case INPUT_JOY_BUTTON: {
@@ -512,8 +512,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_input->get_ok()->set_text(TTR("Add"));
}
- device_special_value_label->hide();
- device_special_value->hide();
} break;
default: {}
}
@@ -673,17 +671,24 @@ void ProjectSettingsEditor::_update_actions() {
if (name == "")
continue;
+ Dictionary action = ProjectSettings::get_singleton()->get(pi.name);
+ Array events = action["events"];
+
TreeItem *item = input_editor->create_item(root);
item->set_text(0, name);
- item->add_button(0, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
- if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) {
- item->add_button(0, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
- item->set_editable(0, true);
- }
item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
- Dictionary action = ProjectSettings::get_singleton()->get(pi.name);
- Array events = action["events"];
+ item->set_editable(1, true);
+ item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
+ item->set_range_config(1, 0.0, 1.0, 0.01);
+ item->set_range(1, action["deadzone"]);
+ item->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
+
+ item->add_button(2, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
+ if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) {
+ item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
+ item->set_editable(2, true);
+ }
for (int i = 0; i < events.size(); i++) {
@@ -752,10 +757,11 @@ void ProjectSettingsEditor::_update_actions() {
action->set_text(0, str);
action->set_icon(0, get_icon("JoyAxis", "EditorIcons"));
}
- action->add_button(0, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit"));
- action->add_button(0, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
action->set_metadata(0, i);
action->set_meta("__input", event);
+
+ action->add_button(2, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit"));
+ action->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
}
}
@@ -1790,6 +1796,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
input_editor = memnew(Tree);
vbc->add_child(input_editor);
input_editor->set_v_size_flags(SIZE_EXPAND_FILL);
+ input_editor->set_columns(3);
+ input_editor->set_column_titles_visible(true);
+ input_editor->set_column_title(0, TTR("Action"));
+ input_editor->set_column_title(1, TTR("Deadzone"));
+ input_editor->set_column_expand(1, false);
+ input_editor->set_column_min_width(1, 80);
+ input_editor->set_column_expand(2, false);
+ input_editor->set_column_min_width(2, 50);
input_editor->connect("item_edited", this, "_action_edited");
input_editor->connect("item_activated", this, "_action_activated");
input_editor->connect("cell_selected", this, "_action_selected");
@@ -1846,14 +1860,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
device_index = memnew(OptionButton);
vbc_right->add_child(device_index);
- l = memnew(Label);
- l->set_text(TTR("Special value:"));
- vbc_right->add_child(l);
- device_special_value_label = l;
-
- device_special_value = memnew(SpinBox);
- vbc_right->add_child(device_special_value);
-
setting = false;
//translations
@@ -1979,7 +1985,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
tab_container->add_child(plugin_settings);
timer = memnew(Timer);
- timer->set_wait_time(1.5);
+ timer->set_wait_time(0.1);
timer->connect("timeout", ProjectSettings::get_singleton(), "save");
timer->set_one_shot(true);
add_child(timer);
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index b8bfdcd876..0ced88d7f6 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -83,8 +83,6 @@ class ProjectSettingsEditor : public AcceptDialog {
OptionButton *device_id;
OptionButton *device_index;
Label *device_index_label;
- SpinBox *device_special_value;
- Label *device_special_value_label;
MenuButton *popup_copy_to_feature;
LineEdit *action_name;
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index e912ebe03a..7f46844f6c 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -847,6 +847,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
if (!color_picker) {
//late init for performance
color_picker = memnew(ColorPicker);
+ color_picker->set_deferred_mode(true);
add_child(color_picker);
color_picker->hide();
color_picker->connect("color_changed", this, "_color_changed");
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 7d2127d4f8..88d614ab89 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -166,6 +166,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
}
TreeItem *item = tree->create_item(p_parent);
+
item->set_text(0, p_node->get_name());
if (can_rename && !part_of_subscene /*(p_node->get_owner() == get_scene_node() || p_node==get_scene_node())*/)
item->set_editable(0, true);
@@ -196,7 +197,9 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (part_of_subscene) {
//item->set_selectable(0,marked_selectable);
- item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ if (valid_types.size() == 0) {
+ item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ }
} else if (marked.has(p_node)) {
@@ -323,6 +326,22 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
keep = keep || child_keep;
}
+ if (valid_types.size()) {
+ bool valid = false;
+ for (int i = 0; i < valid_types.size(); i++) {
+ if (p_node->is_class(valid_types[i])) {
+ valid = true;
+ break;
+ }
+ }
+
+ if (!valid) {
+ //item->set_selectable(0,marked_selectable);
+ item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
+ item->set_selectable(0, false);
+ }
+ }
+
if (!keep) {
memdelete(item);
return false;
@@ -716,6 +735,10 @@ bool SceneTreeEditor::get_display_foreign_nodes() const {
return display_foreign;
}
+void SceneTreeEditor::set_valid_types(const Vector<StringName> &p_valid) {
+ valid_types = p_valid;
+}
+
void SceneTreeEditor::set_editor_selection(EditorSelection *p_selection) {
editor_selection = p_selection;
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index b173d7d215..c4f63f5736 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -131,6 +131,8 @@ class SceneTreeEditor : public Control {
List<StringName> *script_types;
bool _is_script_type(const StringName &p_type) const;
+ Vector<StringName> valid_types;
+
public:
void set_filter(const String &p_filter);
String get_filter() const;
@@ -147,6 +149,7 @@ public:
void set_editor_selection(EditorSelection *p_selection);
void set_show_enabled_subscene(bool p_show) { show_enabled_subscene = p_show; }
+ void set_valid_types(const Vector<StringName> &p_valid);
void update_tree() { _update_tree(); }
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index ae88b3a035..45041bcf59 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -493,7 +493,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
//get_cancel()->set_text("Close");
timer = memnew(Timer);
- timer->set_wait_time(1.5);
+ timer->set_wait_time(0.1);
timer->connect("timeout", this, "_settings_save");
timer->set_one_shot(true);
add_child(timer);