Mercurial > molko
changeset 468:91ce23a36143
core: sprite -> mlk_sprite
line wrap: on
line diff
--- a/examples/example-animation/example-animation.c Mon Feb 27 11:06:45 2023 +0100 +++ b/examples/example-animation/example-animation.c Mon Feb 27 11:08:28 2023 +0100 @@ -48,7 +48,7 @@ static struct state *states[1]; static struct texture numbers; static struct mlk_animation animation; -static struct sprite sprite; +static struct mlk_sprite sprite; static int completed = 1; static void @@ -119,7 +119,7 @@ .draw = draw }; - sprite_init(&sprite, &numbers, 48, 48); + mlk_sprite_init(&sprite, &numbers, 48, 48); mlk_animation_init(&animation, &sprite, 1000); mlk_game_init(states, UTIL_SIZE(states));
--- a/examples/example-drawable/example-drawable.c Mon Feb 27 11:06:45 2023 +0100 +++ b/examples/example-drawable/example-drawable.c Mon Feb 27 11:08:28 2023 +0100 @@ -64,7 +64,7 @@ /* 0: Explosion animation. */ static struct texture explosion_tex; -static struct sprite explosion_sprite; +static struct mlk_sprite explosion_sprite; struct explosion { struct mlk_animation anim; @@ -83,7 +83,7 @@ if (mlk_image_openmem(&explosion_tex, assets_sprites_explosion, sizeof (assets_sprites_explosion)) < 0) mlk_panic(); - sprite_init(&explosion_sprite, &explosion_tex, 256, 256); + mlk_sprite_init(&explosion_sprite, &explosion_tex, 256, 256); } static int
--- a/examples/example-sprite/example-sprite.c Mon Feb 27 11:06:45 2023 +0100 +++ b/examples/example-sprite/example-sprite.c Mon Feb 27 11:08:28 2023 +0100 @@ -45,7 +45,7 @@ static char msg[512]; static struct texture texture; -static struct sprite sprite; +static struct mlk_sprite sprite; static unsigned int row, column; static struct state *states[1]; @@ -72,7 +72,7 @@ if (mlk_image_openmem(&texture, assets_sprites_people, sizeof (assets_sprites_people)) < 0) mlk_panic(); - sprite_init(&sprite, &texture, 48, 48); + mlk_sprite_init(&sprite, &texture, 48, 48); } static void @@ -123,7 +123,7 @@ mlk_painter_set_color(0xebede9ff); mlk_painter_clear(); align(ALIGN_CENTER, &x, &y, sprite.cellw, sprite.cellh, 0, 0, W, H); - sprite_draw(&sprite, row, column, x, y); + mlk_sprite_draw(&sprite, row, column, x, y); label_draw(&help); mlk_painter_present(); }
--- a/libmlk-core/mlk/core/animation.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-core/mlk/core/animation.c Mon Feb 27 11:08:28 2023 +0100 @@ -36,7 +36,7 @@ } void -mlk_animation_init(struct mlk_animation *an, const struct sprite *sprite, unsigned int delay) +mlk_animation_init(struct mlk_animation *an, const struct mlk_sprite *sprite, unsigned int delay) { assert(an); assert(sprite); @@ -99,7 +99,7 @@ { assert(an); - return sprite_draw(an->sprite, an->row, an->column, x, y); + return mlk_sprite_draw(an->sprite, an->row, an->column, x, y); } void
--- a/libmlk-core/mlk/core/animation.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-core/mlk/core/animation.h Mon Feb 27 11:08:28 2023 +0100 @@ -22,10 +22,10 @@ #include "core.h" struct mlk_drawable; -struct sprite; +struct mlk_sprite; struct mlk_animation { - const struct sprite *sprite; + const struct mlk_sprite *sprite; unsigned int row; unsigned int column; unsigned int delay; @@ -35,7 +35,7 @@ MLK_CORE_BEGIN_DECLS void -mlk_animation_init(struct mlk_animation *, const struct sprite *, unsigned int); +mlk_animation_init(struct mlk_animation *, const struct mlk_sprite *, unsigned int); void mlk_animation_start(struct mlk_animation *);
--- a/libmlk-core/mlk/core/sprite.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-core/mlk/core/sprite.c Mon Feb 27 11:08:28 2023 +0100 @@ -22,7 +22,7 @@ #include "texture.h" void -sprite_init(struct sprite *sprite, +mlk_sprite_init(struct mlk_sprite *sprite, struct texture *tex, unsigned int cellw, unsigned int cellh) @@ -38,19 +38,19 @@ } int -sprite_ok(const struct sprite *sprite) +mlk_sprite_ok(const struct mlk_sprite *sprite) { return sprite && texture_ok(sprite->texture) && sprite->cellw != 0 && sprite->cellh != 0; } int -sprite_draw(const struct sprite *sprite, unsigned int r, unsigned int c, int x, int y) +mlk_sprite_draw(const struct mlk_sprite *sprite, unsigned int r, unsigned int c, int x, int y) { - return sprite_scale(sprite, r, c, x, y, sprite->cellw, sprite->cellh); + return mlk_sprite_scale(sprite, r, c, x, y, sprite->cellw, sprite->cellh); } int -sprite_scale(const struct sprite *sprite, +mlk_sprite_scale(const struct mlk_sprite *sprite, unsigned int r, unsigned int c, int x, @@ -58,7 +58,7 @@ unsigned int w, unsigned int h) { - assert(sprite_ok(sprite)); + assert(mlk_sprite_ok(sprite)); assert(r < sprite->nrows); assert(c < sprite->ncols);
--- a/libmlk-core/mlk/core/sprite.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-core/mlk/core/sprite.h Mon Feb 27 11:08:28 2023 +0100 @@ -23,7 +23,7 @@ struct texture; -struct sprite { +struct mlk_sprite { struct texture *texture; unsigned int cellw; unsigned int cellh; @@ -34,16 +34,16 @@ MLK_CORE_BEGIN_DECLS void -sprite_init(struct sprite *, struct texture *, unsigned int, unsigned int); +mlk_sprite_init(struct mlk_sprite *, struct texture *, unsigned int, unsigned int); int -sprite_ok(const struct sprite *); +mlk_sprite_ok(const struct mlk_sprite *); int -sprite_draw(const struct sprite *, unsigned int, unsigned int, int, int); +mlk_sprite_draw(const struct mlk_sprite *, unsigned int, unsigned int, int, int); int -sprite_scale(const struct sprite *, +mlk_sprite_scale(const struct mlk_sprite *, unsigned int, unsigned int, int,
--- a/libmlk-example/mlk/example/registry.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-example/mlk/example/registry.c Mon Feb 27 11:08:28 2023 +0100 @@ -38,7 +38,7 @@ struct texture registry_images[REGISTRY_IMAGE_NUM]; struct texture registry_textures[REGISTRY_TEXTURE_NUM]; -struct sprite registry_sprites[REGISTRY_TEXTURE_NUM]; +struct mlk_sprite registry_sprites[REGISTRY_TEXTURE_NUM]; struct mlk_sound registry_sounds[REGISTRY_SOUND_NUM]; #define REGISTRY_IMAGE(i, data) \ @@ -97,15 +97,15 @@ { for (size_t i = 0; i < UTIL_SIZE(textures); ++i) { struct texture *texture = ®istry_textures[textures[i].index]; - struct sprite *sprite = ®istry_sprites[textures[i].index]; + struct mlk_sprite *sprite = ®istry_sprites[textures[i].index]; if (mlk_image_openmem(texture, textures[i].data, textures[i].datasz) < 0) mlk_panic(); if (textures[i].cellw == 0 || textures[i].cellh == 0) - sprite_init(sprite, texture, texture->w, texture->h); + mlk_sprite_init(sprite, texture, texture->w, texture->h); else - sprite_init(sprite, texture, textures[i].cellw, textures[i].cellh); + mlk_sprite_init(sprite, texture, textures[i].cellw, textures[i].cellh); } }
--- a/libmlk-example/mlk/example/registry.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-example/mlk/example/registry.h Mon Feb 27 11:08:28 2023 +0100 @@ -54,7 +54,7 @@ extern struct texture registry_images[REGISTRY_IMAGE_NUM]; extern struct texture registry_textures[REGISTRY_TEXTURE_NUM]; -extern struct sprite registry_sprites[REGISTRY_TEXTURE_NUM]; +extern struct mlk_sprite registry_sprites[REGISTRY_TEXTURE_NUM]; extern struct mlk_sound registry_sounds[REGISTRY_SOUND_NUM]; void
--- a/libmlk-example/mlk/example/spell-fire.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-example/mlk/example/spell-fire.c Mon Feb 27 11:08:28 2023 +0100 @@ -55,7 +55,7 @@ { const struct self *self = dw->data; const struct battle_entity *et = self->battle->enemies[self->selection]; - const struct sprite *sprite = et->ch->sprites[CHARACTER_SPRITE_NORMAL]; + const struct mlk_sprite *sprite = et->ch->sprites[CHARACTER_SPRITE_NORMAL]; int x, y; align(ALIGN_CENTER,
--- a/libmlk-rpg/mlk/rpg/battle-bar-default.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar-default.c Mon Feb 27 11:08:28 2023 +0100 @@ -155,7 +155,7 @@ battle_state_selection(bt, &sel); /* A cursor should be present. */ - if (!sprite_ok(BATTLE_THEME(bt)->sprites[THEME_SPRITE_CURSOR])) + if (!mlk_sprite_ok(BATTLE_THEME(bt)->sprites[THEME_SPRITE_CURSOR])) tracef("battle: no cursor sprite in theme"); }
--- a/libmlk-rpg/mlk/rpg/battle-entity-state-attacking.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-entity-state-attacking.c Mon Feb 27 11:08:28 2023 +0100 @@ -56,10 +56,10 @@ } void -battle_entity_state_attacking_init(struct battle_entity_state_attacking *atk, const struct sprite *which) +battle_entity_state_attacking_init(struct battle_entity_state_attacking *atk, const struct mlk_sprite *which) { assert(atk); - assert(sprite_ok(which)); + assert(mlk_sprite_ok(which)); mlk_animation_init(&atk->anim, which, 100); mlk_animation_start(&atk->anim); @@ -83,10 +83,10 @@ } void -battle_entity_state_attacking(struct battle_entity *et, const struct sprite *which) +battle_entity_state_attacking(struct battle_entity *et, const struct mlk_sprite *which) { assert(battle_entity_ok(et)); - assert(sprite_ok(which)); + assert(mlk_sprite_ok(which)); struct self *self;
--- a/libmlk-rpg/mlk/rpg/battle-entity-state-attacking.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-entity-state-attacking.h Mon Feb 27 11:08:28 2023 +0100 @@ -22,14 +22,14 @@ #include <mlk/core/animation.h> struct battle_entity; -struct sprite; +struct mlk_sprite; struct battle_entity_state_attacking { struct mlk_animation anim; }; void -battle_entity_state_attacking_init(struct battle_entity_state_attacking *, const struct sprite *); +battle_entity_state_attacking_init(struct battle_entity_state_attacking *, const struct mlk_sprite *); int battle_entity_state_attacking_update(struct battle_entity_state_attacking *, unsigned int); @@ -38,6 +38,6 @@ battle_entity_state_attacking_draw(const struct battle_entity_state_attacking *, const struct battle_entity *); void -battle_entity_state_attacking(struct battle_entity *, const struct sprite *); +battle_entity_state_attacking(struct battle_entity *, const struct mlk_sprite *); #endif /* !MLK_RPG_BATTLE_ENTITY_STATE_ATTACKING_H */
--- a/libmlk-rpg/mlk/rpg/battle-entity-state.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-entity-state.h Mon Feb 27 11:08:28 2023 +0100 @@ -22,7 +22,7 @@ #include <mlk/core/core.h> struct battle_entity; -struct sprite; +struct mlk_sprite; struct battle_entity_state { void *data;
--- a/libmlk-rpg/mlk/rpg/battle-entity.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-entity.c Mon Feb 27 11:08:28 2023 +0100 @@ -84,7 +84,7 @@ void battle_entity_draw_sprite(const struct battle_entity *et) { - struct sprite *sprite = et->ch->sprites[CHARACTER_SPRITE_NORMAL]; + struct mlk_sprite *sprite = et->ch->sprites[CHARACTER_SPRITE_NORMAL]; int row; /* @@ -97,7 +97,7 @@ else row = 0; - sprite_draw(sprite, row, 0, et->x, et->y); + mlk_sprite_draw(sprite, row, 0, et->x, et->y); } void
--- a/libmlk-rpg/mlk/rpg/battle-state-check.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-check.c Mon Feb 27 11:08:28 2023 +0100 @@ -65,10 +65,10 @@ fadeout_draw(struct mlk_drawable *dw) { const struct fadeout *fade = dw->data; - struct sprite *sprite = fade->ch->sprites[CHARACTER_SPRITE_NORMAL]; + struct mlk_sprite *sprite = fade->ch->sprites[CHARACTER_SPRITE_NORMAL]; texture_set_alpha_mod(sprite->texture, fade->alpha); - sprite_draw(sprite, 0, 0, fade->x, fade->y); + mlk_sprite_draw(sprite, 0, 0, fade->x, fade->y); texture_set_alpha_mod(sprite->texture, 255); }
--- a/libmlk-rpg/mlk/rpg/battle-state-selection.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-selection.c Mon Feb 27 11:08:28 2023 +0100 @@ -116,7 +116,7 @@ draw_cursor(const struct battle *bt, const struct battle_entity *et) { const struct theme *theme = BATTLE_THEME(bt); - const struct sprite *cursor = theme->sprites[THEME_SPRITE_CURSOR]; + const struct mlk_sprite *cursor = theme->sprites[THEME_SPRITE_CURSOR]; int x, y; unsigned int lh; @@ -128,7 +128,7 @@ x = et->name.x - cursor->cellw - theme->padding; y = et->name.y + (((int)(lh) - (int)(cursor->cellh)) / 2); - sprite_draw(cursor, 1, 2, x, y); + mlk_sprite_draw(cursor, 1, 2, x, y); } static void
--- a/libmlk-rpg/mlk/rpg/battle.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle.c Mon Feb 27 11:08:28 2023 +0100 @@ -133,7 +133,7 @@ positionate_name(struct battle_entity *et, const struct battle *bt) { unsigned int lw; - struct sprite *sprite; + struct mlk_sprite *sprite; /* Show the character name below its sprite. */ sprite = et->ch->sprites[CHARACTER_SPRITE_NORMAL];
--- a/libmlk-rpg/mlk/rpg/character.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/character.c Mon Feb 27 11:08:28 2023 +0100 @@ -30,7 +30,7 @@ int character_ok(const struct character *ch) { - return ch && ch->name && ch->reset && sprite_ok(ch->sprites[CHARACTER_SPRITE_NORMAL]); + return ch && ch->name && ch->reset && mlk_sprite_ok(ch->sprites[CHARACTER_SPRITE_NORMAL]); } const char *
--- a/libmlk-rpg/mlk/rpg/character.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/character.h Mon Feb 27 11:08:28 2023 +0100 @@ -25,7 +25,7 @@ struct battle; struct save; -struct sprite; +struct mlk_sprite; struct spell; enum character_status { @@ -76,7 +76,7 @@ unsigned int luckbonus; unsigned int team_order; - struct sprite *sprites[CHARACTER_SPRITE_NUM]; + struct mlk_sprite *sprites[CHARACTER_SPRITE_NUM]; const struct equipment *equipments[CHARACTER_EQUIPMENT_NUM]; const struct spell *spells[CHARACTER_SPELL_MAX];
--- a/libmlk-rpg/mlk/rpg/map.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/map.h Mon Feb 27 11:08:28 2023 +0100 @@ -75,7 +75,7 @@ struct mlk_action_stack astack_seq; /*!< (+) Blocking actions. */ /* Player. */ - struct sprite *player_sprite; /*!< (+) The sprite to use */ + struct mlk_sprite *player_sprite; /*!< (+) The sprite to use */ struct walksprite player_ws; /*!< (-) Walking sprite for moving the player. */ int player_x; /*!< (+) Player position in x */ int player_y; /*!< (+) Player position in y */
--- a/libmlk-rpg/mlk/rpg/tileset-file.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/tileset-file.c Mon Feb 27 11:08:28 2023 +0100 @@ -66,7 +66,7 @@ struct tileset_animation_block { struct texture texture; - struct sprite sprite; + struct mlk_sprite sprite; struct mlk_animation animation; }; @@ -196,7 +196,7 @@ if (mlk_image_open(&anim->texture, util_pathf("%s/%s", ctx->basedir, filename)) < 0) return -1; - sprite_init(&anim->sprite, &anim->texture, ctx->tilewidth, ctx->tileheight); + mlk_sprite_init(&anim->sprite, &anim->texture, ctx->tilewidth, ctx->tileheight); mlk_animation_init(&anim->animation, &anim->sprite, delay); } @@ -239,7 +239,7 @@ if (mlk_image_open(&ctx->tf->image, util_pathf("%s/%s", ctx->basedir, p + 1)) < 0) return -1; - sprite_init(&ctx->tf->sprite, &ctx->tf->image, ctx->tilewidth, ctx->tileheight); + mlk_sprite_init(&ctx->tf->sprite, &ctx->tf->image, ctx->tilewidth, ctx->tileheight); ctx->tileset->sprite = &ctx->tf->sprite; return 0;
--- a/libmlk-rpg/mlk/rpg/tileset-file.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/tileset-file.h Mon Feb 27 11:08:28 2023 +0100 @@ -33,7 +33,7 @@ struct mlk_alloc_pool tiledefs; struct mlk_alloc_pool anims[2]; struct texture image; - struct sprite sprite; + struct mlk_sprite sprite; }; MLK_CORE_BEGIN_DECLS
--- a/libmlk-rpg/mlk/rpg/tileset.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/tileset.c Mon Feb 27 11:08:28 2023 +0100 @@ -51,7 +51,7 @@ int tileset_ok(const struct tileset *ts) { - return ts && sprite_ok(ts->sprite); + return ts && mlk_sprite_ok(ts->sprite); } void @@ -89,5 +89,5 @@ if ((ta = find(ts, r, c))) mlk_animation_draw(ta->animation, x, y); else - sprite_draw(ts->sprite, r, c, x, y); + mlk_sprite_draw(ts->sprite, r, c, x, y); }
--- a/libmlk-rpg/mlk/rpg/tileset.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/tileset.h Mon Feb 27 11:08:28 2023 +0100 @@ -23,7 +23,7 @@ #include <mlk/core/core.h> -struct sprite; +struct mlk_sprite; struct tileset_tiledef { unsigned short id; @@ -43,7 +43,7 @@ size_t tiledefsz; struct tileset_animation *anims; size_t animsz; - struct sprite *sprite; + struct mlk_sprite *sprite; }; MLK_CORE_BEGIN_DECLS
--- a/libmlk-rpg/mlk/rpg/walksprite.c Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/walksprite.c Mon Feb 27 11:08:28 2023 +0100 @@ -24,7 +24,7 @@ #include "walksprite.h" void -walksprite_init(struct walksprite *ws, struct sprite *sprite, unsigned int delay) +walksprite_init(struct walksprite *ws, struct mlk_sprite *sprite, unsigned int delay) { assert(ws); assert(sprite); @@ -65,5 +65,5 @@ assert(ws); assert(orientation < 8); - sprite_draw(ws->sprite, orientation, ws->index, x, y); + mlk_sprite_draw(ws->sprite, orientation, ws->index, x, y); }
--- a/libmlk-rpg/mlk/rpg/walksprite.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/walksprite.h Mon Feb 27 11:08:28 2023 +0100 @@ -21,7 +21,7 @@ #include <mlk/core/core.h> -struct sprite; +struct mlk_sprite; /** * \brief Sprite designed for walking entities. @@ -54,7 +54,7 @@ * ``` */ struct walksprite { - struct sprite *sprite; + struct mlk_sprite *sprite; unsigned int delay; unsigned int index; unsigned int elapsed; @@ -63,7 +63,7 @@ MLK_CORE_BEGIN_DECLS void -walksprite_init(struct walksprite *, struct sprite *, unsigned int); +walksprite_init(struct walksprite *, struct mlk_sprite *, unsigned int); void walksprite_reset(struct walksprite *);
--- a/libmlk-ui/mlk/ui/theme.h Mon Feb 27 11:06:45 2023 +0100 +++ b/libmlk-ui/mlk/ui/theme.h Mon Feb 27 11:08:28 2023 +0100 @@ -26,7 +26,7 @@ struct mlk_font; struct frame; struct label; -struct sprite; +struct mlk_sprite; enum theme_font { THEME_FONT_DEBUG, @@ -50,7 +50,7 @@ struct theme { struct mlk_font *fonts[THEME_FONT_NUM]; - const struct sprite *sprites[THEME_SPRITE_NUM]; + const struct mlk_sprite *sprites[THEME_SPRITE_NUM]; unsigned long colors[THEME_COLOR_NUM]; unsigned int padding;