summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blits.c36
-rw-r--r--menuchoixpersos.c9
2 files changed, 14 insertions, 31 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);
}
diff --git a/menuchoixpersos.c b/menuchoixpersos.c
index 176ec45..66ae603 100644
--- a/menuchoixpersos.c
+++ b/menuchoixpersos.c
@@ -8,6 +8,8 @@
#include <SDL/SDL_ttf.h>
#include "players.h"
+#include "rpg.h"
+
static void init_team_players(struct team_t *team, bool left,
const enum character_class_t *classes, SURFACES *surfaces)
{
@@ -157,7 +159,6 @@ struct team_t *new_enemy_team(SURFACES *surfaces, const struct team_t *ally_team
void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
{
- TTF_Font *police = NULL;
int Vchoix = CLASS_PALADIN;
SDL_Color vert;
bool continuer = true;
@@ -171,8 +172,6 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
vert.g = 189;
vert.b = 31;
- police = TTF_OpenFont ("TIMESI.TTF",36);
-
/* loop until we have actually chosen our three characters */
while (Vnbperso < 3) {
static const char *strings[] = {
@@ -193,7 +192,7 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
}
/* display the string associated with the current character number (aka Please choose ...) */
- surfaces->Ptextechoixmenu = TTF_RenderText_Blended (police, strings[Vnbperso], vert);
+ surfaces->Ptextechoixmenu = TTF_RenderText_Blended(rpg_g.font, strings[Vnbperso], vert);
positions->Vpositiontextemenu.x=XWIN/2-surfaces->Ptextechoixmenu->w/2;
SDL_BlitSurface (surfaces->Ptextechoixmenu,NULL,surfaces->Pecran,&positions->Vpositiontextemenu);
@@ -243,7 +242,7 @@ void Fmenuchoixpersos (SURFACES *surfaces, POSITIONS *positions)
}
}
}
- TTF_CloseFont (police);
+
SDL_Flip(surfaces->Pecran);
ally_team = new_ally_team(surfaces, chr_classes, 3);
enemy_team = new_enemy_team(surfaces, ally_team);