mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
utils: add basic version of PunchNumber utility
This commit is contained in:
parent
6061b8d1bb
commit
61a5eac99e
2 changed files with 15 additions and 0 deletions
13
src/utils.c
13
src/utils.c
|
@ -508,3 +508,16 @@ SYMBOL_EXPORT void DisableCompositor(struct Game* game) {
|
||||||
game->handlers.compositor = NULL;
|
game->handlers.compositor = NULL;
|
||||||
ResizeGamestates(game);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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 EnableCompositor(struct Game* game, void compositor(struct Game* game, struct Gamestate* gamestates));
|
||||||
void DisableCompositor(struct Game* game);
|
void DisableCompositor(struct Game* game);
|
||||||
|
|
||||||
|
char* PunchNumber(struct Game* game, char* text, char ch, int number);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue