Mercurial > molko
diff examples/example-gridmenu/example-gridmenu.c @ 486:d6757c30658e
core: rework errors
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 28 Feb 2023 13:04:13 +0100 |
parents | 3ff1fe64d0cd |
children | f2d3c5a97884 |
line wrap: on
line diff
--- a/examples/example-gridmenu/example-gridmenu.c Tue Feb 28 08:40:35 2023 +0100 +++ b/examples/example-gridmenu/example-gridmenu.c Tue Feb 28 13:04:13 2023 +0100 @@ -17,6 +17,7 @@ */ #include <mlk/core/core.h> +#include <mlk/core/err.h> #include <mlk/core/event.h> #include <mlk/core/game.h> #include <mlk/core/painter.h> @@ -33,18 +34,18 @@ #include <mlk/ui/theme.h> #include <mlk/ui/ui.h> -#define W (1280) -#define H (720) +#include <mlk/example/example.h> +#include <mlk/example/registry.h> static struct mlk_state *states[1]; static void init(void) { - if (mlk_core_init("fr.malikania", "example-gridmenu") < 0 || ui_init() < 0) - mlk_panic(); - if (mlk_window_open("Example - Grid menu", W, H) < 0) - mlk_panic(); + int err; + + if ((err = mlk_example_init("example-gridmenu")) < 0) + mlk_panicf("mlk_example_init: %s", mlk_err_string(err)); } static void @@ -113,7 +114,7 @@ gridmenu_init(&menu, 3, 2, items, MLK_UTIL_SIZE(items)); gridmenu_resize(&menu, 0, 0, 300, 100); - align(ALIGN_CENTER, &menu.x, &menu.y, menu.w, menu.h, 0, 0, W, H); + align(ALIGN_CENTER, &menu.x, &menu.y, menu.w, menu.h, 0, 0, mlk_window.w, mlk_window.h); mlk_game_init(states, MLK_UTIL_SIZE(states)); mlk_game_push(&state);