character: use Spritesheet structs instead of strings with names in callbacks

This commit is contained in:
Sebastian Krzyszkowiak 2018-04-15 23:00:53 +02:00
parent c77c91e570
commit 60b960ab2c
2 changed files with 7 additions and 7 deletions

View file

@ -388,20 +388,20 @@ SYMBOL_EXPORT void AnimateCharacter(struct Game* game, struct Character* charact
if (character->repeats > 0) {
character->repeats--;
if (character->callback) {
character->callback(game, character, NULL, character->spritesheet->name, character->callbackData);
character->callback(game, character, NULL, character->spritesheet, character->callbackData);
}
} else {
if ((!character->reversed) && (character->successor)) {
char* old = character->spritesheet->name;
struct Spritesheet* old = character->spritesheet;
SelectSpritesheet(game, character, character->successor);
if (character->callback) {
character->callback(game, character, character->spritesheet->name, old, character->callbackData);
character->callback(game, character, character->spritesheet, old, character->callbackData);
}
} else if ((character->reversed) && (character->predecessor)) {
char* old = character->spritesheet->name;
struct Spritesheet* old = character->spritesheet;
SelectSpritesheet(game, character, character->predecessor);
if (character->callback) {
character->callback(game, character, character->spritesheet->name, old, character->callbackData);
character->callback(game, character, character->spritesheet, old, character->callbackData);
}
} else {
if (character->repeats == 0) {
@ -411,7 +411,7 @@ SYMBOL_EXPORT void AnimateCharacter(struct Game* game, struct Character* charact
character->pos = character->spritesheet->frameCount - 1;
}
if (character->callback) {
character->callback(game, character, NULL, character->spritesheet->name, character->callbackData);
character->callback(game, character, NULL, character->spritesheet, character->callbackData);
}
}
}

View file

@ -94,7 +94,7 @@ struct Character {
bool reversed; /*!< Whether the current animation has been requested as reversed. */
bool hidden;
void* data; /*!< Additional, custom character data (HP etc.). */
void (*callback)(struct Game*, struct Character*, char* newAnim, char* oldAnim, void*);
void (*callback)(struct Game*, struct Character*, struct Spritesheet* newAnim, struct Spritesheet* oldAnim, void*);
void* callbackData;
bool shared; /*!< Marks the list of spritesheets as shared, so it won't be freed together with the character. */
ALLEGRO_TRANSFORM transform;