diff options
Diffstat (limited to 'src/editor/editor.cpp')
| -rw-r--r-- | src/editor/editor.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index ad23d1e..3c67ecd 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -4,6 +4,36 @@ GAME_EDITOR* editor = 0; +void editor_register_grid_dependency( GAME_EDITOR* e, void* tag, EDITOR_GRID_DEP_CALLBACK cb ) { + if( !e || !tag || !cb ) + return; + + I32 idx = e->grid_dependencies.idx_where( fn( GAME_EDITOR::GRID_DEPENDENCY* dep ) { + return dep->tag == tag; + } ); + + if( idx != -1 ) { + e->grid_dependencies[idx].cb = cb; + return; + } + + GAME_EDITOR::GRID_DEPENDENCY dep; + dep.tag = tag; + dep.cb = cb; + e->grid_dependencies.push( dep ); +} + +void editor_notify_grid_change( GAME_EDITOR* e ) { + if( !e ) + return; + + e->grid_dependencies.each( fn( GAME_EDITOR::GRID_DEPENDENCY* dep ) { + if( dep->cb ) { + dep->cb( e ); + } + } ); +} + GAME_EDITOR* editor_create( GAME_DATA* game ) { if( editor ) { dlog( "editor_create() : attempted to create editor when one already exists\n" ); |
