gfx: Add return value to *_sort functions
This commit is contained in:
parent
da33e4668b
commit
daf6f84ccd
|
@ -40,7 +40,10 @@ int cursor_render(const struct cursor *const c)
|
|||
sprite_get_or_ret(s, -1);
|
||||
|
||||
if (sprite_clone(&cursor_sprite, s))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_clone failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
s->x = c->x;
|
||||
s->y = c->y;
|
||||
|
@ -57,8 +60,12 @@ int cursor_render(const struct cursor *const c)
|
|||
break;
|
||||
}
|
||||
|
||||
sprite_sort(s);
|
||||
return 0;
|
||||
const int ret = sprite_sort(s);
|
||||
|
||||
if (ret)
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void cursor_init(struct cursor *const c)
|
||||
|
|
|
@ -86,7 +86,12 @@ static int renderstr(const enum font f, const short x, short y,
|
|||
s->v += v;
|
||||
s->x = rx;
|
||||
s->y = y;
|
||||
sprite_sort(s);
|
||||
|
||||
if (sprite_sort(s))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rx += cfg->fs;
|
||||
|
|
|
@ -17,14 +17,14 @@ int gfx_set_fullscreen(short w, short h);
|
|||
bool gfx_fullscreen_available(void);
|
||||
bool gfx_fullscreen(void);
|
||||
int gfx_display_size(short *w, short *h);
|
||||
void sprite_sort(struct sprite *s);
|
||||
int sprite_sort(struct sprite *s);
|
||||
int sprite_clone(const struct sprite *src, struct sprite *dst);
|
||||
void rect_init(struct rect *r);
|
||||
void semitrans_rect_init(struct rect *r);
|
||||
void stp_4line_init(struct stp_4line *l);
|
||||
void quad_sort(struct quad *q);
|
||||
void rect_sort(struct rect *r);
|
||||
void stp_4line_sort(struct stp_4line *l);
|
||||
int quad_sort(struct quad *q);
|
||||
int rect_sort(struct rect *r);
|
||||
int stp_4line_sort(struct stp_4line *l);
|
||||
int sprite_from_fp(struct sprite *s, FILE *f);
|
||||
int quad_from_sprite(const struct sprite *s, struct quad *q);
|
||||
bool gfx_inside_drawenv(short x, short y, short w, short h);
|
||||
|
|
|
@ -19,24 +19,28 @@ static void add_to_list(union gfx_sznext *const p)
|
|||
last = p;
|
||||
}
|
||||
|
||||
void sprite_sort(struct sprite *const s)
|
||||
int sprite_sort(struct sprite *const s)
|
||||
{
|
||||
add_to_list(&s->sznext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quad_sort(struct quad *const q)
|
||||
int quad_sort(struct quad *const q)
|
||||
{
|
||||
add_to_list(&q->sznext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rect_sort(struct rect *const r)
|
||||
int rect_sort(struct rect *const r)
|
||||
{
|
||||
add_to_list(&r->sznext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stp_4line_sort(struct stp_4line *const l)
|
||||
int stp_4line_sort(struct stp_4line *const l)
|
||||
{
|
||||
add_to_list(&l->sznext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void gfx_sync(void)
|
||||
|
|
|
@ -98,7 +98,10 @@ static int resize_screen(int w, int h, const bool full_screen)
|
|||
|
||||
for (size_t i = 0; i < list_len; i++)
|
||||
if (sprite_screen_resize_ev(list[i]))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_screen_resize_ev failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
screen_w = w;
|
||||
screen_h = h;
|
||||
|
@ -152,14 +155,16 @@ static int get_resize_events(void)
|
|||
const SDL_ResizeEvent *const res = &ev.resize;
|
||||
|
||||
if (resize_screen(res->w, res->h, false))
|
||||
{
|
||||
fprintf(stderr, "%s: resize_screen failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: SDL_PeepEvents: %s\n",
|
||||
__func__, SDL_GetError());
|
||||
fprintf(stderr, "%s: SDL_PeepEvents: %s\n", __func__, SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -208,6 +213,5 @@ int gfx_draw(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
get_resize_events();
|
||||
return 0;
|
||||
return get_resize_events();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ void semitrans_stp_4line_init(struct stp_4line *r)
|
|||
{
|
||||
}
|
||||
|
||||
void stp_4line_sort(struct stp_4line *const r)
|
||||
int stp_4line_sort(struct stp_4line *const r)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ int quad_from_sprite(const struct sprite *const s, struct quad *const q)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void quad_sort(struct quad *const q)
|
||||
int quad_sort(struct quad *const q)
|
||||
{
|
||||
const bool xflip = q->x0 > q->x1;
|
||||
|
||||
|
@ -40,5 +40,10 @@ void quad_sort(struct quad *const q)
|
|||
SDL_Surface *const s = xflip ? q->s_x : q->s;
|
||||
|
||||
if (SDL_BlitSurface(s, &clip, gfx_screen(), &r))
|
||||
{
|
||||
fprintf(stderr, "SDL_BlitSurface: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <sdl-1.2/gfx_private.h>
|
||||
#include <SDL.h>
|
||||
|
||||
void rect_sort(struct rect *const r)
|
||||
int rect_sort(struct rect *const r)
|
||||
{
|
||||
SDL_Rect rct =
|
||||
{
|
||||
|
@ -19,8 +19,10 @@ void rect_sort(struct rect *const r)
|
|||
if (SDL_FillRect(screen, &rct, map))
|
||||
{
|
||||
fprintf(stderr, "SDL_FillRect: %s\n", SDL_GetError());
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rect_init(struct rect *const r)
|
||||
|
|
|
@ -126,7 +126,7 @@ int sprite_from_fp(struct sprite *const s, FILE *const f)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void sprite_sort(struct sprite *const s)
|
||||
int sprite_sort(struct sprite *const s)
|
||||
{
|
||||
SDL_Rect r =
|
||||
{
|
||||
|
@ -143,5 +143,10 @@ void sprite_sort(struct sprite *const s)
|
|||
};
|
||||
|
||||
if (SDL_BlitSurface(s->s, &clip, gfx_screen(), &r))
|
||||
{
|
||||
fprintf(stderr, "SDL_BlitSurface: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,13 @@ static int render_topleft(const struct gui_bar *const b, const short x,
|
|||
|
||||
s->x = x;
|
||||
s->y = y;
|
||||
sprite_sort(s);
|
||||
return 0;
|
||||
|
||||
const int ret = sprite_sort(s);
|
||||
|
||||
if (ret)
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int render_topright(const struct gui_bar *const b, const short x,
|
||||
|
@ -29,7 +34,12 @@ static int render_topright(const struct gui_bar *const b, const short x,
|
|||
|
||||
s->x = x + b->w - s->w;
|
||||
s->y = y;
|
||||
sprite_sort(s);
|
||||
|
||||
const int ret = sprite_sort(s);
|
||||
|
||||
if (ret)
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -66,7 +76,11 @@ static int render_topmid(const struct gui_bar *const b, const short x,
|
|||
else
|
||||
m->w = mid_w;
|
||||
|
||||
sprite_sort(m);
|
||||
if (sprite_sort(m))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -13,8 +13,13 @@ int gui_button_render_sprite(const struct gui_button *const b)
|
|||
return -1;
|
||||
|
||||
gui_coords(&b->common, &s->x, &s->y);
|
||||
sprite_sort(s);
|
||||
return 0;
|
||||
|
||||
const int ret = sprite_sort(s);
|
||||
|
||||
if (ret)
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void gui_button_get_dim_sprite(const struct gui_button *const b,
|
||||
|
|
|
@ -19,7 +19,13 @@ static int render_left(const struct gui_button *const b,
|
|||
|
||||
s->x = *x;
|
||||
s->y = y;
|
||||
sprite_sort(s);
|
||||
|
||||
if (sprite_sort(s))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*x = s->x + s->w;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,13 @@ static int render_left(const struct gui_line_edit *const l,
|
|||
|
||||
s->x = *x;
|
||||
s->y = y;
|
||||
sprite_sort(s);
|
||||
|
||||
if (sprite_sort(s))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*x = s->x + s->w;
|
||||
return 0;
|
||||
}
|
||||
|
@ -66,7 +72,12 @@ static int render_mid(const struct gui_line_edit *const l,
|
|||
else
|
||||
m->w = mid_w;
|
||||
|
||||
sprite_sort(m);
|
||||
if (sprite_sort(m))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*x += m->w;
|
||||
}
|
||||
}
|
||||
|
@ -85,8 +96,13 @@ static int render_right(const short x, const short y)
|
|||
|
||||
s->x = x;
|
||||
s->y = y;
|
||||
sprite_sort(s);
|
||||
return 0;
|
||||
|
||||
const int ret = sprite_sort(s);
|
||||
|
||||
if (ret)
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int render(const struct gui_common *const g)
|
||||
|
|
|
@ -19,7 +19,12 @@ static int render_top(const struct gui_rounded_rect *const r,
|
|||
|
||||
left->x = x;
|
||||
left->y = y;
|
||||
sprite_sort(left);
|
||||
|
||||
if (sprite_sort(left))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -33,7 +38,12 @@ static int render_top(const struct gui_rounded_rect *const r,
|
|||
|
||||
right->x = x + r->w - ref->w;
|
||||
right->y = y;
|
||||
sprite_sort(right);
|
||||
|
||||
if (sprite_sort(right))
|
||||
{
|
||||
fprintf(stderr, "%s: sprite_sort failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue