Mercurial > molko
changeset 457:04797b35565c
core: painter -> mlk_painter
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 18 Feb 2023 21:07:02 +0100 |
parents | a6933cd252b7 |
children | 02c1481b7dbb |
files | libmlk-core/mlk/core/painter.c libmlk-core/mlk/core/painter.h libmlk-rpg/mlk/rpg/battle-state-closing.c libmlk-rpg/mlk/rpg/battle-state-opening.c libmlk-rpg/mlk/rpg/map.c libmlk-rpg/mlk/rpg/message.c libmlk-ui/mlk/ui/button.c libmlk-ui/mlk/ui/checkbox.c libmlk-ui/mlk/ui/frame.c |
diffstat | 9 files changed, 61 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/libmlk-core/mlk/core/painter.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-core/mlk/core/painter.c Sat Feb 18 21:07:02 2023 +0100 @@ -28,20 +28,20 @@ static struct texture *renderer; struct texture * -painter_get_target(void) +mlk_painter_get_target(void) { return renderer; } void -painter_set_target(struct texture *tex) +mlk_painter_set_target(struct texture *tex) { renderer = tex; SDL_SetRenderTarget(RENDERER(), tex ? tex->handle : NULL); } unsigned long -painter_get_color(void) +mlk_painter_get_color(void) { Uint8 r = 0, g = 0, b = 0, a = 0; @@ -51,7 +51,7 @@ } void -painter_set_color(unsigned long color) +mlk_painter_set_color(unsigned long color) { SDL_SetRenderDrawColor( RENDERER(), @@ -63,19 +63,19 @@ } void -painter_draw_line(int x1, int y1, int x2, int y2) +mlk_painter_draw_line(int x1, int y1, int x2, int y2) { SDL_RenderDrawLine(RENDERER(), x1, y1, x2, y2); } void -painter_draw_point(int x1, int y1) +mlk_painter_draw_point(int x1, int y1) { SDL_RenderDrawPoint(RENDERER(), x1, y1); } void -painter_draw_rectangle(int x, int y, unsigned int width, unsigned int height) +mlk_painter_draw_rectangle(int x, int y, unsigned int width, unsigned int height) { const SDL_Rect rect = { .w = width, @@ -88,7 +88,7 @@ } void -painter_draw_circle(int x, int y, int radius) +mlk_painter_draw_circle(int x, int y, int radius) { // Note that there is more to altering the bitrate of this // method than just changing this value. See how pixels are @@ -103,13 +103,13 @@ } void -painter_clear(void) +mlk_painter_clear(void) { SDL_RenderClear(RENDERER()); } void -painter_present(void) +mlk_painter_present(void) { SDL_RenderPresent(RENDERER()); }
--- a/libmlk-core/mlk/core/painter.h Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-core/mlk/core/painter.h Sat Feb 18 21:07:02 2023 +0100 @@ -26,46 +26,46 @@ CORE_BEGIN_DECLS struct texture * -painter_get_target(void); +mlk_painter_get_target(void); void -painter_set_target(struct texture *); +mlk_painter_set_target(struct texture *); unsigned long -painter_get_color(void); +mlk_painter_get_color(void); void -painter_set_color(unsigned long); +mlk_painter_set_color(unsigned long); void -painter_draw_line(int, int, int, int); +mlk_painter_draw_line(int, int, int, int); void -painter_draw_point(int, int); +mlk_painter_draw_point(int, int); void -painter_draw_rectangle(int, int, unsigned int, unsigned int); +mlk_painter_draw_rectangle(int, int, unsigned int, unsigned int); void -painter_draw_circle(int, int, int); +mlk_painter_draw_circle(int, int, int); void -painter_clear(void); +mlk_painter_clear(void); void -painter_present(void); +mlk_painter_present(void); CORE_END_DECLS -#define PAINTER_BEGIN(tex) \ +#define MLK_PAINTER_BEGIN(tex) \ do { \ struct texture *__current_texture__; \ \ - __current_texture__ = painter_get_target(); \ - painter_set_target((tex)) + __current_texture__ = mlk_painter_get_target(); \ + mlk_painter_set_target((tex)) -#define PAINTER_END() \ - painter_set_target(__current_texture__); \ +#define MLK_PAINTER_END() \ + mlk_painter_set_target(__current_texture__); \ } while (0) #endif /* !MLK_CORE_PAINTER_H */
--- a/libmlk-rpg/mlk/rpg/battle-state-closing.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-closing.c Sat Feb 18 21:07:02 2023 +0100 @@ -68,12 +68,12 @@ if (texture_new(&cls->texture, window.w, window.h) < 0) panic(); - PAINTER_BEGIN(&cls->texture); + MLK_PAINTER_BEGIN(&cls->texture); texture_set_blend_mode(&cls->texture, TEXTURE_BLEND_BLEND); - painter_set_color(0x000000ff); - painter_clear(); - painter_draw_rectangle(0, 0, window.w, window.h); - PAINTER_END(); + mlk_painter_set_color(0x000000ff); + mlk_painter_clear(); + mlk_painter_draw_rectangle(0, 0, window.w, window.h); + MLK_PAINTER_END(); texture_set_alpha_mod(&cls->texture, 0); }
--- a/libmlk-rpg/mlk/rpg/battle-state-opening.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-opening.c Sat Feb 18 21:07:02 2023 +0100 @@ -89,9 +89,9 @@ battle_draw_component(bt, BATTLE_COMPONENT_BACKGROUND | BATTLE_COMPONENT_ENTITIES); /* Draw some bezels opening. */ - painter_set_color(0x000000ff); - painter_draw_rectangle(0, 0, w, h - ch); - painter_draw_rectangle(0, h + ch, w, h - ch); + mlk_painter_set_color(0x000000ff); + mlk_painter_draw_rectangle(0, 0, w, h - ch); + mlk_painter_draw_rectangle(0, h + ch, w, h - ch); } void
--- a/libmlk-rpg/mlk/rpg/map.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/map.c Sat Feb 18 21:07:02 2023 +0100 @@ -503,9 +503,9 @@ texture_scale(colbox, 0, 0, 5, 5, mx + td->x, my + td->y, td->w, td->h, 0); if (map->flags & MAP_FLAGS_SHOW_GRID) { - painter_set_color(0x202e37ff); - painter_draw_line(mx, my, mx + (int)map->tileset->sprite->cellw, my); - painter_draw_line( + mlk_painter_set_color(0x202e37ff); + mlk_painter_draw_line(mx, my, mx + (int)map->tileset->sprite->cellw, my); + mlk_painter_draw_line( mx + (int)map->tileset->sprite->cellw - 1, my, mx + (int)map->tileset->sprite->cellw - 1, my + (int)map->tileset->sprite->cellh); } @@ -538,10 +538,10 @@ if (map->flags & MAP_FLAGS_SHOW_COLLIDE && texture_new(&colbox, 16, 16) == 0) { texture_set_blend_mode(&colbox, TEXTURE_BLEND_BLEND); texture_set_alpha_mod(&colbox, 100); - PAINTER_BEGIN(&colbox); - painter_set_color(0xa53030ff); - painter_clear(); - PAINTER_END(); + MLK_PAINTER_BEGIN(&colbox); + mlk_painter_set_color(0xa53030ff); + mlk_painter_clear(); + MLK_PAINTER_END(); } for (unsigned int r = 0; r < nrows; ++r) { @@ -566,19 +566,19 @@ /* Draw collide box around player if requested. */ texture_set_alpha_mod(&box, 100); texture_set_blend_mode(&box, TEXTURE_BLEND_BLEND); - PAINTER_BEGIN(&box); - painter_set_color(0x4f8fbaff); - painter_clear(); - PAINTER_END(); + MLK_PAINTER_BEGIN(&box); + mlk_painter_set_color(0x4f8fbaff); + mlk_painter_clear(); + MLK_PAINTER_END(); texture_scale(&box, 0, 0, 64, 64, map->player_x - map->view_x, map->player_y - map->view_y, map->player_sprite->cellw, map->player_sprite->cellh, 0.f); /* Do the same for every objects. */ - PAINTER_BEGIN(&box); - painter_set_color(0xa8ca58ff); - painter_clear(); - PAINTER_END(); + MLK_PAINTER_BEGIN(&box); + mlk_painter_set_color(0xa8ca58ff); + mlk_painter_clear(); + MLK_PAINTER_END(); for (size_t i = 0; i < map->blocksz; ++i) { texture_scale(&box, 0, 0, 64, 64,
--- a/libmlk-rpg/mlk/rpg/message.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/message.c Sat Feb 18 21:07:02 2023 +0100 @@ -274,10 +274,10 @@ if (texture_new(&tex, msg->w, msg->h) < 0) panic(); - PAINTER_BEGIN(&tex); + MLK_PAINTER_BEGIN(&tex); draw_frame(msg); draw_lines(msg); - PAINTER_END(); + MLK_PAINTER_END(); /* Compute scaling. */ w = msg->w * msg->scale;
--- a/libmlk-ui/mlk/ui/button.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-ui/mlk/ui/button.c Sat Feb 18 21:07:02 2023 +0100 @@ -63,8 +63,8 @@ align(ALIGN_CENTER, &label.x, &label.y, lw, lh, button->x, button->y, button->w, button->h); - painter_set_color(0x577277ff); - painter_draw_rectangle(button->x, button->y, button->w, button->h); + mlk_painter_set_color(0x577277ff); + mlk_painter_draw_rectangle(button->x, button->y, button->w, button->h); label_draw(&label); }
--- a/libmlk-ui/mlk/ui/checkbox.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-ui/mlk/ui/checkbox.c Sat Feb 18 21:07:02 2023 +0100 @@ -43,14 +43,14 @@ assert(cb); - painter_set_color(0x151d28ff); - painter_draw_rectangle(cb->x, cb->y, cb->w, cb->h); - painter_set_color(0xd7b594ff); - painter_draw_rectangle(cb->x + 1, cb->y + 1, cb->w - 2, cb->h - 2); + mlk_painter_set_color(0x151d28ff); + mlk_painter_draw_rectangle(cb->x, cb->y, cb->w, cb->h); + mlk_painter_set_color(0xd7b594ff); + mlk_painter_draw_rectangle(cb->x + 1, cb->y + 1, cb->w - 2, cb->h - 2); if (cb->checked) { - painter_set_color(0x341c27ff); - painter_draw_rectangle(cb->x + 5, cb->y + 5, cb->w - 10, cb->h - 10); + mlk_painter_set_color(0x341c27ff); + mlk_painter_draw_rectangle(cb->x + 5, cb->y + 5, cb->w - 10, cb->h - 10); } }
--- a/libmlk-ui/mlk/ui/frame.c Sat Feb 18 21:03:19 2023 +0100 +++ b/libmlk-ui/mlk/ui/frame.c Sat Feb 18 21:07:02 2023 +0100 @@ -33,11 +33,11 @@ (void)t; if (frame->style == FRAME_STYLE_BOX) - painter_set_color(0x7a4841ff); + mlk_painter_set_color(0x7a4841ff); else - painter_set_color(0xad7757ff); + mlk_painter_set_color(0xad7757ff); - painter_draw_rectangle(frame->x, frame->y, frame->w, frame->h); + mlk_painter_draw_rectangle(frame->x, frame->y, frame->w, frame->h); } void