diff options
| author | aura <nw@moneybot.cc> | 2026-07-27 11:55:57 +0200 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-07-27 11:55:57 +0200 |
| commit | 372f23024163e0fab57a847ddda41f06857efd7e (patch) | |
| tree | ca57dd38a583387a7bbcc970b7d359731df0f4bf /src/editor/editor.h | |
| parent | 452e3619450ab9e7d22886445f61cc90272e4d60 (diff) | |
undo/redo props - WIP
Diffstat (limited to 'src/editor/editor.h')
| -rw-r--r-- | src/editor/editor.h | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/src/editor/editor.h b/src/editor/editor.h index 4050029..b506d9c 100644 --- a/src/editor/editor.h +++ b/src/editor/editor.h @@ -34,12 +34,13 @@ enum EditorSelectType_t { EDITOR_SELECT_SURFPROPS }; -enum EditorUndoType_t { +enum EditorActionType_t { EDITOR_UNDO_NONE = 0, EDITOR_UNDO_CREATE_WALLS = 1, EDITOR_UNDO_CREATE_POLY = 2, EDITOR_UNDO_CREATE_SPRITES = 3, - EDITOR_UNDO_CREATE_ENTITIES = 4 + EDITOR_UNDO_CREATE_ENTITIES = 4, + EDITOR_UNDO_EDITPROPS = 5 }; enum EditorInfoBoxType_t { @@ -96,6 +97,55 @@ struct GAME_EDITOR_TOOL { I32 objecttype; }; +struct EDITOR_UNDO_PROPS { + struct PROP_VALUE { + LIST<U8> oldval{}; + LIST<U8> newval{}; + FNV1A hash; + U32 size; + + PROP_VALUE() = default; + PROP_VALUE( FNV1A _hash, U32 _size ) { + this->hash = _hash; + this->size = _size; + + this->oldval.resize( _size ); + this->newval.resize( _size ); + } + PROP_VALUE( FNV1A _hash, U32 _size, void* oldv, void* newv ) { + this->hash = _hash; + this->size = _size; + + this->oldval.resize( _size ); + this->newval.resize( _size ); + memcpy( this->oldval.data, oldv, _size ); + memcpy( this->newval.data, newv, _size ); + } + }; + + struct CHANGES { + EOBJECT* obj; + LIST<PROP_VALUE> props; + }; + LIST<CHANGES> changes; +}; + +struct EDITOR_UNDO_CREATE { + U8 objtype{}; + I32 start_idx{}; + + LIST<MAP_WALL> walls{}; + LIST<MAP_POLYGON> polys{}; + LIST<MAP_SPRITE> sprites{}; + LIST<MAP_ENTITY> entities{}; +}; + +struct EDITOR_UNDO_ACTION { + U8 type; + EDITOR_UNDO_PROPS props; + EDITOR_UNDO_CREATE create; +}; + struct GAME_EDITOR { GAME_DATA* game; @@ -150,14 +200,6 @@ struct GAME_EDITOR { LIST<GUI_LIST_ENTRY> map_list{}; - struct EDITOR_UNDO_ACTION { - U8 type{}; - 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{}; }; @@ -214,6 +256,7 @@ extern void editor_undo_record_create_walls( GAME_EDITOR* e, I32 start_idx, I32 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 void editor_undo_record_change_prop( GAME_EDITOR* e, FNV1A hash, void* oldv, void* newv, U32 size ); extern U8 editor_undo( GAME_EDITOR* e ); extern U8 editor_redo( GAME_EDITOR* e ); @@ -261,6 +304,8 @@ struct GUI_EDITOR_2DVIEW : GUI_VIEW { I32 pending_wall_undo_idx; I32 pending_object_undo_idx; U8 pending_object_undo_type; + + EDITOR_UNDO_PROPS pending_undo_props{}; }; struct GUI_EDITOR_PROPVIEW : GUI_VIEW { |
