summaryrefslogtreecommitdiff
path: root/blits.c
diff options
context:
space:
mode:
Diffstat (limited to 'blits.c')
-rw-r--r--blits.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/blits.c b/blits.c
index 4ccb4b9..72a33fa 100644
--- a/blits.c
+++ b/blits.c
@@ -9,20 +9,20 @@
#include "players.h"
#include "entry.h"
+#include "rpg.h"
+
static void blit_chr_infos(SURFACES *surfaces, struct character_t *chr)
{
- TTF_Font *police=NULL;
SDL_Color fg={132,215,107,0},bg={100,0,0,0};
char string[256];
SDL_Surface *surf_hp;
SDL_Surface *surf_mp;
- police=TTF_OpenFont("TIMESBI.TTF",18);
sprintf(string, "PV %d/%d ", chr->hp, chr->max_hp);
- surf_hp = TTF_RenderText_Shaded(police, string, fg, bg);
+ surf_hp = TTF_RenderText_Shaded(rpg_g.font, string, fg, bg);
sprintf(string, "PM %d/%d ", chr->mp, chr->max_mp);
- surf_mp = TTF_RenderText_Shaded(police, string, fg, bg);
+ surf_mp = TTF_RenderText_Shaded(rpg_g.font, string, fg, bg);
chr->pos_hp.x = chr->pos.x + chr->def_surf->w / 2 - surf_hp->w / 2;
chr->pos_mp.x = chr->pos.x + chr->def_surf->w / 2 - surf_mp->w / 2;
@@ -39,8 +39,6 @@ static void blit_chr_infos(SURFACES *surfaces, struct character_t *chr)
SDL_FreeSurface(surf_hp);
SDL_FreeSurface(surf_mp);
-
- TTF_CloseFont(police);
}
void blit_character(SURFACES *surfaces, struct character_t *chr)
@@ -88,7 +86,6 @@ static void blit_character_affinities(SURFACES *surfaces, POSITIONS *positions,
static
void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
{
- TTF_Font *police = NULL;
SDL_Color couleur = {132,215,107,0};
char chaine[50];
@@ -99,16 +96,13 @@ void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct char
}
sprintf (chaine,"%d/%d", chr->hp, chr->max_hp);
- police=TTF_OpenFont ("TIMESBI.TTF",18);
- surfaces->Ppvcible=TTF_RenderText_Blended (police,chaine,couleur);
+ surfaces->Ppvcible=TTF_RenderText_Blended(rpg_g.font, chaine, couleur);
SDL_BlitSurface (surfaces->Ppvcible,NULL,surfaces->Pecran,&positions->Vpositionpvcible);
- TTF_CloseFont (police);
}
static
void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
{
- TTF_Font *police = NULL;
SDL_Color couleur = {132,215,107,0};
char chaine[50];
@@ -118,16 +112,13 @@ void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct char
surfaces->Ppmcible=NULL;
}
sprintf (chaine,"%d/%d", chr->mp, chr->max_mp);
- police=TTF_OpenFont ("TIMESBI.TTF",18);
- surfaces->Ppmcible=TTF_RenderText_Blended (police,chaine,couleur);
+ surfaces->Ppmcible=TTF_RenderText_Blended(rpg_g.font, chaine, couleur);
SDL_BlitSurface (surfaces->Ppmcible,NULL,surfaces->Pecran,&positions->Vpositionpmcible);
- TTF_CloseFont (police);
}
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);
SDL_Surface *surf_name;
SDL_Rect pos_name;;
@@ -136,7 +127,7 @@ static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struc
if (target->is_chr) {
/* display the name of the character */
- surf_name = TTF_RenderText_Blended(font, target->chr->name, color);
+ surf_name = TTF_RenderText_Blended(rpg_g.font, target->chr->name, color);
/* display the affinities of the character */
blit_character_affinities(surfaces, positions, target->chr);
@@ -145,7 +136,7 @@ static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struc
Fblitterpvcible (surfaces,positions, target->chr);
Fblitterpmcible (surfaces,positions, target->chr);
} else {
- surf_name = TTF_RenderText_Blended(font, target->team->name, color);
+ surf_name = TTF_RenderText_Blended(rpg_g.font, target->team->name, color);
}
pos_name.x = positions->Vpositioncadrecible.x + surfaces->Pcadrecible->w / 2 - surf_name->w / 2;
@@ -154,7 +145,6 @@ static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struc
SDL_BlitSurface(surf_name, NULL, surfaces->Pecran, &pos_name);
SDL_FreeSurface(surf_name);
- TTF_CloseFont(font);
}
void update_selected_target(SURFACES *surfaces, POSITIONS *positions, struct target_t *target)
@@ -197,7 +187,6 @@ void update_selected_target(SURFACES *surfaces, POSITIONS *positions, struct tar
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;
@@ -209,7 +198,6 @@ void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct
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) {
@@ -223,27 +211,24 @@ void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct
SDL_BlitSurface(surfaces->Pactionselectionnee, NULL, surfaces->Pecran, &positions->Vpositionactionselectionnee[i]);
}
- surf = TTF_RenderText_Blended(font, entries[off + i].name, color);
+ surf = TTF_RenderText_Blended(rpg_g.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 display_incr(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, unsigned int incr, SDL_Color color)
{
- TTF_Font *font = TTF_OpenFont("TIMES.TTF", 30);
char string[256];
SDL_Surface *surf;
sprintf(string, "%d", incr);
- TTF_SetFontStyle(font, TTF_STYLE_BOLD);
- surf = TTF_RenderText_Blended(font, string, color);
+ surf = TTF_RenderText_Blended(rpg_g.font, string, color);
blit_character(surfaces, target);
SDL_BlitSurface(surf, NULL, surfaces->Pecran, &target->pos_curs);
@@ -254,5 +239,4 @@ void display_incr(SURFACES *surfaces, POSITIONS *positions, struct character_t *
positions->Vpositiondegats.h = surf->h;
SDL_FreeSurface(surf);
- TTF_CloseFont(font);
}