diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-09-25 12:05:37 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-09-25 12:05:37 -0400 |
| commit | b84438b140c64b084919ea3366d4f4ff66e5b1c7 (patch) | |
| tree | 409434d8f9fd8700ffb49eb71bf9cfe56ad8e54c /src/level.cpp | |
| parent | 0e6193c2195f4b24bafb6f2ff4012db383180ff9 (diff) | |
pke: pke_level unregister root ui box
Necessary for editor + manually managing boxes
without using invisibility
Diffstat (limited to 'src/level.cpp')
| -rw-r--r-- | src/level.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/level.cpp b/src/level.cpp index 27e7722..f839a6e 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -163,3 +163,20 @@ void pke_level_register_root_ui_box(pke_level *level, pke_ui_box *box) { assert(box != nullptr); pk_arr_append_t(&level->root_ui_boxes, box); } + +bool find_box_fn(void *user_data, void *item) { + (void)user_data; + void *box = *reinterpret_cast<pke_ui_box **>(item); + return user_data == box; +} + +void pke_level_unregister_root_ui_box(pke_level *level, pke_ui_box *box) { + assert(level != nullptr); + assert(box != nullptr); + uint32_t idx = pk_arr_find_first_index(&level->root_ui_boxes, box, find_box_fn); + if (idx < level->root_ui_boxes.next) { + pk_arr_remove_at(&level->root_ui_boxes, idx); + } else { + fprintf(stderr, "[pke_level_unregister_root_ui_box] attempted to unregister ui box that was not registered with level '%*s'!\n", LEVEL_NAME_MAX_LEN, level->name); + } +} |
