summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp18
-rw-r--r--editor/editor_node.cpp2
-rw-r--r--editor/editor_themes.cpp2
-rw-r--r--editor/filesystem_dock.cpp1
-rw-r--r--editor/icons/icon_auto_key.svg56
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp168
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h3
-rw-r--r--editor/plugins/item_list_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp39
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp54
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h1
-rw-r--r--editor/scene_tree_dock.cpp68
-rw-r--r--editor/scene_tree_editor.cpp29
14 files changed, 300 insertions, 145 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 09b23ae90e..2307d340d8 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -717,6 +717,9 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) {
return;
p_new_len = MAX(0.001, p_new_len);
+ if (use_fps && animation->get_step() > 0) {
+ p_new_len *= animation->get_step();
+ }
editing = true;
undo_redo->create_action(TTR("Change Animation Length"));
@@ -1017,7 +1020,11 @@ void AnimationTimelineEdit::update_values() {
return;
editing = true;
- length->set_value(animation->get_length());
+ if (use_fps && animation->get_step() > 0) {
+ length->set_value(animation->get_length() / animation->get_step());
+ } else {
+ length->set_value(animation->get_length());
+ }
loop->set_pressed(animation->has_loop());
editing = false;
}
@@ -1104,6 +1111,7 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) {
void AnimationTimelineEdit::set_use_fps(bool p_use_fps) {
use_fps = p_use_fps;
+ update_values();
update();
}
bool AnimationTimelineEdit::is_using_fps() const {
@@ -1164,7 +1172,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
len_hb->add_child(time_icon);
length = memnew(EditorSpinSlider);
length->set_min(0.001);
- length->set_max(3600);
+ length->set_max(36000);
length->set_step(0.01);
length->set_allow_greater(true);
length->set_custom_minimum_size(Vector2(70 * EDSCALE, 0));
@@ -2532,6 +2540,7 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
step->set_block_signals(false);
step->set_read_only(false);
snap->set_disabled(false);
+ snap_mode->set_disabled(true);
} else {
hscroll->hide();
edit->set_disabled(true);
@@ -2540,6 +2549,7 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
step->set_block_signals(false);
step->set_read_only(true);
snap->set_disabled(true);
+ snap_mode->set_disabled(false);
}
}
@@ -3530,6 +3540,9 @@ void AnimationTrackEditor::_snap_mode_changed(int p_mode) {
}
void AnimationTrackEditor::_update_step_spinbox() {
+ if (!animation.is_valid()) {
+ return;
+ }
step->set_block_signals(true);
if (timeline->is_using_fps()) {
@@ -5030,6 +5043,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
snap_mode->add_item(TTR("FPS"));
bottom_hb->add_child(snap_mode);
snap_mode->connect("item_selected", this, "_snap_mode_changed");
+ snap_mode->set_disabled(true);
bottom_hb->add_child(memnew(VSeparator));
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 8a67002503..851d6a0aa6 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1306,6 +1306,7 @@ void EditorNode::_dialog_action(String p_file) {
_save_default_environment();
_save_scene_with_preview(p_file, scene_idx);
_add_to_recent_scenes(p_file);
+ save_layout();
if (scene_idx != -1)
_discard_changes();
@@ -4069,6 +4070,7 @@ void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout, const S
for (int i = 0; i < scenes.size(); i++) {
load_scene(scenes[i]);
}
+ save_layout();
restoring_scenes = false;
}
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 0869f6ce77..9641e10114 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -687,7 +687,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
theme->set_constant("draw_relationship_lines", "Tree", relationship_line_opacity >= 0.01);
theme->set_constant("draw_guides", "Tree", relationship_line_opacity < 0.01);
- theme->set_constant("scroll_border", "Tree", default_margin_size * EDSCALE);
+ theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
theme->set_constant("scroll_speed", "Tree", 12);
Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 5a1383be6d..c32cd1de50 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1021,6 +1021,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
for (int j = 0; j < ed->get_edited_scene_count(); j++) {
if (ed->get_scene_path(j) == file_changed_paths[i]) {
ed->get_edited_scene_root(j)->set_filename(new_item_path);
+ editor->save_layout();
break;
}
}
diff --git a/editor/icons/icon_auto_key.svg b/editor/icons/icon_auto_key.svg
new file mode 100644
index 0000000000..cbafe1ac38
--- /dev/null
+++ b/editor/icons/icon_auto_key.svg
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ version="1.1"
+ viewBox="0 0 16 16"
+ id="svg6"
+ sodipodi:docname="icon_auto_key.svg"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
+ <metadata
+ id="metadata12">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs10" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1854"
+ inkscape:window-height="1016"
+ id="namedview8"
+ showgrid="false"
+ inkscape:zoom="10.429825"
+ inkscape:cx="10.199345"
+ inkscape:cy="-4.0344119"
+ inkscape:window-x="66"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg6" />
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;stroke-width:0.0333107"
+ d="M 3.5469681,13.426786 C 2.7965829,13.263778 2.2774312,12.503915 2.4037297,11.753472 c 0.1081234,-0.642451 0.6006808,-1.135008 1.2431317,-1.243131 0.9667125,-0.162696 1.8555225,0.726112 1.6928259,1.692826 -0.103766,0.616558 -0.5592173,1.098057 -1.1588427,1.225117 -0.2719576,0.05763 -0.3626872,0.05741 -0.6338765,-0.0014 z m 8.0861339,-0.08275 c -0.746862,-0.13829 -1.23937,-0.720718 -1.23937,-1.465649 0,-0.527377 0.244831,-0.978806 0.679757,-1.253362 0.471386,-0.297574 1.114188,-0.297574 1.585574,0 0.682727,0.430986 0.892336,1.362194 0.460575,2.046149 -0.307786,0.487563 -0.940521,0.773963 -1.486536,0.672862 z M 0.60726032,9.8305658 V 7.7161233 L 1.1770842,7.7070075 1.7469079,7.6978939 3.1889882,5.1995916 4.6310686,2.7012893 h 3.1726318 3.1726316 l 1.442755,2.4983023 1.442755,2.4983023 0.651097,0.00903 0.651096,0.00903 v 2.1145264 2.1145257 h -0.566282 -0.566281 v -0.161225 c 0,-0.234927 -0.113135,-0.639704 -0.255664,-0.914727 -0.16895,-0.326004 -0.574198,-0.731251 -0.900202,-0.9002019 -0.656732,-0.3403483 -1.428549,-0.3403483 -2.085281,0 -0.326004,0.1689519 -0.731252,0.5741989 -0.9002019,0.9002029 -0.1425297,0.275023 -0.2556639,0.6798 -0.2556639,0.914727 v 0.161225 H 7.8570969 6.0797346 L 6.0617736,11.686851 C 6.006289,10.889347 5.447548,10.170679 4.6603773,9.884336 4.4466221,9.8065798 4.3737631,9.797427 3.9716406,9.7978134 3.5871254,9.7981885 3.4905638,9.809405 3.3054265,9.8752358 2.5067319,10.159236 1.9362359,10.884501 1.8813215,11.68568 l -0.017772,0.259329 H 1.2354063 0.60726287 Z M 12.399247,7.7466889 c 0,-0.037287 -0.02623,-0.1073444 -0.0583,-0.1556843 -0.03206,-0.04834 -0.561225,-0.958444 -1.17592,-2.0224529 L 10.047407,3.6339894 7.6977565,3.6254406 C 5.4917229,3.6174174 5.3450379,3.6204563 5.2979001,3.6754094 5.1898818,3.8013046 2.9723198,7.6840061 2.9723198,7.7472381 c 0,0.067139 0.00758,0.067247 4.7134636,0.067247 h 4.7134636 z"
+ id="path6243"
+ inkscape:connector-curvature="0" />
+</svg>
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index c3cac582ad..b2923a1ff2 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1340,6 +1340,10 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
// Confirms the node rotation
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
_commit_canvas_item_state(drag_selection, TTR("Rotate CanvasItem"));
+ if (key_auto_insert_button->is_pressed()) {
+ _insert_animation_keys(false, true, false, true);
+ }
+
drag_type = DRAG_NONE;
return true;
}
@@ -1641,6 +1645,9 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
// Confirm resize
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
_commit_canvas_item_state(drag_selection, TTR("Resize CanvasItem"));
+ if (key_auto_insert_button->is_pressed()) {
+ _insert_animation_keys(false, false, true, true);
+ }
drag_type = DRAG_NONE;
viewport->update();
return true;
@@ -1747,6 +1754,10 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
// Confirm resize
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && !b->is_pressed()) {
_commit_canvas_item_state(drag_selection, TTR("Scale CanvasItem"));
+ if (key_auto_insert_button->is_pressed()) {
+ _insert_animation_keys(false, false, true, true);
+ }
+
drag_type = DRAG_NONE;
viewport->update();
return true;
@@ -1852,6 +1863,9 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
_commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true);
}
+ if (key_auto_insert_button->is_pressed()) {
+ _insert_animation_keys(true, false, false, true);
+ }
drag_type = DRAG_NONE;
viewport->update();
return true;
@@ -3384,6 +3398,7 @@ void CanvasItemEditor::_notification(int p_what) {
key_rot_button->set_icon(get_icon("KeyRotation", "EditorIcons"));
key_scale_button->set_icon(get_icon("KeyScale", "EditorIcons"));
key_insert_button->set_icon(get_icon("Key", "EditorIcons"));
+ key_auto_insert_button->set_icon(get_icon("AutoKey", "EditorIcons"));
zoom_minus->set_icon(get_icon("ZoomLess", "EditorIcons"));
zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons"));
@@ -3716,6 +3731,77 @@ void CanvasItemEditor::_button_tool_select(int p_index) {
tool = (Tool)p_index;
}
+void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) {
+
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
+
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
+
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
+ continue;
+
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
+ continue;
+
+ if (Object::cast_to<Node2D>(canvas_item)) {
+ Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
+
+ if (key_pos && p_location)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), p_on_existing);
+ if (key_rot && p_rotation)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "rotation_degrees", Math::rad2deg(n2d->get_rotation()), p_on_existing);
+ if (key_scale && p_scale)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "scale", n2d->get_scale(), p_on_existing);
+
+ if (n2d->has_meta("_edit_bone_") && n2d->get_parent_item()) {
+ //look for an IK chain
+ List<Node2D *> ik_chain;
+
+ Node2D *n = Object::cast_to<Node2D>(n2d->get_parent_item());
+ bool has_chain = false;
+
+ while (n) {
+
+ ik_chain.push_back(n);
+ if (n->has_meta("_edit_ik_")) {
+ has_chain = true;
+ break;
+ }
+
+ if (!n->get_parent_item())
+ break;
+ n = Object::cast_to<Node2D>(n->get_parent_item());
+ }
+
+ if (has_chain && ik_chain.size()) {
+
+ for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) {
+
+ if (key_pos)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), p_on_existing);
+ if (key_rot)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "rotation_degrees", Math::rad2deg(F->get()->get_rotation()), p_on_existing);
+ if (key_scale)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), p_on_existing);
+ }
+ }
+ }
+
+ } else if (Object::cast_to<Control>(canvas_item)) {
+
+ Control *ctrl = Object::cast_to<Control>(canvas_item);
+
+ if (key_pos)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), p_on_existing);
+ if (key_rot)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_degrees(), p_on_existing);
+ if (key_scale)
+ AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), p_on_existing);
+ }
+ }
+}
+
void CanvasItemEditor::_popup_callback(int p_op) {
last_option = MenuOption(p_op);
@@ -3983,73 +4069,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
bool existing = p_op == ANIM_INSERT_KEY_EXISTING;
- Map<Node *, Object *> &selection = editor_selection->get_selection();
-
- for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
-
- CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
- if (!canvas_item || !canvas_item->is_visible_in_tree())
- continue;
-
- if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
- continue;
-
- if (Object::cast_to<Node2D>(canvas_item)) {
- Node2D *n2d = Object::cast_to<Node2D>(canvas_item);
-
- if (key_pos)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), existing);
- if (key_rot)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "rotation_degrees", Math::rad2deg(n2d->get_rotation()), existing);
- if (key_scale)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(n2d, "scale", n2d->get_scale(), existing);
-
- if (n2d->has_meta("_edit_bone_") && n2d->get_parent_item()) {
- //look for an IK chain
- List<Node2D *> ik_chain;
-
- Node2D *n = Object::cast_to<Node2D>(n2d->get_parent_item());
- bool has_chain = false;
-
- while (n) {
-
- ik_chain.push_back(n);
- if (n->has_meta("_edit_ik_")) {
- has_chain = true;
- break;
- }
-
- if (!n->get_parent_item())
- break;
- n = Object::cast_to<Node2D>(n->get_parent_item());
- }
-
- if (has_chain && ik_chain.size()) {
-
- for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) {
-
- if (key_pos)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), existing);
- if (key_rot)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "rotation_degrees", Math::rad2deg(F->get()->get_rotation()), existing);
- if (key_scale)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), existing);
- }
- }
- }
-
- } else if (Object::cast_to<Control>(canvas_item)) {
-
- Control *ctrl = Object::cast_to<Control>(canvas_item);
-
- if (key_pos)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), existing);
- if (key_rot)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_degrees(), existing);
- if (key_scale)
- AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), existing);
- }
- }
+ _insert_animation_keys(true, true, true, existing);
} break;
case ANIM_INSERT_POS: {
@@ -4866,6 +4886,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_loc_button->set_pressed(true);
key_loc_button->set_focus_mode(FOCUS_NONE);
key_loc_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_POS));
+ key_loc_button->set_tooltip(TTR("Translation mask for inserting keys."));
animation_hb->add_child(key_loc_button);
key_rot_button = memnew(Button);
key_rot_button->set_toggle_mode(true);
@@ -4873,21 +4894,30 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_rot_button->set_pressed(true);
key_rot_button->set_focus_mode(FOCUS_NONE);
key_rot_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_ROT));
+ key_rot_button->set_tooltip(TTR("Rotation mask for inserting keys."));
animation_hb->add_child(key_rot_button);
key_scale_button = memnew(Button);
key_scale_button->set_toggle_mode(true);
key_scale_button->set_flat(true);
key_scale_button->set_focus_mode(FOCUS_NONE);
key_scale_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_SCALE));
+ key_scale_button->set_tooltip(TTR("Scale mask for inserting keys."));
animation_hb->add_child(key_scale_button);
key_insert_button = memnew(Button);
key_insert_button->set_flat(true);
key_insert_button->set_focus_mode(FOCUS_NONE);
key_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
- key_insert_button->set_tooltip(TTR("Insert keys."));
+ key_insert_button->set_tooltip(TTR("Insert keys (based on mask)."));
key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT));
-
animation_hb->add_child(key_insert_button);
+ key_auto_insert_button = memnew(Button);
+ key_auto_insert_button->set_flat(true);
+ key_auto_insert_button->set_toggle_mode(true);
+ key_auto_insert_button->set_focus_mode(FOCUS_NONE);
+ //key_auto_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
+ key_auto_insert_button->set_tooltip(TTR("Auto insert keys when objects are translated, rotated on scaled (based on mask).\nKeys are only added to existing tracks, no new tracks will be created.\nKeys must be inserted manually for the first time."));
+ key_auto_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_auto_insert_key", TTR("Auto Insert Key")));
+ animation_hb->add_child(key_auto_insert_button);
animation_menu = memnew(MenuButton);
animation_menu->set_text(TTR("Animation"));
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 9173c55ae0..14ea81f302 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -351,6 +351,7 @@ private:
Button *key_rot_button;
Button *key_scale_button;
Button *key_insert_button;
+ Button *key_auto_insert_button;
PopupMenu *selection_menu;
@@ -422,6 +423,8 @@ private:
Object *_get_editor_data(Object *p_what);
+ void _insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing);
+
void _keying_changed();
void _unhandled_key_input(const Ref<InputEvent> &p_ev);
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 679235e316..701632e576 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -157,7 +157,7 @@ public:
virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }
- virtual void set_item_id(int p_idx, int p_id) { pp->set_item_id(p_idx, p_idx); }
+ virtual void set_item_id(int p_idx, int p_id) { pp->set_item_id(p_idx, p_id); }
virtual int get_item_id(int p_idx) const { return pp->get_item_id(p_idx); }
virtual void set_item_separator(int p_idx, bool p_separator) { pp->set_item_as_separator(p_idx, p_separator); }
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 543771ad1c..c586985957 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -81,6 +81,8 @@ void ScriptTextEditor::set_edited_resource(const RES &p_res) {
emit_signal("name_changed");
code_editor->update_line_and_column();
+
+ _validate_script();
}
void ScriptTextEditor::_update_member_keywords() {
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 03277159fc..8cf00cf67d 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -1038,25 +1038,26 @@ void TileSetEditor::_on_workspace_overlay_draw() {
tileset->get_tile_list(tiles);
for (List<int>::Element *E = tiles->front(); E; E = E->next()) {
int t_id = E->get();
- if (tileset->tile_get_texture(t_id)->get_rid() == current_texture_rid) {
- Rect2i region = tileset->tile_get_region(t_id);
- region.position += WORKSPACE_MARGIN;
- region.position *= workspace->get_scale().x;
- Color c;
- if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
- c = COLOR_SINGLE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE)
- c = COLOR_AUTOTILE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
- c = COLOR_ATLAS;
- String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id);
- Ref<Font> font = get_font("font", "Label");
- region.set_size(font->get_string_size(tile_id_name));
- workspace_overlay->draw_rect(region, c);
- region.position.y += region.size.y - 2;
- c = Color(0.1, 0.1, 0.1);
- workspace_overlay->draw_string(font, region.position, tile_id_name, c);
- }
+ if (tileset->tile_get_texture(t_id)->get_rid() != current_texture_rid)
+ continue;
+
+ Rect2 region = tileset->tile_get_region(t_id);
+ region.position += WORKSPACE_MARGIN;
+ region.position *= workspace->get_scale().x;
+ Color c;
+ if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
+ c = COLOR_SINGLE;
+ else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE)
+ c = COLOR_AUTOTILE;
+ else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
+ c = COLOR_ATLAS;
+ String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id);
+ Ref<Font> font = get_font("font", "Label");
+ region.set_size(font->get_string_size(tile_id_name));
+ workspace_overlay->draw_rect(region, c);
+ region.position.y += region.size.y - 2;
+ c = Color(0.1, 0.1, 0.1);
+ workspace_overlay->draw_string(font, region.position, tile_id_name, c);
}
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 71e22afe95..0aba7f3d15 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -1004,6 +1004,58 @@ void VisualShaderEditor::_duplicate_nodes() {
}
}
+void VisualShaderEditor::_on_nodes_delete() {
+
+ VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
+ List<int> to_erase;
+
+ for (int i = 0; i < graph->get_child_count(); i++) {
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
+ if (gn) {
+ if (gn->is_selected() && gn->is_close_button_visible()) {
+ to_erase.push_back(gn->get_name().operator String().to_int());
+ }
+ }
+ }
+
+ if (to_erase.empty())
+ return;
+
+ undo_redo->create_action(TTR("Delete Nodes"));
+
+ for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
+ undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get());
+ undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, visual_shader->get_node(type, F->get()), visual_shader->get_node_position(type, F->get()), F->get());
+ }
+
+ List<VisualShader::Connection> conns;
+ visual_shader->get_node_connections(type, &conns);
+
+ List<VisualShader::Connection> used_conns;
+ for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
+ for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
+ if (E->get().from_node == F->get() || E->get().to_node == F->get()) {
+
+ bool cancel = false;
+ for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) {
+ if (R->get().from_node == E->get().from_node && R->get().from_port == E->get().from_port && R->get().to_node == E->get().to_node && R->get().to_port == E->get().to_port) {
+ cancel = true; // to avoid ERR_ALREADY_EXISTS warning
+ break;
+ }
+ }
+ if (!cancel) {
+ undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ used_conns.push_back(E->get());
+ }
+ }
+ }
+ }
+
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
+}
+
void VisualShaderEditor::_mode_selected(int p_id) {
_update_options_menu();
_update_graph();
@@ -1175,6 +1227,7 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_node_selected", &VisualShaderEditor::_node_selected);
ClassDB::bind_method("_scroll_changed", &VisualShaderEditor::_scroll_changed);
ClassDB::bind_method("_delete_request", &VisualShaderEditor::_delete_request);
+ ClassDB::bind_method("_on_nodes_delete", &VisualShaderEditor::_on_nodes_delete);
ClassDB::bind_method("_node_changed", &VisualShaderEditor::_node_changed);
ClassDB::bind_method("_edit_port_default_input", &VisualShaderEditor::_edit_port_default_input);
ClassDB::bind_method("_port_edited", &VisualShaderEditor::_port_edited);
@@ -1224,6 +1277,7 @@ VisualShaderEditor::VisualShaderEditor() {
graph->connect("node_selected", this, "_node_selected");
graph->connect("scroll_offset_changed", this, "_scroll_changed");
graph->connect("duplicate_nodes_request", this, "_duplicate_nodes");
+ graph->connect("delete_nodes_request", this, "_on_nodes_delete");
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_BOOLEAN);
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 2709d72931..4b0b48ad92 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -143,6 +143,7 @@ class VisualShaderEditor : public VBoxContainer {
void _node_selected(Object *p_node);
void _delete_request(int);
+ void _on_nodes_delete();
void _removed_from_graph();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 752c1afff2..bd245d5da9 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1741,7 +1741,7 @@ void SceneTreeDock::_update_script_button() {
button_clear_script->show();
}
} else {
- button_create_script->show();
+ button_create_script->hide();
Array selection = editor_selection->get_selected_nodes();
for (int i = 0; i < selection.size(); i++) {
Node *n = Object::cast_to<Node>(selection[i]);
@@ -2208,17 +2208,20 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (profile_allow_script_editing) {
- if (!existing_script.is_valid()) {
- menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
+ if (selection.size() == 1) {
+ if (!existing_script.is_valid()) {
+ menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
+ } else {
+ menu->add_icon_shortcut(get_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_ATTACH_SCRIPT);
+ }
}
if (selection.size() > 1 || existing_script.is_valid()) {
menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
- menu->add_icon_shortcut(get_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_ATTACH_SCRIPT);
}
+ menu->add_separator();
}
if (profile_allow_editing) {
- menu->add_separator();
if (selection.size() == 1) {
menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME);
}
@@ -2230,12 +2233,12 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN);
menu->add_icon_shortcut(get_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE);
menu->add_icon_shortcut(get_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT);
+ menu->add_icon_shortcut(get_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT);
}
}
if (selection.size() == 1) {
if (profile_allow_editing) {
- menu->add_icon_shortcut(get_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT);
menu->add_separator();
menu->add_icon_shortcut(get_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
menu->add_icon_shortcut(get_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
@@ -2277,7 +2280,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME);
}
menu->add_separator();
- menu->add_icon_item(get_icon("Help", "EditorIcons"), TTR("Open documentation"), TOOL_OPEN_DOCUMENTATION);
+ menu->add_icon_item(get_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION);
if (profile_allow_editing) {
menu->add_separator();
@@ -2508,7 +2511,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
HBoxContainer *filter_hbc = memnew(HBoxContainer);
filter_hbc->add_constant_override("separate", 0);
- ToolButton *tb;
ED_SHORTCUT("scene_tree/rename", TTR("Rename"));
ED_SHORTCUT("scene_tree/batch_rename", TTR("Batch Rename"), KEY_MASK_CMD | KEY_F2);
@@ -2529,19 +2531,17 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KEY_MASK_SHIFT | KEY_DELETE);
ED_SHORTCUT("scene_tree/delete", TTR("Delete"), KEY_DELETE);
- tb = memnew(ToolButton);
- tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW, false));
- tb->set_tooltip(TTR("Add/Create a New Node"));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_child_node"));
- filter_hbc->add_child(tb);
- button_add = tb;
+ button_add = memnew(ToolButton);
+ button_add->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW, false));
+ button_add->set_tooltip(TTR("Add/Create a New Node"));
+ button_add->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_child_node"));
+ filter_hbc->add_child(button_add);
- tb = memnew(ToolButton);
- tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_INSTANCE, false));
- tb->set_tooltip(TTR("Instance a scene file as a Node. Creates an inherited scene if no root node exists."));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/instance_scene"));
- filter_hbc->add_child(tb);
- button_instance = tb;
+ button_instance = memnew(ToolButton);
+ button_instance->connect("pressed", this, "_tool_selected", make_binds(TOOL_INSTANCE, false));
+ button_instance->set_tooltip(TTR("Instance a scene file as a Node. Creates an inherited scene if no root node exists."));
+ button_instance->set_shortcut(ED_GET_SHORTCUT("scene_tree/instance_scene"));
+ filter_hbc->add_child(button_instance);
vbc->add_child(filter_hbc);
filter = memnew(LineEdit);
@@ -2551,21 +2551,19 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
filter->add_constant_override("minimum_spaces", 0);
filter->connect("text_changed", this, "_filter_changed");
- tb = memnew(ToolButton);
- tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_ATTACH_SCRIPT, false));
- tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
- filter_hbc->add_child(tb);
- tb->hide();
- button_create_script = tb;
-
- tb = memnew(ToolButton);
- tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
- tb->set_tooltip(TTR("Clear a script for the selected node."));
- tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script"));
- filter_hbc->add_child(tb);
- button_clear_script = tb;
- tb->hide();
+ button_create_script = memnew(ToolButton);
+ button_create_script->connect("pressed", this, "_tool_selected", make_binds(TOOL_ATTACH_SCRIPT, false));
+ button_create_script->set_tooltip(TTR("Attach a new or existing script for the selected node."));
+ button_create_script->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
+ filter_hbc->add_child(button_create_script);
+ button_create_script->hide();
+
+ button_clear_script = memnew(ToolButton);
+ button_clear_script->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
+ button_clear_script->set_tooltip(TTR("Clear a script for the selected node."));
+ button_clear_script->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script"));
+ filter_hbc->add_child(button_clear_script);
+ button_clear_script->hide();
button_hb = memnew(HBoxContainer);
vbc->add_child(button_hb);
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 42272d0e6e..f2d11c2753 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -1121,22 +1121,17 @@ SceneTreeEditor::~SceneTreeEditor() {
void SceneTreeDialog::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- connect("confirmed", this, "_select");
- }
-
- if (p_what == NOTIFICATION_EXIT_TREE) {
- disconnect("confirmed", this, "_select");
- }
- if (p_what == NOTIFICATION_DRAW) {
-
- RID ci = get_canvas_item();
- get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
- }
-
- if (p_what == NOTIFICATION_VISIBILITY_CHANGED && is_visible_in_tree()) {
-
- tree->update_tree();
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ connect("confirmed", this, "_select");
+ } break;
+ case NOTIFICATION_EXIT_TREE: {
+ disconnect("confirmed", this, "_select");
+ } break;
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (is_visible_in_tree())
+ tree->update_tree();
+ } break;
}
}
@@ -1165,8 +1160,6 @@ SceneTreeDialog::SceneTreeDialog() {
tree = memnew(SceneTreeEditor(false, false, true));
add_child(tree);
- //set_child_rect(tree);
-
tree->get_scene_tree()->connect("item_activated", this, "_select");
}