Feature #1033 ยป 0055-Make-action_decision_want-icon-animation-slower.patch
| client/tilespec.c | ||
|---|---|---|
|
struct anim {
|
||
|
int frames;
|
||
|
int current;
|
||
|
int time;
|
||
|
int time_per_frame;
|
||
|
struct sprite **sprites;
|
||
|
};
|
||
| ... | ... | |
|
@param frames Number of frames in the animation
|
||
|
@return New anim structure
|
||
|
****************************************************************************/
|
||
|
static struct anim *anim_new(int frames)
|
||
|
static struct anim *anim_new(int frames, int time_per_frame)
|
||
|
{
|
||
|
struct anim *ret = fc_malloc(sizeof(struct anim));
|
||
|
ret->frames = frames;
|
||
|
ret->current = 0;
|
||
|
ret->time = 0;
|
||
|
ret->time_per_frame = time_per_frame;
|
||
|
ret->sprites = fc_malloc(frames * sizeof(struct sprite *));
|
||
|
return ret;
|
||
| ... | ... | |
|
@param t Tileset to load animation from
|
||
|
@param tag Base tag of the animation sprites
|
||
|
****************************************************************************/
|
||
|
static struct anim *anim_load(struct tileset *t, const char *tag)
|
||
|
static struct anim *anim_load(struct tileset *t, const char *tag,
|
||
|
int time_per_frame)
|
||
|
{
|
||
|
int frames = 0;
|
||
|
char buf[1500];
|
||
| ... | ... | |
|
return nullptr;
|
||
|
}
|
||
|
ret = anim_new(frames);
|
||
|
ret = anim_new(frames, time_per_frame);
|
||
|
for (i = 0; i < frames; i++) {
|
||
|
fc_snprintf(buf, sizeof(buf), "%s%d", tag, i);
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
static void anim_advance_time(struct anim *a)
|
||
|
{
|
||
|
a->current++;
|
||
|
a->current %= a->frames;
|
||
|
a->time++;
|
||
|
}
|
||
|
/************************************************************************//**
|
||
|
Get current frame (sprite) of the animation
|
||
|
@param a Animation
|
||
|
@return The sprite
|
||
|
****************************************************************************/
|
||
|
static struct sprite *anim_get_current_frame(struct anim *a)
|
||
|
{
|
||
|
return a->sprites[(a->time / a->time_per_frame) % a->frames];
|
||
|
}
|
||
|
/************************************************************************//**
|
||
| ... | ... | |
|
SET_SPRITE(unit.lowfuel, "unit.lowfuel");
|
||
|
SET_SPRITE(unit.tired, "unit.tired");
|
||
|
t->sprites.unit.action_decision_want = anim_load(t, "unit.action_decision_want");
|
||
|
t->sprites.unit.action_decision_want = anim_load(t, "unit.action_decision_want",
|
||
|
3);
|
||
|
for (i = 0; i < NUM_TILES_HP_BAR; i++) {
|
||
|
fc_snprintf(buffer, sizeof(buffer), "unit.hp_%d", i*10);
|
||
| ... | ... | |
|
t->sprites.unit.vet_lev[i] = load_sprite(t, buffer, TRUE, TRUE, FALSE);
|
||
|
}
|
||
|
t->sprites.unit.select = anim_load(t, "unit.select");
|
||
|
t->sprites.unit.select = anim_load(t, "unit.select", 1);
|
||
|
SET_SPRITE(citybar.shields, "citybar.shields");
|
||
|
SET_SPRITE(citybar.food, "citybar.food");
|
||
| ... | ... | |
|
ADD_SPRITE(s, TRUE, FULL_TILE_X_OFFSET, FULL_TILE_Y_OFFSET)
|
||
|
#define ADD_ANIM_SPRITE(s, draw_fog, x_offset, y_offset) \
|
||
|
ADD_SPRITE(s->sprites[s->current], draw_fog, x_offset, y_offset)
|
||
|
ADD_SPRITE(anim_get_current_frame(s), draw_fog, x_offset, y_offset)
|
||
|
/************************************************************************//**
|
||
|
Assemble some data that is used in building the tile sprite arrays.
|
||
| ... | ... | |
|
void reset_focus_unit_state(struct tileset *t)
|
||
|
{
|
||
|
if (t->sprites.unit.select != nullptr) {
|
||
|
t->sprites.unit.select->current = 0;
|
||
|
t->sprites.unit.select->time = 0;
|
||
|
} else {
|
||
|
focus_unit_state = FALSE;
|
||
|
}
|
||