diff options
| author | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2026-09-03 19:11:39 +0500 |
|---|---|---|
| committer | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2026-09-03 19:11:39 +0500 |
| commit | c88bb49416aaeb13c3969727a305bc7ed3263963 (patch) | |
| tree | 997c136ee0cfc0a5ba6c153c78ab268d0195ac4a /src/puzzles | |
| parent | aaefc10681cc2bcb30268c67de1a4784e0ca891f (diff) | |
more transitions
Diffstat (limited to 'src/puzzles')
| -rw-r--r-- | src/puzzles/collection.c | 7 | ||||
| -rw-r--r-- | src/puzzles/puzzle.h | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/puzzles/collection.c b/src/puzzles/collection.c index 5a46239..ea1a3b1 100644 --- a/src/puzzles/collection.c +++ b/src/puzzles/collection.c @@ -99,7 +99,7 @@ size_t getElementCount(DIR *dir, CollectionElement *el) { return outp; } -void initCollectionFromDir(CollectionElement *el, void (*callback)(CollectionElement *)) { +void initCollectionFromDir(CollectionElement *el, void (*callback)(CollectionElement *), void *callbackData) { if (el == NULL) return; TraceLog(LOG_INFO, "Initializing a collection element from %s/", el->path); @@ -145,6 +145,7 @@ void initCollectionFromDir(CollectionElement *el, void (*callback)(CollectionEle read_el->path = strdup(full_path_buf); read_el->name = getName(entry->d_name); read_el->callback = callback; + read_el->callbackData = callbackData; idx += 1; } @@ -155,7 +156,7 @@ void initCollectionFromDir(CollectionElement *el, void (*callback)(CollectionEle closedir(dir); } -void InitializeCollection(CollectionElement *el, void (*callback)(CollectionElement *)) { +void InitializeCollection(CollectionElement *el, void (*callback)(CollectionElement *), void *callbackData) { if (el == NULL) { TraceLog(LOG_ERROR, "Failed to initialize collection element: the element is NULL"); return; @@ -163,7 +164,7 @@ void InitializeCollection(CollectionElement *el, void (*callback)(CollectionElem switch (el->type) { case COLLECTION_ELEMENT_PUZZLE: break; case COLLECTION_ELEMENT_COLLECTION: - initCollectionFromDir(el, callback); + initCollectionFromDir(el, callback, callbackData); break; default: TraceLog(LOG_WARNING, "Invalid CollectionElement type for %s", el->path); diff --git a/src/puzzles/puzzle.h b/src/puzzles/puzzle.h index 5af6d6e..b269282 100644 --- a/src/puzzles/puzzle.h +++ b/src/puzzles/puzzle.h @@ -116,6 +116,8 @@ typedef struct CollectionElement { size_t childCount; /// OnClick callback void (*callback)(struct CollectionElement *); + /// The data that will be passed with the callback + void *callbackData; /// If the element is initialized it has children and an icon loaded into mem bool IsInitialized; /// The element has an icon @@ -127,7 +129,7 @@ typedef struct CollectionElement { /// Accepts an element which children will be created and a generic callback that /// will be called when the collection enement is selected. /// The element passes a selected element as a callback argummment -void InitializeCollection(CollectionElement *el, void (*callback)(CollectionElement *)); +void InitializeCollection(CollectionElement *el, void (*callback)(CollectionElement *), void *callbackData); void DrawCollectionElement(CollectionElement *el, CollectionElement *parent, Rectangle rec); void UpdateCollectionElement(CollectionElement *el); void DeinitCollectionElement(CollectionElement *el); |
