diff --git a/src/utils.c b/src/utils.c index 61ba1de..a290836 100644 --- a/src/utils.c +++ b/src/utils.c @@ -508,3 +508,16 @@ SYMBOL_EXPORT void DisableCompositor(struct Game* game) { game->handlers.compositor = NULL; ResizeGamestates(game); } + +SYMBOL_EXPORT char* PunchNumber(struct Game* game, char* txt, char ch, int number) { + // TODO: support numbers > 10 + char* text = strdup(txt); + char* tmp = text; + while (*tmp) { + if (*tmp == ch) { + *tmp = '0' + number; + } + tmp++; + } + return AddGarbage(game, text); +} diff --git a/src/utils.h b/src/utils.h index 8426d2c..f083b18 100644 --- a/src/utils.h +++ b/src/utils.h @@ -90,4 +90,6 @@ ALLEGRO_BITMAP* CreateNotPreservedBitmap(int width, int height); void EnableCompositor(struct Game* game, void compositor(struct Game* game, struct Gamestate* gamestates)); void DisableCompositor(struct Game* game); +char* PunchNumber(struct Game* game, char* text, char ch, int number); + #endif