Mercurial > molko
changeset 473:02b16dd49b54
core: trace -> mlk_trace
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 27 Feb 2023 11:26:23 +0100 |
parents | bc5483849614 |
children | ca30ff96bbe0 |
files | examples/example-gridmenu/example-gridmenu.c examples/example-trace/example-trace.c libmlk-core/mlk/core/trace.c libmlk-core/mlk/core/trace.h libmlk-rpg/mlk/rpg/battle-bar-default.c libmlk-rpg/mlk/rpg/battle-state-check.c libmlk-rpg/mlk/rpg/battle.c libmlk-rpg/mlk/rpg/map-file.c libmlk-rpg/mlk/rpg/message.c libmlk-ui/mlk/ui/button.c libmlk-ui/mlk/ui/gridmenu.c libmlk-ui/mlk/ui/notify.c |
diffstat | 12 files changed, 27 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/example-gridmenu/example-gridmenu.c Mon Feb 27 11:24:38 2023 +0100 +++ b/examples/example-gridmenu/example-gridmenu.c Mon Feb 27 11:26:23 2023 +0100 @@ -66,7 +66,7 @@ break; default: if (gridmenu_handle(st->data, ev)) - tracef("selected index: %zu (%s)", menu->selected, menu->items[menu->selected]); + mlk_tracef("selected index: %zu (%s)", menu->selected, menu->items[menu->selected]); break; } }
--- a/examples/example-trace/example-trace.c Mon Feb 27 11:24:38 2023 +0100 +++ b/examples/example-trace/example-trace.c Mon Feb 27 11:26:23 2023 +0100 @@ -45,7 +45,7 @@ if (window_open("Example - Trace", W, H) < 0) mlk_panic(); - trace_handler = trace_hud_handler; + mlk_trace_handler = trace_hud_handler; } static void @@ -60,12 +60,12 @@ trace_hud_clear(); break; default: - tracef("keydown pressed: %d", ev->key.key); + mlk_tracef("keydown pressed: %d", ev->key.key); break; } break; case MLK_EVENT_CLICKDOWN: - tracef("click at %d,%d", ev->click.x, ev->click.y); + mlk_tracef("click at %d,%d", ev->click.x, ev->click.y); break; case MLK_EVENT_QUIT: mlk_game_quit();
--- a/libmlk-core/mlk/core/trace.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-core/mlk/core/trace.c Mon Feb 27 11:26:23 2023 +0100 @@ -29,34 +29,33 @@ puts(line); } -void (*trace_handler)(const char *) = default_handler; -void *trace_data = NULL; +void (*mlk_trace_handler)(const char *) = default_handler; void -tracef(const char *fmt, ...) +mlk_tracef(const char *fmt, ...) { assert(fmt); va_list ap; - if (!trace_handler) + if (!mlk_trace_handler) return; va_start(ap, fmt); - traceva(fmt, ap); + mlk_traceva(fmt, ap); va_end(ap); } void -traceva(const char *fmt, va_list ap) +mlk_traceva(const char *fmt, va_list ap) { assert(fmt); char buf[TRACE_LINE_MAX]; - if (!trace_handler) + if (!mlk_trace_handler) return; vsnprintf(buf, sizeof (buf), fmt, ap); - trace_handler(buf); + mlk_trace_handler(buf); }
--- a/libmlk-core/mlk/core/trace.h Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-core/mlk/core/trace.h Mon Feb 27 11:26:23 2023 +0100 @@ -25,16 +25,15 @@ #define TRACE_LINE_MAX (1024) -extern void (*trace_handler)(const char *); -extern void *trace_data; +extern void (*mlk_trace_handler)(const char *); MLK_CORE_BEGIN_DECLS void -tracef(const char *, ...); +mlk_tracef(const char *, ...); void -traceva(const char *, va_list); +mlk_traceva(const char *, va_list); MLK_CORE_END_DECLS
--- a/libmlk-rpg/mlk/rpg/battle-bar-default.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar-default.c Mon Feb 27 11:26:23 2023 +0100 @@ -156,7 +156,7 @@ /* A cursor should be present. */ if (!mlk_sprite_ok(BATTLE_THEME(bt)->sprites[THEME_SPRITE_CURSOR])) - tracef("battle: no cursor sprite in theme"); + mlk_tracef("battle: no cursor sprite in theme"); } static void
--- a/libmlk-rpg/mlk/rpg/battle-state-check.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-check.c Mon Feb 27 11:26:23 2023 +0100 @@ -84,7 +84,7 @@ struct fadeout *fade; if (!bt->effects) { - tracef("can't create a fadeout effect without a drawable_stack"); + mlk_tracef("can't create a fadeout effect without a drawable_stack"); return; }
--- a/libmlk-rpg/mlk/rpg/battle.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle.c Mon Feb 27 11:26:23 2023 +0100 @@ -395,7 +395,7 @@ struct indicator *id; if (!(bt->effects)) { - tracef("unable to add id without a drawable_stack"); + mlk_tracef("unable to add id without a drawable_stack"); return; }
--- a/libmlk-rpg/mlk/rpg/map-file.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/map-file.c Mon Feb 27 11:26:23 2023 +0100 @@ -88,7 +88,7 @@ struct map_block *reg; if (!ctx->mf->load_action) { - tracef("ignoring action %d,%d,%u,%u,%d,%s", x, y, w, h, block, exec); + mlk_tracef("ignoring action %d,%d,%u,%u,%d,%s", x, y, w, h, block, exec); continue; }
--- a/libmlk-rpg/mlk/rpg/message.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/message.c Mon Feb 27 11:26:23 2023 +0100 @@ -128,9 +128,9 @@ label.flags = LABEL_FLAGS_SHADOW; if (label.x + lw > msg->w) - tracef("message width too small: %u < %u", msg->w, min_width(msg)); + mlk_tracef("message width too small: %u < %u", msg->w, min_width(msg)); if (label.y + lh > msg->h) - tracef("message height too small: %u < %u", msg->h, min_height(msg)); + mlk_tracef("message height too small: %u < %u", msg->h, min_height(msg)); /* * The function label_draw will use THEME_COLOR_NORMAL to draw @@ -161,7 +161,7 @@ : MESSAGE_STATE_SHOWING; if (msg->flags & MESSAGE_FLAGS_AUTOMATIC && msg->timeout == 0) - tracef("message is automatic but has zero timeout"); + mlk_tracef("message is automatic but has zero timeout"); } void @@ -267,7 +267,7 @@ unsigned int w, h; if (msg->w == 0 || msg->h == 0) { - tracef("message has null dimensions"); + mlk_tracef("message has null dimensions"); return; }
--- a/libmlk-ui/mlk/ui/button.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-ui/mlk/ui/button.c Mon Feb 27 11:26:23 2023 +0100 @@ -56,9 +56,9 @@ label_query(&label, &lw, &lh); if (lw > button->w) - tracef("button width is too small for text: %u < %u", button->w, lw); + mlk_tracef("button width is too small for text: %u < %u", button->w, lw); if (lh > button->h) - tracef("button height is too small for text: %u < %u", button->h, lh); + mlk_tracef("button height is too small for text: %u < %u", button->h, lh); align(ALIGN_CENTER, &label.x, &label.y, lw, lh, button->x, button->y, button->w, button->h);
--- a/libmlk-ui/mlk/ui/gridmenu.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-ui/mlk/ui/gridmenu.c Mon Feb 27 11:26:23 2023 +0100 @@ -82,7 +82,7 @@ * is outside of the elements. */ if (reqw > menu->w) { - tracef("gridmenu width is too small: %u < %u", menu->w, reqw); + mlk_tracef("gridmenu width is too small: %u < %u", menu->w, reqw); menu->spacew = 1; } else if (menu->ncols > 1) { reqw -= theme->padding * 2; @@ -90,7 +90,7 @@ } if (reqh > menu->h) { - tracef("gridmenu height is too small: %u < %u", menu->h, reqh); + mlk_tracef("gridmenu height is too small: %u < %u", menu->h, reqh); menu->spaceh = 1; } else if (menu->nrows > 1) { reqh -= theme->padding * 2;
--- a/libmlk-ui/mlk/ui/notify.c Mon Feb 27 11:24:38 2023 +0100 +++ b/libmlk-ui/mlk/ui/notify.c Mon Feb 27 11:26:23 2023 +0100 @@ -80,7 +80,7 @@ /* Align icon at the left center. */ if (n->icon->h >= HEIGHT) { - tracef("notification icon is too large: %u > %u", n->icon->h, HEIGHT); + mlk_tracef("notification icon is too large: %u > %u", n->icon->h, HEIGHT); geo->icon_x = x + geo->theme->padding; geo->icon_y = y + geo->theme->padding; } else {