From 413ef78504278d37080b9b59a652e4bbd5e2a0fc Mon Sep 17 00:00:00 2001 From: kasull Date: Sun, 1 Mar 2026 20:18:08 -0500 Subject: editor ui rework add responsive editor relayout for window resize rework header with back/save, view mode buttons, and 2d view type selector add clipped, scrollable assets and contextual tool panels simplify tool button wiring and repeated layout logic simplify 2d top-down editor internals and shared grid update hooks --- src/editor/editor.h | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/editor/editor.h') diff --git a/src/editor/editor.h b/src/editor/editor.h index cd42a4e..0fee667 100644 --- a/src/editor/editor.h +++ b/src/editor/editor.h @@ -8,7 +8,6 @@ const F32 EDITOR_DEFAULT_POLY_SIDES = 6.f; const F32 EDITOR_DEFAULT_WALL_HEIGHT = 80.f; const F32 EDITOR_DEFAULT_PLACEMENT_HEIGHT = 0.f; const I32 EDITOR_POLY_SIDES_MIN = 3; -const I32 EDITOR_POLY_SIDES_MAX = 32; enum EditorTools_t { EDITOR_TOOL_NONE, @@ -36,6 +35,9 @@ enum EditorSelectType_t { EDITOR_SELECT_SURFPROPS }; +struct GAME_EDITOR; +typedef void( *EDITOR_GRID_DEP_CALLBACK )( GAME_EDITOR* e ); + struct GAME_EDITOR_TOOL { U8 type; @@ -68,6 +70,24 @@ struct GAME_EDITOR { struct GUI_EDITOR_PROPVIEW* props; struct GUI_EDITOR_TOOLVIEW* tool; I32 map_select{}; + + I32 props_w{300}; + I32 props_h{300}; + I32 view_h{370}; + + GUI_VIEW* assets{}; + GUI_VIEW* status{}; + I32 assets_scroll{}; + I32 view_mode{}; + I32 view2d_type{}; + + GUI_LABEL* header_viewtype_label{}; + GUI_BUTTON* header_back{}; + GUI_BUTTON* header_save{}; + GUI_BUTTON* header_mode_2d{}; + GUI_BUTTON* header_mode_3d{}; + GUI_BUTTON* header_mode_sim{}; + GUI_BASE* header_viewtype{}; } gui; @@ -78,6 +98,12 @@ struct GAME_EDITOR { F32 spritesize{}; U8 drawbsp{}; + struct GRID_DEPENDENCY { + void* tag{}; + EDITOR_GRID_DEP_CALLBACK cb{}; + }; + LIST grid_dependencies{}; + LIST map_list{}; }; @@ -87,6 +113,9 @@ extern STAT editor_load_map( GAME_EDITOR* e, const char* mapname ); extern STAT editor_save_map( GAME_EDITOR* e ); extern STAT editor_new_map( GAME_EDITOR* e, const char* mapname ); extern STAT editor_close( GAME_EDITOR* e ); +extern void editor_resize( GAME_EDITOR* e, I32 w, I32 h ); +extern void editor_register_grid_dependency( GAME_EDITOR* e, void* tag, EDITOR_GRID_DEP_CALLBACK cb ); +extern void editor_notify_grid_change( GAME_EDITOR* e ); extern LIST* editor_get_map_list( GAME_EDITOR* e ); @@ -136,6 +165,8 @@ struct GUI_EDITOR_PROPVIEW : GUI_VIEW { struct GUI_EDITOR_TOOLVIEW : GUI_VIEW { GUI_VIEW* itemview; U8 wallshape_dropdown_open; + I32 scroll; + I32 content_h; }; struct GUI_EDITOR_TEXTUREPICKER : GUI_WINDOW { -- cgit v1.2.3 From 5c4e9c8b140b14ba9671b8efcc47d71c6c4f2217 Mon Sep 17 00:00:00 2001 From: kasull Date: Tue, 3 Mar 2026 12:22:40 -0500 Subject: ui header/menu and add undo/redo for creation actions full-width toolbar/menubar layer move save into file menu and add edit menu actions for undo/redo menubar dropdown interaction modal update header/view-type labels and menu layout behavior creation-history tracking for walls and polygons undo (ctrl+z) and redo (ctrl+r) in 2d editor improve list/button visual states --- src/editor/editor.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/editor/editor.h') diff --git a/src/editor/editor.h b/src/editor/editor.h index 0fee667..2067df5 100644 --- a/src/editor/editor.h +++ b/src/editor/editor.h @@ -35,6 +35,12 @@ enum EditorSelectType_t { EDITOR_SELECT_SURFPROPS }; +enum EditorUndoType_t { + EDITOR_UNDO_NONE = 0, + EDITOR_UNDO_CREATE_WALLS = 1, + EDITOR_UNDO_CREATE_POLY = 2 +}; + struct GAME_EDITOR; typedef void( *EDITOR_GRID_DEP_CALLBACK )( GAME_EDITOR* e ); @@ -81,9 +87,9 @@ struct GAME_EDITOR { I32 view_mode{}; I32 view2d_type{}; + GUI_BASE* header_toolbar{}; GUI_LABEL* header_viewtype_label{}; GUI_BUTTON* header_back{}; - GUI_BUTTON* header_save{}; GUI_BUTTON* header_mode_2d{}; GUI_BUTTON* header_mode_3d{}; GUI_BUTTON* header_mode_sim{}; @@ -105,6 +111,15 @@ struct GAME_EDITOR { LIST grid_dependencies{}; LIST map_list{}; + + struct EDITOR_UNDO_ACTION { + U8 type{}; + I32 start_idx{}; + LIST walls{}; + LIST polys{}; + }; + LIST undo_actions{}; + LIST redo_actions{}; }; extern GAME_EDITOR* editor_create( struct GAME_DATA* game ); @@ -124,6 +139,11 @@ extern void editor_new_map_cb( void* ); extern void editor_create_map_view( GAME_EDITOR* e ); extern void editor_update_properties_column( GAME_EDITOR* e ); +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 U8 editor_undo( GAME_EDITOR* e ); +extern U8 editor_redo( GAME_EDITOR* e ); struct GUI_EDITORWINDOW : GUI_WINDOW {}; struct GUI_EDITOR_3DVIEW : GUI_VIEW { @@ -153,6 +173,8 @@ struct GUI_EDITOR_2DVIEW : GUI_VIEW { U8 poly_drag; VEC2 poly_start; VEC2 poly_end; + + I32 pending_wall_undo_idx; }; struct GUI_EDITOR_PROPVIEW : GUI_VIEW { -- cgit v1.2.3 From be91342733fd56d1e7bafe72e82a8ac4dc67b79d Mon Sep 17 00:00:00 2001 From: kasull Date: Tue, 3 Mar 2026 18:49:43 -0500 Subject: fix use after free --- src/editor/editor.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/editor/editor.h') diff --git a/src/editor/editor.h b/src/editor/editor.h index 2067df5..ad43705 100644 --- a/src/editor/editor.h +++ b/src/editor/editor.h @@ -128,6 +128,7 @@ extern STAT editor_load_map( GAME_EDITOR* e, const char* mapname ); extern STAT editor_save_map( GAME_EDITOR* e ); extern STAT editor_new_map( GAME_EDITOR* e, const char* mapname ); extern STAT editor_close( GAME_EDITOR* e ); +extern void editor_clear_gui_state_refs( GAME_EDITOR* e ); extern void editor_resize( GAME_EDITOR* e, I32 w, I32 h ); extern void editor_register_grid_dependency( GAME_EDITOR* e, void* tag, EDITOR_GRID_DEP_CALLBACK cb ); extern void editor_notify_grid_change( GAME_EDITOR* e ); -- cgit v1.2.3