summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp22
-rw-r--r--editor/editor_inspector.cpp10
-rw-r--r--editor/editor_inspector.h4
-rw-r--r--editor/fileserver/editor_file_server.cpp10
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp303
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h18
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp3
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp2
-rw-r--r--editor/project_export.cpp76
-rw-r--r--editor/project_export.h6
11 files changed, 334 insertions, 122 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 37d26d8e0f..f65825e395 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1253,14 +1253,14 @@ void AnimationTrackEdit::_notification(int p_what) {
float offset = animation->track_get_key_time(track, i) - timeline->get_value();
if (editor->is_key_selected(track, i) && editor->is_moving_selection()) {
- offset += editor->get_moving_selection_offset();
+ offset = editor->snap_time(offset + editor->get_moving_selection_offset());
}
offset = offset * scale + limit;
if (i < animation->track_get_key_count(track) - 1) {
float offset_n = animation->track_get_key_time(track, i + 1) - timeline->get_value();
if (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) {
- offset_n += editor->get_moving_selection_offset();
+ offset_n = editor->snap_time(offset_n + editor->get_moving_selection_offset());
}
offset_n = offset_n * scale + limit;
@@ -3187,7 +3187,8 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo
case Animation::TYPE_ANIMATION: {
value = p_id.value;
} break;
- default: {}
+ default: {
+ }
}
undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_id.track_idx, time, value);
@@ -3876,9 +3877,7 @@ void AnimationTrackEditor::_move_selection_begin() {
void AnimationTrackEditor::_move_selection(float p_offset) {
moving_selection_offset = p_offset;
- if (snap->is_pressed() && step->get_value() != 0) {
- moving_selection_offset = Math::stepify(moving_selection_offset, step->get_value());
- }
+
for (int i = 0; i < track_edits.size(); i++) {
track_edits[i]->update();
}
@@ -3998,7 +3997,7 @@ void AnimationTrackEditor::_move_selection_commit() {
// 2- remove overlapped keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float newtime = E->get().pos + motion;
+ float newtime = snap_time(E->get().pos + motion);
int idx = animation->track_find_key(E->key().track, newtime, true);
if (idx == -1)
continue;
@@ -4022,7 +4021,7 @@ void AnimationTrackEditor::_move_selection_commit() {
// 3-move the keys (re insert them)
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float newpos = E->get().pos + motion;
+ float newpos = snap_time(E->get().pos + motion);
/*
if (newpos<0)
continue; //no add at the beginning
@@ -4033,7 +4032,7 @@ void AnimationTrackEditor::_move_selection_commit() {
// 4-(undo) remove inserted keys
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float newpos = E->get().pos + motion;
+ float newpos = snap_time(E->get().pos + motion);
/*
if (newpos<0)
continue; //no remove what no inserted
@@ -4069,7 +4068,7 @@ void AnimationTrackEditor::_move_selection_commit() {
for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
float oldpos = E->get().pos;
- float newpos = oldpos + motion;
+ float newpos = snap_time(oldpos + motion);
//if (newpos>=0)
undo_redo->add_do_method(this, "_select_at_anim", animation, E->key().track, newpos);
undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos);
@@ -4346,7 +4345,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
case Animation::TYPE_METHOD: text += " (Methods)"; break;
case Animation::TYPE_BEZIER: text += " (Bezier)"; break;
case Animation::TYPE_AUDIO: text += " (Audio)"; break;
- default: {};
+ default: {
+ };
}
TreeItem *it = track_copy_select->create_item(troot);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 8be4a118e6..d6f337cc20 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -626,7 +626,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
}
if (keying_rect.has_point(mb->get_position())) {
- emit_signal("property_keyed", property);
+ emit_signal("property_keyed", property, use_keying_next());
if (use_keying_next()) {
call_deferred("emit_signal", "property_changed", property, object->get(property).operator int64_t() + 1);
@@ -2030,20 +2030,20 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array
changing--;
}
-void EditorInspector::_property_keyed(const String &p_path) {
+void EditorInspector::_property_keyed(const String &p_path, bool p_advance) {
if (!object)
return;
- emit_signal("property_keyed", p_path, object->get(p_path), true); //second param is deprecated
+ emit_signal("property_keyed", p_path, object->get(p_path), p_advance); //second param is deprecated
}
-void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value) {
+void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance) {
if (!object)
return;
- emit_signal("property_keyed", p_path, p_value, false); //second param is deprecated
+ emit_signal("property_keyed", p_path, p_value, p_advance); //second param is deprecated
}
void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index 57d1ab6fb3..00841178bd 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -295,8 +295,8 @@ class EditorInspector : public ScrollContainer {
void _property_changed(const String &p_path, const Variant &p_value, bool changing = false);
void _property_changed_update_all(const String &p_path, const Variant &p_value);
void _multiple_properties_changed(Vector<String> p_paths, Array p_values);
- void _property_keyed(const String &p_path);
- void _property_keyed_with_value(const String &p_path, const Variant &p_value);
+ void _property_keyed(const String &p_path, bool p_advance);
+ void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance);
void _property_checked(const String &p_path, bool p_checked);
diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp
index 27fe716855..306f047860 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -150,13 +150,13 @@ void EditorFileServer::_subthread_start(void *s) {
s.parse_utf8(fileutf8.ptr());
if (cmd == FileAccessNetwork::COMMAND_FILE_EXISTS) {
- DEBUG_PRINT("FILE EXISTS: " + s);
+ print_verbose("FILE EXISTS: " + s);
}
if (cmd == FileAccessNetwork::COMMAND_GET_MODTIME) {
- DEBUG_PRINT("MOD TIME: " + s);
+ print_verbose("MOD TIME: " + s);
}
if (cmd == FileAccessNetwork::COMMAND_OPEN_FILE) {
- DEBUG_PRINT("OPEN: " + s);
+ print_verbose("OPEN: " + s);
}
if (!s.begins_with("res://")) {
@@ -243,7 +243,7 @@ void EditorFileServer::_subthread_start(void *s) {
int read = cd->files[id]->get_buffer(buf.ptrw(), blocklen);
ERR_CONTINUE(read < 0);
- DEBUG_PRINT("GET BLOCK - offset: " + itos(offset) + ", blocklen: " + itos(blocklen));
+ print_verbose("GET BLOCK - offset: " + itos(offset) + ", blocklen: " + itos(blocklen));
//not found, continue
encode_uint32(id, buf4);
@@ -259,7 +259,7 @@ void EditorFileServer::_subthread_start(void *s) {
} break;
case FileAccessNetwork::COMMAND_CLOSE: {
- DEBUG_PRINT("CLOSED");
+ print_verbose("CLOSED");
ERR_CONTINUE(!cd->files.has(id));
memdelete(cd->files[id]);
cd->files.erase(id);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 45f7f36cbd..a0763e03f1 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -179,8 +179,21 @@ void CanvasItemEditor::_snap_if_closer_float(float p_value, float p_target_snap,
}
}
-bool CanvasItemEditor::_is_node_editable(const Node *p_node) {
- return (!(p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_")) && !(ClassDB::is_parent_class(p_node->get_parent()->get_class_name(), "Container") && ClassDB::is_parent_class(p_node->get_class_name(), "Control")));
+bool CanvasItemEditor::_is_node_locked(const Node *p_node) {
+ return p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_");
+}
+
+bool CanvasItemEditor::_is_node_movable(const Node *p_node, bool p_popup_warning) {
+ if (_is_node_locked(p_node)) {
+ return false;
+ }
+ if (Object::cast_to<Control>(p_node) && Object::cast_to<Container>(p_node->get_parent())) {
+ if (p_popup_warning) {
+ _popup_warning_temporarily(warning_child_of_container, 3.0);
+ }
+ return false;
+ }
+ return true;
}
void CanvasItemEditor::_snap_if_closer_point(Point2 p_value, Point2 p_target_snap, Point2 &r_current_snap, bool (&r_snapped)[2], real_t rotation, float p_radius) {
@@ -415,7 +428,7 @@ void CanvasItemEditor::_expand_encompassing_rect_using_children(Rect2 &r_rect, c
}
}
- if (canvas_item && canvas_item->is_visible_in_tree() && (include_locked_nodes || !_is_node_editable(canvas_item))) {
+ if (canvas_item && canvas_item->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(canvas_item))) {
Transform2D xform = p_parent_xform * p_canvas_xform * canvas_item->get_transform();
Rect2 rect = canvas_item->_edit_get_rect();
if (r_first) {
@@ -437,7 +450,7 @@ Rect2 CanvasItemEditor::_get_encompassing_rect(const Node *p_node) {
return rect;
}
-void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, int p_limit, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
+void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
if (!p_node)
return;
if (Object::cast_to<Viewport>(p_node))
@@ -449,16 +462,14 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
if (canvas_item) {
if (!canvas_item->is_set_as_toplevel()) {
- _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
} else {
- _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, canvas_item->get_transform(), p_canvas_xform);
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, canvas_item->get_transform(), p_canvas_xform);
}
} else {
CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
- _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, Transform2D(), cl ? cl->get_transform() : p_canvas_xform);
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, Transform2D(), cl ? cl->get_transform() : p_canvas_xform);
}
- if (p_limit != 0 && r_items.size() >= p_limit)
- return;
}
if (canvas_item && canvas_item->is_visible_in_tree()) {
@@ -478,11 +489,11 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
return;
}
-void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, int p_limit) {
+void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items) {
Node *scene = editor->get_edited_scene();
- _find_canvas_items_at_pos(p_pos, scene, r_items, p_limit);
+ _find_canvas_items_at_pos(p_pos, scene, r_items);
//Remove invalid results
for (int i = 0; i < r_items.size(); i++) {
@@ -513,7 +524,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
}
//Remove the item if invalid
- if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || !_is_node_editable(canvas_item)) {
+ if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || _is_node_locked(canvas_item)) {
r_items.remove(i);
i--;
} else {
@@ -614,7 +625,7 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
bool editable = p_node == scene || p_node->get_owner() == scene || scene->is_editable_instance(p_node->get_owner());
bool lock_children = p_node->has_meta("_edit_group_") && p_node->get_meta("_edit_group_");
- bool locked = !_is_node_editable(p_node);
+ bool locked = _is_node_locked(p_node);
if (!lock_children || !editable) {
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
@@ -681,7 +692,7 @@ List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retreive_lock
List<CanvasItem *> selection;
for (Map<Node *, Object *>::Element *E = editor_selection->get_selection().front(); E; E = E->next()) {
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key());
- if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retreive_locked || _is_node_editable(canvas_item))) {
+ if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retreive_locked || !_is_node_locked(canvas_item))) {
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (se) {
selection.push_back(canvas_item);
@@ -1287,18 +1298,28 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
// Start rotation
if (drag_type == DRAG_NONE) {
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
- drag_selection = _get_edited_canvas_items();
- if (drag_selection.size() > 0 && ((b->get_control() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE)) {
- drag_type = DRAG_ROTATE;
- drag_from = transform.affine_inverse().xform(b->get_position());
- CanvasItem *canvas_item = drag_selection[0];
- if (canvas_item->_edit_use_pivot()) {
- drag_rotation_center = canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_pivot());
- } else {
- drag_rotation_center = canvas_item->get_global_transform_with_canvas().get_origin();
+ if ((b->get_control() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
+ List<CanvasItem *> selection = _get_edited_canvas_items();
+
+ // Remove not movable nodes
+ for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
+ if (!_is_node_movable(E->get(), true))
+ selection.erase(E);
+ }
+
+ drag_selection = selection;
+ if (drag_selection.size() > 0) {
+ drag_type = DRAG_ROTATE;
+ drag_from = transform.affine_inverse().xform(b->get_position());
+ CanvasItem *canvas_item = drag_selection[0];
+ if (canvas_item->_edit_use_pivot()) {
+ drag_rotation_center = canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_pivot());
+ } else {
+ drag_rotation_center = canvas_item->get_global_transform_with_canvas().get_origin();
+ }
+ _save_canvas_item_state(drag_selection);
+ return true;
}
- _save_canvas_item_state(drag_selection);
- return true;
}
}
}
@@ -1361,7 +1382,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
Control *control = Object::cast_to<Control>(selection[0]);
- if (control && !Object::cast_to<Container>(control->get_parent())) {
+ if (control && _is_node_movable(control)) {
Vector2 anchor_pos[4];
anchor_pos[0] = Vector2(control->get_anchor(MARGIN_LEFT), control->get_anchor(MARGIN_TOP));
anchor_pos[1] = Vector2(control->get_anchor(MARGIN_RIGHT), control->get_anchor(MARGIN_TOP));
@@ -1480,7 +1501,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
CanvasItem *canvas_item = selection[0];
- if (canvas_item->_edit_use_rect()) {
+ if (canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) {
Rect2 rect = canvas_item->_edit_get_rect();
Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
@@ -1648,27 +1669,30 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
if (selection.size() == 1) {
CanvasItem *canvas_item = selection[0];
- Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
- Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
+ if (_is_node_movable(canvas_item)) {
- drag_type = DRAG_SCALE_BOTH;
+ Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
+ Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
- Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
- Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
- drag_type = DRAG_SCALE_X;
- }
- Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
- drag_type = DRAG_SCALE_Y;
- }
+ drag_type = DRAG_SCALE_BOTH;
- drag_from = transform.affine_inverse().xform(b->get_position());
- drag_selection = List<CanvasItem *>();
- drag_selection.push_back(canvas_item);
- _save_canvas_item_state(drag_selection);
- return true;
+ Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
+ Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ if (x_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
+ drag_type = DRAG_SCALE_X;
+ }
+ Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ if (y_handle_rect.has_point(simple_xform.affine_inverse().xform(b->get_position()))) {
+ drag_type = DRAG_SCALE_Y;
+ }
+
+ drag_from = transform.affine_inverse().xform(b->get_position());
+ drag_selection = List<CanvasItem *>();
+ drag_selection.push_back(canvas_item);
+ _save_canvas_item_state(drag_selection);
+ return true;
+ }
}
}
}
@@ -1747,12 +1771,22 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
if (drag_type == DRAG_NONE) {
//Start moving the nodes
if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
- List<CanvasItem *> selection = _get_edited_canvas_items();
- if (((b->get_alt() && !b->get_control()) || tool == TOOL_MOVE) && selection.size() > 0) {
- drag_type = DRAG_MOVE;
- drag_from = transform.affine_inverse().xform(b->get_position());
- drag_selection = selection;
- _save_canvas_item_state(drag_selection);
+ if ((b->get_alt() && !b->get_control()) || tool == TOOL_MOVE) {
+ List<CanvasItem *> selection = _get_edited_canvas_items();
+
+ // Remove not movable nodes
+ for (int i = 0; i < selection.size(); i++) {
+ if (!_is_node_movable(selection[i], true)) {
+ selection.erase(selection[i]);
+ }
+ }
+
+ if (selection.size() > 0) {
+ drag_type = DRAG_MOVE;
+ drag_from = transform.affine_inverse().xform(b->get_position());
+ drag_selection = selection;
+ _save_canvas_item_state(drag_selection);
+ }
return true;
}
}
@@ -2002,7 +2036,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
Vector<_SelectResult> selection;
// Retrieve the items
- _get_canvas_items_at_pos(click, selection, editor_selection->get_selection().empty() ? 1 : 0);
+ _get_canvas_items_at_pos(click, selection);
// Retrieve the bones
_get_bones_at_pos(click, selection);
@@ -2030,10 +2064,19 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
// Drag the node(s) if requested
List<CanvasItem *> selection = _get_edited_canvas_items();
- drag_type = DRAG_MOVE;
- drag_selection = selection;
- drag_from = click;
- _save_canvas_item_state(drag_selection);
+ // Remove not movable nodes
+ for (int i = 0; i < selection.size(); i++) {
+ if (!_is_node_movable(selection[i], true)) {
+ selection.erase(selection[i]);
+ }
+ }
+
+ if (selection.size() > 0) {
+ drag_type = DRAG_MOVE;
+ drag_selection = selection;
+ drag_from = click;
+ _save_canvas_item_state(drag_selection);
+ }
}
// Select the item
return true;
@@ -2166,6 +2209,8 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
//printf("Zoom or pan\n");
} else if ((accepted = _gui_input_select(p_event))) {
//printf("Selection\n");
+ } else {
+ //printf("Not accepted\n");
}
if (accepted)
@@ -2696,12 +2741,12 @@ void CanvasItemEditor::_draw_selection() {
// Draw control-related helpers
Control *control = Object::cast_to<Control>(canvas_item);
- if (control) {
+ if (control && _is_node_movable(control)) {
_draw_control_helpers(control);
}
// Draw the resize handles
- if (tool == TOOL_SELECT && canvas_item->_edit_use_rect()) {
+ if (tool == TOOL_SELECT && canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) {
Rect2 rect = canvas_item->_edit_get_rect();
Vector2 endpoints[4] = {
xform.xform(rect.position),
@@ -2729,40 +2774,41 @@ void CanvasItemEditor::_draw_selection() {
bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
if ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y) {
-
- Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
- Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
-
- Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
- bool uniform = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
- Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom;
-
- if (drag_type == DRAG_SCALE_X) {
- scale_factor.x += offset.x;
- if (uniform) {
- scale_factor.y += offset.x;
- }
- } else if (drag_type == DRAG_SCALE_Y) {
- scale_factor.y -= offset.y;
- if (uniform) {
- scale_factor.x -= offset.y;
+ if (_is_node_movable(canvas_item)) {
+ Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized();
+ Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
+
+ Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE);
+ bool uniform = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+ Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom;
+
+ if (drag_type == DRAG_SCALE_X) {
+ scale_factor.x += offset.x;
+ if (uniform) {
+ scale_factor.y += offset.x;
+ }
+ } else if (drag_type == DRAG_SCALE_Y) {
+ scale_factor.y -= offset.y;
+ if (uniform) {
+ scale_factor.x -= offset.y;
+ }
}
- }
- //scale_factor *= zoom;
+ //scale_factor *= zoom;
- viewport->draw_set_transform_matrix(simple_xform);
- Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- Color x_axis_color(1.0, 0.4, 0.4, 0.6);
- viewport->draw_rect(x_handle_rect, x_axis_color);
- viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), x_axis_color);
+ viewport->draw_set_transform_matrix(simple_xform);
+ Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ Color x_axis_color(1.0, 0.4, 0.4, 0.6);
+ viewport->draw_rect(x_handle_rect, x_axis_color);
+ viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), x_axis_color);
- Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
- Color y_axis_color(0.4, 1.0, 0.4, 0.6);
- viewport->draw_rect(y_handle_rect, y_axis_color);
- viewport->draw_line(Point2(), Point2(0, -scale_factor.y * EDSCALE), y_axis_color);
+ Rect2 y_handle_rect = Rect2(-5 * EDSCALE, -(scale_factor.y + 10) * EDSCALE, 10 * EDSCALE, 10 * EDSCALE);
+ Color y_axis_color(0.4, 1.0, 0.4, 0.6);
+ viewport->draw_rect(y_handle_rect, y_axis_color);
+ viewport->draw_line(Point2(), Point2(0, -scale_factor.y * EDSCALE), y_axis_color);
- viewport->draw_set_transform_matrix(viewport->get_transform());
+ viewport->draw_set_transform_matrix(viewport->get_transform());
+ }
}
}
}
@@ -2938,7 +2984,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
_draw_invisible_nodes_positions(p_node->get_child(i), parent_xform, canvas_xform);
}
- if (canvas_item && !canvas_item->_edit_use_rect() && (!editor_selection->is_selected(canvas_item) || !_is_node_editable(canvas_item))) {
+ if (canvas_item && !canvas_item->_edit_use_rect() && (!editor_selection->is_selected(canvas_item) || _is_node_locked(canvas_item))) {
Transform2D xform = transform * canvas_xform * parent_xform;
// Draw the node's position
@@ -3127,6 +3173,8 @@ void CanvasItemEditor::_draw_viewport() {
group_button->set_disabled(selection.empty());
ungroup_button->set_visible(all_group);
+ info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+
_draw_grid();
_draw_selection();
_draw_axis();
@@ -3355,11 +3403,14 @@ void CanvasItemEditor::_notification(int p_what) {
void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
- drag_type = DRAG_NONE;
+ Array selection = editor_selection->get_selected_nodes();
+ if (selection.size() != 1 || (Node *)selection[0] != p_canvas_item) {
+ drag_type = DRAG_NONE;
- // Clear the selection
- editor_selection->clear(); //_clear_canvas_items();
- editor_selection->add_node(p_canvas_item);
+ // Clear the selection
+ editor_selection->clear(); //_clear_canvas_items();
+ editor_selection->add_node(p_canvas_item);
+ }
}
void CanvasItemEditor::_queue_update_bone_list() {
@@ -3491,6 +3542,35 @@ void CanvasItemEditor::_update_scrollbars() {
updating_scroll = false;
}
+void CanvasItemEditor::_popup_warning_depop(Control *p_control) {
+ ERR_FAIL_COND(!popup_temporarily_timers.has(p_control));
+
+ Timer *timer = popup_temporarily_timers[p_control];
+ p_control->hide();
+ remove_child(timer);
+ popup_temporarily_timers.erase(p_control);
+ memdelete(timer);
+ info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+}
+
+void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const float p_duration) {
+ Timer *timer;
+ if (!popup_temporarily_timers.has(p_control)) {
+ timer = memnew(Timer);
+ timer->connect("timeout", this, "_popup_warning_depop", varray(p_control));
+ timer->set_one_shot(true);
+ add_child(timer);
+
+ popup_temporarily_timers[p_control] = timer;
+ } else {
+ timer = popup_temporarily_timers[p_control];
+ }
+
+ timer->start(p_duration);
+ p_control->show();
+ info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+}
+
void CanvasItemEditor::_update_scroll(float) {
if (updating_scroll)
@@ -4197,7 +4277,7 @@ void CanvasItemEditor::_bind_methods() {
ClassDB::bind_method("_snap_changed", &CanvasItemEditor::_snap_changed);
ClassDB::bind_method("_update_bone_list", &CanvasItemEditor::_update_bone_list);
ClassDB::bind_method("_tree_changed", &CanvasItemEditor::_tree_changed);
-
+ ClassDB::bind_method("_popup_warning_depop", &CanvasItemEditor::_popup_warning_depop);
ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &CanvasItemEditor::_selection_result_pressed);
ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &CanvasItemEditor::_selection_menu_hide);
ClassDB::bind_method(D_METHOD("set_state"), &CanvasItemEditor::set_state);
@@ -4383,7 +4463,22 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
viewport->update();
}
+void CanvasItemEditor::add_control_to_info_overlay(Control *p_control) {
+ ERR_FAIL_COND(!p_control);
+
+ p_control->set_h_size_flags(p_control->get_h_size_flags() & ~Control::SIZE_EXPAND_FILL);
+ info_overlay->add_child(p_control);
+ info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+}
+
+void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) {
+
+ info_overlay->remove_child(p_control);
+ info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+}
+
void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) {
+ ERR_FAIL_COND(!p_control);
hb->add_child(p_control);
}
@@ -4452,6 +4547,28 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
viewport->connect("draw", this, "_draw_viewport");
viewport->connect("gui_input", this, "_gui_input_viewport");
+ info_overlay = memnew(VBoxContainer);
+ info_overlay->set_anchors_and_margins_preset(Control::PRESET_BOTTOM_LEFT);
+ info_overlay->set_margin(MARGIN_LEFT, 10);
+ info_overlay->set_margin(MARGIN_BOTTOM, -15);
+ info_overlay->set_v_grow_direction(Control::GROW_DIRECTION_BEGIN);
+ info_overlay->add_constant_override("separation", 10);
+ viewport_scrollable->add_child(info_overlay);
+
+ Theme *info_overlay_theme = memnew(Theme);
+ info_overlay_theme->copy_default_theme();
+ info_overlay->set_theme(info_overlay_theme);
+
+ StyleBoxFlat *info_overlay_label_stylebox = memnew(StyleBoxFlat);
+ info_overlay_label_stylebox->set_bg_color(Color(0.0, 0.0, 0.0, 0.2));
+ info_overlay_label_stylebox->set_expand_margin_size_all(4);
+ info_overlay_theme->set_stylebox("normal", "Label", info_overlay_label_stylebox);
+
+ warning_child_of_container = memnew(Label);
+ warning_child_of_container->hide();
+ warning_child_of_container->set_text("Warning: Children of a container get their position and size determined only by their parent");
+ add_control_to_info_overlay(warning_child_of_container);
+
h_scroll = memnew(HScrollBar);
viewport->add_child(h_scroll);
h_scroll->connect("value_changed", this, "_update_scroll");
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index dc7b74112f..59777fb085 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -220,6 +220,11 @@ private:
ToolButton *zoom_reset;
ToolButton *zoom_plus;
+ Map<Control *, Timer *> popup_temporarily_timers;
+
+ Label *warning_child_of_container;
+ VBoxContainer *info_overlay;
+
Transform2D transform;
bool show_grid;
bool show_rulers;
@@ -369,9 +374,10 @@ private:
Ref<ShortCut> multiply_grid_step_shortcut;
Ref<ShortCut> divide_grid_step_shortcut;
- bool _is_node_editable(const Node *p_node);
- void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, int p_limit = 0, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
- void _get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, int p_limit = 0);
+ bool _is_node_locked(const Node *p_node);
+ bool _is_node_movable(const Node *p_node, bool p_popup_warning = false);
+ void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
+ void _get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items);
void _get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items);
void _find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_node, List<CanvasItem *> *r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
@@ -477,6 +483,9 @@ private:
void _update_bone_list();
void _tree_changed(Node *);
+ void _popup_warning_temporarily(Control *p_control, const float p_duration);
+ void _popup_warning_depop(Control *p_control);
+
friend class CanvasItemEditorPlugin;
protected:
@@ -542,6 +551,9 @@ public:
void add_control_to_menu_panel(Control *p_control);
void remove_control_from_menu_panel(Control *p_control);
+ void add_control_to_info_overlay(Control *p_control);
+ void remove_control_from_info_overlay(Control *p_control);
+
HSplitContainer *get_palette_split();
VSplitContainer *get_bottom_split();
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 33e1f7c6a3..7c3e524d89 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -846,7 +846,8 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
p->set_item_checked(0, true);
p->connect("id_pressed", this, "_set_snap_mode");
hb_grid = memnew(HBoxContainer);
- hb_tools->add_child(hb_grid);
+ //hb_tools->add_child(hb_grid);
+ main_vb->add_child(hb_grid);
hb_grid->add_child(memnew(VSeparator));
hb_grid->add_child(memnew(Label(TTR("Offset:"))));
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 635813f4b2..213cd2ce1a 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -300,7 +300,7 @@ void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p
}
node->set_cell(p_pos.x, p_pos.y, p_value, p_flip_h, p_flip_v, p_transpose);
- if (manual_autotile || node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE) {
+ if (manual_autotile || (p_value != -1 && node->get_tileset()->tile_get_tile_mode(p_value) == TileSet::ATLAS_TILE)) {
if (current != -1) {
node->set_cell_autotile_coord(p_pos.x, p_pos.y, position);
}
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 01768c201e..d0e0b3e006 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -958,7 +958,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
Ref<InputEventMouseMotion> mm = p_ie;
if (mb.is_valid()) {
- if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && !creating_shape) {
if (!current_tile_region.has_point(mb->get_position())) {
List<int> *tiles = new List<int>();
tileset->get_tile_list(tiles);
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index f4f1f8068d..27d8bd97fb 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -165,6 +165,27 @@ void ProjectExportDialog::_update_presets() {
updating = false;
}
+void ProjectExportDialog::_update_export_all() {
+
+ bool can_export = EditorExport::get_singleton()->get_export_preset_count() > 0 ? true : false;
+
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
+ Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i);
+ bool needs_templates;
+ String error;
+ if (preset->get_export_path() == "" || !preset->get_platform()->can_export(preset, error, needs_templates)) {
+ can_export = false;
+ break;
+ }
+ }
+
+ if (can_export) {
+ export_all_button->set_disabled(false);
+ } else {
+ export_all_button->set_disabled(true);
+ }
+}
+
void ProjectExportDialog::_edit_preset(int p_index) {
if (p_index < 0 || p_index >= presets->get_item_count()) {
@@ -267,6 +288,7 @@ void ProjectExportDialog::_edit_preset(int p_index) {
custom_features->set_text(current->get_custom_features());
_update_feature_list();
+ _update_export_all();
updating = false;
}
@@ -864,6 +886,42 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) {
}
}
+void ProjectExportDialog::_export_all_dialog() {
+
+ export_all_dialog->show();
+ export_all_dialog->popup_centered_minsize(Size2(300, 80));
+}
+
+void ProjectExportDialog::_export_all_dialog_action(const String &p_str) {
+
+ export_all_dialog->hide();
+
+ _export_all(p_str == "release" ? false : true);
+}
+
+void ProjectExportDialog::_export_all(bool p_debug) {
+
+ String mode = p_debug ? TTR("Debug") : TTR("Release");
+ EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count());
+
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
+ Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i);
+ ERR_FAIL_COND(preset.is_null());
+ Ref<EditorExportPlatform> platform = preset->get_platform();
+ ERR_FAIL_COND(platform.is_null());
+
+ ep.step(preset->get_name(), i);
+
+ Error err = platform->export_project(preset, p_debug, preset->get_export_path(), 0);
+ if (err != OK) {
+ error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " " + platform->get_name());
+ error_dialog->show();
+ error_dialog->popup_centered_minsize(Size2(300, 80));
+ ERR_PRINT("Failed to export project");
+ }
+ }
+}
+
void ProjectExportDialog::_bind_methods() {
ClassDB::bind_method("_add_preset", &ProjectExportDialog::_add_preset);
@@ -890,6 +948,9 @@ void ProjectExportDialog::_bind_methods() {
ClassDB::bind_method("_validate_export_path", &ProjectExportDialog::_validate_export_path);
ClassDB::bind_method("_export_project", &ProjectExportDialog::_export_project);
ClassDB::bind_method("_export_project_to_path", &ProjectExportDialog::_export_project_to_path);
+ ClassDB::bind_method("_export_all", &ProjectExportDialog::_export_all);
+ ClassDB::bind_method("_export_all_dialog", &ProjectExportDialog::_export_all_dialog);
+ ClassDB::bind_method("_export_all_dialog_action", &ProjectExportDialog::_export_all_dialog_action);
ClassDB::bind_method("_custom_features_changed", &ProjectExportDialog::_custom_features_changed);
ClassDB::bind_method("_tab_changed", &ProjectExportDialog::_tab_changed);
}
@@ -1059,6 +1120,19 @@ ProjectExportDialog::ProjectExportDialog() {
// Disable initially before we select a valid preset
export_button->set_disabled(true);
+ export_all_dialog = memnew(ConfirmationDialog);
+ add_child(export_all_dialog);
+ export_all_dialog->set_title("Export All");
+ export_all_dialog->set_text(TTR("Export mode?"));
+ export_all_dialog->get_ok()->hide();
+ export_all_dialog->add_button(TTR("Debug"), true, "debug");
+ export_all_dialog->add_button(TTR("Release"), true, "release");
+ export_all_dialog->connect("custom_action", this, "_export_all_dialog_action");
+
+ export_all_button = add_button(TTR("Export All"), !OS::get_singleton()->get_swap_ok_cancel(), "export");
+ export_all_button->connect("pressed", this, "_export_all_dialog");
+ export_all_button->set_disabled(true);
+
export_pck_zip = memnew(FileDialog);
export_pck_zip->add_filter("*.zip ; ZIP File");
export_pck_zip->add_filter("*.pck ; Godot Game Pack");
@@ -1122,6 +1196,8 @@ ProjectExportDialog::ProjectExportDialog() {
default_filename = "UnnamedProject";
}
}
+
+ _update_export_all();
}
ProjectExportDialog::~ProjectExportDialog() {
diff --git a/editor/project_export.h b/editor/project_export.h
index 23a6db8942..7009968138 100644
--- a/editor/project_export.h
+++ b/editor/project_export.h
@@ -93,6 +93,8 @@ private:
ConfirmationDialog *patch_erase;
Button *export_button;
+ Button *export_all_button;
+ AcceptDialog *export_all_dialog;
LineEdit *custom_features;
RichTextLabel *custom_feature_display;
@@ -114,6 +116,7 @@ private:
void _duplicate_preset();
void _delete_preset();
void _delete_preset_confirm();
+ void _update_export_all();
void _update_presets();
@@ -143,6 +146,9 @@ private:
void _validate_export_path(const String &p_path);
void _export_project();
void _export_project_to_path(const String &p_path);
+ void _export_all_dialog();
+ void _export_all_dialog_action(const String &p_str);
+ void _export_all(bool p_debug);
void _update_feature_list();
void _custom_features_changed(const String &p_text);