diff options
| author | kasull <qsullian@gmail.com> | 2026-03-11 00:24:47 -0400 |
|---|---|---|
| committer | kasull <qsullian@gmail.com> | 2026-03-11 00:24:47 -0400 |
| commit | ae6718ec0fb21077b767e189aca26b0fed488775 (patch) | |
| tree | a4216103d8a9a77edbc470dc4ab094e77ac30261 /src/editor/editor.h | |
| parent | bc1ea16c5be92e3bc810b0a30e01fbc9a7f191a9 (diff) | |
editor object placement and context menus
replace the editor menubar dropdown flow with a reusable context menu
component
merge sprite/entity placement into a single object tool
persist entities, and add undo
support for created sprites and entities
Diffstat (limited to 'src/editor/editor.h')
| -rw-r--r-- | src/editor/editor.h | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/src/editor/editor.h b/src/editor/editor.h index 6735d47..828f2e4 100644 --- a/src/editor/editor.h +++ b/src/editor/editor.h @@ -14,8 +14,7 @@ enum EditorTools_t { EDITOR_TOOL_SELECT, EDITOR_TOOL_WALL, EDITOR_TOOL_POLY, - EDITOR_TOOL_SPRITE, - EDITOR_TOOL_ENT + EDITOR_TOOL_OBJECT }; enum EditorWallShape_t { @@ -38,7 +37,9 @@ enum EditorSelectType_t { enum EditorUndoType_t { EDITOR_UNDO_NONE = 0, EDITOR_UNDO_CREATE_WALLS = 1, - EDITOR_UNDO_CREATE_POLY = 2 + EDITOR_UNDO_CREATE_POLY = 2, + EDITOR_UNDO_CREATE_SPRITES = 3, + EDITOR_UNDO_CREATE_ENTITIES = 4 }; enum EditorInfoBoxType_t { @@ -58,15 +59,22 @@ enum Editor2DViewType_t { EDITOR_2DVIEW_FRONT_ELEVATION = 2 }; -enum EditorMenubarEntryType_t { - EDITOR_MENUBAR_ENTRY_FUNCTION = 0, - EDITOR_MENUBAR_ENTRY_SUBMENU = 1 +enum EditorObjectType_t { + EDITOR_OBJECT_SPRITE = 0, + EDITOR_OBJECT_ENTITY = 1 }; -struct EDITOR_MENUBAR_ENTRY { +typedef void( *EDITOR_CONTEXTMENU_CALLBACK )( void* data ); +struct EDITOR_CONTEXTMENU_ITEM; +typedef U8( *EDITOR_CONTEXTMENU_ENABLED_CALLBACK )( const EDITOR_CONTEXTMENU_ITEM* item ); + +struct EDITOR_CONTEXTMENU_ITEM { char text[64]{}; - U8 type{}; - LIST<EDITOR_MENUBAR_ENTRY> entries{}; + void* data{}; + EDITOR_CONTEXTMENU_CALLBACK cb{}; + EDITOR_CONTEXTMENU_ENABLED_CALLBACK enabled_cb{}; + U8 enabled{1}; + LIST<EDITOR_CONTEXTMENU_ITEM> items{}; }; struct GAME_EDITOR; @@ -85,6 +93,7 @@ struct GAME_EDITOR_TOOL { /* entity */ U32 entclass; void* entprops; + I32 objecttype; }; struct GAME_EDITOR { @@ -115,6 +124,7 @@ struct GAME_EDITOR { I32 view_mode{}; I32 view2d_type{}; + struct GUI_EDITOR_CONTEXTMENU* contextmenu{}; GUI_BASE* header_toolbar{}; GUI_LABEL* header_viewtype_label{}; GUI_BUTTON* header_back{}; @@ -145,6 +155,8 @@ struct GAME_EDITOR { I32 start_idx{}; LIST<MAP_WALL> walls{}; LIST<MAP_POLYGON> polys{}; + LIST<MAP_SPRITE> sprites{}; + LIST<MAP_ENTITY> entities{}; }; LIST<EDITOR_UNDO_ACTION> undo_actions{}; LIST<EDITOR_UNDO_ACTION> redo_actions{}; @@ -197,11 +209,14 @@ extern void editor_create_map_view( GAME_EDITOR* e ); extern void editor_update_properties_column( GAME_EDITOR* e ); extern const char* editor_tool_name(); extern void editor_set_view_mode( I32 mode ); -extern void editor_toolbar_set_open( struct GUI_EDITOR_TOOLBAR* bar, U8 file_open, U8 edit_open ); -extern U8 editor_toolbar_menu_open( const struct GUI_EDITOR_TOOLBAR* bar ); +extern void editor_show_contextmenu( I32 x, I32 y, LIST<EDITOR_CONTEXTMENU_ITEM>* items, const char* title = 0 ); +extern void editor_hide_contextmenu(); +extern U8 editor_contextmenu_open(); extern void editor_undo_clear( GAME_EDITOR* e ); extern void editor_undo_record_create_walls( GAME_EDITOR* e, I32 start_idx, I32 count ); extern void editor_undo_record_create_poly( GAME_EDITOR* e, I32 start_idx ); +extern void editor_undo_record_create_sprite( GAME_EDITOR* e, I32 start_idx ); +extern void editor_undo_record_create_entity( GAME_EDITOR* e, I32 start_idx ); extern U8 editor_undo( GAME_EDITOR* e ); extern U8 editor_redo( GAME_EDITOR* e ); @@ -233,8 +248,11 @@ struct GUI_EDITOR_2DVIEW : GUI_VIEW { U8 poly_drag; VEC2 poly_start; VEC2 poly_end; + VEC3 pending_object_pos; I32 pending_wall_undo_idx; + I32 pending_object_undo_idx; + U8 pending_object_undo_type; }; struct GUI_EDITOR_PROPVIEW : GUI_VIEW { @@ -247,6 +265,8 @@ struct GUI_EDITOR_PROPVIEW : GUI_VIEW { struct GUI_EDITOR_TOOLVIEW : GUI_VIEW { GUI_VIEW* itemview; U8 wallshape_dropdown_open; + U8 objecttype_dropdown_open; + U8 entclass_dropdown_open; I32 scroll; I32 content_h; }; @@ -283,12 +303,19 @@ struct GUI_EDITOR_VIEWTYPE_SEGMENT : GUI_BASE { I32 held_seg{-1}; }; +struct GUI_EDITOR_CONTEXTMENU : GUI_BASE { + LIST<EDITOR_CONTEXTMENU_ITEM>* items{}; + U8 initheld{1}; + U8 held{}; + I32 held_idx{-1}; + char title[64]{}; +}; + struct GUI_EDITOR_TOOLBAR : GUI_BASE { U8 held{}; I32 held_root{-1}; - I32 held_sub{-1}; - I32 open_root{-1}; - LIST<EDITOR_MENUBAR_ENTRY> entries{}; + I32 active_root{-1}; + LIST<EDITOR_CONTEXTMENU_ITEM> entries{}; }; extern GUI_EDITORWINDOW* gui_editorwindow( I32 w, I32 h ); |
