You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Add per-scene UndoRedo
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_properties.h"
|
||||
#include "editor/editor_scale.h"
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
|
||||
void TileDataEditor::_tile_set_changed_plan_update() {
|
||||
_tile_set_changed_update_needed = true;
|
||||
@@ -248,7 +249,14 @@ void GenericTilePolygonEditor::_zoom_changed() {
|
||||
}
|
||||
|
||||
void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
|
||||
UndoRedo *undo_redo = use_undo_redo ? editor_undo_redo : memnew(UndoRedo);
|
||||
Ref<EditorUndoRedoManager> undo_redo;
|
||||
if (use_undo_redo) {
|
||||
undo_redo = editor_undo_redo;
|
||||
} else {
|
||||
// This nice hack allows for discarding undo actions without making code too complex.
|
||||
undo_redo.instantiate();
|
||||
}
|
||||
|
||||
switch (p_item_pressed) {
|
||||
case RESET_TO_DEFAULT_TILE: {
|
||||
undo_redo->create_action(TTR("Reset Polygons"));
|
||||
@@ -322,9 +330,6 @@ void GenericTilePolygonEditor::_advanced_menu_item_pressed(int p_item_pressed) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!use_undo_redo) {
|
||||
memdelete(undo_redo);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericTilePolygonEditor::_grab_polygon_point(Vector2 p_pos, const Transform2D &p_polygon_xform, int &r_polygon_index, int &r_point_index) {
|
||||
@@ -409,7 +414,14 @@ void GenericTilePolygonEditor::_snap_to_half_pixel(Point2 &r_point) {
|
||||
}
|
||||
|
||||
void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) {
|
||||
UndoRedo *undo_redo = use_undo_redo ? editor_undo_redo : memnew(UndoRedo);
|
||||
Ref<EditorUndoRedoManager> undo_redo;
|
||||
if (use_undo_redo) {
|
||||
undo_redo = editor_undo_redo;
|
||||
} else {
|
||||
// This nice hack allows for discarding undo actions without making code too complex.
|
||||
undo_redo.instantiate();
|
||||
}
|
||||
|
||||
real_t grab_threshold = EDITOR_GET("editors/polygon_editor/point_grab_radius");
|
||||
|
||||
hovered_polygon_index = -1;
|
||||
@@ -600,10 +612,6 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event)
|
||||
}
|
||||
|
||||
base_control->update();
|
||||
|
||||
if (!use_undo_redo) {
|
||||
memdelete(undo_redo);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericTilePolygonEditor::set_use_undo_redo(bool p_use_undo_redo) {
|
||||
|
||||
Reference in New Issue
Block a user