summaryrefslogtreecommitdiff
path: root/blits.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-08 15:04:26 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-08 15:37:48 +0100
commit1f9c71b49eeef9cd05b542515c06200b4a25f693 (patch)
tree6a29ab8af1ae447236013cbd78e5089937b72b1f /blits.c
parentadceeb1192fdd1d14e0f55219bbd1bcb14eacc05 (diff)
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 <duskcoder@gmail.com>
Diffstat (limited to 'blits.c')
-rw-r--r--blits.c40
1 files changed, 40 insertions, 0 deletions
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;