diff options
Diffstat (limited to 'src/editor/view3d.cpp')
| -rw-r--r-- | src/editor/view3d.cpp | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/src/editor/view3d.cpp b/src/editor/view3d.cpp index 292760a..cdec211 100644 --- a/src/editor/view3d.cpp +++ b/src/editor/view3d.cpp @@ -1,5 +1,7 @@ #include "editor.h" +#include "../render/gl_2d_font.h" + #include "../game/objlist.h" #include "../game/world/draw.h" #include "../game/world/bsp_draw.h" @@ -14,37 +16,43 @@ void gui_editor_3dview_draw_showpos( GUI_EDITOR_3DVIEW* view ) { VEC3 pos = objl->pl->pos; F32 speed = vec_len( objl->pl->velocity ); - - gui_draw_str( - x + view->w - 2, y + 2, - ALIGN_R, - FNT_JPN12, - ui_clr.txt, - "pos: %.02f %.02f %.02f (%.02f)", - pos.x, pos.y, pos.z, speed + STR posstr = STR( "pos: %.02f %.02f %.02f (%.02f)", pos.x, pos.y, pos.z, speed ); + STR rotstr = STR( "rot: %.02f %.02f", objl->pl->rot.y, objl->pl->rot.x ); + + VEC2 posdim = gl_font_dim( _gui.fonts.jpn12.glfnt, posstr ); + VEC2 rotdim = gl_font_dim( _gui.fonts.jpn12.glfnt, rotstr ); + + gl_font_draw( + _gui.fonts.jpn12.glfnt, + _gui.batch->shader, + VEC2( x + view->w - 2 - posdim.x, y + 2 ), + posstr, + ui_clr.txt ); - - gui_draw_str( - x + view->w - 2, y + 18, - ALIGN_R, - FNT_JPN12, - ui_clr.txt, - "rot: %.02f %.02f", - objl->pl->rot.y, - objl->pl->rot.x + gl_font_draw( + _gui.fonts.jpn12.glfnt, + _gui.batch->shader, + VEC2( x + view->w - 2 - rotdim.x, y + 18 ), + rotstr, + ui_clr.txt ); - if( input.mouselock ) { - gui_draw_str( - x + 2, y + 2, - ALIGN_L, - FNT_JPN12, - ui_clr.txt, - "[capturing mouse]" + gl_font_draw( + _gui.fonts.jpn12.glfnt, + _gui.batch->shader, + VEC2( x + 2, y + 2 ), + "[capturing mouse]", + ui_clr.txt ); } } +struct WORLD_DRAW_CB_DATA { + VEC2 wnd; + VEC2 winsize; + GUI_EDITOR_3DVIEW* view; +}; + void gui_editor_3dview_draw_fn( void* ptr ) { GUI_EDITOR_3DVIEW* view = (GUI_EDITOR_3DVIEW*)ptr; @@ -59,14 +67,25 @@ void gui_editor_3dview_draw_fn( void* ptr ) { VEC2 wnd = { (F32)x, (F32)y }; VEC2 winsize = { (F32)view->w, (F32)view->h }; + static WORLD_DRAW_CB_DATA data; + data = { wnd, winsize, view }; CLR col = gui_is_fg_window( view )? ui_clr.border : ui_clr.border_inactive; gui_draw_frect( x-1, y-1, view->w+2, view->h+2, col ); gui_draw_frect( x, y, view->w, view->h, CLR::BLACK() ); - if( editor->drawbsp && editor->map->bsp ) - bsp_draw( editor->map->bsp, editor->game, wnd, winsize ); - else - world_draw( editor->game, objl->world, wnd, winsize ); + if( editor->drawbsp && editor->map->bsp ) { + gui_push_callback( &data, fn( void* data ) { + WORLD_DRAW_CB_DATA* d = (WORLD_DRAW_CB_DATA*)data; + bsp_draw( editor->map->bsp, editor->game, d->wnd, d->winsize ); + gui_editor_3dview_draw_showpos( d->view); + } ); + } else { + gui_push_callback( &data, fn( void* data ) { + WORLD_DRAW_CB_DATA* d = (WORLD_DRAW_CB_DATA*)data; + world_draw( editor->game, objl->world, d->wnd, d->winsize ); + gui_editor_3dview_draw_showpos( d->view ); + } ); + } gui_draw_push_clip( x, y, view->w, view->h ); view->children.each( fn( GUI_BASE** childptr ) { @@ -77,7 +96,6 @@ void gui_editor_3dview_draw_fn( void* ptr ) { 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 ) { |
