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/properties.cpp | |
| parent | 452e3619450ab9e7d22886445f61cc90272e4d60 (diff) | |
undo/redo props - WIP
Diffstat (limited to 'src/editor/properties.cpp')
| -rw-r--r-- | src/editor/properties.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/editor/properties.cpp b/src/editor/properties.cpp index a9835e4..109e622 100644 --- a/src/editor/properties.cpp +++ b/src/editor/properties.cpp @@ -111,6 +111,8 @@ U8 gui_editor_propview_is_selected( GUI_EDITOR_PROPVIEW *e, void *what, U8 selty void gui_editor_propview_sync_props_value( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop ) { void* valuep = eprop_ptr( prop ); + + EDITOR_UNDO_ACTION rec{ .type = EDITOR_UNDO_EDITPROPS }; for( auto& it : view->curselect ) { EOBJECT* eobj = (EOBJECT*)it.obj; EDITOR_PROP* otherp = eprop_from_name( eobj, prop->displayname ); @@ -118,10 +120,22 @@ void gui_editor_propview_sync_props_value( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO if( otherp && otherp->type == prop->type ) { void* targetp = eprop_ptr( otherp ); - if( targetp != valuep ) + if( targetp != valuep ) { + EDITOR_UNDO_PROPS::CHANGES changes; + + void* oldval = alloca( prop->size ); + memcpy( oldval, targetp, prop->size ); memcpy( targetp, valuep, prop->size ); + + changes.props.push( { prop->hash, prop->size, oldval, targetp } ); + changes.obj = eobj; + rec.props.changes.push( changes ); + } } } + + if( rec.props.changes.size ) + editor->undo_actions.push( rec ); } void gui_editor_propview_sync_props_value( GUI_EDITOR_PROPVIEW* view, const char* propname ) { @@ -134,6 +148,10 @@ void gui_editor_propview_sync_props_value( GUI_EDITOR_PROPVIEW* view, const char } void gui_editor_propview_sync_props_fdiff( GUI_EDITOR_PROPVIEW* view, EDITOR_PROP* prop, F32* fdiff, U32 valc ) { + if( !fdiff ) + return; + + EDITOR_UNDO_ACTION rec{ .type = EDITOR_UNDO_EDITPROPS }; for( auto& it : view->curselect ) { EOBJECT* eobj = (EOBJECT*)it.obj; EDITOR_PROP* otherp = eprop_from_name( eobj, prop->displayname ); @@ -144,10 +162,21 @@ void gui_editor_propview_sync_props_fdiff( GUI_EDITOR_PROPVIEW* view, EDITOR_PRO if( targetp == eprop_ptr( prop ) ) continue; + EDITOR_UNDO_PROPS::CHANGES changes; + F32* oldval = (F32*)alloca( prop->size ); + memcpy( oldval, targetp, prop->size ); + for( U32 i = 0; i < valc; ++i ) targetp[i] += fdiff[i]; + + changes.props.push( { prop->hash, prop->size, oldval, targetp } ); + changes.obj = eobj; + rec.props.changes.push( changes ); } } + + if( rec.props.changes.size ) + editor->undo_actions.push( rec ); } void gui_editor_propview_sync_props_fdiff( GUI_EDITOR_PROPVIEW* view, const char* propname, F32* fdiff, U32 valc ) { |
