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.cpp138
1 files changed, 72 insertions, 66 deletions
diff --git a/src/editor/view2d.cpp b/src/editor/view2d.cpp
index f1b5b17..8bcd588 100644
--- a/src/editor/view2d.cpp
+++ b/src/editor/view2d.cpp
@@ -1,4 +1,5 @@
#include <math.h>
+#include "SDL_scancode.h"
#include "editor.h"
#include "../render/gl_2d.h"
#include "../game/object.h"
@@ -187,13 +188,15 @@ void gui_editor_2dview_select( GUI_EDITOR_2DVIEW* view, void* what, U8 seltype )
U8 gui_editor_2dview_is_gizmo_active( GUI_EDITOR_2DVIEW* view, void* what, U8 seltype ) {
GUI_EDITOR_PROPVIEW* props = editor->gui.props;
- if( props->seltype == EDITOR_SELECT_WALL && (seltype == EDITOR_SELECT_WVERTEX) ) {
- MAP_WALL* s = (MAP_WALL*)props->curselect;
- if( what == &s->start || what == &s->end )
+ for( auto& it : props->curselect ) {
+ if( it.seltype == EDITOR_SELECT_WALL && (seltype == EDITOR_SELECT_WVERTEX) ) {
+ MAP_WALL* s = (MAP_WALL*)it.obj;
+ if( what == &s->start || what == &s->end )
+ return 1;
+ }
+ else if( it.seltype == seltype && it.obj == what ) {
return 1;
- }
- else if( props->seltype == seltype && props->curselect == what ) {
- return 1;
+ }
}
if( view->curdrag ) {
@@ -830,9 +833,11 @@ void gui_editor_2dview_input_select_onmove( GUI_EDITOR_2DVIEW* view ) {
GUI_EDITOR_PROPVIEW* props = editor->gui.props;
// special case for dragging wall vertices, just always update
- U8 iswallv = props->seltype == EDITOR_SELECT_WALL && view->dragtype == EDITOR_SELECT_WVERTEX;
- if( props->curselect == view->curdrag || iswallv )
- gui_editor_propview_update( editor->gui.props );
+ for( auto& it : props->curselect ) {
+ U8 iswallv = it.seltype == EDITOR_SELECT_WALL && view->dragtype == EDITOR_SELECT_WVERTEX;
+ if( it.obj == view->curdrag || iswallv )
+ gui_editor_propview_update( editor->gui.props );
+ }
}
void gui_editor_2dview_input_select_drag_wall( GUI_EDITOR_2DVIEW* view ) {
@@ -955,7 +960,7 @@ void gui_editor_2dview_input_select_drag_origin( GUI_EDITOR_2DVIEW* view ) {
void gui_editor_2dview_input_select_ondrop( GUI_EDITOR_2DVIEW* view ) {
if( !view->dragmoved )
- gui_editor_propview_select( editor->gui.props, view->curdrag, view->dragtype );
+ gui_editor_propview_select( editor->gui.props, view->curdrag, view->dragtype, !input.keys[SDL_SCANCODE_LCTRL] );
view->curdrag = 0;
}
@@ -1389,76 +1394,77 @@ void gui_editor_2dview_input_tool_draw( GUI_EDITOR_2DVIEW* view ) {
}
void gui_editor_view2d_delete_obj( GUI_EDITOR_2DVIEW* view ) {
- void* it;
- U8 type;
-
+ LIST<GUI_EDITOR_PROPVIEW::PROPVIEW_SELECT> sel{};
if( view->curdrag && view->dragtype ) {
- it = view->curdrag;
- type = view->dragtype;
+ sel.push( {
+ .obj = view->curdrag,
+ .seltype = view->dragtype
+ } );
view->curdrag = 0;
view->dragtype = EDITOR_SELECT_NONE;
- } else if( editor->gui.props->curselect ) {
- it = editor->gui.props->curselect;
- type = editor->gui.props->seltype;
+ } else if( editor->gui.props->curselect.size ) {
view->curselect = 0;
view->seltype = EDITOR_SELECT_NONE;
+ sel = editor->gui.props->curselect;
+ editor->gui.props->curselect.clear();
+
+ gui_editor_propview_select( editor->gui.props, 0, 0 );
}
else return;
- U8 cleared = 1;
- switch( type ) {
- case EDITOR_SELECT_POLY: {
- I32 idx = editor->map->polygons.idx_of( (MAP_POLYGON*)it );
- if( idx != -1 )
- editor->map->polygons.erase( idx );
- } break;
- case EDITOR_SELECT_WALL: {
- I32 idx = editor->map->walls.idx_of( (MAP_WALL*)it );
- if( idx != -1 )
- editor->map->walls.erase( idx );
- }; break;
- case EDITOR_SELECT_SPRITE: {
- I32 idx = editor->map->sprites.idx_of( (MAP_SPRITE*)it );
- if( idx != -1 )
- editor->map->sprites.erase( idx );
- }; break;
- case EDITOR_SELECT_ENT: {
- I32 idx = editor->map->entities.idx_of( (MAP_ENTITY*)it );
- if( idx != -1 )
- editor->map->entities.erase( idx );
- }; break;
- case EDITOR_SELECT_PVERTEX: {
- I32 vidx = -1, idx = editor->map->polygons.idx_where( fn( MAP_POLYGON* p ) {
- vidx = p->vertices.idx_where( fn( MAP_VERTEX* v ) {
- return v == it;
+ for( auto& _it: sel ) {
+ void* it = _it.obj;
+ U8 type = _it.seltype;
+ switch( type ) {
+ case EDITOR_SELECT_POLY: {
+ I32 idx = editor->map->polygons.idx_of( (MAP_POLYGON*)it );
+ if( idx != -1 )
+ editor->map->polygons.erase( idx );
+ } break;
+ case EDITOR_SELECT_WALL: {
+ I32 idx = editor->map->walls.idx_of( (MAP_WALL*)it );
+ if( idx != -1 )
+ editor->map->walls.erase( idx );
+ }; break;
+ case EDITOR_SELECT_SPRITE: {
+ I32 idx = editor->map->sprites.idx_of( (MAP_SPRITE*)it );
+ if( idx != -1 )
+ editor->map->sprites.erase( idx );
+ }; break;
+ case EDITOR_SELECT_ENT: {
+ I32 idx = editor->map->entities.idx_of( (MAP_ENTITY*)it );
+ if( idx != -1 )
+ editor->map->entities.erase( idx );
+ }; break;
+ case EDITOR_SELECT_PVERTEX: {
+ I32 vidx = -1, idx = editor->map->polygons.idx_where( fn( MAP_POLYGON* p ) {
+ vidx = p->vertices.idx_where( fn( MAP_VERTEX* v ) {
+ return v == it;
+ } );
+ return vidx != -1;
} );
- return vidx != -1;
- } );
- if( idx != -1 && vidx != -1 ) {
- MAP_POLYGON* p = &editor->map->polygons[idx];
- if( p->vertices.size <= 3 ) {
- editor->map->polygons.erase( idx );
- break;
+ if( idx != -1 && vidx != -1 ) {
+ MAP_POLYGON* p = &editor->map->polygons[idx];
+ if( p->vertices.size <= 3 ) {
+ editor->map->polygons.erase( idx );
+ break;
+ }
+ editor->map->polygons[idx].vertices.erase( vidx );
}
- editor->map->polygons[idx].vertices.erase( vidx );
- }
- }; break;
- case EDITOR_SELECT_WVERTEX: {
- I32 idx = editor->map->walls.idx_where( fn( MAP_WALL* w ) {
- return &w->end == it || &w->start == it;
- } );
+ }; break;
+ case EDITOR_SELECT_WVERTEX: {
+ I32 idx = editor->map->walls.idx_where( fn( MAP_WALL* w ) {
+ return &w->end == it || &w->start == it;
+ } );
- if( idx != -1 )
- editor->map->walls.erase( idx );
- }; break;
- default:
- cleared = 0; break;
+ if( idx != -1 )
+ editor->map->walls.erase( idx );
+ }; break;
+ default: break;
+ }
}
- if( cleared && it == editor->gui.props->curselect ) {
- gui_editor_propview_select( editor->gui.props, 0, 0 );
- }
}
void gui_editor_2dview_key_input( GUI_EDITOR_2DVIEW* view ) {