Mercurial > molko
comparison examples/example-gridmenu/example-gridmenu.c @ 459:541cb950997b
examples: add libmlk-example library
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 26 Feb 2023 19:44:47 +0100 |
parents | 773a082f0b91 |
children | 5729efd23286 |
comparison
equal
deleted
inserted
replaced
458:02c1481b7dbb | 459:541cb950997b |
---|---|
54 ui_finish(); | 54 ui_finish(); |
55 core_finish(); | 55 core_finish(); |
56 } | 56 } |
57 | 57 |
58 static void | 58 static void |
59 handle(struct state *st, const union event *ev) | 59 handle(struct state *st, const union mlk_event *ev) |
60 { | 60 { |
61 struct gridmenu *menu = st->data; | 61 struct gridmenu *menu = st->data; |
62 | 62 |
63 switch (ev->type) { | 63 switch (ev->type) { |
64 case EVENT_QUIT: | 64 case MLK_EVENT_QUIT: |
65 game_quit(); | 65 mlk_game_quit(); |
66 break; | 66 break; |
67 default: | 67 default: |
68 if (gridmenu_handle(st->data, ev)) | 68 if (gridmenu_handle(st->data, ev)) |
69 tracef("selected index: %zu (%s)", menu->selected, menu->items[menu->selected]); | 69 tracef("selected index: %zu (%s)", menu->selected, menu->items[menu->selected]); |
70 break; | 70 break; |
72 } | 72 } |
73 | 73 |
74 static void | 74 static void |
75 draw(struct state *st) | 75 draw(struct state *st) |
76 { | 76 { |
77 painter_set_color(0x4f8fbaff); | 77 mlk_painter_set_color(0x4f8fbaff); |
78 painter_clear(); | 78 mlk_painter_clear(); |
79 gridmenu_draw(st->data); | 79 gridmenu_draw(st->data); |
80 painter_present(); | 80 mlk_painter_present(); |
81 } | 81 } |
82 | 82 |
83 static void | 83 static void |
84 run(void) | 84 run(void) |
85 { | 85 { |
113 gridmenu_init(&menu, 3, 2, items, UTIL_SIZE(items)); | 113 gridmenu_init(&menu, 3, 2, items, UTIL_SIZE(items)); |
114 gridmenu_resize(&menu, 0, 0, 300, 100); | 114 gridmenu_resize(&menu, 0, 0, 300, 100); |
115 | 115 |
116 align(ALIGN_CENTER, &menu.x, &menu.y, menu.w, menu.h, 0, 0, W, H); | 116 align(ALIGN_CENTER, &menu.x, &menu.y, menu.w, menu.h, 0, 0, W, H); |
117 | 117 |
118 game_init(states, UTIL_SIZE(states)); | 118 mlk_game_init(states, UTIL_SIZE(states)); |
119 game_push(&state); | 119 mlk_game_push(&state); |
120 game_loop(); | 120 mlk_game_loop(); |
121 } | 121 } |
122 | 122 |
123 int | 123 int |
124 main(int argc, char **argv) | 124 main(int argc, char **argv) |
125 { | 125 { |