#include "graphic.hpp" #include "menu.hpp" #include "control.hpp" #define POKE "\x94" #define TRAINER "\x92" #define PKMN "\x96" #define S(v) reinterpret_cast(v) const menu_t start_menu = { .top_left = {10, 0}, .bottom_right = {19, 15}, .width = 1, .height = 7, .h_advance = 0, .v_advance = 2, .items = (menu_item_t[]){ { S(POKE "DEX") }, { S(POKE "MON") }, { S("ITEM" ) }, { S(TRAINER ) }, { S("SAVE" ) }, { S("OPTION" ) }, { S("EXIT" ) }, }, }; const menu_t fight_menu = { .top_left = {8, 12}, .bottom_right = {19, 17}, .width = 2, .height = 2, .h_advance = 6, .v_advance = 2, .items = (menu_item_t[]) { { S("FIGHT") }, { S(PKMN ) }, { S("ITEM" ) }, { S("RUN") }, }, }; #undef S void draw_menu(const uint32_t base_pattern, const menu_t& menu) { draw_box_border(base_pattern, menu.top_left, menu.bottom_right); draw_box_background(base_pattern, menu.top_left, menu.bottom_right); for (uint32_t y = 0; y < menu.height; y++) { for (uint32_t x = 0; x < menu.width; x++) { const menu_item_t& item = menu.items[menu.width * y + x]; const uint32_t cell_x = menu.top_left.x + 2 + (menu.h_advance * x); const uint32_t cell_y = menu.top_left.y + menu.v_advance + (menu.v_advance * y); draw_text(base_pattern, item.label, cell_x, cell_y); } } } void draw_menu_cursor(const uint32_t base_pattern, const menu_t& menu, const cursor_t& cursor) { const uint32_t cell_x = menu.top_left.x + 1 + (menu.h_advance * cursor.x); const uint32_t cell_y = menu.top_left.y + menu.v_advance + (menu.v_advance * cursor.y); put_char(base_pattern, cell_x, cell_y, interactive::l_arrow_solid); }