diff options
Diffstat (limited to 'src/editor/editor.cpp')
| -rw-r--r-- | src/editor/editor.cpp | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index ba61961..c96f908 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -31,7 +31,7 @@ void editor_clear_gui_state_refs( GAME_EDITOR* e ) { e->gui.header_viewtype = 0; } -static void editor_push_undo_action( GAME_EDITOR* e, const GAME_EDITOR::EDITOR_UNDO_ACTION& action ) { +void editor_push_undo_action( GAME_EDITOR* e, const GAME_EDITOR::EDITOR_UNDO_ACTION& action ) { if( !e ) return; @@ -39,7 +39,7 @@ static void editor_push_undo_action( GAME_EDITOR* e, const GAME_EDITOR::EDITOR_U e->undo_actions.push( action ); } -static void editor_refresh_after_map_change( GAME_EDITOR* e ) { +void editor_refresh_after_map_change( GAME_EDITOR* e ) { if( !e || !e->map ) return; @@ -54,13 +54,13 @@ static U8 editor_clr_eq( const CLR& a, const CLR& b ) { return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; } -static U8 editor_vertex_eq( const MAP_VERTEX& a, const MAP_VERTEX& b ) { +U8 editor_vertex_eq( const MAP_VERTEX& a, const MAP_VERTEX& b ) { return a.pos == b.pos && a.uv == b.uv && editor_clr_eq( a.clr, b.clr ); } -static U8 editor_wall_eq( const MAP_WALL& a, const MAP_WALL& b ) { +U8 editor_wall_eq( const MAP_WALL& a, const MAP_WALL& b ) { return a.start == b.start && a.end == b.end && a.uvstart == b.uvstart @@ -68,7 +68,7 @@ static U8 editor_wall_eq( const MAP_WALL& a, const MAP_WALL& b ) { && a.propid == b.propid; } -static U8 editor_poly_eq( const MAP_POLYGON& a, const MAP_POLYGON& b ) { +U8 editor_poly_eq( const MAP_POLYGON& a, const MAP_POLYGON& b ) { if( a.type != b.type || a.propid != b.propid ) return 0; if( !( a.mins == b.mins ) || !( a.maxs == b.maxs ) ) @@ -83,19 +83,19 @@ static U8 editor_poly_eq( const MAP_POLYGON& a, const MAP_POLYGON& b ) { return 1; } -static U8 editor_sprite_eq( const MAP_SPRITE& a, const MAP_SPRITE& b ) { +U8 editor_sprite_eq( const MAP_SPRITE& a, const MAP_SPRITE& b ) { return a.pos == b.pos && a.size == b.size && editor_clr_eq( a.clr, b.clr ) && a.tex == b.tex; } -static U8 editor_entity_eq( const MAP_ENTITY& a, const MAP_ENTITY& b ) { +U8 editor_entity_eq( const MAP_ENTITY& a, const MAP_ENTITY& b ) { return a.pos == b.pos && a.classid == b.classid; } -static I32 editor_clamp_valid_idx( I32 idx, I32 size ) { +I32 editor_clamp_valid_idx( I32 idx, I32 size ) { if( size <= 0 ) return -1; if( idx < 0 ) @@ -105,12 +105,12 @@ static I32 editor_clamp_valid_idx( I32 idx, I32 size ) { return idx; } -static I32 editor_idx_distance( I32 a, I32 b ) { +I32 editor_idx_distance( I32 a, I32 b ) { return a > b ? a - b : b - a; } template <typename MATCH_FN> -static I32 editor_find_nearest_idx( I32 size, I32 expected_idx, MATCH_FN match ) { +I32 editor_find_nearest_idx( I32 size, I32 expected_idx, MATCH_FN match ) { if( size <= 0 ) return -1; @@ -134,7 +134,7 @@ static I32 editor_find_nearest_idx( I32 size, I32 expected_idx, MATCH_FN match ) return best; } -static I32 editor_find_wall_idx( WORLD_MAP* map, const MAP_WALL& want, I32 expected_idx ) { +I32 editor_find_wall_idx( WORLD_MAP* map, const MAP_WALL& want, I32 expected_idx ) { if( !map ) return -1; @@ -143,7 +143,7 @@ static I32 editor_find_wall_idx( WORLD_MAP* map, const MAP_WALL& want, I32 expec } ); } -static I32 editor_find_poly_idx( WORLD_MAP* map, const MAP_POLYGON& want, I32 expected_idx ) { +I32 editor_find_poly_idx( WORLD_MAP* map, const MAP_POLYGON& want, I32 expected_idx ) { if( !map ) return -1; @@ -152,7 +152,7 @@ static I32 editor_find_poly_idx( WORLD_MAP* map, const MAP_POLYGON& want, I32 ex } ); } -static I32 editor_find_sprite_idx( WORLD_MAP* map, const MAP_SPRITE& want, I32 expected_idx ) { +I32 editor_find_sprite_idx( WORLD_MAP* map, const MAP_SPRITE& want, I32 expected_idx ) { if( !map ) return -1; @@ -161,7 +161,7 @@ static I32 editor_find_sprite_idx( WORLD_MAP* map, const MAP_SPRITE& want, I32 e } ); } -static I32 editor_find_entity_idx( WORLD_MAP* map, const MAP_ENTITY& want, I32 expected_idx ) { +I32 editor_find_entity_idx( WORLD_MAP* map, const MAP_ENTITY& want, I32 expected_idx ) { if( !map ) return -1; @@ -170,14 +170,9 @@ static I32 editor_find_entity_idx( WORLD_MAP* map, const MAP_ENTITY& want, I32 e } ); } -static void editor_mark_clear_wall_refs( GAME_EDITOR* e, MAP_WALL* w, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { - if( e->gui.props ) { - if( e->gui.props->seltype == EDITOR_SELECT_WALL && e->gui.props->curselect == w ) - *clear_props_select = 1; - if( e->gui.props->seltype == EDITOR_SELECT_WVERTEX - && ( e->gui.props->curselect == &w->start || e->gui.props->curselect == &w->end ) ) - *clear_props_select = 1; - } +void editor_mark_clear_wall_refs( GAME_EDITOR* e, MAP_WALL* w, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { + if( gui_editor_propview_is_selected( e->gui.props, w, EDITOR_SELECT_WALL ) ) + *clear_props_select = 1; if( e->gui.v2d ) { if( e->gui.v2d->seltype == EDITOR_SELECT_WALL && e->gui.v2d->curselect == w ) @@ -194,16 +189,12 @@ static void editor_mark_clear_wall_refs( GAME_EDITOR* e, MAP_WALL* w, U8* clear_ } } -static void editor_mark_clear_poly_refs( GAME_EDITOR* e, MAP_POLYGON* p, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { - if( e->gui.props ) { - if( e->gui.props->seltype == EDITOR_SELECT_POLY && e->gui.props->curselect == p ) +void editor_mark_clear_poly_refs( GAME_EDITOR* e, MAP_POLYGON* p, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { + if( gui_editor_propview_is_selected( e->gui.props, p, EDITOR_SELECT_POLY ) ) + *clear_props_select = 1; + for( auto& it : p->vertices ) { + if( gui_editor_propview_is_selected( e->gui.props, &it, EDITOR_SELECT_PVERTEX ) ) *clear_props_select = 1; - if( e->gui.props->seltype == EDITOR_SELECT_PVERTEX ) { - p->vertices.each( fn( MAP_VERTEX* v ) { - if( e->gui.props->curselect == v ) - *clear_props_select = 1; - } ); - } } if( e->gui.v2d ) { @@ -227,8 +218,9 @@ static void editor_mark_clear_poly_refs( GAME_EDITOR* e, MAP_POLYGON* p, U8* cle } } -static void editor_mark_clear_sprite_refs( GAME_EDITOR* e, MAP_SPRITE* s, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { - if( e->gui.props && e->gui.props->seltype == EDITOR_SELECT_SPRITE && e->gui.props->curselect == s ) +void editor_mark_clear_sprite_refs( GAME_EDITOR* e, MAP_SPRITE* s, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { + // todo : only clear the selected item + if( gui_editor_propview_is_selected( e->gui.props, s, EDITOR_SELECT_SPRITE ) ) *clear_props_select = 1; if( e->gui.v2d ) { @@ -239,8 +231,8 @@ static void editor_mark_clear_sprite_refs( GAME_EDITOR* e, MAP_SPRITE* s, U8* cl } } -static void editor_mark_clear_entity_refs( GAME_EDITOR* e, MAP_ENTITY* ent, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { - if( e->gui.props && e->gui.props->seltype == EDITOR_SELECT_ENT && e->gui.props->curselect == ent ) +void editor_mark_clear_entity_refs( GAME_EDITOR* e, MAP_ENTITY* ent, U8* clear_props_select, U8* clear_view_select, U8* clear_view_drag ) { + if( gui_editor_propview_is_selected( e->gui.props, ent, EDITOR_SELECT_ENT ) ) *clear_props_select = 1; if( e->gui.v2d ) { |
