diff options
| -rw-r--r-- | src/editor/gui.cpp | 13 | ||||
| -rw-r--r-- | src/editor/view3d.cpp | 32 |
2 files changed, 31 insertions, 14 deletions
diff --git a/src/editor/gui.cpp b/src/editor/gui.cpp index 94967cc..1060c00 100644 --- a/src/editor/gui.cpp +++ b/src/editor/gui.cpp @@ -121,18 +121,6 @@ void editor_create_tools_row( GAME_EDITOR* e ) { editor_update_active_tool_label( e ); } -void editor_create_view_settings_row( GAME_EDITOR* e ) { - I32 x = 320, y = 426; - - gui_button( x, y, 100, 20, "compile bsp", pfn( void* b ) { - if( editor->map->bsp ) - bsp_free( editor->map->bsp ); - editor->map->bsp = bsp_build_map( editor->map ); - } ); x += 110; - - gui_checkbox( x, y, "draw bsp", &e->drawbsp ); -} - void editor_create_map_view( GAME_EDITOR* e ) { if( !e->map ) { dlog( "editor_create_map_views() : no map loaded\n" ); @@ -153,7 +141,6 @@ void editor_create_map_view( GAME_EDITOR* e ) { editor_create_properties_column( e ); editor_create_game_view_column( e ); editor_create_tools_row( e ); - editor_create_view_settings_row( e ); } void close_new_map_popup( void* ) { diff --git a/src/editor/view3d.cpp b/src/editor/view3d.cpp index 64cfe85..f8d1def 100644 --- a/src/editor/view3d.cpp +++ b/src/editor/view3d.cpp @@ -6,6 +6,7 @@ #include "../game.h" const I32 EDITORVIEW_TITLE_OFFSET = 15; +const I32 EDITORVIEW_TOOLBAR_OFFSET = 20; void gui_editor_3dview_draw_showpos( GUI_EDITOR_3DVIEW* view ) { I32 x = gui_relx( view ); @@ -66,11 +67,22 @@ void gui_editor_3dview_draw_fn( void* ptr ) { else world_draw( editor->game, objl->world, wnd, winsize ); + gui_draw_push_clip( x, y, view->w, view->h ); + view->children.each( fn( GUI_BASE** childptr ) { + GUI_BASE* child = *childptr; + if( !child->enabled ) return; + + if( child->draw_fn ) child->draw_fn( child ); + else dlog( "gui_view_draw_fn(): child %p no draw_fn\n", child ); + } ); + gui_draw_pop_clip(); gui_editor_3dview_draw_showpos( view ); } void gui_editor_3dview_input_fn( void* ptr ) { GUI_EDITOR_3DVIEW* view = (GUI_EDITOR_3DVIEW*)ptr; + if( !input.mouselock ) + gui_base_input_fn( view ); if( !objl->pl ) return; @@ -79,7 +91,7 @@ void gui_editor_3dview_input_fn( void* ptr ) { I32 view_x = gui_relx( view ); I32 view_y = gui_rely( view ) + EDITORVIEW_TITLE_OFFSET; if( input.mouse.pos.x >= view_x && input.mouse.pos.x < view_x + view->w && - input.mouse.pos.y >= view_y && input.mouse.pos.y < view_y + view->h ) { + input.mouse.pos.y >= view_y && input.mouse.pos.y < view_y + view->h - EDITORVIEW_TOOLBAR_OFFSET ) { if( !input.mouselock && !view->heldoutbounds ) input_capture_mouse( true ); } else { @@ -90,6 +102,19 @@ void gui_editor_3dview_input_fn( void* ptr ) { game_on_tick( editor->game ); } +void gui_editor_3dview_create_toolbar( GUI_EDITOR_3DVIEW* view ) { + GAME_EDITOR* e = editor; + I32 x = 1, y = view->h - 4; + + gui_button( x, y, 90, 18, "compile bsp", pfn( void* b ) { + if( editor->map->bsp ) + bsp_free( editor->map->bsp ); + editor->map->bsp = bsp_build_map( editor->map ); + } ); x += 100; + + gui_checkbox( x, y, "draw bsp", &e->drawbsp ); +} + GUI_EDITOR_3DVIEW* gui_editor_3dview( I32 x, I32 y, I32 w, I32 h ) { GUI_EDITOR_3DVIEW* view = new GUI_EDITOR_3DVIEW; view->x = x; @@ -108,5 +133,10 @@ GUI_EDITOR_3DVIEW* gui_editor_3dview( I32 x, I32 y, I32 w, I32 h ) { parent->children.push( view ); view->parent = parent; + + gui_set_view( view ); + gui_editor_3dview_create_toolbar( view ); + gui_set_view( (GUI_VIEW*)parent ); + return view; } |
