comparison 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
comparison
equal deleted inserted replaced
485:3ff1fe64d0cd 486:d6757c30658e
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19 #include <mlk/core/core.h> 19 #include <mlk/core/core.h>
20 #include <mlk/core/err.h>
20 #include <mlk/core/event.h> 21 #include <mlk/core/event.h>
21 #include <mlk/core/game.h> 22 #include <mlk/core/game.h>
22 #include <mlk/core/painter.h> 23 #include <mlk/core/painter.h>
23 #include <mlk/core/panic.h> 24 #include <mlk/core/panic.h>
24 #include <mlk/core/state.h> 25 #include <mlk/core/state.h>
31 #include <mlk/ui/gridmenu.h> 32 #include <mlk/ui/gridmenu.h>
32 #include <mlk/ui/label.h> 33 #include <mlk/ui/label.h>
33 #include <mlk/ui/theme.h> 34 #include <mlk/ui/theme.h>
34 #include <mlk/ui/ui.h> 35 #include <mlk/ui/ui.h>
35 36
36 #define W (1280) 37 #include <mlk/example/example.h>
37 #define H (720) 38 #include <mlk/example/registry.h>
38 39
39 static struct mlk_state *states[1]; 40 static struct mlk_state *states[1];
40 41
41 static void 42 static void
42 init(void) 43 init(void)
43 { 44 {
44 if (mlk_core_init("fr.malikania", "example-gridmenu") < 0 || ui_init() < 0) 45 int err;
45 mlk_panic(); 46
46 if (mlk_window_open("Example - Grid menu", W, H) < 0) 47 if ((err = mlk_example_init("example-gridmenu")) < 0)
47 mlk_panic(); 48 mlk_panicf("mlk_example_init: %s", mlk_err_string(err));
48 } 49 }
49 50
50 static void 51 static void
51 quit(void) 52 quit(void)
52 { 53 {
111 }; 112 };
112 113
113 gridmenu_init(&menu, 3, 2, items, MLK_UTIL_SIZE(items)); 114 gridmenu_init(&menu, 3, 2, items, MLK_UTIL_SIZE(items));
114 gridmenu_resize(&menu, 0, 0, 300, 100); 115 gridmenu_resize(&menu, 0, 0, 300, 100);
115 116
116 align(ALIGN_CENTER, &menu.x, &menu.y, menu.w, menu.h, 0, 0, W, H); 117 align(ALIGN_CENTER, &menu.x, &menu.y, menu.w, menu.h, 0, 0, mlk_window.w, mlk_window.h);
117 118
118 mlk_game_init(states, MLK_UTIL_SIZE(states)); 119 mlk_game_init(states, MLK_UTIL_SIZE(states));
119 mlk_game_push(&state); 120 mlk_game_push(&state);
120 mlk_game_loop(); 121 mlk_game_loop();
121 } 122 }