summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/editor/properties.cpp105
-rw-r--r--src/editor/properties.h3
-rw-r--r--src/editor/view2d.cpp187
-rw-r--r--src/game/world/map.cpp3
-rw-r--r--src/gui/base.h6
-rw-r--r--src/gui/floatinput.cpp9
-rw-r--r--src/gui/vectorinput.cpp10
7 files changed, 205 insertions, 118 deletions
diff --git a/src/editor/properties.cpp b/src/editor/properties.cpp
index 0cc0e56..a9835e4 100644
--- a/src/editor/properties.cpp
+++ b/src/editor/properties.cpp
@@ -71,6 +71,28 @@ void gui_editor_propview_select( GUI_EDITOR_PROPVIEW* view, void* what, U8 selty
sel.seltype = EDITOR_SELECT_WALL;
}
+ if( seltype == EDITOR_SELECT_PVERTEX ) {
+ for( auto& it : view->curselect ) {
+ if( it.seltype == EDITOR_SELECT_POLY ) {
+ MAP_POLYGON* p = (MAP_POLYGON*)it.obj;
+ I32 i = p->vertices.idx_where( fn( MAP_VERTEX* v ) { return v == sel.obj; } );
+ if( i != -1 )
+ return;
+ }
+ }
+ }
+
+ if( seltype == EDITOR_SELECT_POLY ) {
+ MAP_POLYGON* p = (MAP_POLYGON*)sel.obj;
+ for( auto& it : view->curselect ) {
+ if( it.seltype == EDITOR_SELECT_PVERTEX ) {
+ I32 i = p->vertices.idx_where( fn( MAP_VERTEX* v ) { return v == sel.obj; } );
+ if( i != -1 )
+ view->curselect.erase( i );
+ }
+ }
+ }
+
if( view->curselect.idx_where( fn( PROPSELECT* p ) { return p->obj == sel.obj; } ) != -1 )
return;
@@ -144,9 +166,9 @@ struct TEXBTN_CB {
GL_TEX2D** texp;
};
-void gui_editor_propview_create_eobj_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space );
+void gui_editor_propview_create_eobj_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space, U8 val = 1 );
void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT* e, I32* x, I32* y, I32 w );
-void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space ) {
+void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 s, U8 val = 1 ) {
F32 action_x = propview_action_x( view );
I32 action2_x = propview_action2_x( view );
const char* n = prop->displayname;
@@ -159,32 +181,34 @@ void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO
switch( prop->type ) {
case EPROP_F32: { GUI_FLOATINPUT* in = gui_floatinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), min, max, step );
+ in->drawval = val;
in->cb = pfn( void* ptr ) {
GUI_FLOATINPUT* fin = (GUI_FLOATINPUT*)ptr;
gui_editor_propview_sync_props_fdiff( editor->gui.props, (EDITOR_PROP*)fin->cbextra, &fin->lastchange, 1 );
}; in->cbextra = prop;
- *y += (space+18);
+ *y += (s+18);
} break;
case EPROP_VEC2: case EPROP_VEC3: case EPROP_VEC4: { U32 c = prop->type - EPROP_VEC2 + 2;
- GUI_VECTORINPUT* in = gui_vectorinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), c, min, max, step, "xyzw", c == 2 ? "%.03f" : "%0.02f" );
+ GUI_VECTORINPUT* in = gui_vectorinput( *x, *y, w, n, (F32*)eprop_ptr( prop ), c, min, max, step, "xyzw", c == 2 ? "%.03f" : "%0.02f", val );
in->cb = pfn( void* ptr ) {
GUI_VECTORINPUT* vin = (GUI_VECTORINPUT*)ptr;
gui_editor_propview_sync_props_fdiff( editor->gui.props, (EDITOR_PROP*)vin->cbextra, vin->lastchange.data, vin->inputs.size );
}; in->cbextra = prop;
- *y += (space+18);
+ *y += (s+18);
} break;
case EPROP_CLR: { GUI_COLORINPUT* cin = gui_colorinput( *x, *y, w, n, (CLR*)eprop_ptr( prop ) );
cin->cb = pfn( void* ptr ) {
GUI_COLORINPUT* cin = (GUI_COLORINPUT*)ptr;
gui_editor_propview_sync_props_fdiff( editor->gui.props, (EDITOR_PROP*)cin->cbextra, cin->lastchange.data, cin->inputs.size );
}; cin->cbextra = prop;
- *y += (space+18);
+ *y += (s+18);
}break;
case EPROP_MAPPROP: {
MAP_PROPREF* ref = (MAP_PROPREF*)eprop_ptr( prop );
SURF_PROPS* props = map_get_props( editor->map, *ref );
- gui_label( *x, *y, "prop id: %d", *ref );
+ if( val ) gui_label( *x, *y, "prop id: %d", *ref );
+ else gui_label( *x, *y, "prop id: *" );
GUI_BUTTON* newprop = gui_button( action2_x, *y, 20, 20, "+", pfn( void* ptr ) {
GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
@@ -199,17 +223,19 @@ void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO
gui_editor_propview_update( editor->gui.props );
} ); newprop->extra = prop;
- GUI_BUTTON* goprop = gui_button( action_x, *y, 20, 20, "\x1A", pfn( void* ptr ) {
- GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
- gui_editor_propview_select( editor->gui.props, btn->extra, EDITOR_SELECT_SURFPROPS );
- } ); goprop->extra = props; *y += space;
-
+ if( val ) {
+ GUI_BUTTON* goprop = gui_button( action_x, *y, 20, 20, "\x1A", pfn( void* ptr ) {
+ GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
+ gui_editor_propview_select( editor->gui.props, btn->extra, EDITOR_SELECT_SURFPROPS );
+ } ); goprop->extra = props;
+ } *y += s;
*x += 10; gui_editor_propview_create_eobj_props( view, props, x, y, w - 10 ); *x -= 10;
} break;
case EPROP_TEXTURE: {
GL_TEX2D** tex = (GL_TEX2D**)eprop_ptr( prop );
- if( *tex ) gui_label( *x, *y, "%s: %s", n, (*tex)->name );
- else gui_label( *x, *y, "%s: none", n );
+ if( val && *tex ) gui_label( *x, *y, "%s: %s", n, (*tex)->name );
+ else if( !val ) gui_label( *x, *y, "%s: *", n );
+ else gui_label( *x, *y, "%s: none", n );
GUI_BUTTON* btn = gui_button( action_x, *y, 20, 20, "\x1A", cfn( void* ptr ) {
GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
GL_TEX2D** ptex = (GL_TEX2D**)btn->extra;
@@ -219,30 +245,33 @@ void gui_editor_propview_create_eobj_prop( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO
gui_editor_propview_sync_props_value( editor->gui.props, (EDITOR_PROP*)picker->cbextra );
gui_editor_propview_update( editor->gui.props );
}; picker->cbextra = prop;
- } ); btn->extra = tex; *y += space;
+ } ); btn->extra = tex; *y += s;
} break;
case EPROP_VERTEX_LIST: {
LIST<MAP_VERTEX>* list = ( LIST<MAP_VERTEX>* )eprop_ptr( prop );
- gui_label( *x, *y, "%s : %d", n, list->size ); *y += space;
- for( U32 i = 0; i < list->size; ++i ) {
- MAP_VERTEX* v = &list->data[i];
- gui_label( (*x) + 10, *y, "[%d] -> [%s]", i, to_str( v->pos ).data );
- GUI_BUTTON* btn = gui_button( action_x, *y, 20, 20, "\x1A", pfn( void* ptr ) {
- GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
- gui_editor_propview_select( editor->gui.props, btn->extra, EDITOR_SELECT_PVERTEX );
- } ); btn->extra = v; *y += space;
- }
+ if( val ) {
+ gui_label( *x, *y, "%s : %d", n, list->size ); *y += s;
+ for( U32 i = 0; i < list->size; ++i ) {
+ MAP_VERTEX* v = &list->data[i];
+ gui_label( (*x) + 10, *y, "[%d] -> [%s]", i, to_str( v->pos ).data );
+ GUI_BUTTON* btn = gui_button( action_x, *y, 20, 20, "\x1A", pfn( void* ptr ) {
+ GUI_BUTTON* btn = (GUI_BUTTON*)ptr;
+ gui_editor_propview_select( editor->gui.props, btn->extra, EDITOR_SELECT_PVERTEX );
+ } ); btn->extra = v; *y += s;
+ }
+ } else gui_label( *x, *y, "%s : *", n ); *y += s;
} break;
- default: return gui_editor_propview_create_eobj_prop_ro( view, prop, x, y, w, space ); break;
+ default: return gui_editor_propview_create_eobj_prop_ro( view, prop, x, y, w, s, val );
}
}
-void gui_editor_propview_create_eobj_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 space ) {
+void gui_editor_propview_create_eobj_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, I32* x, I32* y, I32 w, I32 s, U8 val ) {
STR str = prop->displayname;
str += " : [";
void* ptr = eprop_ptr( prop );
- switch( prop->type ) {
+ if( !val ) str += "*";
+ else switch( prop->type ) {
case EPROP_F32: str += to_str( *(F32*)ptr ); break;
case EPROP_VEC2: str += to_str( *(VEC2*)ptr ); break;
case EPROP_VEC3: str += to_str( *(VEC3*)ptr ); break;
@@ -258,7 +287,7 @@ void gui_editor_propview_create_eobj_prop_ro( GUI_EDITOR_PROPVIEW* view, EDITOR_
str += "]";
gui_label( *x, *y, str.data );
- *y += space;
+ *y += s;
}
void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT* e, I32* x, I32* y, I32 w ) {
@@ -266,6 +295,7 @@ void gui_editor_propview_create_eobj_props( GUI_EDITOR_PROPVIEW* view, EOBJECT*
for( auto& it : e->eprops ) {
EDITOR_PROP* eprop = eprop_from_ref( e, it );
+
if( eprop->readonly )
gui_editor_propview_create_eobj_prop_ro( view, eprop, x, y, w, space );
else
@@ -447,10 +477,25 @@ void gui_editor_propview_create_groupprops( GUI_EDITOR_PROPVIEW* view ) {
U32 space = 20;
for( auto& it : view->curprops ) {
+ U8 val = 1;
+ for( auto& sel : view->curselect ) {
+ EDITOR_PROP* it2 = eprop_from_name( (EOBJECT*)sel.obj, it->displayname );
+ if( !it2 )
+ continue;
+
+ void* d1 = eprop_ptr( it );
+ void* d2 = eprop_ptr( it2 );
+
+ if( !!memcmp( d1, d2, it->size ) ) {
+ val = 0;
+ break;
+ }
+ }
+
if( it->readonly )
- gui_editor_propview_create_eobj_prop_ro( view, it, &x, &y, w, space );
+ gui_editor_propview_create_eobj_prop_ro( view, it, &x, &y, w, space, val );
else
- gui_editor_propview_create_eobj_prop( view, it, &x, &y, w, space );
+ gui_editor_propview_create_eobj_prop( view, it, &x, &y, w, space, val );
}
}
diff --git a/src/editor/properties.h b/src/editor/properties.h
index ef59b0d..810c075 100644
--- a/src/editor/properties.h
+++ b/src/editor/properties.h
@@ -77,7 +77,8 @@ enum EditorPropType_t {
EPROP_TEXTURE,
EPROP_TEXTURE_LIST,
EPROP_VERTEX,
- EPROP_VERTEX_LIST
+ EPROP_VERTEX_LIST,
+ EPROP_LAST
};
struct EPROP_ENTRY {
diff --git a/src/editor/view2d.cpp b/src/editor/view2d.cpp
index 8bcd588..c4738dd 100644
--- a/src/editor/view2d.cpp
+++ b/src/editor/view2d.cpp
@@ -691,6 +691,30 @@ void gui_editor_2dview_draw_player( GUI_EDITOR_2DVIEW* view, I32 x, I32 y ) {
gui_draw_frect( (I32)pos2d.x-3, (I32)pos2d.y-3, 6, 6, CLR::RED() );
}
+void gui_editor_2dview_draw_object_preview( GUI_EDITOR_2DVIEW* view ) {
+ if( editor->tool.type != EDITOR_TOOL_OBJECT || !view->held )
+ return;
+
+ VEC2 pos = gui_editor_2dview_world3_to_screen( view, view->pending_object_pos );
+ I32 px = (I32)pos.x;
+ I32 py = (I32)pos.y;
+
+ if( view->pending_object_undo_type == EDITOR_SELECT_ENT ) {
+ gui_draw_line( px - 6, py, px + 6, py, CLR::WHITE( 0.8f ) );
+ gui_draw_line( px, py - 6, px, py + 6, CLR::WHITE( 0.8f ) );
+ return;
+ }
+
+ F32 wantedsize = editor->spritesize;
+ gui_draw_rect(
+ (I32)( pos.x - wantedsize * 0.5f ),
+ (I32)( pos.y - wantedsize * 0.5f ),
+ (I32)wantedsize,
+ (I32)wantedsize,
+ CLR::WHITE( 0.8f )
+ );
+}
+
void gui_editor_2dview_draw_origin( GUI_EDITOR_2DVIEW* view, I32 x, I32 y ) {
WORLD_MAP* m = editor->map;
@@ -814,6 +838,36 @@ VEC2 gui_editor_2dview_input_get_drag_vec( GUI_EDITOR_2DVIEW* view ) {
return { editor->grid * igridx, editor->grid * igridy };
}
+U8 gui_editor_2dview_input_select_drag_obj( GUI_EDITOR_2DVIEW* view, void* obj, U8 seltype );
+U8 gui_editor_2dview_move_group( GUI_EDITOR_2DVIEW* view ) {
+ U8 update = 0;
+ if( view->dragtype == EDITOR_SELECT_WVERTEX || view->dragtype == EDITOR_SELECT_PVERTEX )
+ return update;
+
+ GUI_EDITOR_PROPVIEW* props = editor->gui.props;
+ // update all selected objects
+ for( auto& it : props->curselect ) {
+ if( it.obj == view->curdrag ) {
+ update = 1;
+ continue;
+ }
+
+ // special case where a wall is selected but we are dragging one of its vertices
+ if( props->curselect.size == 1 && it.seltype == EDITOR_SELECT_WALL ) {
+ MAP_WALL* w = (MAP_WALL*)it.obj;
+ if( &w->start == view->curdrag || &w->end == view->curdrag ) {
+ update = 1;
+ continue;
+ }
+ }
+
+ if( gui_editor_2dview_input_select_drag_obj( view, it.obj, it.seltype ) )
+ update = 1;
+ }
+
+ return update;
+}
+
void gui_editor_2dview_input_select_onmove( GUI_EDITOR_2DVIEW* view ) {
I32 mx, my;
gui_cursor_pos( &mx, &my );
@@ -825,24 +879,22 @@ void gui_editor_2dview_input_select_onmove( GUI_EDITOR_2DVIEW* view ) {
F32 rmx = copysignf( fmodf( fabsf( dx ), editor->grid ), dx );
F32 rmy = copysignf( fmodf( fabsf( dy ), editor->grid ), dy );
+
+ GUI_EDITOR_PROPVIEW* props = editor->gui.props;
+ U8 update = !is_zero( gui_editor_2dview_input_get_drag_vec( view ) );
+ if( update && gui_editor_propview_is_selected( props, view->curdrag, view->dragtype ) ) {
+ if( gui_editor_2dview_move_group( view ) )
+ gui_editor_propview_update( props );
+ }
+
view->oldmx = mx;
view->oldmy = my;
view->mremainx = rmx;
view->mremainy = rmy;
view->dragmoved = 1;
-
- GUI_EDITOR_PROPVIEW* props = editor->gui.props;
- // special case for dragging wall vertices, just always update
- 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 ) {
- MAP_WALL* s = (MAP_WALL*)view->curdrag;
-
+void gui_editor_2dview_input_select_drag_wall( GUI_EDITOR_2DVIEW* view, MAP_WALL* s ) {
gui_editor_2dview_snap_plane( &s->start );
gui_editor_2dview_snap_plane( &s->end );
@@ -851,40 +903,31 @@ void gui_editor_2dview_input_select_drag_wall( GUI_EDITOR_2DVIEW* view ) {
gui_editor_2dview_add_plane_delta( &s->start, mv );
gui_editor_2dview_add_plane_delta( &s->end, mv );
map_check_bounds( editor->map );
-
- gui_editor_2dview_input_select_onmove( view );
}
}
-void gui_editor_2dview_input_select_drag_vertex( GUI_EDITOR_2DVIEW* view ) {
- if( view->dragtype == EDITOR_SELECT_WVERTEX ) {
- VEC3* v = (VEC3*)view->curdrag;
- gui_editor_2dview_snap_plane( v );
+void gui_editor_2dview_input_select_drag_pos( GUI_EDITOR_2DVIEW* view, VEC3* v ) {
+ gui_editor_2dview_snap_plane( v );
- VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
- if( !is_zero( mv ) ) {
- gui_editor_2dview_add_plane_delta( v, mv );
- map_check_bounds( editor->map );
- gui_editor_2dview_input_select_onmove( view );
- }
- return;
+ VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
+ if( !is_zero( mv ) ) {
+ gui_editor_2dview_add_plane_delta( v, mv );
+ map_check_bounds( editor->map );
}
+}
- MAP_VERTEX* v = (MAP_VERTEX*)view->curdrag;
+
+void gui_editor_2dview_input_select_drag_vertex( GUI_EDITOR_2DVIEW* view, MAP_VERTEX* v ) {
gui_editor_2dview_snap_plane( &v->pos );
VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
if( !is_zero( mv ) ) {
gui_editor_2dview_add_plane_delta( &v->pos, mv );
map_check_bounds( editor->map );
-
- gui_editor_2dview_input_select_onmove( view );
}
}
-void gui_editor_2dview_input_select_drag_polygon( GUI_EDITOR_2DVIEW* view ) {
- MAP_POLYGON* p = (MAP_POLYGON*)view->curdrag;
-
+void gui_editor_2dview_input_select_drag_polygon( GUI_EDITOR_2DVIEW* view, MAP_POLYGON* p ) {
VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
if( !is_zero( mv ) ) {
p->vertices.each( fn( MAP_VERTEX* v ) {
@@ -894,70 +937,55 @@ void gui_editor_2dview_input_select_drag_polygon( GUI_EDITOR_2DVIEW* view ) {
map_polygon_calc_bounds( p );
map_check_bounds( editor->map );
- gui_editor_2dview_input_select_onmove( view );
}
}
-void gui_editor_2dview_input_select_drag_sprite( GUI_EDITOR_2DVIEW* view ) {
- MAP_SPRITE* s = (MAP_SPRITE*)view->curdrag;
-
+void gui_editor_2dview_input_select_drag_sprite( GUI_EDITOR_2DVIEW* view, MAP_SPRITE* s ) {
gui_editor_2dview_snap_plane( &s->pos );
VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
if( !is_zero( mv ) ) {
gui_editor_2dview_add_plane_delta( &s->pos, mv );
- gui_editor_2dview_input_select_onmove( view );
}
}
-void gui_editor_2dview_draw_object_preview( GUI_EDITOR_2DVIEW* view ) {
- if( editor->tool.type != EDITOR_TOOL_OBJECT || !view->held )
- return;
-
- VEC2 pos = gui_editor_2dview_world3_to_screen( view, view->pending_object_pos );
- I32 px = (I32)pos.x;
- I32 py = (I32)pos.y;
-
- if( view->pending_object_undo_type == EDITOR_SELECT_ENT ) {
- gui_draw_line( px - 6, py, px + 6, py, CLR::WHITE( 0.8f ) );
- gui_draw_line( px, py - 6, px, py + 6, CLR::WHITE( 0.8f ) );
- return;
- }
-
- F32 wantedsize = editor->spritesize;
- gui_draw_rect(
- (I32)( pos.x - wantedsize * 0.5f ),
- (I32)( pos.y - wantedsize * 0.5f ),
- (I32)wantedsize,
- (I32)wantedsize,
- CLR::WHITE( 0.8f )
- );
-}
-
-void gui_editor_2dview_input_select_drag_entity( GUI_EDITOR_2DVIEW* view ) {
- MAP_ENTITY* e = (MAP_ENTITY*)view->curdrag;
+void gui_editor_2dview_input_select_drag_entity( GUI_EDITOR_2DVIEW* view, MAP_ENTITY* e ) {
gui_editor_2dview_snap_plane( &e->pos );
VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
if( !is_zero( mv ) ) {
gui_editor_2dview_add_plane_delta( &e->pos, mv );
- gui_editor_2dview_input_select_onmove( view );
}
}
-void gui_editor_2dview_input_select_drag_origin( GUI_EDITOR_2DVIEW* view ) {
- WORLD_MAP* m = editor->map;
-
+void gui_editor_2dview_input_select_drag_origin( GUI_EDITOR_2DVIEW* view, WORLD_MAP* m ) {
gui_editor_2dview_snap_plane( &m->startpos );
VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
if( !is_zero( mv ) ) {
gui_editor_2dview_add_plane_delta( &m->startpos, mv );
- gui_editor_2dview_input_select_onmove( view );
}
}
+U8 gui_editor_2dview_input_select_drag_obj( GUI_EDITOR_2DVIEW* view, void* obj, U8 seltype ) {
+ I32 mx, my;
+ gui_cursor_pos( &mx, &my );
+
+ void* p = obj;
+ switch( seltype ) {
+ case EDITOR_SELECT_WALL: gui_editor_2dview_input_select_drag_wall( view, (MAP_WALL*)p ); return 1;
+ case EDITOR_SELECT_POLY: gui_editor_2dview_input_select_drag_polygon( view, (MAP_POLYGON*)p ); return 1;
+ case EDITOR_SELECT_ENT: gui_editor_2dview_input_select_drag_entity( view, (MAP_ENTITY*)p ); return 1;
+ case EDITOR_SELECT_SPRITE: gui_editor_2dview_input_select_drag_sprite( view, (MAP_SPRITE*)p ); return 1;
+ case EDITOR_SELECT_ORIGIN: gui_editor_2dview_input_select_drag_origin( view, (WORLD_MAP*)p ); return 1;
+ case EDITOR_SELECT_PVERTEX: gui_editor_2dview_input_select_drag_vertex( view, (MAP_VERTEX*)p ); return 1;
+ case EDITOR_SELECT_WVERTEX: gui_editor_2dview_input_select_drag_pos( view, (VEC3*)p ); return 1;
+ }
+
+ return 0;
+}
+
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, !input.keys[SDL_SCANCODE_LCTRL] );
@@ -989,19 +1017,15 @@ void gui_editor_2dview_input_select_drag( GUI_EDITOR_2DVIEW* view ) {
return;
}
- switch( view->dragtype ) {
- case EDITOR_SELECT_WALL: gui_editor_2dview_input_select_drag_wall( view ); break;
- case EDITOR_SELECT_POLY: gui_editor_2dview_input_select_drag_polygon( view ); break;
- case EDITOR_SELECT_ENT: gui_editor_2dview_input_select_drag_entity( view ); break;
- case EDITOR_SELECT_SPRITE: gui_editor_2dview_input_select_drag_sprite( view ); break;
- case EDITOR_SELECT_ORIGIN: gui_editor_2dview_input_select_drag_origin( view ); break;
- case EDITOR_SELECT_WVERTEX:
- case EDITOR_SELECT_PVERTEX:
- gui_editor_2dview_input_select_drag_vertex( view ); break;
- default: {
- view->oldmx = mx;
- view->oldmy = my;
- } break;
+ if( !gui_editor_2dview_input_select_drag_obj( view, view->curdrag, view->dragtype ) ) {
+ view->oldmx = mx;
+ view->oldmy = my;
+ return;
+ }
+
+ VEC2 mv = gui_editor_2dview_input_get_drag_vec( view );
+ if( !is_zero( mv ) ) {
+ gui_editor_2dview_input_select_onmove( view );
}
}
@@ -1403,8 +1427,6 @@ void gui_editor_view2d_delete_obj( GUI_EDITOR_2DVIEW* view ) {
view->curdrag = 0;
view->dragtype = EDITOR_SELECT_NONE;
} 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();
@@ -1412,6 +1434,9 @@ void gui_editor_view2d_delete_obj( GUI_EDITOR_2DVIEW* view ) {
}
else return;
+ view->curselect = 0;
+ view->seltype = EDITOR_SELECT_NONE;
+
for( auto& _it: sel ) {
void* it = _it.obj;
U8 type = _it.seltype;
diff --git a/src/game/world/map.cpp b/src/game/world/map.cpp
index 7b8060b..fb94215 100644
--- a/src/game/world/map.cpp
+++ b/src/game/world/map.cpp
@@ -113,6 +113,9 @@ STAT map_polygon_verts_from_section( WORLD_MAP* m, MAP_POLYGON* p, CFG_SECTION*
}
void map_polygon_calc_bounds( MAP_POLYGON* p ) {
+ p->mins = { INFINITY, INFINITY, INFINITY };
+ p->maxs = { -INFINITY, -INFINITY, -INFINITY };
+
p->vertices.each( fn( MAP_VERTEX* v ) {
p->mins.x = min( v->pos.x, p->mins.x );
p->mins.y = min( v->pos.y, p->mins.y );
diff --git a/src/gui/base.h b/src/gui/base.h
index 0418afd..1a1c4cb 100644
--- a/src/gui/base.h
+++ b/src/gui/base.h
@@ -95,7 +95,8 @@ extern struct GUI_VECTORINPUT* gui_vectorinput(
F32 max,
F32 step = 1.f,
const char* letters = "xyzw",
- const char* printfmt = "%.2f"
+ const char* printfmt = "%.2f",
+ U8 showval = 1
);
extern struct GUI_COLORINPUT* gui_colorinput(
@@ -234,6 +235,7 @@ struct GUI_FLOATINPUT : GUI_BASE {
I32 lastmx;
U8 heldoutbounds;
U8 held;
+ U8 drawval;
// for color sliders
CLR bgcol;
@@ -329,7 +331,7 @@ struct __gui_internal {
GL_BATCH2D* batch;
};
-void __gui_internal_vectorinput_init(
+extern void __gui_internal_vectorinput_init(
GUI_VECTORINPUT* input,
I32 x, I32 y, I32 w,
const char* title,
diff --git a/src/gui/floatinput.cpp b/src/gui/floatinput.cpp
index 5ce92fe..095c562 100644
--- a/src/gui/floatinput.cpp
+++ b/src/gui/floatinput.cpp
@@ -111,11 +111,13 @@ void gui_floatinput_draw_unbound( GUI_FLOATINPUT* input ) {
F32 val = *input->pval;
gui_draw_str( x + 2, y + 2, ALIGN_L, FNT_JPN12, ui_clr.txt, input->name );
- gui_draw_str( x + w - 2, y + 2, ALIGN_R, FNT_JPN12, ui_clr.txt, input->valfmt, val );
+ if( input->drawval )
+ gui_draw_str( x + w - 2, y + 2, ALIGN_R, FNT_JPN12, ui_clr.txt, input->valfmt, val );
- I32 t1w, t2w, t3w;
+ I32 t1w, t2w = 0, t3w;
gui_draw_get_str_bounds( &t1w, 0, FNT_JPN12, input->name );
- gui_draw_get_str_bounds( &t2w, 0, FNT_JPN12, input->valfmt, val );
+ if( input->drawval )
+ gui_draw_get_str_bounds( &t2w, 0, FNT_JPN12, input->valfmt, val );
gui_draw_get_str_bounds( &t3w, 0, FNT_JPN12, "<->" );
I32 stw = t2w + t3w - 2;
@@ -336,6 +338,7 @@ struct GUI_FLOATINPUT* gui_floatinput( I32 x, I32 y, I32 w, const char* title, F
input->max = max;
input->step = step;
input->valfmt = valfmt;
+ input->drawval = 1;
input->wraparound = 0;
input->customclr = 0;
diff --git a/src/gui/vectorinput.cpp b/src/gui/vectorinput.cpp
index daed540..ad28c0d 100644
--- a/src/gui/vectorinput.cpp
+++ b/src/gui/vectorinput.cpp
@@ -106,7 +106,8 @@ GUI_VECTORINPUT* gui_vectorinput(
F32 max,
F32 step,
const char* letters,
- const char* printfmt
+ const char* printfmt,
+ U8 showval
) {
if( !gui_check_target() ) return 0;
if( valc > 25 ) {
@@ -128,5 +129,12 @@ GUI_VECTORINPUT* gui_vectorinput(
printfmt
);
+ if( !showval ) {
+ for( auto& it : input->inputview->children ) {
+ GUI_FLOATINPUT* f = (GUI_FLOATINPUT*)it;
+ f->drawval = 0;
+ }
+ }
+
return input;
}