Merge pull request #37412 from KoBeWi/great_tree_escape
Properly handle node remove via undo
This commit is contained in:
commit
0168709978
|
@ -39,6 +39,13 @@
|
||||||
#include "scene/resources/rectangle_shape_2d.h"
|
#include "scene/resources/rectangle_shape_2d.h"
|
||||||
#include "scene/resources/segment_shape_2d.h"
|
#include "scene/resources/segment_shape_2d.h"
|
||||||
|
|
||||||
|
void CollisionShape2DEditor::_node_removed(Node *p_node) {
|
||||||
|
|
||||||
|
if (p_node == node) {
|
||||||
|
node = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Variant CollisionShape2DEditor::get_handle_value(int idx) const {
|
Variant CollisionShape2DEditor::get_handle_value(int idx) const {
|
||||||
|
|
||||||
switch (shape_type) {
|
switch (shape_type) {
|
||||||
|
@ -525,6 +532,20 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CollisionShape2DEditor::_notification(int p_what) {
|
||||||
|
|
||||||
|
switch (p_what) {
|
||||||
|
|
||||||
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
get_tree()->connect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed));
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
|
get_tree()->disconnect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed));
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CollisionShape2DEditor::edit(Node *p_node) {
|
void CollisionShape2DEditor::edit(Node *p_node) {
|
||||||
|
|
||||||
if (!canvas_item_editor) {
|
if (!canvas_item_editor) {
|
||||||
|
|
|
@ -71,6 +71,8 @@ class CollisionShape2DEditor : public Control {
|
||||||
void _get_current_shape_type();
|
void _get_current_shape_type();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _notification(int p_what);
|
||||||
|
void _node_removed(Node *p_node);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -38,6 +38,13 @@
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "scene/gui/split_container.h"
|
#include "scene/gui/split_container.h"
|
||||||
|
|
||||||
|
void TileMapEditor::_node_removed(Node *p_node) {
|
||||||
|
|
||||||
|
if (p_node == node) {
|
||||||
|
node = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TileMapEditor::_notification(int p_what) {
|
void TileMapEditor::_notification(int p_what) {
|
||||||
|
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
|
@ -60,6 +67,7 @@ void TileMapEditor::_notification(int p_what) {
|
||||||
|
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
|
||||||
|
get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
|
||||||
paint_button->set_icon(get_theme_icon("Edit", "EditorIcons"));
|
paint_button->set_icon(get_theme_icon("Edit", "EditorIcons"));
|
||||||
bucket_fill_button->set_icon(get_theme_icon("Bucket", "EditorIcons"));
|
bucket_fill_button->set_icon(get_theme_icon("Bucket", "EditorIcons"));
|
||||||
picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
|
picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
|
||||||
|
@ -80,6 +88,10 @@ void TileMapEditor::_notification(int p_what) {
|
||||||
p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_theme_icon("Remove", "EditorIcons"));
|
p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_theme_icon("Remove", "EditorIcons"));
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
|
get_tree()->disconnect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,7 @@ class TileMapEditor : public VBoxContainer {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
void _node_removed(Node *p_node);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
CellOp _get_op_from_cell(const Point2i &p_pos);
|
CellOp _get_op_from_cell(const Point2i &p_pos);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue