diff options
Diffstat (limited to 'src/editor/view3d.cpp')
| -rw-r--r-- | src/editor/view3d.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/editor/view3d.cpp b/src/editor/view3d.cpp new file mode 100644 index 0000000..f9bd60e --- /dev/null +++ b/src/editor/view3d.cpp @@ -0,0 +1,88 @@ +#include "editor.h" + +#include "../game/objlist.h" +#include "../game/world/draw.h" +#include "../game/world/bsp_draw.h" +#include "../game.h" + +const I32 EDITORVIEW_TITLE_OFFSET = 15; + +void gui_editor_3dview_draw_showpos( GUI_EDITOR_3DVIEW* view ) { + I32 x = gui_relx( view ); + I32 y = gui_rely( view ) + EDITORVIEW_TITLE_OFFSET; + + VEC3 pos = objl->pl->pos; + + gui_draw_str( + x + view->w - 2, y + 2, + ALIGN_R, + FNT_JPN12, + ui_clr.txt, + "pos: %.02f %.02f %.02f", + pos.x, pos.y, pos.z + ); + + 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 + ); +} + +void gui_editor_3dview_draw_fn( void* ptr ) { + GUI_EDITOR_3DVIEW* view = (GUI_EDITOR_3DVIEW*)ptr; + + if( !objl->pl ) + return; + + I32 x = gui_relx( view ); + I32 y = gui_rely( view ); + + gui_draw_str( x, y, ALIGN_L, FNT_JPN12, ui_clr.txt, "3d view" ); + y += EDITORVIEW_TITLE_OFFSET; + + VEC2 wnd = { (F32)x, (F32)y }; + VEC2 winsize = { (F32)view->w, (F32)view->h }; + + 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 ); + + gui_editor_3dview_draw_showpos( view ); +} + +void gui_editor_3dview_input_fn( void* ptr ) { + if( !objl->pl ) + return; + + game_on_tick( editor->game ); +} + +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; + view->y = y; + view->xbound = view->w = w; + view->h = h; + view->ybound = h + EDITORVIEW_TITLE_OFFSET; + + view->draw_fn = gui_editor_3dview_draw_fn; + view->input_fn = gui_editor_3dview_input_fn; + strcpy( view->name, "EDITOR_3D_VIEW" ); + + GUI_BASE* parent = gui_get_view(); + if( !parent ) + parent = gui_get_window(); + + parent->children.push( view ); + view->parent = parent; + return view; +} |
