summaryrefslogtreecommitdiff
path: root/src/level.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/level.cpp')
-rw-r--r--src/level.cpp17
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);
+ }
+}