From 1aa17de9188790f049c0edc4281597cb4e535627 Mon Sep 17 00:00:00 2001 From: aura Date: Tue, 11 Aug 2026 19:10:04 +0200 Subject: wip on shape tool --- src/editor/editor.h | 11 ++++++++--- src/editor/view2d.cpp | 26 ++++++++++++++++++++------ 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/editor/editor.h b/src/editor/editor.h index 3d27951..8838d8f 100644 --- a/src/editor/editor.h +++ b/src/editor/editor.h @@ -19,7 +19,13 @@ enum EditorTools_t { enum EditorWallShape_t { EDITOR_WALLSHAPE_LINE = 0, - EDITOR_WALLSHAPE_POLYGON = 1 + EDITOR_WALLSHAPE_POLYGON = 1, + EDITOR_WALLSHAPE_PATH = 2 +}; + +enum EditorPolyShape_t { + EDITOR_POLYSHAPE_DRAG = 0, + EDITOR_POLYSHAPE_PATH = 1 }; enum EditorSelectType_t { @@ -43,8 +49,6 @@ enum EditorActionType_t { EDITOR_UNDO_EDITPROPS = 1 << 5, EDITOR_UNDO_CREATE_MAPPROP = 1 << 6, - - EDITOR_UNDO_CREATE_EOBJ = EDITOR_UNDO_CREATE_WALLS | EDITOR_UNDO_CREATE_POLY | EDITOR_UNDO_CREATE_SPRITES | EDITOR_UNDO_CREATE_ENTITIES, }; @@ -91,6 +95,7 @@ struct GAME_EDITOR_TOOL { /* shapes */ I32 wallshape; + I32 polyshape; F32 polysides; F32 wallheight; F32 placementheight; diff --git a/src/editor/view2d.cpp b/src/editor/view2d.cpp index fe82c08..7a7ea3e 100644 --- a/src/editor/view2d.cpp +++ b/src/editor/view2d.cpp @@ -1334,8 +1334,7 @@ void gui_editor_2dview_input_scroll( GUI_EDITOR_2DVIEW* view ) { view->dragheld = 0; } -void gui_editor_2dview_input_tool_wall( GUI_EDITOR_2DVIEW* view ) { - if( editor->tool.wallshape == EDITOR_WALLSHAPE_POLYGON ) { +void gui_editor_2dview_input_tool_wall_shape( GUI_EDITOR_2DVIEW* view ) { U8 m1 = gui_mbutton_down( 0 ); I32 mx, my; gui_cursor_pos( &mx, &my ); @@ -1360,8 +1359,10 @@ void gui_editor_2dview_input_tool_wall( GUI_EDITOR_2DVIEW* view ) { view->poly_end = world; return; - } +} + +void gui_editor_2dview_input_tool_wall_line( GUI_EDITOR_2DVIEW* view ) { U8 m1 = gui_mbutton_down( 0 ); if( !m1 ) { if( view->held ) { @@ -1413,7 +1414,14 @@ void gui_editor_2dview_input_tool_wall( GUI_EDITOR_2DVIEW* view ) { } } -void gui_editor_2dview_input_tool_poly( GUI_EDITOR_2DVIEW* view ) { +void gui_editor_2dview_input_tool_wall( GUI_EDITOR_2DVIEW* view ) { + switch( editor->tool.wallshape ) { + case EDITOR_WALLSHAPE_POLYGON: return gui_editor_2dview_input_tool_wall_shape( view ); + default: return gui_editor_2dview_input_tool_wall_line( view ); + } +} + +void gui_editor_2dview_input_tool_poly_drag( GUI_EDITOR_2DVIEW* view ) { U8 m1 = gui_mbutton_down( 0 ); I32 mx, my; gui_cursor_pos( &mx, &my ); @@ -1439,6 +1447,12 @@ void gui_editor_2dview_input_tool_poly( GUI_EDITOR_2DVIEW* view ) { view->poly_end = world; } +void gui_editor_2dview_input_tool_poly( GUI_EDITOR_2DVIEW* view ) { + switch( editor->tool.polyshape ) { + default: return gui_editor_2dview_input_tool_poly_drag( view ); + } +} + void gui_editor_2dview_input_tool_object( GUI_EDITOR_2DVIEW* view ) { U8 m1 = gui_mbutton_down( 0 ); if( !m1 ) { @@ -1504,8 +1518,8 @@ void gui_editor_2dview_input_tool_draw( GUI_EDITOR_2DVIEW* view ) { } switch( editor->tool.type ) { - case EDITOR_TOOL_WALL: return gui_editor_2dview_input_tool_wall( view ); - case EDITOR_TOOL_POLY: return gui_editor_2dview_input_tool_poly( view ); + case EDITOR_TOOL_WALL: return gui_editor_2dview_input_tool_wall( view ); + case EDITOR_TOOL_POLY: return gui_editor_2dview_input_tool_poly( view ); case EDITOR_TOOL_OBJECT: return gui_editor_2dview_input_tool_object( view ); default: return; } -- cgit v1.2.3