From 1f9c71b49eeef9cd05b542515c06200b4a25f693 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 8 Jan 2015 15:04:26 +0100 Subject: use a generic way to navigate through entries entries are actually any action or subaction that can be performed. Attack, White Magic and so on are root actions. Fire, Ice X are subactions of Black Magic. Signed-off-by: Olivier Gayot --- blits.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'blits.c') diff --git a/blits.c b/blits.c index 318e72f..2eb49d4 100644 --- a/blits.c +++ b/blits.c @@ -152,6 +152,46 @@ void Fchangercurseurpersos (SURFACES *surfaces, POSITIONS *positions, struct cha TTF_CloseFont(police); } +void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct entry_t *entries, int cnt, int selected) +{ + SDL_Color color = {0, 0, 0, 0}; + TTF_Font *font; + SDL_Surface *surf; + int off; + + if (selected == -1) { + SDL_BlitSurface(surfaces->Pfondjeu, &positions->Vpositioncadreactions, surfaces->Pecran, &positions->Vpositioncadreactions); + SDL_Flip(surfaces->Pecran); + return; + } + + SDL_BlitSurface(surfaces->Pcadreactions, NULL, surfaces->Pecran, &positions->Vpositioncadreactions); + + font = TTF_OpenFont("TIMESBI.TTF", 20); + off = selected / 3 * 3; + /* display at most three actions */ + for (int i = 0; i < 3; ++i) { + if (off + i >= cnt) { + SDL_BlitSurface(surfaces->Pactiondesactivee, NULL, surfaces->Pecran, &positions->Vpositionactionselectionnee[i]); + continue; + } + + /* if the current entry is the selected one */ + if (selected == off + i) { + SDL_BlitSurface(surfaces->Pactionselectionnee, NULL, surfaces->Pecran, &positions->Vpositionactionselectionnee[i]); + } + + surf = TTF_RenderText_Blended(font, entries[off + i].name, color); + + SDL_BlitSurface(surf, NULL, surfaces->Pecran, &positions->Vpositionnomactions[i]); + + SDL_FreeSurface(surf); + } + + TTF_CloseFont(font); + SDL_Flip(surfaces->Pecran); +} + void Fchangeractionselectionnee(SURFACES *surfaces, POSITIONS *positions,int selection,int page,int nbactions,int type) { int i; -- cgit v1.2.3