diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 22:06:21 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 22:21:33 +0100 |
commit | c25e1d6fd68f1f85af9e7f6dd0d35c725000014f (patch) | |
tree | efb7cb8a1d1919877c3b218a1510140935d43ec3 /blits.c | |
parent | 8c37dc0c5e6f4e588d37f5900764125716bc7f77 (diff) |
allow to display a multiple selection
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'blits.c')
-rw-r--r-- | blits.c | 55 |
1 files changed, 37 insertions, 18 deletions
@@ -125,7 +125,7 @@ void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct char TTF_CloseFont (police); } -static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struct character_t *chr) +static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struct target_t *target) { SDL_Color color = {0x8a, 0x00, 0x00, 0x00}; TTF_Font *font = TTF_OpenFont("times.ttf", 20); @@ -135,18 +135,22 @@ static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struc /* display the information frame */ SDL_BlitSurface(surfaces->Pcadrecible, NULL, surfaces->Pecran, &positions->Vpositioncadrecible); - /* display the name of the character */ - surf_name = TTF_RenderText_Blended(font, chr->name, color); + if (target->is_chr) { + /* display the name of the character */ + surf_name = TTF_RenderText_Blended(font, target->chr->name, color); - pos_name.x = positions->Vpositioncadrecible.x + surfaces->Pcadrecible->w / 2 - surf_name->w / 2; - pos_name.y = positions->Vpositioncadrecible.y + 10; + /* display the affinities of the character */ + blit_character_affinities(surfaces, positions, target->chr); - /* display the affinities of the character */ - blit_character_affinities(surfaces, positions, chr); + /* display its HP / MP */ + Fblitterpvcible (surfaces,positions, target->chr); + Fblitterpmcible (surfaces,positions, target->chr); + } else { + surf_name = TTF_RenderText_Blended(font, target->team->name, color); + } - /* display its HP / MP */ - Fblitterpvcible (surfaces,positions, chr); - Fblitterpmcible (surfaces,positions, chr); + pos_name.x = positions->Vpositioncadrecible.x + surfaces->Pcadrecible->w / 2 - surf_name->w / 2; + pos_name.y = positions->Vpositioncadrecible.y + 10; SDL_BlitSurface(surf_name, NULL, surfaces->Pecran, &pos_name); @@ -154,25 +158,40 @@ static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struc TTF_CloseFont(font); } -void update_selected_target(SURFACES *surfaces, POSITIONS *positions, struct character_t *chr) +void update_selected_target(SURFACES *surfaces, POSITIONS *positions, struct target_t *target) { /* clear cursor */ SDL_BlitSurface(surfaces->Pfondjeu, &positions->last_cursor, surfaces->Pecran, &positions->last_cursor); - if (chr == NULL) { + if (target == NULL) { /* clear the target informations frame */ SDL_BlitSurface(surfaces->Pfondjeu, &positions->Vpositioncadrecible, surfaces->Pecran, &positions->Vpositioncadrecible); } else { /* display the new cursor */ - positions->last_cursor.x = chr->pos_curs.x; - positions->last_cursor.y = chr->pos_curs.y; + if (target->is_chr) { + positions->last_cursor.x = target->chr->pos_curs.x; + positions->last_cursor.y = target->chr->pos_curs.y; - positions->last_cursor.w = chr->curs->w; - positions->last_cursor.h = chr->curs->h; + positions->last_cursor.w = target->chr->curs->w; + positions->last_cursor.h = target->chr->curs->h; - SDL_BlitSurface(chr->curs, NULL, surfaces->Pecran, &chr->pos_curs); + SDL_BlitSurface(target->chr->curs, NULL, surfaces->Pecran, &target->chr->pos_curs); + + } else { + for (int i = 0; i < target->team->chr_cnt; ++i) { + struct character_t *chr = &target->team->chrs[i]; + + positions->last_cursor.x = chr->pos_curs.x; + positions->last_cursor.y = chr->pos_curs.y; + + positions->last_cursor.w = chr->curs->w; + positions->last_cursor.h = chr->curs->h; + + SDL_BlitSurface(chr->curs, NULL, surfaces->Pecran, &chr->pos_curs); + } + } - display_target_infos(surfaces, positions, chr); + display_target_infos(surfaces, positions, target); } } |