summaryrefslogtreecommitdiff
path: root/src/editor/view2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor/view2d.cpp')
-rw-r--r--src/editor/view2d.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/editor/view2d.cpp b/src/editor/view2d.cpp
index 6814fd2..b68846e 100644
--- a/src/editor/view2d.cpp
+++ b/src/editor/view2d.cpp
@@ -433,7 +433,9 @@ void gui_editor_2dview_create_poly_from_drag( GUI_EDITOR_2DVIEW* view ) {
}
map_polygon_calc_bounds( &newp );
+ I32 poly_idx = editor->map->polygons.size;
editor->map->polygons.push( newp );
+ editor_undo_record_create_poly( editor, poly_idx );
gui_editor_2dview_check_bounds_preserve_view( view );
}
@@ -443,6 +445,7 @@ void gui_editor_2dview_create_wallpoly_from_drag( GUI_EDITOR_2DVIEW* view ) {
return;
I32 propid = gui_editor_2dview_find_or_create_wallpoly_propid();
+ I32 first_wall_idx = editor->map->walls.size;
F32 depth = gui_editor_2dview_placement_z();
F32 wallheight = gui_editor_2dview_wall_height();
@@ -459,6 +462,8 @@ void gui_editor_2dview_create_wallpoly_from_drag( GUI_EDITOR_2DVIEW* view ) {
wall.propid = propid;
editor->map->walls.push( wall );
}
+ I32 new_wall_count = editor->map->walls.size - first_wall_idx;
+ editor_undo_record_create_walls( editor, first_wall_idx, new_wall_count );
gui_editor_2dview_check_bounds_preserve_view( view );
}
@@ -1141,8 +1146,11 @@ void gui_editor_2dview_input_tool_wall( GUI_EDITOR_2DVIEW* view ) {
U8 m1 = gui_mbutton_down( 0 );
if( !m1 ) {
if( view->held ) {
+ if( view->pending_wall_undo_idx >= 0 )
+ editor_undo_record_create_walls( editor, view->pending_wall_undo_idx, 1 );
gui_editor_2dview_check_bounds_preserve_view( view );
}
+ view->pending_wall_undo_idx = -1;
view->held = 0;
view->curdrag = 0;
return;
@@ -1168,6 +1176,7 @@ void gui_editor_2dview_input_tool_wall( GUI_EDITOR_2DVIEW* view ) {
I32 idx = editor->map->walls.size;
editor->map->walls.push( neww );
+ view->pending_wall_undo_idx = idx;
view->curdrag = &editor->map->walls[idx].end;
view->held = 1;
@@ -1338,12 +1347,31 @@ void gui_editor_view2d_delete_obj( GUI_EDITOR_2DVIEW* view ) {
void gui_editor_2dview_key_input( GUI_EDITOR_2DVIEW* view ) {
static U8 del_held = 0;
+ static U8 undo_held = 0;
+ static U8 redo_held = 0;
if( kb_down( SDLK_DELETE ) && !input.mouselock ) {
if( !del_held )
gui_editor_view2d_delete_obj( view );
del_held = 1;
} else del_held = 0;
+
+ U8 ctrl = kb_down( SDLK_LCTRL ) || kb_down( SDLK_RCTRL );
+ U8 z = kb_down( SDLK_z );
+ if( ctrl && z && !input.mouselock ) {
+ if( !undo_held )
+ editor_undo( editor );
+
+ undo_held = 1;
+ } else undo_held = 0;
+
+ U8 r = kb_down( SDLK_r );
+ if( ctrl && r && !input.mouselock ) {
+ if( !redo_held )
+ editor_redo( editor );
+
+ redo_held = 1;
+ } else redo_held = 0;
}
void gui_editor_2dview_input_fn( void* ptr ) {
@@ -1469,6 +1497,7 @@ GUI_EDITOR_2DVIEW* gui_editor_2dview( I32 x, I32 y, I32 w, I32 h ) {
view->poly_drag = 0;
view->poly_start = { 0.f, 0.f };
view->poly_end = { 0.f, 0.f };
+ view->pending_wall_undo_idx = -1;
GUI_BASE* parent = gui_get_view();
if( !parent )