summaryrefslogtreecommitdiff
path: root/blits.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-11 02:02:07 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-11 03:01:46 +0100
commit65364d2e2f40807fdd03ade25917f728adc0ef77 (patch)
treee2d2e5d0a7e329f50009a086959b4226fe27dde7 /blits.c
parentd590bfdcdfa8799439cffa41fc74346e9923b6e7 (diff)
coding rules: stop at 78 colsrewrite
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'blits.c')
-rw-r--r--blits.c93
1 files changed, 60 insertions, 33 deletions
diff --git a/blits.c b/blits.c
index 40e20f4..51ce1e7 100644
--- a/blits.c
+++ b/blits.c
@@ -11,7 +11,7 @@
#include "rpg.h"
-static void blit_chr_infos(SURFACES *surfaces, struct character_t *chr)
+static void blit_chr_infos(SURFACES *surfaces, struct chr_t *chr)
{
SDL_Color fg={132,215,107,0},bg={100,0,0,0};
char string[256];
@@ -41,7 +41,7 @@ static void blit_chr_infos(SURFACES *surfaces, struct character_t *chr)
SDL_FreeSurface(surf_mp);
}
-void blit_character(SURFACES *surfaces, struct character_t *chr)
+void blit_character(SURFACES *surfaces, struct chr_t *chr)
{
SDL_BlitSurface(chr->surf, NULL, surfaces->Pecran, &chr->pos);
@@ -63,28 +63,37 @@ void blit_team(SURFACES *surfaces, struct team_t *team)
}
}
-static void blit_character_affinities(SURFACES *surfaces, POSITIONS *positions, const struct character_t *chr)
+static void
+blit_character_affinities(SURFACES *surfaces, POSITIONS *positions,
+ const struct chr_t *chr)
{
static const enum affinity_t affinities[] = {
- AFFINITY_SENSITIVE,
- AFFINITY_RESISTANCE,
- AFFINITY_INVULNERABILITY,
- AFFINITY_ABSORPTION,
+ AFFIN_SENSITIVE,
+ AFFIN_RESISTANCE,
+ AFFIN_INVULN,
+ AFFIN_ABSORPTION,
};
for (int i = 0; i < countof(affinities); ++i) {
- for (enum element_t elmt = 0; elmt < ELEMENT_COUNT; ++elmt) {
+ for (enum element_t elmt = 0; elmt < ELEM_COUNT; ++elmt) {
+ SDL_Surface *surf;
+ SDL_Rect *rect;
+
if (chr->affinities[elmt] == affinities[i]) {
- SDL_BlitSurface(surfaces->Pactive, NULL, surfaces->screen, &positions->activedesactive[i * ELEMENT_COUNT + elmt]);
+ surf = surfaces->Pactive;
} else {
- SDL_BlitSurface(surfaces->Pdesactive, NULL, surfaces->screen, &positions->activedesactive[i * ELEMENT_COUNT + elmt]);
+ surf = surfaces->Pdesactive;
}
+
+ rect = &positions->activedesactive[i * ELEM_COUNT + elmt];
+
+ SDL_BlitSurface(surf, NULL, surfaces->screen, rect);
}
}
}
-static
-void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
+static void Fblitterpvcible(SURFACES *surfaces, POSITIONS *positions,
+ const struct chr_t *chr)
{
SDL_Color couleur = {132,215,107,0};
char chaine[50];
@@ -97,8 +106,8 @@ void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct char
SDL_FreeSurface(surf);
}
-static
-void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *chr)
+static void Fblitterpmcible(SURFACES *surfaces, POSITIONS *positions,
+ const struct chr_t *chr)
{
SDL_Color couleur = {132,215,107,0};
char chaine[50];
@@ -111,18 +120,21 @@ void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct char
SDL_FreeSurface(surf);
}
-static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struct target_t *target)
+static void display_target_infos(SURFACES *surfaces, POSITIONS *positions,
+ struct target_t *target)
{
SDL_Color color = {0x8a, 0x00, 0x00, 0x00};
SDL_Surface *surf_name;
- SDL_Rect pos_name;;
+ SDL_Rect pos_name;
+ const char *name;
/* display the information frame */
- SDL_BlitSurface(surfaces->Pcadrecible, NULL, surfaces->screen, &positions->cadrecible);
+ SDL_BlitSurface(surfaces->Pcadrecible, NULL, surfaces->screen,
+ &positions->cadrecible);
if (target->is_chr) {
/* display the name of the character */
- surf_name = TTF_RenderText_Blended(rpg_g.font, target->chr->name, color);
+ name = target->chr->name;
/* display the affinities of the character */
blit_character_affinities(surfaces, positions, target->chr);
@@ -131,10 +143,13 @@ 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(rpg_g.font, target->team->name, color);
+ name = target->team->name;
}
- pos_name.x = positions->cadrecible.x + surfaces->Pcadrecible->w / 2 - surf_name->w / 2;
+ surf_name = TTF_RenderText_Blended(rpg_g.font, name, color);
+
+ pos_name.x = positions->cadrecible.x +
+ surfaces->Pcadrecible->w / 2 - surf_name->w / 2;
pos_name.y = positions->cadrecible.y + 10;
SDL_BlitSurface(surf_name, NULL, surfaces->Pecran, &pos_name);
@@ -142,14 +157,17 @@ static void display_target_infos(SURFACES *surfaces, POSITIONS *positions, struc
SDL_FreeSurface(surf_name);
}
-void update_selected_target(SURFACES *surfaces, POSITIONS *positions, struct target_t *target)
+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);
+ SDL_BlitSurface(surfaces->background, &positions->last_cursor,
+ surfaces->screen, &positions->last_cursor);
if (target == NULL) {
/* clear the target informations frame */
- SDL_BlitSurface(surfaces->background, &positions->cadrecible, surfaces->screen, &positions->cadrecible);
+ SDL_BlitSurface(surfaces->background, &positions->cadrecible,
+ surfaces->screen, &positions->cadrecible);
} else {
/* display the new cursor */
if (target->is_chr) {
@@ -159,11 +177,12 @@ void update_selected_target(SURFACES *surfaces, POSITIONS *positions, struct tar
positions->last_cursor.w = target->chr->curs->w;
positions->last_cursor.h = target->chr->curs->h;
- SDL_BlitSurface(target->chr->curs, NULL, surfaces->Pecran, &target->chr->pos_curs);
+ SDL_BlitSurface(target->chr->curs, NULL, surfaces->screen,
+ &target->chr->pos_curs);
} else {
for (int i = 0; i < target->team->chr_cnt; ++i) {
- struct character_t *chr = &target->team->chrs[i];
+ struct chr_t *chr = &target->team->chrs[i];
positions->last_cursor.x = chr->pos_curs.x;
positions->last_cursor.y = chr->pos_curs.y;
@@ -171,7 +190,8 @@ void update_selected_target(SURFACES *surfaces, POSITIONS *positions, struct tar
positions->last_cursor.w = chr->curs->w;
positions->last_cursor.h = chr->curs->h;
- SDL_BlitSurface(chr->curs, NULL, surfaces->Pecran, &chr->pos_curs);
+ SDL_BlitSurface(chr->curs, NULL, surfaces->screen,
+ &chr->pos_curs);
}
}
@@ -179,19 +199,22 @@ 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)
+void update_list_entries(SURFACES *surfaces, POSITIONS *positions,
+ const struct entry_t *entries, int cnt, int selected)
{
SDL_Color color = {0, 0, 0, 0};
SDL_Surface *surf;
int off;
if (selected == -1) {
- SDL_BlitSurface(surfaces->Pfondjeu, &positions->cadreactions, surfaces->Pecran, &positions->cadreactions);
+ SDL_BlitSurface(surfaces->background, &positions->cadreactions,
+ surfaces->screen, &positions->cadreactions);
SDL_Flip(surfaces->Pecran);
return;
}
- SDL_BlitSurface(surfaces->Pcadreactions, NULL, surfaces->Pecran, &positions->cadreactions);
+ SDL_BlitSurface(surfaces->Pcadreactions, NULL, surfaces->screen,
+ &positions->cadreactions);
off = selected / 3 * 3;
/* display at most three actions */
@@ -200,13 +223,15 @@ void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct
char buffer[256];
if (off + i >= cnt) {
- SDL_BlitSurface(surfaces->Pactiondesactivee, NULL, surfaces->Pecran, &positions->actionselectionnee[i]);
+ SDL_BlitSurface(surfaces->Pactiondesactivee, NULL,
+ surfaces->screen, &positions->actionselectionnee[i]);
continue;
}
/* if the current entry is the selected one */
if (selected == off + i) {
- SDL_BlitSurface(surfaces->Pactionselectionnee, NULL, surfaces->Pecran, &positions->actionselectionnee[i]);
+ SDL_BlitSurface(surfaces->Pactionselectionnee, NULL,
+ surfaces->screen, &positions->actionselectionnee[i]);
}
if (entries[off + i].children_cnt) {
@@ -218,7 +243,8 @@ void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct
surf = TTF_RenderText_Blended(rpg_g.font, string, color);
- SDL_BlitSurface(surf, NULL, surfaces->Pecran, &positions->nomactions[i]);
+ SDL_BlitSurface(surf, NULL, surfaces->screen,
+ &positions->nomactions[i]);
SDL_FreeSurface(surf);
}
@@ -226,7 +252,8 @@ void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct
SDL_Flip(surfaces->Pecran);
}
-void display_incr(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, unsigned int incr, SDL_Color color)
+void display_incr(SURFACES *surfaces, POSITIONS *positions,
+ struct chr_t *target, unsigned int incr, SDL_Color color)
{
char string[256];
SDL_Surface *surf;