summaryrefslogtreecommitdiff
path: root/src/editor/view3d.cpp
diff options
context:
space:
mode:
authornavewindre <boneyaard@gmail.com>2025-11-28 14:41:22 +0100
committerGitHub <noreply@github.com>2025-11-28 14:41:22 +0100
commit9c05c795d7b59c5ab94fb769f315c712b37df0cd (patch)
tree16cccf8cbb88703de798066a06f94013f89a8a5a /src/editor/view3d.cpp
parentf8b92ce3aa08b1445c9f956d8166830946562d12 (diff)
parent3e094f20d4dda90e0356aba3f0abc4b7c7015844 (diff)
Merge pull request #1 from navewindre/windows-compat
Windows compat
Diffstat (limited to 'src/editor/view3d.cpp')
-rw-r--r--src/editor/view3d.cpp56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/editor/view3d.cpp b/src/editor/view3d.cpp
index f9bd60e..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 );
@@ -31,6 +32,16 @@ void gui_editor_3dview_draw_showpos( GUI_EDITOR_3DVIEW* view ) {
objl->pl->rot.y,
objl->pl->rot.x
);
+
+ if( input.mouselock ) {
+ gui_draw_str(
+ x + 2, y + 2,
+ ALIGN_L,
+ FNT_JPN12,
+ ui_clr.txt,
+ "[capturing mouse]"
+ );
+ }
}
void gui_editor_3dview_draw_fn( void* ptr ) {
@@ -55,17 +66,55 @@ void gui_editor_3dview_draw_fn( void* ptr ) {
bsp_draw( editor->map->bsp, editor->game, wnd, winsize );
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;
+ if( input.mouse.left ) {
+ 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 - EDITORVIEW_TOOLBAR_OFFSET ) {
+ if( !input.mouselock && !view->heldoutbounds )
+ input_capture_mouse( true );
+ } else {
+ view->heldoutbounds = 1;
+ }
+ } else view->heldoutbounds = 0;
+
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;
@@ -84,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;
}